@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/index.js
CHANGED
|
@@ -144,13 +144,13 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain, integ
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
var VELT_SDK_VERSION = '4.5.0-beta.
|
|
147
|
+
var VELT_SDK_VERSION = '4.5.0-beta.49';
|
|
148
148
|
var VELT_SDK_INIT_EVENT = 'onVeltInit';
|
|
149
149
|
var VELT_TAB_ID = 'veltTabId';
|
|
150
150
|
// integrity map for the Velt SDK
|
|
151
151
|
// Note: generate integrity hashes with: https://www.srihash.org/
|
|
152
152
|
var INTEGRITY_MAP = {
|
|
153
|
-
'4.5.0-beta.
|
|
153
|
+
'4.5.0-beta.49': 'sha384-6hQcdyGrq9dJM2m/nmqACvLcUD1WKuFB7ArF+s1z6xCTaNFZq0DBjgA1KpP5NM3v',
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
var SnippylyProvider = function (props) {
|
|
@@ -7350,19 +7350,32 @@ function useNotificationUtils() {
|
|
|
7350
7350
|
}, [client, setNotificationElement, notificationElement]);
|
|
7351
7351
|
return notificationElement;
|
|
7352
7352
|
}
|
|
7353
|
-
function useNotificationsData() {
|
|
7353
|
+
function useNotificationsData(query) {
|
|
7354
7354
|
var notificationElement = useNotificationUtils();
|
|
7355
7355
|
var _a = React__default["default"].useState(null), data = _a[0], setData = _a[1];
|
|
7356
|
+
var subscriptionRef = React.useRef();
|
|
7357
|
+
var memoizedData = React.useMemo(function () {
|
|
7358
|
+
return query;
|
|
7359
|
+
}, [JSON.stringify(query)]);
|
|
7356
7360
|
React.useEffect(function () {
|
|
7357
7361
|
if (!(notificationElement === null || notificationElement === void 0 ? void 0 : notificationElement.getNotificationsData))
|
|
7358
7362
|
return;
|
|
7359
|
-
|
|
7363
|
+
// Unsubscribe from the previous subscription if it exists
|
|
7364
|
+
if (subscriptionRef.current) {
|
|
7365
|
+
subscriptionRef.current.unsubscribe();
|
|
7366
|
+
}
|
|
7367
|
+
var subscription = notificationElement.getNotificationsData(memoizedData).subscribe(function (res) {
|
|
7360
7368
|
setData(res);
|
|
7361
7369
|
});
|
|
7370
|
+
// Store the new subscription
|
|
7371
|
+
subscriptionRef.current = subscription;
|
|
7372
|
+
// Cleanup function
|
|
7362
7373
|
return function () {
|
|
7363
|
-
|
|
7374
|
+
if (subscriptionRef.current) {
|
|
7375
|
+
subscriptionRef.current.unsubscribe();
|
|
7376
|
+
}
|
|
7364
7377
|
};
|
|
7365
|
-
}, [notificationElement === null || notificationElement === void 0 ? void 0 : notificationElement.getNotificationsData]);
|
|
7378
|
+
}, [notificationElement === null || notificationElement === void 0 ? void 0 : notificationElement.getNotificationsData, memoizedData]);
|
|
7366
7379
|
return data;
|
|
7367
7380
|
}
|
|
7368
7381
|
function useUnreadNotificationsCount() {
|