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

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
@@ -5030,41 +5030,22 @@ function NotificationsWidget({
5030
5030
  setOptimisticReadIds((prev) => {
5031
5031
  const next = new Set(prev);
5032
5032
  let changed = false;
5033
+ const notificationIds = new Set(notifications.map((n) => n.id));
5033
5034
  prev.forEach((id) => {
5034
5035
  const notification = notifications.find((n) => n.id === id);
5036
+ if (!notificationIds.has(id)) {
5037
+ next.delete(id);
5038
+ changed = true;
5039
+ return;
5040
+ }
5035
5041
  if (notification?.read === true) {
5036
5042
  next.delete(id);
5037
5043
  changed = true;
5038
- console.log(
5039
- "[NotificationsWidget] Clearing optimistic state for server-confirmed read:",
5040
- id
5041
- );
5042
5044
  }
5043
5045
  });
5044
5046
  return changed ? next : prev;
5045
5047
  });
5046
5048
  }, [notifications]);
5047
- React2__namespace.useEffect(() => {
5048
- console.log(
5049
- "[NotificationsWidget] Notifications received:",
5050
- notifications.length
5051
- );
5052
- console.log(
5053
- "[NotificationsWidget] Unread count:",
5054
- unreadCount,
5055
- "| Optimistic read IDs:",
5056
- Array.from(optimisticReadIds)
5057
- );
5058
- console.log(
5059
- "[NotificationsWidget] Notification read states:",
5060
- notifications.map((n) => ({
5061
- id: n.id,
5062
- title: n.title,
5063
- read: n.read,
5064
- isRead: getIsRead(n)
5065
- }))
5066
- );
5067
- }, [notifications, unreadCount, optimisticReadIds, getIsRead]);
5068
5049
  const sortedNotifications = React2__namespace.useMemo(
5069
5050
  () => [...notifications].sort(
5070
5051
  (a, b) => b.timestamp.getTime() - a.timestamp.getTime()
@@ -5075,7 +5056,7 @@ function NotificationsWidget({
5075
5056
  const maxListHeight = Math.min(maxVisible, 5) * notificationHeight;
5076
5057
  const hasMore = sortedNotifications.length > maxVisible;
5077
5058
  React2__namespace.useEffect(() => {
5078
- if (playSound && soundType !== "none" && unreadCount > prevCount && prevCount > 0) {
5059
+ if (playSound && soundType !== "none" && unreadCount > prevCount) {
5079
5060
  const now = Date.now();
5080
5061
  if (now - lastSoundPlayedRef.current >= soundCooldown) {
5081
5062
  playNotificationSound(soundType, soundUrl);
@@ -5092,26 +5073,13 @@ function NotificationsWidget({
5092
5073
  (n) => n.id === notificationId
5093
5074
  );
5094
5075
  if (!notification || getIsReadRef.current(notification)) {
5095
- console.log(
5096
- "[NotificationsWidget] Skipping handleMarkAsRead - already read or not found:",
5097
- notificationId
5098
- );
5099
5076
  return;
5100
5077
  }
5101
- console.log("[NotificationsWidget] Marking as read:", notificationId);
5102
5078
  processingIdsRef.current.add(notificationId);
5103
5079
  setOptimisticReadIds((prev) => new Set(prev).add(notificationId));
5104
5080
  try {
5105
5081
  await Promise.resolve(onMarkAsRead(notificationId));
5106
- console.log(
5107
- "[NotificationsWidget] Successfully marked as read (keeping optimistic state):",
5108
- notificationId
5109
- );
5110
- } catch (error) {
5111
- console.error(
5112
- "[NotificationsWidget] Failed to mark as read, reverting:",
5113
- error
5114
- );
5082
+ } catch {
5115
5083
  setOptimisticReadIds((prev) => {
5116
5084
  const next = new Set(prev);
5117
5085
  next.delete(notificationId);
@@ -5134,11 +5102,7 @@ function NotificationsWidget({
5134
5102
  });
5135
5103
  try {
5136
5104
  await Promise.resolve(onMarkAllAsRead());
5137
- } catch (error) {
5138
- console.error(
5139
- "[NotificationsWidget] Failed to mark all as read, reverting:",
5140
- error
5141
- );
5105
+ } catch {
5142
5106
  setOptimisticReadIds((prev) => {
5143
5107
  const next = new Set(prev);
5144
5108
  unreadIds.forEach((id) => next.delete(id));
@@ -5149,15 +5113,9 @@ function NotificationsWidget({
5149
5113
  React2__namespace.useEffect(() => {
5150
5114
  if (!isOpen || !onMarkAsRead) return;
5151
5115
  intersectedIdsRef.current.clear();
5152
- console.log(
5153
- "[NotificationsWidget] Creating IntersectionObserver for popover"
5154
- );
5155
5116
  const timeoutId = setTimeout(() => {
5156
5117
  const scrollContainer = scrollContainerRef.current;
5157
5118
  if (!scrollContainer) {
5158
- console.warn(
5159
- "[NotificationsWidget] Scroll container not found for observer"
5160
- );
5161
5119
  return;
5162
5120
  }
5163
5121
  const observer = new IntersectionObserver(
@@ -5174,18 +5132,7 @@ function NotificationsWidget({
5174
5132
  );
5175
5133
  const isRead = notification ? getIsReadRef.current(notification) : false;
5176
5134
  if (notification && !isRead) {
5177
- console.log(
5178
- "[NotificationsWidget] Marking notification as read via intersection:",
5179
- notificationId
5180
- );
5181
5135
  handleMarkAsRead(notificationId);
5182
- } else {
5183
- console.log(
5184
- "[NotificationsWidget] Skipping already-read notification:",
5185
- notificationId,
5186
- "read=",
5187
- isRead
5188
- );
5189
5136
  }
5190
5137
  }
5191
5138
  }
@@ -5200,14 +5147,8 @@ function NotificationsWidget({
5200
5147
  const notificationElements = scrollContainer.querySelectorAll(
5201
5148
  "[data-notification-id]"
5202
5149
  );
5203
- console.log(
5204
- "[NotificationsWidget] Observing",
5205
- notificationElements.length,
5206
- "notifications"
5207
- );
5208
5150
  notificationElements.forEach((el) => observer.observe(el));
5209
5151
  return () => {
5210
- console.log("[NotificationsWidget] Disconnecting IntersectionObserver");
5211
5152
  observer.disconnect();
5212
5153
  };
5213
5154
  }, 100);
@@ -5223,16 +5164,6 @@ function NotificationsWidget({
5223
5164
  onNotificationClick?.(notification);
5224
5165
  }
5225
5166
  };
5226
- console.log(
5227
- "[NotificationsWidget] Rendering bell with unreadCount:",
5228
- unreadCount,
5229
- "| showDot:",
5230
- unreadCount > 0,
5231
- "| dotBgColor:",
5232
- dotBgColor,
5233
- "| styles.dot:",
5234
- styles.dot
5235
- );
5236
5167
  return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
5237
5168
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
5238
5169
  react.motion.button,