@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.js CHANGED
@@ -4998,6 +4998,24 @@ 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
+ prev.forEach((id) => {
5006
+ const notification = notifications.find((n) => n.id === id);
5007
+ if (notification?.read === true) {
5008
+ next.delete(id);
5009
+ changed = true;
5010
+ console.log(
5011
+ "[NotificationsWidget] Clearing optimistic state for server-confirmed read:",
5012
+ id
5013
+ );
5014
+ }
5015
+ });
5016
+ return changed ? next : prev;
5017
+ });
5018
+ }, [notifications]);
5001
5019
  React2.useEffect(() => {
5002
5020
  console.log(
5003
5021
  "[NotificationsWidget] Notifications received:",
@@ -5058,14 +5076,9 @@ function NotificationsWidget({
5058
5076
  try {
5059
5077
  await Promise.resolve(onMarkAsRead(notificationId));
5060
5078
  console.log(
5061
- "[NotificationsWidget] Successfully marked as read:",
5079
+ "[NotificationsWidget] Successfully marked as read (keeping optimistic state):",
5062
5080
  notificationId
5063
5081
  );
5064
- setOptimisticReadIds((prev) => {
5065
- const next = new Set(prev);
5066
- next.delete(notificationId);
5067
- return next;
5068
- });
5069
5082
  } catch (error) {
5070
5083
  console.error(
5071
5084
  "[NotificationsWidget] Failed to mark as read, reverting:",