2024-08-04 07:09:52 -07:00
|
|
|
import { getClient } from '../api';
|
2021-07-21 19:04:28 -07:00
|
|
|
|
2024-08-23 09:46:14 -07:00
|
|
|
import type { CreatePushNotificationsSubscriptionParams, UpdatePushNotificationsSubscriptionParams } from 'pl-api';
|
2024-08-28 04:41:08 -07:00
|
|
|
import type { AppDispatch, RootState } from 'pl-fe/store';
|
2024-08-06 10:52:36 -07:00
|
|
|
|
|
|
|
const createPushSubscription = (params: CreatePushNotificationsSubscriptionParams) =>
|
2024-08-23 09:46:14 -07:00
|
|
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
|
|
|
getClient(getState).pushNotifications.createSubscription(params);
|
2021-07-21 19:04:28 -07:00
|
|
|
|
2022-06-15 13:11:36 -07:00
|
|
|
const fetchPushSubscription = () =>
|
2024-08-23 09:46:14 -07:00
|
|
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
|
|
|
getClient(getState).pushNotifications.getSubscription();
|
2021-07-21 19:04:28 -07:00
|
|
|
|
2024-08-23 09:46:14 -07:00
|
|
|
const updatePushSubscription = (params: UpdatePushNotificationsSubscriptionParams) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
|
|
|
getClient(getState).pushNotifications.updateSubscription(params);
|
2021-07-21 19:04:28 -07:00
|
|
|
|
2022-06-15 13:11:36 -07:00
|
|
|
const deletePushSubscription = () =>
|
2024-08-23 09:46:14 -07:00
|
|
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
|
|
|
getClient(getState).pushNotifications.deleteSubscription();
|
2022-06-15 13:11:36 -07:00
|
|
|
|
|
|
|
export {
|
|
|
|
createPushSubscription,
|
|
|
|
fetchPushSubscription,
|
|
|
|
updatePushSubscription,
|
|
|
|
deletePushSubscription,
|
|
|
|
};
|