@layers-app/shared 0.4.6 → 0.4.8
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/assets/default-workspace-avatar.jpg.js +1 -1
- package/dist/components/AliasTextInput/AliasTextInput.d.ts.map +1 -1
- package/dist/components/AliasTextInput/AliasTextInput.js +32 -32
- package/dist/components/AppContainer/AppContainer.d.ts +1 -1
- package/dist/components/AppContainer/AppContainer.d.ts.map +1 -1
- package/dist/components/AppContainer/AppContainer.js +82 -70
- package/dist/components/AppContainer/AppContainer.module.css.js +20 -10
- package/dist/components/AppContainer/components/AppsSidebar/DesktopUpdateButton.d.ts +6 -0
- package/dist/components/AppContainer/components/AppsSidebar/DesktopUpdateButton.d.ts.map +1 -0
- package/dist/components/AppContainer/components/AppsSidebar/DesktopUpdateButton.js +161 -0
- package/dist/components/AppContainer/components/AppsSidebar/TopSection.d.ts.map +1 -1
- package/dist/components/AppContainer/components/AppsSidebar/TopSection.js +77 -49
- package/dist/components/AppContainer/components/AppsSidebar/UserSection.d.ts.map +1 -1
- package/dist/components/AppContainer/components/AppsSidebar/UserSection.js +238 -105
- package/dist/components/AppContainer/components/Main.js +4 -4
- package/dist/components/AppContainer/components/NavbarContent.d.ts.map +1 -1
- package/dist/components/AppContainer/components/NavbarContent.js +16 -2
- package/dist/components/AppContainer/components/SlideAnimation.js +4 -4
- package/dist/components/AppContainer/components/ToolSidebar.d.ts +5 -0
- package/dist/components/AppContainer/components/ToolSidebar.d.ts.map +1 -1
- package/dist/components/AppContainer/components/ToolSidebar.js +51 -39
- package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.d.ts +62 -1
- package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.d.ts.map +1 -1
- package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.js +1107 -137
- package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.module.css.js +158 -6
- package/dist/components/AppContainer/types.d.ts +12 -0
- package/dist/components/AppContainer/types.d.ts.map +1 -1
- package/dist/components/AttachmentsPreview/AttachmentsPreview.d.ts +3 -1
- package/dist/components/AttachmentsPreview/AttachmentsPreview.d.ts.map +1 -1
- package/dist/components/AttachmentsPreview/AttachmentsPreview.js +237 -93
- package/dist/components/AttachmentsPreview/AttachmentsPreview.module.css.js +18 -16
- package/dist/components/Chat/ChatInput/index.d.ts +13 -1
- package/dist/components/Chat/ChatInput/index.d.ts.map +1 -1
- package/dist/components/Chat/ChatInput/index.js +264 -164
- package/dist/components/Chat/ChatInput/useVoiceRecorder.d.ts +16 -0
- package/dist/components/Chat/ChatInput/useVoiceRecorder.d.ts.map +1 -0
- package/dist/components/Chat/ChatInput/useVoiceRecorder.js +83 -0
- package/dist/components/Chat/ChatMessage/ChatMessage.module.css.js +20 -16
- package/dist/components/Chat/ChatMessage/index.d.ts +16 -0
- package/dist/components/Chat/ChatMessage/index.d.ts.map +1 -1
- package/dist/components/Chat/ChatMessage/index.js +153 -118
- package/dist/components/Chat/MessageActions/index.d.ts +2 -0
- package/dist/components/Chat/MessageActions/index.d.ts.map +1 -1
- package/dist/components/Chat/MessageActions/index.js +189 -50
- package/dist/components/Chat/MessageAuthor/index.d.ts +7 -1
- package/dist/components/Chat/MessageAuthor/index.d.ts.map +1 -1
- package/dist/components/Chat/MessageAuthor/index.js +39 -25
- package/dist/components/Chat/MessageList/MessageList.module.css.js +14 -12
- package/dist/components/Chat/MessageList/index.d.ts +17 -25
- package/dist/components/Chat/MessageList/index.d.ts.map +1 -1
- package/dist/components/Chat/MessageList/index.js +201 -149
- package/dist/components/Chat/MessageMeta/index.d.ts.map +1 -1
- package/dist/components/Chat/MessageMeta/index.js +21 -19
- package/dist/components/ColorPicker/ColorPicker.d.ts +3 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts.map +1 -1
- package/dist/components/ColorPicker/ColorPicker.js +81 -76
- package/dist/components/ColorPicker/ColorPickerToolbar.d.ts +1 -0
- package/dist/components/ColorPicker/ColorPickerToolbar.d.ts.map +1 -1
- package/dist/components/ColorPicker/ColorPickerToolbar.js +97 -91
- package/dist/components/CommentComposer/CommentEditorHotkeys.d.ts +2 -1
- package/dist/components/CommentComposer/CommentEditorHotkeys.d.ts.map +1 -1
- package/dist/components/CommentComposer/CommentEditorHotkeys.js +29 -26
- package/dist/components/CommentComposer/index.d.ts +1 -1
- package/dist/components/CommentComposer/index.d.ts.map +1 -1
- package/dist/components/CommentComposer/index.js +70 -68
- package/dist/components/CommentComposer/types.d.ts +6 -0
- package/dist/components/CommentComposer/types.d.ts.map +1 -1
- package/dist/components/CustomKBD/index.js +21 -22
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts.map +1 -1
- package/dist/components/EmojiPicker/EmojiPicker.js +129 -121
- package/dist/components/EntityTitle/EntityTitle.d.ts +3 -4
- package/dist/components/EntityTitle/EntityTitle.d.ts.map +1 -1
- package/dist/components/EntityTitle/EntityTitle.js +81 -80
- package/dist/components/FormViewer/helpers/conditions.d.ts.map +1 -1
- package/dist/components/FormViewer/helpers/conditions.js +33 -17
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.d.ts +3 -1
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.d.ts.map +1 -1
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.js +26 -25
- package/dist/components/NewToolbar/utils.d.ts +12 -0
- package/dist/components/NewToolbar/utils.d.ts.map +1 -0
- package/dist/components/Notification/InfiniteScroll.d.ts +12 -0
- package/dist/components/Notification/InfiniteScroll.d.ts.map +1 -0
- package/dist/components/Notification/InfiniteScroll.js +42 -0
- package/dist/components/Notification/Notification.d.ts +4 -1
- package/dist/components/Notification/Notification.d.ts.map +1 -1
- package/dist/components/Notification/Notification.module.css.js +28 -4
- package/dist/components/Notification/atoms/ActionBadge.d.ts +11 -0
- package/dist/components/Notification/atoms/ActionBadge.d.ts.map +1 -0
- package/dist/components/Notification/atoms/ActionBadge.js +53 -0
- package/dist/components/Notification/atoms/ArchiveIcon.d.ts +7 -0
- package/dist/components/Notification/atoms/ArchiveIcon.d.ts.map +1 -0
- package/dist/components/Notification/atoms/ArchiveIcon.js +40 -0
- package/dist/components/Notification/atoms/InboxIcon.d.ts +7 -0
- package/dist/components/Notification/atoms/InboxIcon.d.ts.map +1 -0
- package/dist/components/Notification/atoms/InboxIcon.js +33 -0
- package/dist/components/Notification/atoms/MarkReadIcon.d.ts +7 -0
- package/dist/components/Notification/atoms/MarkReadIcon.d.ts.map +1 -0
- package/dist/components/Notification/atoms/MarkReadIcon.js +33 -0
- package/dist/components/Notification/atoms/ResourceIcon.d.ts +7 -0
- package/dist/components/Notification/atoms/ResourceIcon.d.ts.map +1 -0
- package/dist/components/Notification/atoms/TabBadge.d.ts +7 -0
- package/dist/components/Notification/atoms/TabBadge.d.ts.map +1 -0
- package/dist/components/Notification/atoms/TabBadge.js +32 -0
- package/dist/components/Notification/atoms/UnreadDot.d.ts +6 -0
- package/dist/components/Notification/atoms/UnreadDot.d.ts.map +1 -0
- package/dist/components/Notification/atoms/UnreadDot.js +23 -0
- package/dist/components/Notification/atoms/index.d.ts +5 -0
- package/dist/components/Notification/atoms/index.d.ts.map +1 -0
- package/dist/components/Notification/hooks/index.d.ts +8 -0
- package/dist/components/Notification/hooks/index.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useInboxActions.d.ts +12 -0
- package/dist/components/Notification/hooks/useInboxActions.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useInboxActions.js +58 -0
- package/dist/components/Notification/hooks/useInboxLoader.d.ts +8 -0
- package/dist/components/Notification/hooks/useInboxLoader.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useInboxLoader.js +49 -0
- package/dist/components/Notification/hooks/useNotificationItem.d.ts +26 -0
- package/dist/components/Notification/hooks/useNotificationItem.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useNotificationItem.js +51 -0
- package/dist/components/Notification/hooks/useNotificationStore.d.ts +49 -0
- package/dist/components/Notification/hooks/useNotificationStore.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useNotificationStore.js +139 -0
- package/dist/components/Notification/hooks/useNotificationStream.d.ts +2 -0
- package/dist/components/Notification/hooks/useNotificationStream.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useNotificationStream.js +86 -0
- package/dist/components/Notification/hooks/useNotificationTime.d.ts +2 -0
- package/dist/components/Notification/hooks/useNotificationTime.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useNotificationTime.js +23 -0
- package/dist/components/Notification/hooks/useNotificationsApi.d.ts +25 -0
- package/dist/components/Notification/hooks/useNotificationsApi.d.ts.map +1 -0
- package/dist/components/Notification/hooks/useNotificationsApi.js +64 -0
- package/dist/components/Notification/lib/api.d.ts +4 -0
- package/dist/components/Notification/lib/api.d.ts.map +1 -0
- package/dist/components/Notification/lib/api.js +19 -0
- package/dist/components/Notification/lib/index.d.ts +5 -0
- package/dist/components/Notification/lib/index.d.ts.map +1 -0
- package/dist/components/Notification/lib/notificationText.d.ts +10 -0
- package/dist/components/Notification/lib/notificationText.d.ts.map +1 -0
- package/dist/components/Notification/lib/notificationText.js +131 -0
- package/dist/components/Notification/lib/stripHtml.d.ts +2 -0
- package/dist/components/Notification/lib/stripHtml.d.ts.map +1 -0
- package/dist/components/Notification/lib/stripHtml.js +6 -0
- package/dist/components/Notification/lib/types.d.ts +45 -0
- package/dist/components/Notification/lib/types.d.ts.map +1 -0
- package/dist/components/Notification/lib/types.js +9 -0
- package/dist/components/Notification/molecules/InboxEmpty.d.ts +8 -0
- package/dist/components/Notification/molecules/InboxEmpty.d.ts.map +1 -0
- package/dist/components/Notification/molecules/InboxEmpty.js +21 -0
- package/dist/components/Notification/molecules/InboxHeader.d.ts +17 -0
- package/dist/components/Notification/molecules/InboxHeader.d.ts.map +1 -0
- package/dist/components/Notification/molecules/InboxHeader.js +73 -0
- package/dist/components/Notification/molecules/InboxTabs.d.ts +15 -0
- package/dist/components/Notification/molecules/InboxTabs.d.ts.map +1 -0
- package/dist/components/Notification/molecules/InboxTabs.js +60 -0
- package/dist/components/Notification/molecules/NotificationActions.d.ts +9 -0
- package/dist/components/Notification/molecules/NotificationActions.d.ts.map +1 -0
- package/dist/components/Notification/molecules/NotificationActions.js +64 -0
- package/dist/components/Notification/molecules/NotificationAvatar.d.ts +17 -0
- package/dist/components/Notification/molecules/NotificationAvatar.d.ts.map +1 -0
- package/dist/components/Notification/molecules/NotificationAvatar.js +38 -0
- package/dist/components/Notification/molecules/NotificationContent.d.ts +22 -0
- package/dist/components/Notification/molecules/NotificationContent.d.ts.map +1 -0
- package/dist/components/Notification/molecules/NotificationContent.js +183 -0
- package/dist/components/Notification/molecules/index.d.ts +7 -0
- package/dist/components/Notification/molecules/index.d.ts.map +1 -0
- package/dist/components/Notification/organisms/InboxItem.d.ts +14 -0
- package/dist/components/Notification/organisms/InboxItem.d.ts.map +1 -0
- package/dist/components/Notification/organisms/InboxItem.js +100 -0
- package/dist/components/Notification/organisms/InboxPanel.d.ts +4 -0
- package/dist/components/Notification/organisms/InboxPanel.d.ts.map +1 -0
- package/dist/components/Notification/organisms/InboxPanel.js +99 -0
- package/dist/components/Notification/organisms/index.d.ts +3 -0
- package/dist/components/Notification/organisms/index.d.ts.map +1 -0
- package/dist/components/OnboardingTour/index.d.ts +1 -1
- package/dist/components/OnboardingTour/index.d.ts.map +1 -1
- package/dist/components/OnboardingTour/useOnboardingTour.d.ts +2 -0
- package/dist/components/OnboardingTour/useOnboardingTour.d.ts.map +1 -1
- package/dist/components/OnboardingTour/useOnboardingTour.js +63 -51
- package/dist/components/modals/RemoveConfirmModal.d.ts.map +1 -1
- package/dist/components/modals/RemoveConfirmModal.js +27 -26
- package/dist/config/brand.d.ts.map +1 -1
- package/dist/config/brand.js +29 -29
- package/dist/config/envConfig.d.ts +4 -0
- package/dist/config/envConfig.d.ts.map +1 -1
- package/dist/config/envConfig.js +29 -28
- package/dist/helpers/getFileIcons.js +5 -5
- package/dist/helpers/getFileType.d.ts.map +1 -1
- package/dist/helpers/getFileType.js +11 -2
- package/dist/helpers/platform.d.ts +1 -1
- package/dist/helpers/platform.d.ts.map +1 -1
- package/dist/helpers/platform.js +1 -0
- package/dist/helpers/showNotifications.d.ts +8 -14
- package/dist/helpers/showNotifications.d.ts.map +1 -1
- package/dist/helpers/showNotifications.js +107 -111
- package/dist/helpers/showNotifications.module.css.js +4 -16
- package/dist/hooks/useDateUtils.d.ts.map +1 -1
- package/dist/hooks/useDateUtils.js +19 -23
- package/dist/index.css +1 -1
- package/dist/index.js +576 -573
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/Audio.context.js +15 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/Audio.js +228 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/Audio.module.css.js +4 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioControls.js +19 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioMuteButton.js +30 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioPlayButton.js +40 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioSkipButton.js +28 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioSpectrum.js +137 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioSpeedControl.js +31 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioTimeDisplay.js +44 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioTimeline.js +71 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioVolumeSlider.js +43 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/components/AudioWaveform.js +166 -0
- package/dist/node_modules/@gfazioli/mantine-audio/dist/esm/use-audio.js +201 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/Video.context.js +15 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/Video.js +272 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/Video.module.css.js +4 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoCaptionsButton.js +55 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoControls.js +30 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoFullscreenButton.js +31 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoMuteButton.js +29 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoPiPButton.js +29 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoPlayButton.js +28 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoSkipButton.js +27 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoTimeDisplay.js +44 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/components/VideoTimeline.js +70 -0
- package/dist/node_modules/@gfazioli/mantine-video/dist/esm/use-video.js +170 -0
- package/package.json +5 -3
- package/dist/components/Notification/Notification.js +0 -119
- package/dist/components/Notification/NotificationCard.d.ts +0 -10
- package/dist/components/Notification/NotificationCard.d.ts.map +0 -1
- package/dist/components/Notification/NotificationCard.js +0 -93
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useCallback as o } from "react";
|
|
2
|
+
import { useNavigate as U } from "react-router-dom";
|
|
3
|
+
import { useNotificationStore as d } from "./useNotificationStore.js";
|
|
4
|
+
import { useNotificationsApi as b } from "./useNotificationsApi.js";
|
|
5
|
+
import { isMention as x, buildNotificationLink as M } from "../lib/notificationText.js";
|
|
6
|
+
function O(p, n, c, l) {
|
|
7
|
+
const m = U(), i = b(), e = d((t) => t.updateNotification), f = d((t) => t.removeNotification), s = o(
|
|
8
|
+
(t, a) => {
|
|
9
|
+
const r = d.getState(), { all: T, mentions: w } = r.unreadCounts;
|
|
10
|
+
r.setUnreadCounts({
|
|
11
|
+
all: Math.max(0, T + t),
|
|
12
|
+
mentions: x(a) ? Math.max(0, w + t) : w
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
[]
|
|
16
|
+
), h = o((t) => {
|
|
17
|
+
new URL(t, window.location.origin).pathname === window.location.pathname ? window.location.assign(t) : (m(t), l?.());
|
|
18
|
+
}, [m, l]), A = o(
|
|
19
|
+
async (t) => {
|
|
20
|
+
const a = M(t.notificationType, t.objectId, t.parentId, p, t.link);
|
|
21
|
+
if (!t.read) {
|
|
22
|
+
e(t.id, { read: !0 }), s(-1, t.notificationType), a && h(a), await i.markAsRead([t.id]), n();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
a && (m(a), l?.());
|
|
26
|
+
},
|
|
27
|
+
[i, m, h, e, n, p, s, l]
|
|
28
|
+
), y = o(async (t) => {
|
|
29
|
+
const a = d.getState().notifications.find((r) => r.id === t);
|
|
30
|
+
e(t, { read: !0 }), a && !a.read && s(-1, a.notificationType), await i.markAsRead([t]), n();
|
|
31
|
+
}, [i, e, n, s]), k = o(async (t) => {
|
|
32
|
+
const a = d.getState().notifications.find((r) => r.id === t);
|
|
33
|
+
e(t, { read: !1 }), a && a.read && s(1, a.notificationType), await i.markAsUnread([t]), n();
|
|
34
|
+
}, [i, e, n, s]), u = o((t) => {
|
|
35
|
+
i.archiveIds([t]), f(t), n();
|
|
36
|
+
}, [i, f, n]), v = o((t) => {
|
|
37
|
+
i.unarchiveIds([t]), f(t), n();
|
|
38
|
+
}, [i, f, n]), R = o(async () => {
|
|
39
|
+
await i.markAllAsRead(), c(0);
|
|
40
|
+
}, [i, c]), I = o(async () => {
|
|
41
|
+
await i.archiveAll(), c(0);
|
|
42
|
+
}, [i, c]), N = o(async () => {
|
|
43
|
+
await i.archiveRead(), c(0);
|
|
44
|
+
}, [i, c]);
|
|
45
|
+
return {
|
|
46
|
+
handleClick: A,
|
|
47
|
+
handleRead: y,
|
|
48
|
+
handleUnread: k,
|
|
49
|
+
handleArchive: u,
|
|
50
|
+
handleUnarchive: v,
|
|
51
|
+
handleMarkAllRead: R,
|
|
52
|
+
handleArchiveAll: I,
|
|
53
|
+
handleArchiveRead: N
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
O as useInboxActions
|
|
58
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function useInboxLoader(activeWorkspaceId: string): {
|
|
2
|
+
loadPage: (p: number) => Promise<void>;
|
|
3
|
+
handleLoadMore: () => void;
|
|
4
|
+
refreshCounts: () => Promise<void>;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
hasMore: boolean;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useInboxLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInboxLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/hooks/useInboxLoader.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,iBAAiB,EAAE,MAAM;kBAiB1C,MAAM;;;;;EA8CnB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useCallback as d, useEffect as L, useRef as M } from "react";
|
|
2
|
+
import { useNotificationStore as n, getActiveSourceValues as p } from "./useNotificationStore.js";
|
|
3
|
+
import { useNotificationsApi as P } from "./useNotificationsApi.js";
|
|
4
|
+
const A = 20;
|
|
5
|
+
function T(e) {
|
|
6
|
+
const a = P(), c = n((t) => t.tab), r = n((t) => t.unreadOnly), s = n((t) => t.activeSources), g = n((t) => t.page), y = n((t) => t.loading), f = n((t) => t.hasMore), N = n((t) => t.refreshTrigger), C = n((t) => t.setNotifications), x = n((t) => t.appendNotifications), u = n((t) => t.setUnreadCounts), h = n((t) => t.setLoading), m = n((t) => t.nextPage), i = d(
|
|
7
|
+
async (t) => {
|
|
8
|
+
h(!0);
|
|
9
|
+
try {
|
|
10
|
+
const b = p(s), o = await a.fetchNotifications(
|
|
11
|
+
c,
|
|
12
|
+
t,
|
|
13
|
+
A,
|
|
14
|
+
r,
|
|
15
|
+
b,
|
|
16
|
+
e || void 0
|
|
17
|
+
);
|
|
18
|
+
t === 0 ? C(o.data.notifications, o.pagination.totalElements) : x(o.data.notifications, o.pagination.totalElements), u({ all: o.data.unreadCount, mentions: o.data.unreadMentions });
|
|
19
|
+
} catch {
|
|
20
|
+
} finally {
|
|
21
|
+
h(!1);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[a, c, r, s, e]
|
|
25
|
+
);
|
|
26
|
+
L(() => {
|
|
27
|
+
i(0);
|
|
28
|
+
}, [c, r, s, e, N]);
|
|
29
|
+
const l = M(!1), E = d(() => {
|
|
30
|
+
if (l.current || !f) return;
|
|
31
|
+
l.current = !0;
|
|
32
|
+
const t = g + 1;
|
|
33
|
+
m(), i(t).finally(() => {
|
|
34
|
+
l.current = !1;
|
|
35
|
+
});
|
|
36
|
+
}, [f, g, m, i]), S = d(async () => {
|
|
37
|
+
try {
|
|
38
|
+
const t = p(s);
|
|
39
|
+
u(
|
|
40
|
+
await a.fetchCounts(e || void 0, t)
|
|
41
|
+
);
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}, [a, e, s, u]);
|
|
45
|
+
return { loadPage: i, handleLoadMore: E, refreshCounts: S, loading: y, hasMore: f };
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
T as useInboxLoader
|
|
49
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NotificationDTO, NotificationVariant } from '../lib/types';
|
|
2
|
+
export declare function useNotificationItem(n: NotificationDTO): {
|
|
3
|
+
resolved: string | null;
|
|
4
|
+
variant: NotificationVariant;
|
|
5
|
+
isUser: boolean;
|
|
6
|
+
actorName: string;
|
|
7
|
+
verb: string;
|
|
8
|
+
source: string;
|
|
9
|
+
sourceKey: string | null;
|
|
10
|
+
time: string;
|
|
11
|
+
statusValue: string | null;
|
|
12
|
+
statusOldValue: string | null;
|
|
13
|
+
taskKey: string | null;
|
|
14
|
+
commentPreview: string | null;
|
|
15
|
+
objectName: string;
|
|
16
|
+
systemTitle: string | null;
|
|
17
|
+
showInvitationActor: boolean;
|
|
18
|
+
fallbackUser: {
|
|
19
|
+
id: string;
|
|
20
|
+
avatar: string | null;
|
|
21
|
+
name: string | null;
|
|
22
|
+
} | null;
|
|
23
|
+
statusFirst: boolean;
|
|
24
|
+
tailConnector: string;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useNotificationItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationItem.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/hooks/useNotificationItem.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAoBzE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;EAuIrD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useTranslation as U } from "react-i18next";
|
|
2
|
+
import { IconEntity as G } from "../../ProjectIcon/ProjectIcon.js";
|
|
3
|
+
import { useAppContainerDataStore as x } from "../../AppContainer/hooks/useAppContainerDataStore.js";
|
|
4
|
+
import { resolveNotificationType as F, getNotificationVerbSelf as $, getNotificationVerb as Y, getSourceLabel as B, getSourceKey as W, getSystemMessage as X } from "../lib/notificationText.js";
|
|
5
|
+
import { stripHtml as q } from "../lib/stripHtml.js";
|
|
6
|
+
import { useNotificationTime as z } from "./useNotificationTime.js";
|
|
7
|
+
function J(e) {
|
|
8
|
+
const o = e || "";
|
|
9
|
+
return o.includes("WORKSPACE_CREATED") ? "system-success" : o.includes("INVITATION_ACCEPTED") ? "system-invitation-accepted" : o.includes("INVITATION_DECLINED") ? "system-invitation-declined" : o.includes("WORKSPACE_DELETED") ? "system-alert" : o === "MISSED_CALL" ? "system-call-missed" : o.includes("SUBSCRIPTION") || o.includes("EXPIRE") ? "system-warning" : "user-action";
|
|
10
|
+
}
|
|
11
|
+
function De(e) {
|
|
12
|
+
const { t: o } = U("appContainer"), r = x((n) => n.user), v = z(), t = F(e.notificationType), A = J(t), E = A === "user-action", D = !e.actorUserId || e.actorUserId === r.id, _ = D ? "" : e.actorName || o("inbox.actor.someone"), c = e.params?.reaction || "", d = c.includes("=") && G.parse(c)?.emoji || c, N = d ? { emoji: d } : void 0, O = D ? $(o, e.notificationType, N) : Y(o, e.notificationType, N), M = B(o, e.notificationType, e.link ?? e.parentId), P = W(e.notificationType, e.link ?? e.parentId), b = v(e.createdAt), l = t === "ACCESS_GRANTED" || t === "ACCESS_REVOKED" || t === "INVITATION_ACCEPTED_BY", C = (n) => {
|
|
13
|
+
const a = `inbox.role.${n}`, i = o(a, { defaultValue: n });
|
|
14
|
+
return i === a ? n : i;
|
|
15
|
+
}, T = t === "TASK_TIME_ESTIMATE_ADDED", m = t === "TASK_TIME_ESTIMATE_CHANGED", S = (n) => {
|
|
16
|
+
if (!n) return null;
|
|
17
|
+
const a = Number(n);
|
|
18
|
+
if (!Number.isFinite(a) || a <= 0) return null;
|
|
19
|
+
const i = a / 60;
|
|
20
|
+
return i >= 1 ? i % 1 === 0 ? `${i}h` : `${i.toFixed(1)}h` : `${Math.round(a)}m`;
|
|
21
|
+
}, p = t === "TASK_TIME_ESTIMATE_REMOVED" || (t === "TASK_START_DATE_REMOVED" || t === "TASK_DUE_DATE_REMOVED") || t === "TASK_PARENT_REMOVED" ? null : e.params?.newValue || null, f = e.params?.oldValue || null, u = l ? e.params?.role || null : T || m ? S(p) : p, K = l && u ? C(u) : u, I = t === "TASK_START_DATE_CHANGED" || t === "TASK_DUE_DATE_CHANGED", R = t === "TASK_START_DATE_ADDED" || t === "TASK_DUE_DATE_ADDED", V = I || m ? m ? S(f) : f : null, g = o(l ? "inbox.asConnector" : "inbox.statusConnector"), h = e.params?.taskKey || null, y = (t === "TASK_COMMENT_ADDED" || t === "PAGE_COMMENT_ADDED" || t === "COMMENT_REPLIED") && e.params?.commentPreview || "", w = y && q(y) || null, k = t === "COMMENT_RESOLVED" || t === "COMMENT_REACTION_ADDED" || t === "MISSED_CALL" || t === "CHANNEL_ADDED" ? "" : e.objectName || "", s = {};
|
|
22
|
+
e.objectName && (s.role = e.objectName, s.channel = e.objectName, s.workspace = e.objectName), e.params?.role && (s.role = C(e.params.role)), e.params?.actor ? s.actor = e.params.actor : e.actorName && (s.actor = e.actorName);
|
|
23
|
+
const L = E ? null : X(
|
|
24
|
+
o,
|
|
25
|
+
e.notificationType,
|
|
26
|
+
Object.keys(s).length ? s : void 0
|
|
27
|
+
) || e.notificationType || "", j = !E && !!_ && !!(t?.includes("INVITATION_ACCEPTED") || t?.includes("INVITATION_DECLINED")), H = r.id ? { id: r.id, avatar: r.avatar || null, name: r.name || null } : null;
|
|
28
|
+
return {
|
|
29
|
+
resolved: t,
|
|
30
|
+
variant: A,
|
|
31
|
+
isUser: E,
|
|
32
|
+
actorName: _,
|
|
33
|
+
verb: O,
|
|
34
|
+
source: M,
|
|
35
|
+
sourceKey: P,
|
|
36
|
+
time: b,
|
|
37
|
+
statusValue: K,
|
|
38
|
+
statusOldValue: V,
|
|
39
|
+
taskKey: h,
|
|
40
|
+
commentPreview: w,
|
|
41
|
+
objectName: k,
|
|
42
|
+
systemTitle: L,
|
|
43
|
+
showInvitationActor: j,
|
|
44
|
+
fallbackUser: H,
|
|
45
|
+
statusFirst: t === "TASK_STATUS_CHANGED" || t === "TASK_TYPE_CHANGED" || t === "TASK_PRIORITY_CHANGED" || t === "TASK_PARENT_CHANGED" || I || R || T || m,
|
|
46
|
+
tailConnector: g
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
De as useNotificationItem
|
|
51
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { NotificationDTO, NotificationTab, SourceCategoryKey, UnreadCounts } from '../lib/types';
|
|
2
|
+
interface PerWorkspaceFilter {
|
|
3
|
+
activeSources: SourceCategoryKey[];
|
|
4
|
+
unreadOnly: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface NotificationStore {
|
|
7
|
+
notifications: NotificationDTO[];
|
|
8
|
+
tab: NotificationTab;
|
|
9
|
+
unreadOnly: boolean;
|
|
10
|
+
activeSources: Set<SourceCategoryKey>;
|
|
11
|
+
unreadCounts: UnreadCounts;
|
|
12
|
+
page: number;
|
|
13
|
+
totalElements: number;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
hasMore: boolean;
|
|
16
|
+
refreshTrigger: number;
|
|
17
|
+
currentWorkspaceId: string | null;
|
|
18
|
+
wsFilters: Record<string, PerWorkspaceFilter>;
|
|
19
|
+
setTab: (tab: NotificationTab) => void;
|
|
20
|
+
setUnreadOnly: (v: boolean) => void;
|
|
21
|
+
toggleSource: (key: SourceCategoryKey) => void;
|
|
22
|
+
setSources: (keys: SourceCategoryKey[]) => void;
|
|
23
|
+
setWorkspaceContext: (workspaceId: string) => void;
|
|
24
|
+
setNotifications: (items: NotificationDTO[], total: number) => void;
|
|
25
|
+
appendNotifications: (items: NotificationDTO[], total: number) => void;
|
|
26
|
+
setUnreadCounts: (counts: UnreadCounts) => void;
|
|
27
|
+
setLoading: (v: boolean) => void;
|
|
28
|
+
nextPage: () => void;
|
|
29
|
+
resetPage: () => void;
|
|
30
|
+
updateNotification: (id: number, patch: Partial<NotificationDTO>) => void;
|
|
31
|
+
removeNotification: (id: number) => void;
|
|
32
|
+
triggerRefresh: () => void;
|
|
33
|
+
}
|
|
34
|
+
export declare const useNotificationStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<NotificationStore>, "setState" | "persist"> & {
|
|
35
|
+
setState(partial: NotificationStore | Partial<NotificationStore> | ((state: NotificationStore) => NotificationStore | Partial<NotificationStore>), replace?: false | undefined): unknown;
|
|
36
|
+
setState(state: NotificationStore | ((state: NotificationStore) => NotificationStore), replace: true): unknown;
|
|
37
|
+
persist: {
|
|
38
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<NotificationStore, unknown, unknown>>) => void;
|
|
39
|
+
clearStorage: () => void;
|
|
40
|
+
rehydrate: () => Promise<void> | void;
|
|
41
|
+
hasHydrated: () => boolean;
|
|
42
|
+
onHydrate: (fn: (state: NotificationStore) => void) => () => void;
|
|
43
|
+
onFinishHydration: (fn: (state: NotificationStore) => void) => () => void;
|
|
44
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<NotificationStore, unknown, unknown>>;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
export declare function getActiveSourceValues(sources: Set<SourceCategoryKey>): number[] | undefined;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=useNotificationStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationStore.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/hooks/useNotificationStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACb,MAAM,cAAc,CAAC;AAGtB,UAAU,kBAAkB;IAC1B,aAAa,EAAE,iBAAiB,EAAE,CAAC;IACnC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,iBAAiB;IACzB,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,GAAG,EAAE,eAAe,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACtC,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAE9C,MAAM,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,YAAY,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,CAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,IAAI,CAAC;IAChD,mBAAmB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,gBAAgB,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,mBAAmB,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvE,eAAe,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC1E,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AA+CD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EA8GhC,CAAC;AAQF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,GAAG,CAAC,iBAAiB,CAAC,GAC9B,MAAM,EAAE,GAAG,SAAS,CAWtB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { create as l } from "zustand";
|
|
2
|
+
import { persist as d, createJSONStorage as g } from "zustand/middleware";
|
|
3
|
+
import { NotificationSourceCategory as S } from "../lib/types.js";
|
|
4
|
+
const p = /* @__PURE__ */ new Set(["INVITATION_CREATED", "INVITATION_CREATE"]), E = /* @__PURE__ */ new Set([
|
|
5
|
+
"ROLE_CREATED",
|
|
6
|
+
"ROLE_ASSIGNED",
|
|
7
|
+
"ROLE_UPDATED",
|
|
8
|
+
"ROLE_DELETED"
|
|
9
|
+
]);
|
|
10
|
+
function c(t) {
|
|
11
|
+
return t.filter((e) => !(e.objectName?.startsWith("_system.") || e.notificationType && p.has(e.notificationType) || !e.notificationType && e.title && E.has(e.title)));
|
|
12
|
+
}
|
|
13
|
+
const m = /* @__PURE__ */ new Set([
|
|
14
|
+
"PAGE",
|
|
15
|
+
"PROJECT",
|
|
16
|
+
"FORM",
|
|
17
|
+
"FLOW"
|
|
18
|
+
]);
|
|
19
|
+
function h(t) {
|
|
20
|
+
return Array.isArray(t) ? t.filter(
|
|
21
|
+
(e) => typeof e == "string" && m.has(e)
|
|
22
|
+
) : [];
|
|
23
|
+
}
|
|
24
|
+
function o(t) {
|
|
25
|
+
return t.currentWorkspaceId ? {
|
|
26
|
+
...t.wsFilters,
|
|
27
|
+
[t.currentWorkspaceId]: {
|
|
28
|
+
activeSources: [...t.activeSources],
|
|
29
|
+
unreadOnly: t.unreadOnly
|
|
30
|
+
}
|
|
31
|
+
} : t.wsFilters;
|
|
32
|
+
}
|
|
33
|
+
const N = l()(
|
|
34
|
+
d(
|
|
35
|
+
(t) => ({
|
|
36
|
+
notifications: [],
|
|
37
|
+
tab: "ALL",
|
|
38
|
+
unreadOnly: !1,
|
|
39
|
+
activeSources: /* @__PURE__ */ new Set(),
|
|
40
|
+
unreadCounts: { all: 0, mentions: 0 },
|
|
41
|
+
page: 0,
|
|
42
|
+
totalElements: 0,
|
|
43
|
+
loading: !1,
|
|
44
|
+
hasMore: !0,
|
|
45
|
+
refreshTrigger: 0,
|
|
46
|
+
currentWorkspaceId: null,
|
|
47
|
+
wsFilters: {},
|
|
48
|
+
setTab: (e) => t({ tab: e, page: 0, notifications: [], hasMore: !0 }),
|
|
49
|
+
setUnreadOnly: (e) => t((r) => ({
|
|
50
|
+
unreadOnly: e,
|
|
51
|
+
wsFilters: o({ ...r, unreadOnly: e }),
|
|
52
|
+
page: 0,
|
|
53
|
+
notifications: [],
|
|
54
|
+
hasMore: !0
|
|
55
|
+
})),
|
|
56
|
+
toggleSource: (e) => t((r) => {
|
|
57
|
+
const i = new Set(r.activeSources);
|
|
58
|
+
return i.has(e) ? i.delete(e) : i.add(e), {
|
|
59
|
+
activeSources: i,
|
|
60
|
+
wsFilters: o({ ...r, activeSources: i }),
|
|
61
|
+
page: 0,
|
|
62
|
+
notifications: [],
|
|
63
|
+
hasMore: !0
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
setSources: (e) => t((r) => {
|
|
67
|
+
const i = new Set(e);
|
|
68
|
+
return {
|
|
69
|
+
activeSources: i,
|
|
70
|
+
wsFilters: o({ ...r, activeSources: i }),
|
|
71
|
+
page: 0,
|
|
72
|
+
notifications: [],
|
|
73
|
+
hasMore: !0
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
setWorkspaceContext: (e) => t((r) => {
|
|
77
|
+
if (r.currentWorkspaceId === e) return r;
|
|
78
|
+
const i = o(r), n = i[e];
|
|
79
|
+
return {
|
|
80
|
+
currentWorkspaceId: e,
|
|
81
|
+
wsFilters: i,
|
|
82
|
+
activeSources: new Set(h(n?.activeSources)),
|
|
83
|
+
unreadOnly: n?.unreadOnly ?? !1,
|
|
84
|
+
page: 0,
|
|
85
|
+
notifications: [],
|
|
86
|
+
hasMore: !0
|
|
87
|
+
};
|
|
88
|
+
}),
|
|
89
|
+
setNotifications: (e, r) => {
|
|
90
|
+
const i = c(e);
|
|
91
|
+
t({
|
|
92
|
+
notifications: i,
|
|
93
|
+
totalElements: r,
|
|
94
|
+
hasMore: e.length < r
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
appendNotifications: (e, r) => t((i) => {
|
|
98
|
+
const n = c(e), u = new Set(i.notifications.map((a) => a.id)), f = n.filter((a) => !u.has(a.id)), s = [...i.notifications, ...f];
|
|
99
|
+
return {
|
|
100
|
+
notifications: s,
|
|
101
|
+
totalElements: r,
|
|
102
|
+
hasMore: e.length > 0 && s.length < r
|
|
103
|
+
};
|
|
104
|
+
}),
|
|
105
|
+
setUnreadCounts: (e) => t({ unreadCounts: e }),
|
|
106
|
+
setLoading: (e) => t({ loading: e }),
|
|
107
|
+
nextPage: () => t((e) => ({ page: e.page + 1 })),
|
|
108
|
+
resetPage: () => t({ page: 0, notifications: [], hasMore: !0 }),
|
|
109
|
+
updateNotification: (e, r) => t((i) => ({
|
|
110
|
+
notifications: i.notifications.map(
|
|
111
|
+
(n) => n.id === e ? { ...n, ...r } : n
|
|
112
|
+
)
|
|
113
|
+
})),
|
|
114
|
+
removeNotification: (e) => t((r) => ({
|
|
115
|
+
notifications: r.notifications.filter((i) => i.id !== e),
|
|
116
|
+
totalElements: r.totalElements - 1
|
|
117
|
+
})),
|
|
118
|
+
triggerRefresh: () => t((e) => ({ refreshTrigger: e.refreshTrigger + 1 }))
|
|
119
|
+
}),
|
|
120
|
+
{
|
|
121
|
+
name: "inbox-filters",
|
|
122
|
+
version: 1,
|
|
123
|
+
storage: g(() => localStorage),
|
|
124
|
+
partialize: (t) => ({ wsFilters: t.wsFilters }),
|
|
125
|
+
migrate: (t, e) => ({ wsFilters: {} })
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
function I(t) {
|
|
130
|
+
if (t.size === 0) return;
|
|
131
|
+
const e = /* @__PURE__ */ new Set();
|
|
132
|
+
for (const r of t)
|
|
133
|
+
e.add(S[r]), r === "PROJECT" && (e.add(4), e.add(5));
|
|
134
|
+
return [...e];
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
I as getActiveSourceValues,
|
|
138
|
+
N as useNotificationStore
|
|
139
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationStream.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/hooks/useNotificationStream.ts"],"names":[],"mappings":"AAWA,wBAAgB,qBAAqB,CAAC,OAAO,UAAO,EAAE,WAAW,CAAC,EAAE,MAAM,QA4JzE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useRef as v, useEffect as g } from "react";
|
|
2
|
+
import { fetchUnreadCounts as U } from "../lib/api.js";
|
|
3
|
+
import { useNotificationStore as S, getActiveSourceValues as p } from "./useNotificationStore.js";
|
|
4
|
+
const w = "/v1/notifications/stream", A = 15e3, M = 1e4, O = 6e4;
|
|
5
|
+
function V(u = !0, t) {
|
|
6
|
+
const C = S((e) => e.setUnreadCounts), y = S((e) => e.triggerRefresh), a = S((e) => e.activeSources), L = S(
|
|
7
|
+
(e) => e.setWorkspaceContext
|
|
8
|
+
), f = v(C), E = v(y), _ = v(t), h = v(a);
|
|
9
|
+
f.current = C, E.current = y, _.current = t, h.current = a, g(() => {
|
|
10
|
+
t && L(t);
|
|
11
|
+
}, [t, L]), g(() => {
|
|
12
|
+
if (!u) return;
|
|
13
|
+
let e = null, n, s, l = M, c = !1, r = !1;
|
|
14
|
+
const o = async () => {
|
|
15
|
+
if (!r)
|
|
16
|
+
try {
|
|
17
|
+
const i = p(h.current), m = await U(
|
|
18
|
+
_.current,
|
|
19
|
+
i
|
|
20
|
+
);
|
|
21
|
+
r || f.current(m);
|
|
22
|
+
} catch (i) {
|
|
23
|
+
console.warn("[NotificationStream] Failed to fetch counts:", i);
|
|
24
|
+
}
|
|
25
|
+
}, N = () => {
|
|
26
|
+
n || r || (n = setInterval(o, A));
|
|
27
|
+
}, T = () => {
|
|
28
|
+
n && (clearInterval(n), n = void 0);
|
|
29
|
+
}, R = () => {
|
|
30
|
+
if (!r) {
|
|
31
|
+
e && (e.close(), e = null);
|
|
32
|
+
try {
|
|
33
|
+
e = new EventSource(w, { withCredentials: !0 }), e.onopen = () => {
|
|
34
|
+
l = M, c = !1, T();
|
|
35
|
+
}, e.addEventListener("notification_created", () => {
|
|
36
|
+
o(), E.current();
|
|
37
|
+
}), e.addEventListener("badge_update", (i) => {
|
|
38
|
+
if (!r) {
|
|
39
|
+
if (h.current.size > 0) {
|
|
40
|
+
o();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const m = JSON.parse(i.data);
|
|
45
|
+
f.current({
|
|
46
|
+
all: m.allUnread ?? 0,
|
|
47
|
+
mentions: m.mentionsUnread ?? 0
|
|
48
|
+
});
|
|
49
|
+
} catch {
|
|
50
|
+
o();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}), e.onerror = () => {
|
|
54
|
+
e && (e.close(), e = null), !r && (c || (c = !0, o(), N()), s = setTimeout(() => {
|
|
55
|
+
R();
|
|
56
|
+
}, l), l = Math.min(l * 2, O));
|
|
57
|
+
};
|
|
58
|
+
} catch {
|
|
59
|
+
c = !0, N();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
o(), R();
|
|
64
|
+
const d = () => {
|
|
65
|
+
document.visibilityState === "visible" && (o(), E.current(), (c || !e) && R());
|
|
66
|
+
};
|
|
67
|
+
return document.addEventListener("visibilitychange", d), window.addEventListener("focus", d), () => {
|
|
68
|
+
r = !0, e && (e.close(), e = null), s && clearTimeout(s), T(), document.removeEventListener("visibilitychange", d), window.removeEventListener("focus", d);
|
|
69
|
+
};
|
|
70
|
+
}, [u]), g(() => {
|
|
71
|
+
if (!u) return;
|
|
72
|
+
let e = !1;
|
|
73
|
+
return (async () => {
|
|
74
|
+
try {
|
|
75
|
+
const n = p(a), s = await U(t, n);
|
|
76
|
+
e || f.current(s);
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
})(), () => {
|
|
80
|
+
e = !0;
|
|
81
|
+
};
|
|
82
|
+
}, [u, t, a]);
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
V as useNotificationStream
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationTime.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/hooks/useNotificationTime.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,IAAI,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAyBjE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback as c } from "react";
|
|
2
|
+
import { useTranslation as f } from "react-i18next";
|
|
3
|
+
function h() {
|
|
4
|
+
const { t, i18n: o } = f("appContainer");
|
|
5
|
+
return c(
|
|
6
|
+
(u) => {
|
|
7
|
+
const e = new Date(u), i = /* @__PURE__ */ new Date(), r = i.getTime() - e.getTime(), n = Math.floor(r / 6e4), a = Math.floor(r / 36e5);
|
|
8
|
+
if (n < 1) return t("inbox.time.justNow");
|
|
9
|
+
if (n < 60) return t("inbox.time.minutesAgo", { count: n });
|
|
10
|
+
if (a < 24) return t("inbox.time.hoursAgo", { count: a });
|
|
11
|
+
const s = o.language === "ru" ? "ru-RU" : "en-US", m = e.getFullYear() === i.getFullYear();
|
|
12
|
+
return new Intl.DateTimeFormat(s, {
|
|
13
|
+
day: "numeric",
|
|
14
|
+
month: "short",
|
|
15
|
+
...m ? {} : { year: "numeric" }
|
|
16
|
+
}).format(e);
|
|
17
|
+
},
|
|
18
|
+
[t, o.language]
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
h as useNotificationTime
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NotificationsResponse, NotificationTab, UnreadCounts } from '../lib/types';
|
|
2
|
+
declare function fetchNotifications(tab: NotificationTab, page: number, size: number, unreadOnly: boolean, sources?: number[], workspaceId?: string): Promise<NotificationsResponse>;
|
|
3
|
+
declare function fetchCounts(workspaceId?: string, sources?: number[]): Promise<UnreadCounts>;
|
|
4
|
+
declare function markAsRead(ids: number[]): Promise<unknown>;
|
|
5
|
+
declare function markAsUnread(ids: number[]): Promise<unknown>;
|
|
6
|
+
declare function markAllAsRead(): Promise<unknown>;
|
|
7
|
+
declare function archiveIds(ids: number[]): Promise<unknown>;
|
|
8
|
+
declare function unarchiveIds(ids: number[]): Promise<unknown>;
|
|
9
|
+
declare function archiveAll(): Promise<unknown>;
|
|
10
|
+
declare function archiveRead(): Promise<unknown>;
|
|
11
|
+
declare const api: {
|
|
12
|
+
readonly fetchNotifications: typeof fetchNotifications;
|
|
13
|
+
readonly fetchCounts: typeof fetchCounts;
|
|
14
|
+
readonly markAsRead: typeof markAsRead;
|
|
15
|
+
readonly markAsUnread: typeof markAsUnread;
|
|
16
|
+
readonly markAllAsRead: typeof markAllAsRead;
|
|
17
|
+
readonly archiveIds: typeof archiveIds;
|
|
18
|
+
readonly unarchiveIds: typeof unarchiveIds;
|
|
19
|
+
readonly archiveAll: typeof archiveAll;
|
|
20
|
+
readonly archiveRead: typeof archiveRead;
|
|
21
|
+
};
|
|
22
|
+
export type NotificationsApi = typeof api;
|
|
23
|
+
export declare function useNotificationsApi(): NotificationsApi;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=useNotificationsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationsApi.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/hooks/useNotificationsApi.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,YAAY,EACb,MAAM,cAAc,CAAC;AAEtB,iBAAS,kBAAkB,CACzB,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,EACnB,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAchC;AAED,iBAAS,WAAW,CAClB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,YAAY,CAAC,CAEvB;AAED,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,oBAKhC;AAED,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,oBAKlC;AAED,iBAAS,aAAa,qBAErB;AAED,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,oBAKhC;AAED,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,oBAKlC;AAED,iBAAS,UAAU,qBAElB;AAED,iBAAS,WAAW,qBAEnB;AAED,QAAA,MAAM,GAAG;;;;;;;;;;CAUC,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,CAAC;AAE1C,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useMemo as s } from "react";
|
|
2
|
+
import { apiFetch as n, fetchUnreadCounts as d } from "../lib/api.js";
|
|
3
|
+
function u(i, t, a, c, r, e) {
|
|
4
|
+
const o = new URLSearchParams({
|
|
5
|
+
tab: i,
|
|
6
|
+
page: String(t),
|
|
7
|
+
size: String(a),
|
|
8
|
+
unreadOnly: String(c)
|
|
9
|
+
});
|
|
10
|
+
return r?.length && r.forEach((f) => o.append("sources", String(f))), e && o.set("workspaceId", e), n(`/v1/notifications?${o}`);
|
|
11
|
+
}
|
|
12
|
+
function h(i, t) {
|
|
13
|
+
return d(i, t);
|
|
14
|
+
}
|
|
15
|
+
function m(i) {
|
|
16
|
+
return n("/v1/notifications/read", {
|
|
17
|
+
method: "PATCH",
|
|
18
|
+
body: JSON.stringify({ notificationIds: i })
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function v(i) {
|
|
22
|
+
return n("/v1/notifications/unread", {
|
|
23
|
+
method: "PATCH",
|
|
24
|
+
body: JSON.stringify({ notificationIds: i })
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function A() {
|
|
28
|
+
return n("/v1/notifications/readAll", { method: "PATCH" });
|
|
29
|
+
}
|
|
30
|
+
function g(i) {
|
|
31
|
+
return n("/v1/notifications/archive", {
|
|
32
|
+
method: "PATCH",
|
|
33
|
+
body: JSON.stringify({ notificationIds: i })
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function l(i) {
|
|
37
|
+
return n("/v1/notifications/unarchive", {
|
|
38
|
+
method: "PATCH",
|
|
39
|
+
body: JSON.stringify({ notificationIds: i })
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function p() {
|
|
43
|
+
return n("/v1/notifications/archiveAll", { method: "PATCH" });
|
|
44
|
+
}
|
|
45
|
+
function y() {
|
|
46
|
+
return n("/v1/notifications/archiveRead", { method: "PATCH" });
|
|
47
|
+
}
|
|
48
|
+
const C = {
|
|
49
|
+
fetchNotifications: u,
|
|
50
|
+
fetchCounts: h,
|
|
51
|
+
markAsRead: m,
|
|
52
|
+
markAsUnread: v,
|
|
53
|
+
markAllAsRead: A,
|
|
54
|
+
archiveIds: g,
|
|
55
|
+
unarchiveIds: l,
|
|
56
|
+
archiveAll: p,
|
|
57
|
+
archiveRead: y
|
|
58
|
+
};
|
|
59
|
+
function H() {
|
|
60
|
+
return s(() => C, []);
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
H as useNotificationsApi
|
|
64
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UnreadCounts } from './types';
|
|
2
|
+
export declare function apiFetch<T>(url: string, options?: RequestInit): Promise<T>;
|
|
3
|
+
export declare function fetchUnreadCounts(workspaceId?: string, sources?: number[]): Promise<UnreadCounts>;
|
|
4
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAsB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAQhF;AAED,wBAAsB,iBAAiB,CACrC,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,YAAY,CAAC,CAMvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
async function o(n, e) {
|
|
2
|
+
const t = await fetch(n, {
|
|
3
|
+
credentials: "include",
|
|
4
|
+
headers: { "Content-Type": "application/json" },
|
|
5
|
+
...e
|
|
6
|
+
});
|
|
7
|
+
if (!t.ok) throw new Error(`${t.status} ${t.statusText}`);
|
|
8
|
+
return t.json();
|
|
9
|
+
}
|
|
10
|
+
async function r(n, e) {
|
|
11
|
+
const t = new URLSearchParams();
|
|
12
|
+
n && t.set("workspaceId", n), e?.length && e.forEach((a) => t.append("sources", String(a)));
|
|
13
|
+
const s = t.toString();
|
|
14
|
+
return o(`/v1/notifications/counts${s ? `?${s}` : ""}`);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
o as apiFetch,
|
|
18
|
+
r as fetchUnreadCounts
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Notification/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
|