@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 CHANGED
@@ -5026,6 +5026,34 @@ function NotificationsWidget({
5026
5026
  getIsReadRef.current = getIsRead;
5027
5027
  }, [getIsRead]);
5028
5028
  const unreadCount = notifications.filter((n) => !getIsRead(n)).length;
5029
+ React2__namespace.useEffect(() => {
5030
+ setOptimisticReadIds((prev) => {
5031
+ const next = new Set(prev);
5032
+ let changed = false;
5033
+ const notificationIds = new Set(notifications.map((n) => n.id));
5034
+ prev.forEach((id) => {
5035
+ const notification = notifications.find((n) => n.id === id);
5036
+ if (!notificationIds.has(id)) {
5037
+ next.delete(id);
5038
+ changed = true;
5039
+ console.log(
5040
+ "[NotificationsWidget] Removing stale optimistic ID:",
5041
+ id
5042
+ );
5043
+ return;
5044
+ }
5045
+ if (notification?.read === true) {
5046
+ next.delete(id);
5047
+ changed = true;
5048
+ console.log(
5049
+ "[NotificationsWidget] Clearing optimistic state for server-confirmed read:",
5050
+ id
5051
+ );
5052
+ }
5053
+ });
5054
+ return changed ? next : prev;
5055
+ });
5056
+ }, [notifications]);
5029
5057
  React2__namespace.useEffect(() => {
5030
5058
  console.log(
5031
5059
  "[NotificationsWidget] Notifications received:",
@@ -5086,14 +5114,9 @@ function NotificationsWidget({
5086
5114
  try {
5087
5115
  await Promise.resolve(onMarkAsRead(notificationId));
5088
5116
  console.log(
5089
- "[NotificationsWidget] Successfully marked as read:",
5117
+ "[NotificationsWidget] Successfully marked as read (keeping optimistic state):",
5090
5118
  notificationId
5091
5119
  );
5092
- setOptimisticReadIds((prev) => {
5093
- const next = new Set(prev);
5094
- next.delete(notificationId);
5095
- return next;
5096
- });
5097
5120
  } catch (error) {
5098
5121
  console.error(
5099
5122
  "[NotificationsWidget] Failed to mark as read, reverting:",