@novu/headless
Advanced tools
Comparing version 0.22.0 to 0.23.0
@@ -132,2 +132,10 @@ import { IUserPreferenceSettings, IStoreQuery, IUserGlobalPreferenceSettings } from '@novu/client'; | ||
}): Promise<void>; | ||
removeNotifications({ messageIds, listener, onSuccess, onError, }: { | ||
messageIds: string[]; | ||
listener: (result: UpdateResult<void, unknown, { | ||
messageIds: string[]; | ||
}>) => void; | ||
onSuccess?: (obj: void) => void; | ||
onError?: (error: unknown) => void; | ||
}): Promise<void>; | ||
updateAction({ messageId, actionButtonType, status, payload, listener, onSuccess, onError, }: { | ||
@@ -134,0 +142,0 @@ messageId: IUpdateActionVariables['messageId']; |
@@ -188,3 +188,3 @@ "use strict"; | ||
if (data === null || data === void 0 ? void 0 : data.message) { | ||
this.queryClient.removeQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
this.queryClient.refetchQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
exact: false, | ||
@@ -207,5 +207,2 @@ }); | ||
if (Number.isInteger(data === null || data === void 0 ? void 0 : data.unseenCount)) { | ||
this.queryClient.removeQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
exact: false, | ||
}); | ||
this.queryClient.setQueryData(utils_1.UNSEEN_COUNT_QUERY_KEY, (oldData) => { var _a; return ({ count: (_a = data === null || data === void 0 ? void 0 : data.unseenCount) !== null && _a !== void 0 ? _a : oldData.count }); }); | ||
@@ -227,5 +224,2 @@ listener(data.unseenCount); | ||
if (Number.isInteger(data === null || data === void 0 ? void 0 : data.unreadCount)) { | ||
this.queryClient.removeQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
exact: false, | ||
}); | ||
this.queryClient.setQueryData(utils_1.UNREAD_COUNT_QUERY_KEY, (oldData) => { var _a; return ({ count: (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : oldData.count }); }); | ||
@@ -426,3 +420,3 @@ listener(data.unreadCount); | ||
onSuccess: (data) => { | ||
this.queryClient.removeQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
this.queryClient.refetchQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
exact: false, | ||
@@ -448,2 +442,30 @@ }); | ||
} | ||
removeNotifications({ messageIds, listener, onSuccess, onError, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.assertSessionInitialized(); | ||
const { result, unsubscribe } = this.queryService.subscribeMutation({ | ||
options: { | ||
mutationFn: (variables) => this.api.removeMessages(variables.messageIds), | ||
onSuccess: (data) => { | ||
this.queryClient.refetchQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
exact: false, | ||
}); | ||
}, | ||
}, | ||
listener: (res) => this.callUpdateListener(res, listener), | ||
}); | ||
result | ||
.mutate({ messageIds }) | ||
.then((data) => { | ||
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data); | ||
return data; | ||
}) | ||
.catch((error) => { | ||
onError === null || onError === void 0 ? void 0 : onError(error); | ||
}) | ||
.finally(() => { | ||
unsubscribe(); | ||
}); | ||
}); | ||
} | ||
updateAction({ messageId, actionButtonType, status, payload, listener, onSuccess, onError, }) { | ||
@@ -540,3 +562,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
onSuccess: (data) => { | ||
this.queryClient.refetchQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
this.queryClient.removeQueries(utils_1.NOTIFICATIONS_QUERY_KEY, { | ||
exact: false, | ||
@@ -543,0 +565,0 @@ }); |
{ | ||
"name": "@novu/headless", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"repository": "https://github.com/novuhq/novu", | ||
@@ -31,4 +31,4 @@ "description": "Headless client package that is a thin abstraction layer over the API client + state and socket management", | ||
"dependencies": { | ||
"@novu/client": "^0.22.0", | ||
"@novu/shared": "^0.22.0", | ||
"@novu/client": "^0.23.0", | ||
"@novu/shared": "^0.23.0", | ||
"@tanstack/query-core": "^4.15.1", | ||
@@ -51,3 +51,3 @@ "socket.io-client": "4.7.2" | ||
}, | ||
"gitHead": "c8bec33862b7cbefacb94badf6b11bf25607a913" | ||
"gitHead": "fa8b86080f039734c8c8abf794dd0f0b57235904" | ||
} |
Sorry, the diff of this file is not supported yet
56427
922
+ Added@novu/client@0.23.1(transitive)
+ Added@novu/shared@0.23.1(transitive)
- Removed@novu/client@0.22.0(transitive)
- Removed@novu/shared@0.22.0(transitive)
Updated@novu/client@^0.23.0
Updated@novu/shared@^0.23.0