@janovix/blocks 1.2.0-rc.11 → 1.2.0-rc.12

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,24 @@ 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
+ prev.forEach((id) => {
5034
+ const notification = notifications.find((n) => n.id === id);
5035
+ if (notification?.read === true) {
5036
+ next.delete(id);
5037
+ changed = true;
5038
+ console.log(
5039
+ "[NotificationsWidget] Clearing optimistic state for server-confirmed read:",
5040
+ id
5041
+ );
5042
+ }
5043
+ });
5044
+ return changed ? next : prev;
5045
+ });
5046
+ }, [notifications]);
5029
5047
  React2__namespace.useEffect(() => {
5030
5048
  console.log(
5031
5049
  "[NotificationsWidget] Notifications received:",
@@ -5086,14 +5104,9 @@ function NotificationsWidget({
5086
5104
  try {
5087
5105
  await Promise.resolve(onMarkAsRead(notificationId));
5088
5106
  console.log(
5089
- "[NotificationsWidget] Successfully marked as read:",
5107
+ "[NotificationsWidget] Successfully marked as read (keeping optimistic state):",
5090
5108
  notificationId
5091
5109
  );
5092
- setOptimisticReadIds((prev) => {
5093
- const next = new Set(prev);
5094
- next.delete(notificationId);
5095
- return next;
5096
- });
5097
5110
  } catch (error) {
5098
5111
  console.error(
5099
5112
  "[NotificationsWidget] Failed to mark as read, reverting:",