@veltdev/react 4.5.0-beta.48 → 4.5.0-beta.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +19 -6
- package/cjs/index.js.map +1 -1
- package/cjs/types/constants.d.ts +1 -1
- package/cjs/types/hooks/NotificationElement.d.ts +2 -2
- package/esm/index.js +19 -6
- package/esm/index.js.map +1 -1
- package/esm/types/constants.d.ts +1 -1
- package/esm/types/hooks/NotificationElement.d.ts +2 -2
- package/index.d.ts +2 -2
- package/package.json +1 -1
package/cjs/types/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const VELT_SDK_VERSION = "4.5.0-beta.
|
|
2
|
+
export declare const VELT_SDK_VERSION = "4.5.0-beta.49";
|
|
3
3
|
export declare const VELT_SDK_INIT_EVENT = "onVeltInit";
|
|
4
4
|
export declare const VELT_TAB_ID = "veltTabId";
|
|
5
5
|
export declare const INTEGRITY_MAP: Record<string, string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Notification, NotificationElement, NotificationInitialSettingsConfig, NotificationSettingsConfig } from "@veltdev/types";
|
|
1
|
+
import { GetNotificationsDataQuery, Notification, NotificationElement, NotificationInitialSettingsConfig, NotificationSettingsConfig } from "@veltdev/types";
|
|
2
2
|
export declare function useNotificationUtils(): NotificationElement | undefined;
|
|
3
|
-
export declare function useNotificationsData(): Notification[] | null;
|
|
3
|
+
export declare function useNotificationsData(query?: GetNotificationsDataQuery): Notification[] | null;
|
|
4
4
|
export declare function useUnreadNotificationsCount(): {
|
|
5
5
|
forYou: number | null;
|
|
6
6
|
all: number | null;
|
package/esm/index.js
CHANGED
|
@@ -136,13 +136,13 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain, integ
|
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
var VELT_SDK_VERSION = '4.5.0-beta.
|
|
139
|
+
var VELT_SDK_VERSION = '4.5.0-beta.49';
|
|
140
140
|
var VELT_SDK_INIT_EVENT = 'onVeltInit';
|
|
141
141
|
var VELT_TAB_ID = 'veltTabId';
|
|
142
142
|
// integrity map for the Velt SDK
|
|
143
143
|
// Note: generate integrity hashes with: https://www.srihash.org/
|
|
144
144
|
var INTEGRITY_MAP = {
|
|
145
|
-
'4.5.0-beta.
|
|
145
|
+
'4.5.0-beta.49': 'sha384-6hQcdyGrq9dJM2m/nmqACvLcUD1WKuFB7ArF+s1z6xCTaNFZq0DBjgA1KpP5NM3v',
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
var SnippylyProvider = function (props) {
|
|
@@ -7342,19 +7342,32 @@ function useNotificationUtils() {
|
|
|
7342
7342
|
}, [client, setNotificationElement, notificationElement]);
|
|
7343
7343
|
return notificationElement;
|
|
7344
7344
|
}
|
|
7345
|
-
function useNotificationsData() {
|
|
7345
|
+
function useNotificationsData(query) {
|
|
7346
7346
|
var notificationElement = useNotificationUtils();
|
|
7347
7347
|
var _a = React.useState(null), data = _a[0], setData = _a[1];
|
|
7348
|
+
var subscriptionRef = useRef();
|
|
7349
|
+
var memoizedData = useMemo(function () {
|
|
7350
|
+
return query;
|
|
7351
|
+
}, [JSON.stringify(query)]);
|
|
7348
7352
|
useEffect(function () {
|
|
7349
7353
|
if (!(notificationElement === null || notificationElement === void 0 ? void 0 : notificationElement.getNotificationsData))
|
|
7350
7354
|
return;
|
|
7351
|
-
|
|
7355
|
+
// Unsubscribe from the previous subscription if it exists
|
|
7356
|
+
if (subscriptionRef.current) {
|
|
7357
|
+
subscriptionRef.current.unsubscribe();
|
|
7358
|
+
}
|
|
7359
|
+
var subscription = notificationElement.getNotificationsData(memoizedData).subscribe(function (res) {
|
|
7352
7360
|
setData(res);
|
|
7353
7361
|
});
|
|
7362
|
+
// Store the new subscription
|
|
7363
|
+
subscriptionRef.current = subscription;
|
|
7364
|
+
// Cleanup function
|
|
7354
7365
|
return function () {
|
|
7355
|
-
|
|
7366
|
+
if (subscriptionRef.current) {
|
|
7367
|
+
subscriptionRef.current.unsubscribe();
|
|
7368
|
+
}
|
|
7356
7369
|
};
|
|
7357
|
-
}, [notificationElement === null || notificationElement === void 0 ? void 0 : notificationElement.getNotificationsData]);
|
|
7370
|
+
}, [notificationElement === null || notificationElement === void 0 ? void 0 : notificationElement.getNotificationsData, memoizedData]);
|
|
7358
7371
|
return data;
|
|
7359
7372
|
}
|
|
7360
7373
|
function useUnreadNotificationsCount() {
|