@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 +9 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -78
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5002,41 +5002,22 @@ function NotificationsWidget({
|
|
|
5002
5002
|
setOptimisticReadIds((prev) => {
|
|
5003
5003
|
const next = new Set(prev);
|
|
5004
5004
|
let changed = false;
|
|
5005
|
+
const notificationIds = new Set(notifications.map((n) => n.id));
|
|
5005
5006
|
prev.forEach((id) => {
|
|
5006
5007
|
const notification = notifications.find((n) => n.id === id);
|
|
5008
|
+
if (!notificationIds.has(id)) {
|
|
5009
|
+
next.delete(id);
|
|
5010
|
+
changed = true;
|
|
5011
|
+
return;
|
|
5012
|
+
}
|
|
5007
5013
|
if (notification?.read === true) {
|
|
5008
5014
|
next.delete(id);
|
|
5009
5015
|
changed = true;
|
|
5010
|
-
console.log(
|
|
5011
|
-
"[NotificationsWidget] Clearing optimistic state for server-confirmed read:",
|
|
5012
|
-
id
|
|
5013
|
-
);
|
|
5014
5016
|
}
|
|
5015
5017
|
});
|
|
5016
5018
|
return changed ? next : prev;
|
|
5017
5019
|
});
|
|
5018
5020
|
}, [notifications]);
|
|
5019
|
-
React2.useEffect(() => {
|
|
5020
|
-
console.log(
|
|
5021
|
-
"[NotificationsWidget] Notifications received:",
|
|
5022
|
-
notifications.length
|
|
5023
|
-
);
|
|
5024
|
-
console.log(
|
|
5025
|
-
"[NotificationsWidget] Unread count:",
|
|
5026
|
-
unreadCount,
|
|
5027
|
-
"| Optimistic read IDs:",
|
|
5028
|
-
Array.from(optimisticReadIds)
|
|
5029
|
-
);
|
|
5030
|
-
console.log(
|
|
5031
|
-
"[NotificationsWidget] Notification read states:",
|
|
5032
|
-
notifications.map((n) => ({
|
|
5033
|
-
id: n.id,
|
|
5034
|
-
title: n.title,
|
|
5035
|
-
read: n.read,
|
|
5036
|
-
isRead: getIsRead(n)
|
|
5037
|
-
}))
|
|
5038
|
-
);
|
|
5039
|
-
}, [notifications, unreadCount, optimisticReadIds, getIsRead]);
|
|
5040
5021
|
const sortedNotifications = React2.useMemo(
|
|
5041
5022
|
() => [...notifications].sort(
|
|
5042
5023
|
(a, b) => b.timestamp.getTime() - a.timestamp.getTime()
|
|
@@ -5047,7 +5028,7 @@ function NotificationsWidget({
|
|
|
5047
5028
|
const maxListHeight = Math.min(maxVisible, 5) * notificationHeight;
|
|
5048
5029
|
const hasMore = sortedNotifications.length > maxVisible;
|
|
5049
5030
|
React2.useEffect(() => {
|
|
5050
|
-
if (playSound && soundType !== "none" && unreadCount > prevCount
|
|
5031
|
+
if (playSound && soundType !== "none" && unreadCount > prevCount) {
|
|
5051
5032
|
const now = Date.now();
|
|
5052
5033
|
if (now - lastSoundPlayedRef.current >= soundCooldown) {
|
|
5053
5034
|
playNotificationSound(soundType, soundUrl);
|
|
@@ -5064,26 +5045,13 @@ function NotificationsWidget({
|
|
|
5064
5045
|
(n) => n.id === notificationId
|
|
5065
5046
|
);
|
|
5066
5047
|
if (!notification || getIsReadRef.current(notification)) {
|
|
5067
|
-
console.log(
|
|
5068
|
-
"[NotificationsWidget] Skipping handleMarkAsRead - already read or not found:",
|
|
5069
|
-
notificationId
|
|
5070
|
-
);
|
|
5071
5048
|
return;
|
|
5072
5049
|
}
|
|
5073
|
-
console.log("[NotificationsWidget] Marking as read:", notificationId);
|
|
5074
5050
|
processingIdsRef.current.add(notificationId);
|
|
5075
5051
|
setOptimisticReadIds((prev) => new Set(prev).add(notificationId));
|
|
5076
5052
|
try {
|
|
5077
5053
|
await Promise.resolve(onMarkAsRead(notificationId));
|
|
5078
|
-
|
|
5079
|
-
"[NotificationsWidget] Successfully marked as read (keeping optimistic state):",
|
|
5080
|
-
notificationId
|
|
5081
|
-
);
|
|
5082
|
-
} catch (error) {
|
|
5083
|
-
console.error(
|
|
5084
|
-
"[NotificationsWidget] Failed to mark as read, reverting:",
|
|
5085
|
-
error
|
|
5086
|
-
);
|
|
5054
|
+
} catch {
|
|
5087
5055
|
setOptimisticReadIds((prev) => {
|
|
5088
5056
|
const next = new Set(prev);
|
|
5089
5057
|
next.delete(notificationId);
|
|
@@ -5106,11 +5074,7 @@ function NotificationsWidget({
|
|
|
5106
5074
|
});
|
|
5107
5075
|
try {
|
|
5108
5076
|
await Promise.resolve(onMarkAllAsRead());
|
|
5109
|
-
} catch
|
|
5110
|
-
console.error(
|
|
5111
|
-
"[NotificationsWidget] Failed to mark all as read, reverting:",
|
|
5112
|
-
error
|
|
5113
|
-
);
|
|
5077
|
+
} catch {
|
|
5114
5078
|
setOptimisticReadIds((prev) => {
|
|
5115
5079
|
const next = new Set(prev);
|
|
5116
5080
|
unreadIds.forEach((id) => next.delete(id));
|
|
@@ -5121,15 +5085,9 @@ function NotificationsWidget({
|
|
|
5121
5085
|
React2.useEffect(() => {
|
|
5122
5086
|
if (!isOpen || !onMarkAsRead) return;
|
|
5123
5087
|
intersectedIdsRef.current.clear();
|
|
5124
|
-
console.log(
|
|
5125
|
-
"[NotificationsWidget] Creating IntersectionObserver for popover"
|
|
5126
|
-
);
|
|
5127
5088
|
const timeoutId = setTimeout(() => {
|
|
5128
5089
|
const scrollContainer = scrollContainerRef.current;
|
|
5129
5090
|
if (!scrollContainer) {
|
|
5130
|
-
console.warn(
|
|
5131
|
-
"[NotificationsWidget] Scroll container not found for observer"
|
|
5132
|
-
);
|
|
5133
5091
|
return;
|
|
5134
5092
|
}
|
|
5135
5093
|
const observer = new IntersectionObserver(
|
|
@@ -5146,18 +5104,7 @@ function NotificationsWidget({
|
|
|
5146
5104
|
);
|
|
5147
5105
|
const isRead = notification ? getIsReadRef.current(notification) : false;
|
|
5148
5106
|
if (notification && !isRead) {
|
|
5149
|
-
console.log(
|
|
5150
|
-
"[NotificationsWidget] Marking notification as read via intersection:",
|
|
5151
|
-
notificationId
|
|
5152
|
-
);
|
|
5153
5107
|
handleMarkAsRead(notificationId);
|
|
5154
|
-
} else {
|
|
5155
|
-
console.log(
|
|
5156
|
-
"[NotificationsWidget] Skipping already-read notification:",
|
|
5157
|
-
notificationId,
|
|
5158
|
-
"read=",
|
|
5159
|
-
isRead
|
|
5160
|
-
);
|
|
5161
5108
|
}
|
|
5162
5109
|
}
|
|
5163
5110
|
}
|
|
@@ -5172,14 +5119,8 @@ function NotificationsWidget({
|
|
|
5172
5119
|
const notificationElements = scrollContainer.querySelectorAll(
|
|
5173
5120
|
"[data-notification-id]"
|
|
5174
5121
|
);
|
|
5175
|
-
console.log(
|
|
5176
|
-
"[NotificationsWidget] Observing",
|
|
5177
|
-
notificationElements.length,
|
|
5178
|
-
"notifications"
|
|
5179
|
-
);
|
|
5180
5122
|
notificationElements.forEach((el) => observer.observe(el));
|
|
5181
5123
|
return () => {
|
|
5182
|
-
console.log("[NotificationsWidget] Disconnecting IntersectionObserver");
|
|
5183
5124
|
observer.disconnect();
|
|
5184
5125
|
};
|
|
5185
5126
|
}, 100);
|
|
@@ -5195,16 +5136,6 @@ function NotificationsWidget({
|
|
|
5195
5136
|
onNotificationClick?.(notification);
|
|
5196
5137
|
}
|
|
5197
5138
|
};
|
|
5198
|
-
console.log(
|
|
5199
|
-
"[NotificationsWidget] Rendering bell with unreadCount:",
|
|
5200
|
-
unreadCount,
|
|
5201
|
-
"| showDot:",
|
|
5202
|
-
unreadCount > 0,
|
|
5203
|
-
"| dotBgColor:",
|
|
5204
|
-
dotBgColor,
|
|
5205
|
-
"| styles.dot:",
|
|
5206
|
-
styles.dot
|
|
5207
|
-
);
|
|
5208
5139
|
return /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
5209
5140
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
5210
5141
|
motion.button,
|