@janovix/blocks 1.2.0-rc.11 → 1.2.0-rc.13
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/dist/index.cjs +29 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4998,6 +4998,34 @@ function NotificationsWidget({
|
|
|
4998
4998
|
getIsReadRef.current = getIsRead;
|
|
4999
4999
|
}, [getIsRead]);
|
|
5000
5000
|
const unreadCount = notifications.filter((n) => !getIsRead(n)).length;
|
|
5001
|
+
React2.useEffect(() => {
|
|
5002
|
+
setOptimisticReadIds((prev) => {
|
|
5003
|
+
const next = new Set(prev);
|
|
5004
|
+
let changed = false;
|
|
5005
|
+
const notificationIds = new Set(notifications.map((n) => n.id));
|
|
5006
|
+
prev.forEach((id) => {
|
|
5007
|
+
const notification = notifications.find((n) => n.id === id);
|
|
5008
|
+
if (!notificationIds.has(id)) {
|
|
5009
|
+
next.delete(id);
|
|
5010
|
+
changed = true;
|
|
5011
|
+
console.log(
|
|
5012
|
+
"[NotificationsWidget] Removing stale optimistic ID:",
|
|
5013
|
+
id
|
|
5014
|
+
);
|
|
5015
|
+
return;
|
|
5016
|
+
}
|
|
5017
|
+
if (notification?.read === true) {
|
|
5018
|
+
next.delete(id);
|
|
5019
|
+
changed = true;
|
|
5020
|
+
console.log(
|
|
5021
|
+
"[NotificationsWidget] Clearing optimistic state for server-confirmed read:",
|
|
5022
|
+
id
|
|
5023
|
+
);
|
|
5024
|
+
}
|
|
5025
|
+
});
|
|
5026
|
+
return changed ? next : prev;
|
|
5027
|
+
});
|
|
5028
|
+
}, [notifications]);
|
|
5001
5029
|
React2.useEffect(() => {
|
|
5002
5030
|
console.log(
|
|
5003
5031
|
"[NotificationsWidget] Notifications received:",
|
|
@@ -5058,14 +5086,9 @@ function NotificationsWidget({
|
|
|
5058
5086
|
try {
|
|
5059
5087
|
await Promise.resolve(onMarkAsRead(notificationId));
|
|
5060
5088
|
console.log(
|
|
5061
|
-
"[NotificationsWidget] Successfully marked as read:",
|
|
5089
|
+
"[NotificationsWidget] Successfully marked as read (keeping optimistic state):",
|
|
5062
5090
|
notificationId
|
|
5063
5091
|
);
|
|
5064
|
-
setOptimisticReadIds((prev) => {
|
|
5065
|
-
const next = new Set(prev);
|
|
5066
|
-
next.delete(notificationId);
|
|
5067
|
-
return next;
|
|
5068
|
-
});
|
|
5069
5092
|
} catch (error) {
|
|
5070
5093
|
console.error(
|
|
5071
5094
|
"[NotificationsWidget] Failed to mark as read, reverting:",
|