@nivaro/react 0.3.41 → 0.3.42
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/components/LayoutForm.js +100 -98
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +644 -15
- package/dist/index.js +814 -775
- package/dist/shared/components/ActivityEntry.js +154 -0
- package/dist/shared/components/AudienceConfirmPanel.js +98 -0
- package/dist/shared/components/BackgroundRunOffer.js +43 -31
- package/dist/shared/components/BroadcastView.js +225 -204
- package/dist/shared/components/CollectionBrowserView.js +3924 -3584
- package/dist/shared/components/ConfigHistory.js +153 -0
- package/dist/shared/components/ConfigReadBack.js +65 -0
- package/dist/shared/components/DataTable.js +379 -346
- package/dist/shared/components/ForceReloadBanner.js +47 -40
- package/dist/shared/components/IdleReloadWatcher.js +69 -0
- package/dist/shared/components/ItemEditForm.js +4041 -3853
- package/dist/shared/components/MyWorkView.js +278 -213
- package/dist/shared/components/NotificationBell.js +130 -121
- package/dist/shared/components/ProfileView.js +776 -1003
- package/dist/shared/components/RecentRecordsRail.js +34 -16
- package/dist/shared/components/RecordReadView.js +500 -477
- package/dist/shared/components/Skeletons.js +199 -0
- package/dist/shared/components/SlowNotice.js +63 -0
- package/dist/shared/components/Term.js +23 -0
- package/dist/shared/components/WidgetSlot.js +350 -353
- package/dist/shared/components/access/PermissionSummary.js +106 -0
- package/dist/shared/components/bulk/BulkActionButtons.js +76 -73
- package/dist/shared/components/chat/ChatPanel.js +902 -886
- package/dist/shared/components/chat/MemberPaging.js +70 -0
- package/dist/shared/components/chat/RoomParts.js +147 -117
- package/dist/shared/components/chat/ScreenClip.js +73 -69
- package/dist/shared/components/chat/chat-core.js +449 -396
- package/dist/shared/components/chat/huddle/huddle-store.js +48 -43
- package/dist/shared/components/help-videos/api.js +2 -5
- package/dist/shared/components/help-videos/viewer/HelpVideoMatchChip.js +79 -0
- package/dist/shared/components/help-videos/viewer/matchChip.js +50 -0
- package/dist/shared/components/imports/CollectionImportPanel.js +139 -133
- package/dist/shared/components/imports/RunDetailSheet.js +222 -227
- package/dist/shared/components/integrations/console/ErrorExplanation.js +121 -0
- package/dist/shared/components/integrations/console/PartnerDetail.js +175 -174
- package/dist/shared/components/integrations/console/SubmissionRow.js +36 -34
- package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +50 -48
- package/dist/shared/components/item-edit/FieldComments.js +212 -0
- package/dist/shared/components/item-edit/FieldRow.js +340 -336
- package/dist/shared/components/item-edit/RecordHeaderActions.js +23 -22
- package/dist/shared/components/item-edit/RelationCombobox.js +231 -222
- package/dist/shared/components/item-edit/RuleHiddenNotes.js +55 -0
- package/dist/shared/components/item-edit/field-comments-context.js +6 -0
- package/dist/shared/components/item-edit/field-sources.js +33 -0
- package/dist/shared/components/item-edit/rule-hidden.js +30 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +113 -96
- package/dist/shared/components/layout-editor/editors/cascade-filters.js +170 -145
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +22 -18
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +177 -159
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +35 -34
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +124 -111
- package/dist/shared/components/layout-editor/inspector/kit.js +292 -277
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/list/CopyListLinkButton.js +41 -0
- package/dist/shared/components/list/InlineEdit.js +363 -0
- package/dist/shared/components/notifications/NotificationCenterView.js +213 -181
- package/dist/shared/components/notifications/NotificationDetailBits.js +205 -82
- package/dist/shared/components/notifications/NotificationRulesEditor.js +515 -0
- package/dist/shared/components/notifications/TestMyRules.js +137 -0
- package/dist/shared/components/notifications/changes-lines.js +24 -0
- package/dist/shared/components/notifications/why-lines.js +64 -0
- package/dist/shared/components/panels/CommentPanel.js +316 -281
- package/dist/shared/components/panels/LegalHoldBanner.js +38 -0
- package/dist/shared/components/panels/PipelinePanel.js +201 -196
- package/dist/shared/components/panels/RevisionsPanel.js +496 -479
- package/dist/shared/components/pipeline/PipelineEditorView.js +1587 -1560
- package/dist/shared/components/pipeline/PipelineStateOwners.js +116 -103
- package/dist/shared/components/profile/PersonDidPanel.js +188 -0
- package/dist/shared/components/profile/PersonProfile.js +57 -52
- package/dist/shared/components/queue/QueueWorklist.js +1526 -1365
- package/dist/shared/hooks/useSlowReason.js +39 -0
- package/dist/shared/lib/activity-sentence.js +670 -0
- package/dist/shared/lib/config-sentences.js +418 -0
- package/dist/shared/lib/core-glossary.js +229 -0
- package/dist/shared/lib/error-hints.js +159 -0
- package/dist/shared/lib/error-message.js +105 -0
- package/dist/shared/lib/error-toast.js +22 -0
- package/dist/shared/lib/field-comments.js +25 -0
- package/dist/shared/lib/filter-sentence.js +261 -0
- package/dist/shared/lib/glossary.js +55 -48
- package/dist/shared/lib/idle-reload.js +138 -0
- package/dist/shared/lib/layout-resolve.js +42 -29
- package/dist/shared/lib/list-inline-edit.js +190 -0
- package/dist/shared/lib/list-link.js +147 -0
- package/dist/shared/lib/prefetch.js +259 -106
- package/dist/shared/lib/record-ref.js +72 -0
- package/dist/shared/lib/reload-holds.js +25 -0
- package/dist/shared/lib/safe-error.js +52 -24
- package/dist/shared/lib/skeleton-shapes.js +72 -0
- package/dist/shared/lib/slow-reason.js +63 -0
- package/package.json +1 -1
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { readItems as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { toast as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as g, patch as R, post as
|
|
7
|
-
import { isDndActive as
|
|
8
|
-
import { useLiveRefetchInterval as
|
|
9
|
-
import { playNotificationSound as
|
|
10
|
-
import { announceLocalPrefs as
|
|
11
|
-
import { bindChatOutbox as
|
|
12
|
-
import { discardOutbox as
|
|
13
|
-
import { huddleHolds as
|
|
14
|
-
const
|
|
15
|
-
function
|
|
16
|
-
const e =
|
|
1
|
+
import { readItems as Z } from "@nivaro/sdk";
|
|
2
|
+
import { useQueryClient as q, useMutation as y, useQuery as p, useInfiniteQuery as J } from "@tanstack/react-query";
|
|
3
|
+
import { useContext as X, useState as O, useEffect as w, useMemo as k, useCallback as I, useRef as Q, createContext as ee } from "react";
|
|
4
|
+
import { toast as te } from "sonner";
|
|
5
|
+
import { useNivaroClient as f } from "../../context.js";
|
|
6
|
+
import { get as g, patch as R, post as F, del as N } from "../../lib/commands.js";
|
|
7
|
+
import { isDndActive as ne } from "../../lib/dnd.js";
|
|
8
|
+
import { useLiveRefetchInterval as se } from "../../lib/live-queries.js";
|
|
9
|
+
import { playNotificationSound as re } from "../../lib/notification-sound.js";
|
|
10
|
+
import { announceLocalPrefs as oe } from "../../lib/user-sync.js";
|
|
11
|
+
import { bindChatOutbox as ae, enqueueChatOutbox as ie } from "./chat-outbox.js";
|
|
12
|
+
import { discardOutbox as Ft, editOutbox as Kt, holdOutbox as Ot, nudgeChatOutbox as It, retryOutbox as xt, useOutbox as kt } from "./chat-outbox.js";
|
|
13
|
+
import { huddleHolds as ce, holdNotification as ue } from "./huddle/huddle-hold.js";
|
|
14
|
+
const Pe = ["👍", "✅", "👀", "🎉", "❤️", "😂"], le = ee(null);
|
|
15
|
+
function _() {
|
|
16
|
+
const e = X(le);
|
|
17
17
|
if (!e) throw new Error("Chat components must be wrapped in <ChatProvider>");
|
|
18
18
|
return e;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const Qe = 0, Ne = {
|
|
21
21
|
collections: { messages: "chat_messages", reads: "chat_last_read", presence: "user_presence" },
|
|
22
22
|
globalRoom: "global",
|
|
23
23
|
globalLabel: "General",
|
|
24
24
|
entityPattern: String.raw`\b([A-Za-z]{2,4}\d{2}(?:INV)?-\d+)\b`
|
|
25
25
|
};
|
|
26
|
-
function
|
|
26
|
+
function Ue(e, t) {
|
|
27
27
|
return `dm:${[e.toUpperCase(), t.toUpperCase()].sort().join(":")}`;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function H(e, t) {
|
|
30
30
|
if (!e.startsWith("dm:")) return null;
|
|
31
|
-
const
|
|
32
|
-
return [
|
|
31
|
+
const n = e.slice(3);
|
|
32
|
+
return [n.slice(0, 36), n.slice(37)].find((o) => o.toLowerCase() !== t.toLowerCase()) ?? null;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
const
|
|
36
|
-
|
|
34
|
+
function K(e, t) {
|
|
35
|
+
const n = _(), s = q(), o = (t ?? []).join("|");
|
|
36
|
+
w(() => {
|
|
37
37
|
const r = () => {
|
|
38
|
-
for (const a of e)
|
|
38
|
+
for (const a of e) s.invalidateQueries({ queryKey: a });
|
|
39
39
|
};
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
42
|
-
}, [
|
|
43
|
-
}
|
|
44
|
-
function
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
return
|
|
49
|
-
for (const o of t)
|
|
40
|
+
if (n.subscribeRooms) return n.subscribeRooms(t ?? [], r);
|
|
41
|
+
if (n.realtime) return n.realtime(n.collections.messages, r);
|
|
42
|
+
}, [n.subscribeRooms, n.realtime, o, s]);
|
|
43
|
+
}
|
|
44
|
+
function de(e, t) {
|
|
45
|
+
const n = _(), s = q();
|
|
46
|
+
w(() => {
|
|
47
|
+
if (n.realtime)
|
|
48
|
+
return n.realtime(e, () => {
|
|
49
|
+
for (const o of t) s.invalidateQueries({ queryKey: o });
|
|
50
50
|
});
|
|
51
|
-
}, [
|
|
51
|
+
}, [n.realtime, e, s]);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
var
|
|
55
|
-
const
|
|
53
|
+
function Ae(e, t = null) {
|
|
54
|
+
var U, A, D;
|
|
55
|
+
const n = _(), s = f(), o = t ? "around" in t ? `around:${t.around}` : `date:${t.date}` : "latest", { data: r, isLoading: a } = p({
|
|
56
56
|
queryKey: ["nvr-chat", e, o],
|
|
57
57
|
queryFn: async () => {
|
|
58
58
|
const C = { room: e, limit: 80 };
|
|
59
|
-
return t && "around" in t && (C.around = t.around), t && "date" in t && (C.date = t.date), await
|
|
59
|
+
return t && "around" in t && (C.around = t.around), t && "date" in t && (C.date = t.date), await s.request(
|
|
60
60
|
g("/chat/messages", C)
|
|
61
61
|
);
|
|
62
62
|
},
|
|
63
63
|
enabled: !!e,
|
|
64
64
|
staleTime: 5e3,
|
|
65
|
-
refetchInterval:
|
|
65
|
+
refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
|
|
66
66
|
});
|
|
67
|
-
|
|
68
|
-
const [i, c] =
|
|
69
|
-
|
|
70
|
-
c([]),
|
|
67
|
+
K([["nvr-chat"], ["nvr-chat-rooms"], ["nvr-chat-thread"]], e ? [e] : []);
|
|
68
|
+
const [i, c] = O([]), [m, l] = O(null), [d, u] = O(!1);
|
|
69
|
+
w(() => {
|
|
70
|
+
c([]), l(null);
|
|
71
71
|
}, [e, o]);
|
|
72
|
-
const
|
|
73
|
-
if (i.length === 0) return
|
|
74
|
-
const C = new Set(
|
|
75
|
-
return [...i.filter((
|
|
76
|
-
}, [i,
|
|
77
|
-
var
|
|
72
|
+
const v = (r == null ? void 0 : r.data) ?? [], h = k(() => {
|
|
73
|
+
if (i.length === 0) return v;
|
|
74
|
+
const C = new Set(v.map((S) => S.id));
|
|
75
|
+
return [...i.filter((S) => !C.has(S.id)), ...v];
|
|
76
|
+
}, [i, v]), b = I(async () => {
|
|
77
|
+
var S;
|
|
78
78
|
if (!e || d) return;
|
|
79
|
-
const C =
|
|
79
|
+
const C = h[0];
|
|
80
80
|
if (C) {
|
|
81
|
-
|
|
81
|
+
u(!0);
|
|
82
82
|
try {
|
|
83
|
-
const
|
|
83
|
+
const E = await s.request(
|
|
84
84
|
g("/chat/messages", { room: e, limit: 60, before: C.id })
|
|
85
85
|
);
|
|
86
|
-
c((Y) => [...
|
|
86
|
+
c((Y) => [...E.data ?? [], ...Y]), l(!!((S = E.meta) != null && S.has_older));
|
|
87
87
|
} finally {
|
|
88
|
-
|
|
88
|
+
u(!1);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
}, [e,
|
|
91
|
+
}, [e, h, s, d]);
|
|
92
92
|
return {
|
|
93
|
-
messages:
|
|
93
|
+
messages: h,
|
|
94
94
|
loading: a,
|
|
95
|
-
hasOlder:
|
|
96
|
-
hasNewer: !!((
|
|
97
|
-
anchorId: ((
|
|
98
|
-
loadOlder:
|
|
95
|
+
hasOlder: m ?? !!((U = r == null ? void 0 : r.meta) != null && U.has_older),
|
|
96
|
+
hasNewer: !!((A = r == null ? void 0 : r.meta) != null && A.has_newer),
|
|
97
|
+
anchorId: ((D = r == null ? void 0 : r.meta) == null ? void 0 : D.anchor) ?? null,
|
|
98
|
+
loadOlder: b,
|
|
99
99
|
loadingOlder: d
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
102
|
+
function De(e, t) {
|
|
103
|
+
const n = _(), s = f(), { data: o, isLoading: r } = p({
|
|
104
104
|
queryKey: ["nvr-chat-thread", e, t],
|
|
105
|
-
queryFn: async () => (await
|
|
105
|
+
queryFn: async () => (await s.request(
|
|
106
106
|
g("/chat/messages", { room: e, thread: t, limit: 300 })
|
|
107
107
|
)).data ?? [],
|
|
108
108
|
enabled: !!e && !!t,
|
|
109
109
|
staleTime: 5e3,
|
|
110
|
-
refetchInterval:
|
|
110
|
+
refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
|
|
111
111
|
});
|
|
112
|
-
|
|
112
|
+
K([["nvr-chat-thread"]], e ? [e] : []);
|
|
113
113
|
const a = o ?? [];
|
|
114
114
|
return {
|
|
115
115
|
root: a.find((i) => i.id === t) ?? null,
|
|
@@ -117,47 +117,47 @@ function Ae(e, t) {
|
|
|
117
117
|
loading: r
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Ee(e) {
|
|
121
121
|
var r, a, i;
|
|
122
|
-
const t =
|
|
123
|
-
return
|
|
122
|
+
const t = f(), n = q(), s = _();
|
|
123
|
+
return ae(t, n, ((r = s.me) == null ? void 0 : r.id) ?? null), { mutate: I(
|
|
124
124
|
(c) => {
|
|
125
|
-
var
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
client_id:
|
|
125
|
+
var l, d;
|
|
126
|
+
const m = typeof c == "string" ? { text: c } : c;
|
|
127
|
+
ie({
|
|
128
|
+
client_id: me(),
|
|
129
129
|
room: e,
|
|
130
|
-
text:
|
|
131
|
-
mentions:
|
|
132
|
-
attachments:
|
|
133
|
-
parent_id:
|
|
134
|
-
quote_id:
|
|
135
|
-
urgent: !!
|
|
130
|
+
text: m.text,
|
|
131
|
+
mentions: m.mentions ?? [],
|
|
132
|
+
attachments: m.attachments ?? [],
|
|
133
|
+
parent_id: m.parentId ?? null,
|
|
134
|
+
quote_id: m.quoteId ?? null,
|
|
135
|
+
urgent: !!m.urgent,
|
|
136
136
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137
|
-
sender: ((
|
|
138
|
-
sender_name: ((d =
|
|
137
|
+
sender: ((l = s.me) == null ? void 0 : l.id) ?? "",
|
|
138
|
+
sender_name: ((d = s.me) == null ? void 0 : d.name) ?? null
|
|
139
139
|
});
|
|
140
140
|
},
|
|
141
|
-
[e, (a =
|
|
141
|
+
[e, (a = s.me) == null ? void 0 : a.id, (i = s.me) == null ? void 0 : i.name]
|
|
142
142
|
), isPending: !1 };
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function me() {
|
|
145
145
|
var t;
|
|
146
146
|
const e = globalThis.crypto;
|
|
147
147
|
return ((t = e == null ? void 0 : e.randomUUID) == null ? void 0 : t.call(e)) ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
148
148
|
}
|
|
149
|
-
function G(e, t,
|
|
150
|
-
const
|
|
149
|
+
function G(e, t, n) {
|
|
150
|
+
const s = (t == null ? void 0 : t.toLowerCase()) ?? "";
|
|
151
151
|
return e.map((r) => {
|
|
152
|
-
var c,
|
|
152
|
+
var c, m, l, d, u;
|
|
153
153
|
const a = r.kind === "unknown" ? "entity" : r.kind, i = a === "global" ? (
|
|
154
154
|
// The server names General only when an admin renamed it.
|
|
155
|
-
r.label ??
|
|
155
|
+
r.label ?? n.globalLabel
|
|
156
156
|
) : a === "dm" ? (
|
|
157
157
|
// The server resolves the peer's name from the user table; the
|
|
158
158
|
// message sender is only a fallback for hosts that don't send one.
|
|
159
|
-
r.label ?? (((
|
|
160
|
-
) : r.label ?? ((
|
|
159
|
+
r.label ?? (((m = (c = r.last_message) == null ? void 0 : c.sender) == null ? void 0 : m.toLowerCase()) !== s ? ((l = r.last_message) == null ? void 0 : l.sender_name) ?? null : null) ?? `User ${((d = H(r.room, s)) == null ? void 0 : d.slice(0, 8)) ?? ""}`
|
|
160
|
+
) : r.label ?? ((u = n.roomLabel) == null ? void 0 : u.call(n, r.room)) ?? r.room.toUpperCase();
|
|
161
161
|
return {
|
|
162
162
|
room: r.room,
|
|
163
163
|
label: i,
|
|
@@ -180,83 +180,83 @@ function G(e, t, s) {
|
|
|
180
180
|
return (a.lastMessage ? new Date(a.lastMessage.date_created).getTime() : 0) - i;
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
const e =
|
|
185
|
-
queryKey: ["nvr-chat-rooms",
|
|
183
|
+
function je() {
|
|
184
|
+
const e = _(), t = f(), n = e.me, s = p({
|
|
185
|
+
queryKey: ["nvr-chat-rooms", n == null ? void 0 : n.id],
|
|
186
186
|
queryFn: async () => (await t.request(g("/chat/rooms"))).data ?? [],
|
|
187
|
-
enabled: !!
|
|
187
|
+
enabled: !!n,
|
|
188
188
|
refetchInterval: 45e3,
|
|
189
189
|
staleTime: 1e4
|
|
190
190
|
});
|
|
191
|
-
|
|
191
|
+
K([["nvr-chat-rooms"]]);
|
|
192
192
|
const o = k(
|
|
193
|
-
() => G(
|
|
194
|
-
[
|
|
193
|
+
() => G(s.data ?? [], n == null ? void 0 : n.id, e),
|
|
194
|
+
[s.data, n == null ? void 0 : n.id, e]
|
|
195
195
|
), r = L().chat_badge_mode, a = o.reduce((i, c) => {
|
|
196
|
-
var
|
|
196
|
+
var m;
|
|
197
197
|
if (c.muted) return i;
|
|
198
198
|
if (r === "conversations") {
|
|
199
|
-
const
|
|
200
|
-
return i + (
|
|
199
|
+
const l = c.kind === "dm" || c.kind === "channel" && !!((m = c.channel) != null && m.is_direct);
|
|
200
|
+
return i + (l ? c.unread : c.mentions ?? 0);
|
|
201
201
|
}
|
|
202
202
|
return i + c.unread;
|
|
203
203
|
}, 0);
|
|
204
|
-
return { rooms: o, totalUnread: a, loading:
|
|
204
|
+
return { rooms: o, totalUnread: a, loading: s.isLoading };
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
const t =
|
|
208
|
-
queryKey: ["nvr-chat-rooms",
|
|
209
|
-
queryFn: async () => (await
|
|
206
|
+
function ze(e) {
|
|
207
|
+
const t = _(), n = f(), s = t.me, o = p({
|
|
208
|
+
queryKey: ["nvr-chat-rooms", s == null ? void 0 : s.id, "archived"],
|
|
209
|
+
queryFn: async () => (await n.request(
|
|
210
210
|
g("/chat/rooms", { archived: "1" })
|
|
211
211
|
)).data ?? [],
|
|
212
|
-
enabled: !!
|
|
212
|
+
enabled: !!s && e,
|
|
213
213
|
staleTime: 1e4
|
|
214
214
|
});
|
|
215
|
-
return { rooms: k(() => G(o.data ?? [],
|
|
215
|
+
return { rooms: k(() => G(o.data ?? [], s == null ? void 0 : s.id, t), [o.data, s == null ? void 0 : s.id, t]), loading: o.isLoading };
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
const t =
|
|
217
|
+
function Be(e) {
|
|
218
|
+
const t = f(), { data: n, isLoading: s } = p({
|
|
219
219
|
queryKey: ["nvr-chat-directory", e],
|
|
220
220
|
queryFn: async () => (await t.request(
|
|
221
221
|
g("/chat/directory", e ? { search: e } : void 0)
|
|
222
222
|
)).data ?? [],
|
|
223
223
|
staleTime: 15e3
|
|
224
224
|
});
|
|
225
|
-
return { channels:
|
|
225
|
+
return { channels: n ?? [], loading: s };
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
const e =
|
|
227
|
+
function He() {
|
|
228
|
+
const e = f(), t = q(), n = () => {
|
|
229
229
|
t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
|
|
230
|
-
},
|
|
231
|
-
mutationFn: (
|
|
232
|
-
onSuccess:
|
|
233
|
-
}), o =
|
|
234
|
-
mutationFn: (
|
|
235
|
-
onSuccess:
|
|
236
|
-
}), r =
|
|
237
|
-
mutationFn: ({ room:
|
|
238
|
-
onSuccess:
|
|
239
|
-
}), a =
|
|
240
|
-
mutationFn: ({ room:
|
|
241
|
-
R(`/chat/rooms/${encodeURIComponent(
|
|
230
|
+
}, s = y({
|
|
231
|
+
mutationFn: (l) => e.request(F(`/chat/rooms/${encodeURIComponent(l)}/join`)),
|
|
232
|
+
onSuccess: n
|
|
233
|
+
}), o = y({
|
|
234
|
+
mutationFn: (l) => e.request(N(`/chat/rooms/${encodeURIComponent(l)}/join`)),
|
|
235
|
+
onSuccess: n
|
|
236
|
+
}), r = y({
|
|
237
|
+
mutationFn: ({ room: l, muted: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { muted: d })),
|
|
238
|
+
onSuccess: n
|
|
239
|
+
}), a = y({
|
|
240
|
+
mutationFn: ({ room: l, mode: d }) => e.request(
|
|
241
|
+
R(`/chat/rooms/${encodeURIComponent(l)}`, {
|
|
242
242
|
notify_mode: d === "mentions" ? "mentions" : null
|
|
243
243
|
})
|
|
244
244
|
),
|
|
245
|
-
onSuccess:
|
|
246
|
-
}), i =
|
|
247
|
-
mutationFn: ({ room:
|
|
248
|
-
onSuccess:
|
|
249
|
-
}), c =
|
|
250
|
-
mutationFn: ({ room:
|
|
251
|
-
onSuccess:
|
|
252
|
-
}),
|
|
253
|
-
mutationFn: (
|
|
254
|
-
onSuccess:
|
|
245
|
+
onSuccess: n
|
|
246
|
+
}), i = y({
|
|
247
|
+
mutationFn: ({ room: l, archived: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { archived: d })),
|
|
248
|
+
onSuccess: n
|
|
249
|
+
}), c = y({
|
|
250
|
+
mutationFn: ({ room: l, starred: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { starred: d })),
|
|
251
|
+
onSuccess: n
|
|
252
|
+
}), m = y({
|
|
253
|
+
mutationFn: (l) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { welcome_seen: !0 })),
|
|
254
|
+
onSuccess: n
|
|
255
255
|
});
|
|
256
|
-
return { join:
|
|
256
|
+
return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: m };
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
const t =
|
|
258
|
+
function Ge(e) {
|
|
259
|
+
const t = f(), { data: n, isLoading: s } = p({
|
|
260
260
|
queryKey: ["nvr-chat-members", e],
|
|
261
261
|
queryFn: async () => (await t.request(
|
|
262
262
|
g(`/chat/channels/${e}/members`)
|
|
@@ -264,25 +264,74 @@ function ze(e) {
|
|
|
264
264
|
enabled: e != null,
|
|
265
265
|
staleTime: 1e4
|
|
266
266
|
});
|
|
267
|
-
return { members:
|
|
267
|
+
return { members: n ?? [], loading: s };
|
|
268
|
+
}
|
|
269
|
+
const fe = 50;
|
|
270
|
+
function Ve(e, t) {
|
|
271
|
+
const [n, s] = O(e);
|
|
272
|
+
return w(() => {
|
|
273
|
+
const o = setTimeout(() => s(e), t);
|
|
274
|
+
return () => clearTimeout(o);
|
|
275
|
+
}, [e, t]), n;
|
|
276
|
+
}
|
|
277
|
+
function he(e) {
|
|
278
|
+
const t = String(e.id ?? e.user ?? ""), n = e.first_name ?? null, s = e.last_name ?? null, o = e.email ?? null;
|
|
279
|
+
return {
|
|
280
|
+
id: t,
|
|
281
|
+
name: String(e.name ?? ([n, s].filter(Boolean).join(" ") || o || t)),
|
|
282
|
+
title: e.title ?? null,
|
|
283
|
+
online: e.online === !0,
|
|
284
|
+
first_name: n,
|
|
285
|
+
last_name: s,
|
|
286
|
+
email: o
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function We(e, t, n, s) {
|
|
290
|
+
var c, m, l;
|
|
291
|
+
const o = f(), r = J({
|
|
292
|
+
queryKey: ["nvr-chat-members-page", e, t, n],
|
|
293
|
+
initialPageParam: 0,
|
|
294
|
+
queryFn: async ({ pageParam: d }) => {
|
|
295
|
+
const u = new URLSearchParams({ limit: String(fe), offset: String(d) });
|
|
296
|
+
return n.trim() && u.set("q", n.trim()), await o.request(
|
|
297
|
+
g(`${t}?${u.toString()}`)
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
getNextPageParam: (d, u) => d.has_more ? u.reduce((v, h) => {
|
|
301
|
+
var b;
|
|
302
|
+
return v + (((b = h.data) == null ? void 0 : b.length) ?? 0);
|
|
303
|
+
}, 0) : void 0,
|
|
304
|
+
enabled: s && !!t,
|
|
305
|
+
staleTime: 1e4
|
|
306
|
+
}), a = (((c = r.data) == null ? void 0 : c.pages) ?? []).flatMap((d) => (d.data ?? []).map(he)), i = ((l = (m = r.data) == null ? void 0 : m.pages[0]) == null ? void 0 : l.total) ?? a.length;
|
|
307
|
+
return {
|
|
308
|
+
members: a,
|
|
309
|
+
total: i,
|
|
310
|
+
loading: r.isLoading,
|
|
311
|
+
hasMore: !!r.hasNextPage,
|
|
312
|
+
loadingMore: r.isFetchingNextPage,
|
|
313
|
+
loadMore: () => {
|
|
314
|
+
r.hasNextPage && !r.isFetchingNextPage && r.fetchNextPage();
|
|
315
|
+
}
|
|
316
|
+
};
|
|
268
317
|
}
|
|
269
|
-
function
|
|
270
|
-
const t =
|
|
271
|
-
|
|
272
|
-
}, o =
|
|
318
|
+
function Ye(e) {
|
|
319
|
+
const t = f(), n = q(), s = () => {
|
|
320
|
+
n.invalidateQueries({ queryKey: ["nvr-chat-members", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-members-page"] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), n.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
|
|
321
|
+
}, o = y({
|
|
273
322
|
mutationFn: (i) => t.request(R(`/chat/channels/${e}`, i)),
|
|
274
|
-
onSuccess:
|
|
275
|
-
}), r =
|
|
276
|
-
mutationFn: (i) => t.request(
|
|
277
|
-
onSuccess:
|
|
278
|
-
}), a =
|
|
279
|
-
mutationFn: (i) => t.request(
|
|
280
|
-
onSuccess:
|
|
323
|
+
onSuccess: s
|
|
324
|
+
}), r = y({
|
|
325
|
+
mutationFn: (i) => t.request(F(`/chat/channels/${e}/members`, { user_id: i })),
|
|
326
|
+
onSuccess: s
|
|
327
|
+
}), a = y({
|
|
328
|
+
mutationFn: (i) => t.request(N(`/chat/channels/${e}/members/${i}`)),
|
|
329
|
+
onSuccess: s
|
|
281
330
|
});
|
|
282
331
|
return { update: o, addMember: r, removeMember: a };
|
|
283
332
|
}
|
|
284
|
-
function
|
|
285
|
-
const e =
|
|
333
|
+
function Ze() {
|
|
334
|
+
const e = f(), { data: t } = p({
|
|
286
335
|
queryKey: ["nvr-chat-roles"],
|
|
287
336
|
queryFn: async () => (await e.request(
|
|
288
337
|
g("/chat/roles")
|
|
@@ -291,217 +340,217 @@ function Be() {
|
|
|
291
340
|
});
|
|
292
341
|
return t ?? [];
|
|
293
342
|
}
|
|
294
|
-
function
|
|
295
|
-
const
|
|
343
|
+
function Je(e, t) {
|
|
344
|
+
const n = f(), { data: s, isLoading: o } = p({
|
|
296
345
|
queryKey: ["nvr-chat-user-search", e],
|
|
297
|
-
queryFn: async () => (await
|
|
346
|
+
queryFn: async () => (await n.request(
|
|
298
347
|
g("/users", { limit: 20, ...e.trim() ? { search: e.trim() } : {} })
|
|
299
348
|
)).data ?? [],
|
|
300
349
|
enabled: t,
|
|
301
350
|
staleTime: 3e4
|
|
302
351
|
});
|
|
303
|
-
return { users:
|
|
352
|
+
return { users: s ?? [], loading: o };
|
|
304
353
|
}
|
|
305
|
-
function
|
|
306
|
-
const e =
|
|
307
|
-
return
|
|
308
|
-
mutationFn: (
|
|
354
|
+
function Xe() {
|
|
355
|
+
const e = f(), t = q();
|
|
356
|
+
return y({
|
|
357
|
+
mutationFn: (n) => e.request(F("/chat/channels", n)),
|
|
309
358
|
onSuccess: () => {
|
|
310
359
|
t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
|
|
311
360
|
}
|
|
312
361
|
});
|
|
313
362
|
}
|
|
314
363
|
let j = 0;
|
|
315
|
-
const
|
|
364
|
+
const P = /* @__PURE__ */ new Map();
|
|
316
365
|
function z(e) {
|
|
317
366
|
var t;
|
|
318
367
|
return e.kind === "dm" || e.kind === "channel" && !!((t = e.channel) != null && t.is_direct);
|
|
319
368
|
}
|
|
320
|
-
const
|
|
321
|
-
function
|
|
322
|
-
|
|
369
|
+
const T = /* @__PURE__ */ new Map();
|
|
370
|
+
function et(e) {
|
|
371
|
+
w(() => {
|
|
323
372
|
if (e)
|
|
324
|
-
return
|
|
325
|
-
const t = (
|
|
326
|
-
t <= 0 ?
|
|
373
|
+
return T.set(e, (T.get(e) ?? 0) + 1), () => {
|
|
374
|
+
const t = (T.get(e) ?? 1) - 1;
|
|
375
|
+
t <= 0 ? T.delete(e) : T.set(e, t);
|
|
327
376
|
};
|
|
328
377
|
}, [e]);
|
|
329
378
|
}
|
|
330
|
-
function
|
|
379
|
+
function ye() {
|
|
331
380
|
return typeof document > "u" || document.visibilityState === "visible";
|
|
332
381
|
}
|
|
333
|
-
function
|
|
334
|
-
return
|
|
382
|
+
function B(e) {
|
|
383
|
+
return T.has(e) && ye();
|
|
335
384
|
}
|
|
336
|
-
function
|
|
385
|
+
function ge() {
|
|
337
386
|
const e = L().notification_sound;
|
|
338
387
|
return typeof e == "string" ? e : "off";
|
|
339
388
|
}
|
|
340
389
|
function L() {
|
|
341
|
-
const e =
|
|
390
|
+
const e = f(), { data: t } = p({
|
|
342
391
|
queryKey: ["nvr-profile-prefs"],
|
|
343
|
-
queryFn: () => e.request(g("/users/me")).then((
|
|
344
|
-
var
|
|
345
|
-
return ((
|
|
392
|
+
queryFn: () => e.request(g("/users/me")).then((n) => {
|
|
393
|
+
var s;
|
|
394
|
+
return ((s = n.data) == null ? void 0 : s.preferences) ?? {};
|
|
346
395
|
}),
|
|
347
396
|
staleTime: 6e4
|
|
348
397
|
});
|
|
349
398
|
return t ?? {};
|
|
350
399
|
}
|
|
351
|
-
function
|
|
352
|
-
const e =
|
|
353
|
-
return
|
|
354
|
-
mutationFn: (
|
|
355
|
-
onMutate: (
|
|
356
|
-
const
|
|
357
|
-
return t.setQueryData(["nvr-profile-prefs"], { ...
|
|
400
|
+
function pe() {
|
|
401
|
+
const e = f(), t = q();
|
|
402
|
+
return y({
|
|
403
|
+
mutationFn: (n) => e.request(R("/users/me/preferences", n)),
|
|
404
|
+
onMutate: (n) => {
|
|
405
|
+
const s = t.getQueryData(["nvr-profile-prefs"]);
|
|
406
|
+
return t.setQueryData(["nvr-profile-prefs"], { ...s ?? {}, ...n }), { prev: s };
|
|
358
407
|
},
|
|
359
|
-
onError: (
|
|
408
|
+
onError: (n, s, o) => {
|
|
360
409
|
o != null && o.prev && t.setQueryData(["nvr-profile-prefs"], o.prev);
|
|
361
410
|
},
|
|
362
|
-
onSuccess: (
|
|
411
|
+
onSuccess: (n, s) => oe(Object.keys(s)),
|
|
363
412
|
onSettled: () => {
|
|
364
413
|
t.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), t.invalidateQueries({ queryKey: ["presence-online"] });
|
|
365
414
|
}
|
|
366
415
|
});
|
|
367
416
|
}
|
|
368
|
-
function
|
|
369
|
-
const e = L(), t =
|
|
370
|
-
|
|
371
|
-
if (!
|
|
372
|
-
let
|
|
417
|
+
function tt() {
|
|
418
|
+
const e = L(), t = pe(), n = Object.keys(e).length > 0;
|
|
419
|
+
w(() => {
|
|
420
|
+
if (!n) return;
|
|
421
|
+
let s = "";
|
|
373
422
|
try {
|
|
374
|
-
|
|
423
|
+
s = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
|
|
375
424
|
} catch {
|
|
376
425
|
return;
|
|
377
426
|
}
|
|
378
|
-
if (!(!
|
|
427
|
+
if (!(!s || e.browser_timezone === s)) {
|
|
379
428
|
try {
|
|
380
|
-
if (sessionStorage.getItem("nvr-browser-tz") ===
|
|
381
|
-
sessionStorage.setItem("nvr-browser-tz",
|
|
429
|
+
if (sessionStorage.getItem("nvr-browser-tz") === s) return;
|
|
430
|
+
sessionStorage.setItem("nvr-browser-tz", s);
|
|
382
431
|
} catch {
|
|
383
432
|
}
|
|
384
|
-
t.mutate({ browser_timezone:
|
|
433
|
+
t.mutate({ browser_timezone: s });
|
|
385
434
|
}
|
|
386
|
-
}, [
|
|
387
|
-
}
|
|
388
|
-
function
|
|
389
|
-
const
|
|
390
|
-
r.current = o,
|
|
391
|
-
const a = t ? t.filter((
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
for (const
|
|
395
|
-
const
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
435
|
+
}, [n, e.browser_timezone]);
|
|
436
|
+
}
|
|
437
|
+
function nt(e, t) {
|
|
438
|
+
const n = _(), s = ge(), o = L(), r = Q(o);
|
|
439
|
+
r.current = o, w(() => {
|
|
440
|
+
const a = t ? t.filter((l) => z(l) && !B(l.room)).reduce((l, d) => l + d.unread, 0) : e, i = a > j, c = ce(r.current), m = ne(r.current) || c;
|
|
441
|
+
if (n.sound && i && !m && re(s), n.sound && i && c && ue({ kind: "chat", title: "New message" }), t) {
|
|
442
|
+
const l = P.size > 0, d = T.size > 0;
|
|
443
|
+
for (const u of t) {
|
|
444
|
+
const v = P.get(u.room) ?? 0;
|
|
445
|
+
if (l && !m && !u.muted && z(u) && u.unread > v && !B(u.room)) {
|
|
446
|
+
const h = u.lastMessage, b = h != null && h.sender_name ? String(h.sender_name).trim() : null;
|
|
447
|
+
te(
|
|
448
|
+
u.kind === "dm" ? `New message from ${b || u.label}` : `New message in ${u.label}${b ? ` — ${b}` : ""}`,
|
|
400
449
|
{
|
|
401
|
-
description:
|
|
450
|
+
description: h != null && h.message ? String(h.message).replace(/<[^>]*>/g, "").slice(0, 90) : void 0,
|
|
402
451
|
duration: 4e3,
|
|
403
452
|
...d ? { position: "top-center" } : {},
|
|
404
453
|
// Reading the message is the whole reason the toast exists, so
|
|
405
454
|
// it opens the conversation — only when a host has somewhere to
|
|
406
455
|
// open it, otherwise the click would do nothing.
|
|
407
|
-
...
|
|
456
|
+
...Re() ? {
|
|
408
457
|
className: "cursor-pointer",
|
|
409
458
|
onDismiss: void 0,
|
|
410
459
|
action: {
|
|
411
460
|
label: "Open",
|
|
412
|
-
onClick: () => W(
|
|
461
|
+
onClick: () => W(u.room, u.label)
|
|
413
462
|
}
|
|
414
463
|
} : {}
|
|
415
464
|
}
|
|
416
465
|
);
|
|
417
466
|
}
|
|
418
|
-
|
|
467
|
+
P.set(u.room, u.unread);
|
|
419
468
|
}
|
|
420
469
|
}
|
|
421
470
|
j = a;
|
|
422
|
-
}, [e,
|
|
471
|
+
}, [e, n.sound, t, s]);
|
|
423
472
|
}
|
|
424
|
-
function
|
|
425
|
-
const e =
|
|
426
|
-
return
|
|
427
|
-
mutationFn: (
|
|
473
|
+
function st() {
|
|
474
|
+
const e = f(), t = q();
|
|
475
|
+
return y({
|
|
476
|
+
mutationFn: (n) => e.request(F(`/chat/rooms/${encodeURIComponent(n)}/read`)),
|
|
428
477
|
onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
|
|
429
478
|
});
|
|
430
479
|
}
|
|
431
|
-
const
|
|
480
|
+
const ve = ["nvr-chat-room-types"];
|
|
432
481
|
function V(e) {
|
|
433
482
|
return {
|
|
434
|
-
queryKey:
|
|
483
|
+
queryKey: ve,
|
|
435
484
|
queryFn: async () => {
|
|
436
485
|
const t = await e.request(g("/chat/room-types"));
|
|
437
|
-
return ((t == null ? void 0 : t.data) ?? []).filter((
|
|
486
|
+
return ((t == null ? void 0 : t.data) ?? []).filter((n) => n.is_active);
|
|
438
487
|
},
|
|
439
488
|
staleTime: 5 * 6e4
|
|
440
489
|
};
|
|
441
490
|
}
|
|
442
|
-
function
|
|
443
|
-
const t =
|
|
491
|
+
function rt(e) {
|
|
492
|
+
const t = _(), n = f(), s = (e == null ? void 0 : e.indexOf(":")) ?? -1, o = e && s > 0 ? e.slice(0, s) : null, r = e && s > 0 ? e.slice(s + 1) : null, a = !!e && !!o && !!r && e !== t.globalRoom && o !== "dm" && o !== "ch", { data: i } = p({ ...V(n), enabled: a }), c = a ? i == null ? void 0 : i.find((d) => d.is_active && d.prefix === o) : void 0, { data: m } = p({
|
|
444
493
|
queryKey: ["nvr-chat-entity-record", c == null ? void 0 : c.collection, c == null ? void 0 : c.match_field, r],
|
|
445
494
|
queryFn: async () => {
|
|
446
|
-
var
|
|
447
|
-
return c.match_field === "id" ? r : ((
|
|
495
|
+
var u, v;
|
|
496
|
+
return c.match_field === "id" ? r : ((v = (u = (await n.request(
|
|
448
497
|
g(`/items/${c.collection}`, {
|
|
449
498
|
limit: 1,
|
|
450
499
|
fields: "id",
|
|
451
500
|
filter: JSON.stringify({ [c.match_field]: { _eq: r } })
|
|
452
501
|
})
|
|
453
|
-
)).data) == null ? void 0 :
|
|
502
|
+
)).data) == null ? void 0 : u[0]) == null ? void 0 : v.id) ?? null;
|
|
454
503
|
},
|
|
455
504
|
enabled: !!c && !!r,
|
|
456
505
|
staleTime: 5 * 6e4
|
|
457
506
|
});
|
|
458
|
-
return !c ||
|
|
507
|
+
return !c || m == null ? null : (t.recordUrl ?? ((d, u) => `/collections/${d}/${u}`))(c.collection, m);
|
|
459
508
|
}
|
|
460
|
-
const
|
|
461
|
-
function
|
|
462
|
-
const
|
|
463
|
-
for (const a of e.matchAll(
|
|
464
|
-
|
|
509
|
+
const qe = /@\[([^\]]+)\](?:\([^)]*\))?/g;
|
|
510
|
+
function ot(e, t) {
|
|
511
|
+
const n = new RegExp(t, "gi"), s = [];
|
|
512
|
+
for (const a of e.matchAll(qe))
|
|
513
|
+
s.push({
|
|
465
514
|
start: a.index,
|
|
466
515
|
end: a.index + a[0].length,
|
|
467
516
|
token: { text: `@${a[1]}`, mention: a[1] }
|
|
468
517
|
});
|
|
469
|
-
for (const a of e.matchAll(
|
|
470
|
-
|
|
518
|
+
for (const a of e.matchAll(n))
|
|
519
|
+
s.some((i) => a.index >= i.start && a.index < i.end) || s.push({
|
|
471
520
|
start: a.index,
|
|
472
521
|
end: a.index + a[0].length,
|
|
473
522
|
token: { text: a[0], entity: a[0].toUpperCase() }
|
|
474
523
|
});
|
|
475
|
-
|
|
524
|
+
s.sort((a, i) => a.start - i.start);
|
|
476
525
|
const o = [];
|
|
477
526
|
let r = 0;
|
|
478
|
-
for (const a of
|
|
527
|
+
for (const a of s)
|
|
479
528
|
a.start > r && o.push({ text: e.slice(r, a.start) }), o.push(a.token), r = a.end;
|
|
480
529
|
return r < e.length && o.push({ text: e.slice(r) }), o;
|
|
481
530
|
}
|
|
482
|
-
function
|
|
483
|
-
const
|
|
484
|
-
return
|
|
485
|
-
}
|
|
486
|
-
const
|
|
487
|
-
function
|
|
488
|
-
const t =
|
|
489
|
-
|
|
490
|
-
const
|
|
491
|
-
o.current && clearTimeout(o.current), o.current = null,
|
|
492
|
-
}, [r, t]), i =
|
|
493
|
-
!r || !e || !t.setTypingRoom || (
|
|
531
|
+
function at(e, t) {
|
|
532
|
+
const s = e.slice(0, t).match(/@([^@\n\r]*)$/);
|
|
533
|
+
return s ? s[1] : null;
|
|
534
|
+
}
|
|
535
|
+
const be = 3e3;
|
|
536
|
+
function it(e) {
|
|
537
|
+
const t = _(), n = f();
|
|
538
|
+
q();
|
|
539
|
+
const s = Q(!1), o = Q(null), r = t.me, a = I(() => {
|
|
540
|
+
o.current && clearTimeout(o.current), o.current = null, s.current && r && t.setTypingRoom && (s.current = !1, t.setTypingRoom(r.id, null));
|
|
541
|
+
}, [r, t]), i = I(() => {
|
|
542
|
+
!r || !e || !t.setTypingRoom || (s.current || (s.current = !0, t.setTypingRoom(r.id, e)), o.current && clearTimeout(o.current), o.current = setTimeout(a, be));
|
|
494
543
|
}, [r, e, t, a]);
|
|
495
|
-
|
|
496
|
-
const c =
|
|
544
|
+
w(() => a, [a]);
|
|
545
|
+
const c = se(6e3, {
|
|
497
546
|
safetyMs: 3e4,
|
|
498
547
|
enabled: !!t.realtime
|
|
499
|
-
}), { data:
|
|
548
|
+
}), { data: m } = p({
|
|
500
549
|
queryKey: ["nvr-chat-typing", e],
|
|
501
550
|
queryFn: async () => {
|
|
502
551
|
const d = new Date(Date.now() - 6e4).toISOString();
|
|
503
|
-
return (await
|
|
504
|
-
|
|
552
|
+
return (await n.request(
|
|
553
|
+
Z(t.collections.presence, {
|
|
505
554
|
limit: 10,
|
|
506
555
|
fields: ["user_id", "display_name", "typing_room", "last_seen"],
|
|
507
556
|
filter: { typing_room: { _eq: e }, last_seen: { _gte: d } }
|
|
@@ -512,23 +561,23 @@ function nt(e) {
|
|
|
512
561
|
refetchInterval: c,
|
|
513
562
|
staleTime: 2e3
|
|
514
563
|
});
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
var
|
|
518
|
-
const d = (
|
|
519
|
-
var
|
|
520
|
-
return ((
|
|
521
|
-
}).map((
|
|
522
|
-
return
|
|
523
|
-
}, [
|
|
524
|
-
return { onType: i, clearTyping: a, typingText:
|
|
525
|
-
}
|
|
526
|
-
function
|
|
527
|
-
const t =
|
|
564
|
+
de(t.collections.presence, [["nvr-chat-typing"]]);
|
|
565
|
+
const l = k(() => {
|
|
566
|
+
var v;
|
|
567
|
+
const d = (v = r == null ? void 0 : r.id) == null ? void 0 : v.toLowerCase(), u = (m ?? []).filter((h) => {
|
|
568
|
+
var b;
|
|
569
|
+
return ((b = h.user_id) == null ? void 0 : b.toLowerCase()) !== d;
|
|
570
|
+
}).map((h) => h.display_name ?? "Someone");
|
|
571
|
+
return u.length === 0 ? null : u.length === 1 ? `${u[0]} is typing…` : u.length === 2 ? `${u[0]} and ${u[1]} are typing…` : `${u.length} people are typing…`;
|
|
572
|
+
}, [m, r == null ? void 0 : r.id]);
|
|
573
|
+
return { onType: i, clearTyping: a, typingText: l };
|
|
574
|
+
}
|
|
575
|
+
function ct(e) {
|
|
576
|
+
const t = _(), n = f(), s = t.me, o = e && s ? H(e, s.id) : null, { data: r } = p({
|
|
528
577
|
queryKey: ["nvr-chat-peer-read", e],
|
|
529
578
|
queryFn: async () => {
|
|
530
579
|
var i;
|
|
531
|
-
return ((i = (await
|
|
580
|
+
return ((i = (await n.request(
|
|
532
581
|
g(
|
|
533
582
|
`/chat/rooms/${encodeURIComponent(e)}/peer-read`
|
|
534
583
|
)
|
|
@@ -538,40 +587,40 @@ function st(e) {
|
|
|
538
587
|
refetchInterval: 3e4,
|
|
539
588
|
staleTime: 5e3
|
|
540
589
|
});
|
|
541
|
-
return
|
|
590
|
+
return K([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
|
|
542
591
|
}
|
|
543
|
-
function
|
|
544
|
-
const t =
|
|
545
|
-
return
|
|
546
|
-
mutationFn: ({ messageId:
|
|
547
|
-
onSuccess: () => void
|
|
592
|
+
function ut(e) {
|
|
593
|
+
const t = f(), n = q();
|
|
594
|
+
return y({
|
|
595
|
+
mutationFn: ({ messageId: s, emoji: o }) => t.request(F(`/chat/messages/${s}/reactions`, { emoji: o })),
|
|
596
|
+
onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
|
|
548
597
|
});
|
|
549
598
|
}
|
|
550
|
-
function
|
|
551
|
-
const t =
|
|
552
|
-
return
|
|
553
|
-
mutationFn: ({ messageId:
|
|
554
|
-
onSuccess: () => void
|
|
599
|
+
function lt(e) {
|
|
600
|
+
const t = f(), n = q();
|
|
601
|
+
return y({
|
|
602
|
+
mutationFn: ({ messageId: s, text: o }) => t.request(R(`/chat/messages/${s}`, { message: o })),
|
|
603
|
+
onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
|
|
555
604
|
});
|
|
556
605
|
}
|
|
557
|
-
function
|
|
558
|
-
const t =
|
|
559
|
-
return
|
|
560
|
-
mutationFn: (
|
|
606
|
+
function dt(e) {
|
|
607
|
+
const t = f(), n = q();
|
|
608
|
+
return y({
|
|
609
|
+
mutationFn: (s) => t.request(N(`/chat/messages/${s}`)),
|
|
561
610
|
onSuccess: () => {
|
|
562
|
-
|
|
611
|
+
n.invalidateQueries({ queryKey: ["nvr-chat", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] });
|
|
563
612
|
}
|
|
564
613
|
});
|
|
565
614
|
}
|
|
566
|
-
function
|
|
567
|
-
const
|
|
568
|
-
t.sender && (
|
|
569
|
-
const o = Object.keys(
|
|
570
|
-
queryKey: ["nvr-chat-search",
|
|
615
|
+
function mt(e, t = {}) {
|
|
616
|
+
const n = f(), s = { q: e };
|
|
617
|
+
t.sender && (s.sender = t.sender), t.room && (s.room = t.room), t.from && (s.from = t.from), t.to && (s.to = t.to), t.has_attachment && (s.has_attachment = "1"), t.mentions_me && (s.mentions_me = "1");
|
|
618
|
+
const o = Object.keys(s).length > 1, { data: r, isLoading: a } = p({
|
|
619
|
+
queryKey: ["nvr-chat-search", s],
|
|
571
620
|
queryFn: async () => {
|
|
572
621
|
var c;
|
|
573
|
-
const i = await
|
|
574
|
-
g("/chat/search",
|
|
622
|
+
const i = await n.request(
|
|
623
|
+
g("/chat/search", s)
|
|
575
624
|
);
|
|
576
625
|
return { hits: i.data ?? [], meaning: ((c = i.meta) == null ? void 0 : c.meaning) ?? null };
|
|
577
626
|
},
|
|
@@ -580,26 +629,26 @@ function it(e, t = {}) {
|
|
|
580
629
|
});
|
|
581
630
|
return { hits: (r == null ? void 0 : r.hits) ?? [], meaning: (r == null ? void 0 : r.meaning) ?? null, loading: a };
|
|
582
631
|
}
|
|
583
|
-
function
|
|
584
|
-
const e =
|
|
585
|
-
return
|
|
586
|
-
mutationFn: async (
|
|
632
|
+
function ft() {
|
|
633
|
+
const e = f(), t = q();
|
|
634
|
+
return y({
|
|
635
|
+
mutationFn: async (n) => (await e.request(F("/chat/group-dm", n))).data,
|
|
587
636
|
onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
|
|
588
637
|
});
|
|
589
638
|
}
|
|
590
|
-
function
|
|
591
|
-
const e =
|
|
639
|
+
function _e() {
|
|
640
|
+
const e = f(), { data: t } = p({
|
|
592
641
|
queryKey: ["nvr-chat-config"],
|
|
593
642
|
queryFn: async () => (await e.request(g("/chat/config"))).data ?? { bot_name: null, bot_user_id: null },
|
|
594
643
|
staleTime: 5 * 6e4
|
|
595
644
|
});
|
|
596
645
|
return t ?? { bot_name: null, bot_user_id: null };
|
|
597
646
|
}
|
|
598
|
-
function
|
|
599
|
-
return
|
|
647
|
+
function ht() {
|
|
648
|
+
return _e().bot_name;
|
|
600
649
|
}
|
|
601
|
-
function
|
|
602
|
-
const t =
|
|
650
|
+
function yt(e) {
|
|
651
|
+
const t = f(), { data: n } = p({
|
|
603
652
|
queryKey: ["nvr-chat-pins", e],
|
|
604
653
|
queryFn: async () => (await t.request(
|
|
605
654
|
g(`/chat/rooms/${encodeURIComponent(e)}/pins`)
|
|
@@ -607,16 +656,16 @@ function lt(e) {
|
|
|
607
656
|
enabled: !!e,
|
|
608
657
|
staleTime: 15e3
|
|
609
658
|
});
|
|
610
|
-
return
|
|
659
|
+
return K([["nvr-chat-pins"]], e ? [e] : []), n ?? [];
|
|
611
660
|
}
|
|
612
|
-
function
|
|
613
|
-
const t =
|
|
614
|
-
return
|
|
615
|
-
mutationFn: (
|
|
616
|
-
onSuccess: () => void
|
|
661
|
+
function gt(e) {
|
|
662
|
+
const t = f(), n = q();
|
|
663
|
+
return y({
|
|
664
|
+
mutationFn: (s) => t.request(F(`/chat/messages/${s}/pin`)),
|
|
665
|
+
onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat-pins", e] })
|
|
617
666
|
});
|
|
618
667
|
}
|
|
619
|
-
const
|
|
668
|
+
const x = [
|
|
620
669
|
"#7dd3fc",
|
|
621
670
|
"#86efac",
|
|
622
671
|
"#fcd34d",
|
|
@@ -626,126 +675,130 @@ const I = [
|
|
|
626
675
|
"#99f6e4",
|
|
627
676
|
"#00ceff"
|
|
628
677
|
];
|
|
629
|
-
function
|
|
630
|
-
return
|
|
678
|
+
function pt(e) {
|
|
679
|
+
return x[Ce(e)];
|
|
631
680
|
}
|
|
632
|
-
function
|
|
681
|
+
function Ce(e) {
|
|
633
682
|
let t = 0;
|
|
634
|
-
for (const
|
|
635
|
-
return Math.abs(t) %
|
|
683
|
+
for (const n of e) t = t * 31 + n.charCodeAt(0) | 0;
|
|
684
|
+
return Math.abs(t) % x.length;
|
|
636
685
|
}
|
|
637
|
-
function
|
|
638
|
-
return Number.isInteger(e) && e >= 0 && e <
|
|
686
|
+
function vt(e) {
|
|
687
|
+
return Number.isInteger(e) && e >= 0 && e < x.length ? x[e] : null;
|
|
639
688
|
}
|
|
640
|
-
function
|
|
641
|
-
return [...e].sort((t,
|
|
642
|
-
const
|
|
643
|
-
return !
|
|
689
|
+
function qt(e) {
|
|
690
|
+
return [...e].sort((t, n) => {
|
|
691
|
+
const s = (t.display_name ?? "").trim(), o = (n.display_name ?? "").trim();
|
|
692
|
+
return !s != !o ? s ? -1 : 1 : s.localeCompare(o, void 0, { sensitivity: "base" }) || String(t.user_id).localeCompare(String(n.user_id));
|
|
644
693
|
});
|
|
645
694
|
}
|
|
646
|
-
function
|
|
647
|
-
var
|
|
695
|
+
function bt(e) {
|
|
696
|
+
var n, s;
|
|
648
697
|
if (!e) return "?";
|
|
649
698
|
const t = e.trim().split(/\s+/);
|
|
650
|
-
return ((((
|
|
699
|
+
return ((((n = t[0]) == null ? void 0 : n[0]) ?? "") + (((s = t[1]) == null ? void 0 : s[0]) ?? "")).toUpperCase() || "?";
|
|
651
700
|
}
|
|
652
|
-
let
|
|
653
|
-
function
|
|
654
|
-
return
|
|
655
|
-
|
|
701
|
+
let M = null;
|
|
702
|
+
function _t(e) {
|
|
703
|
+
return M = e, () => {
|
|
704
|
+
M === e && (M = null);
|
|
656
705
|
};
|
|
657
706
|
}
|
|
658
|
-
function
|
|
659
|
-
return
|
|
707
|
+
function Ct() {
|
|
708
|
+
return M !== null;
|
|
660
709
|
}
|
|
661
|
-
function
|
|
662
|
-
|
|
710
|
+
function Rt(e, t) {
|
|
711
|
+
M == null || M(e, t);
|
|
663
712
|
}
|
|
664
713
|
let $ = null;
|
|
665
|
-
function
|
|
714
|
+
function wt(e) {
|
|
666
715
|
return $ = e, () => {
|
|
667
716
|
$ === e && ($ = null);
|
|
668
717
|
};
|
|
669
718
|
}
|
|
670
|
-
function
|
|
719
|
+
function Re() {
|
|
671
720
|
return $ !== null;
|
|
672
721
|
}
|
|
673
722
|
function W(e, t) {
|
|
674
723
|
$ == null || $(e, t);
|
|
675
724
|
}
|
|
676
|
-
function
|
|
677
|
-
const t =
|
|
678
|
-
return
|
|
725
|
+
function St(e = !0) {
|
|
726
|
+
const t = f(), { data: n } = p({ ...V(t), enabled: e });
|
|
727
|
+
return n;
|
|
679
728
|
}
|
|
680
|
-
async function
|
|
729
|
+
async function Tt(e, t, n) {
|
|
681
730
|
var r;
|
|
682
|
-
const
|
|
683
|
-
g("/chat/record-room", { collection: t, item:
|
|
731
|
+
const s = await e.request(
|
|
732
|
+
g("/chat/record-room", { collection: t, item: n })
|
|
684
733
|
);
|
|
685
|
-
if (!((r =
|
|
686
|
-
const o =
|
|
687
|
-
return W(
|
|
734
|
+
if (!((r = s.data) != null && r.room)) return !1;
|
|
735
|
+
const o = s.data.room.slice(s.data.room.indexOf(":") + 1);
|
|
736
|
+
return W(s.data.room, o), !0;
|
|
688
737
|
}
|
|
689
738
|
export {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
739
|
+
Ne as CHAT_DEFAULTS,
|
|
740
|
+
ve as CHAT_ROOM_TYPES_KEY,
|
|
741
|
+
le as ChatConfigContext,
|
|
742
|
+
Qe as GENERAL_CHANNEL_ID,
|
|
743
|
+
fe as MEMBER_PAGE_SIZE,
|
|
744
|
+
Pe as REACTION_EMOJI,
|
|
745
|
+
Re as canOpenChatRoom,
|
|
746
|
+
Ct as canOpenDm,
|
|
747
|
+
pt as chatAvatarColor,
|
|
748
|
+
vt as chatAvatarColorAt,
|
|
749
|
+
Ce as chatAvatarColorIndex,
|
|
750
|
+
bt as chatInitials,
|
|
701
751
|
V as chatRoomTypesQuery,
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
752
|
+
Ft as discardOutbox,
|
|
753
|
+
Tt as discussRecord,
|
|
754
|
+
H as dmPeer,
|
|
755
|
+
Ue as dmRoom,
|
|
756
|
+
Kt as editOutbox,
|
|
757
|
+
at as getMentionQuery,
|
|
758
|
+
Ot as holdOutbox,
|
|
759
|
+
It as nudgeChatOutbox,
|
|
710
760
|
W as openChatRoom,
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
761
|
+
Rt as openDmWith,
|
|
762
|
+
_t as registerDmOpener,
|
|
763
|
+
wt as registerRoomOpener,
|
|
764
|
+
xt as retryOutbox,
|
|
765
|
+
qt as sortOnlineUsers,
|
|
766
|
+
ot as splitMessageTokens,
|
|
767
|
+
he as toPagedMember,
|
|
768
|
+
ze as useArchivedRooms,
|
|
769
|
+
Ye as useChannelAdmin,
|
|
770
|
+
Be as useChannelDirectory,
|
|
771
|
+
Ge as useChannelMembers,
|
|
772
|
+
_e as useChatBotInfo,
|
|
773
|
+
ht as useChatBotName,
|
|
774
|
+
_ as useChatConfig,
|
|
775
|
+
Ae as useChatMessages,
|
|
776
|
+
Ze as useChatRoles,
|
|
777
|
+
je as useChatRooms,
|
|
778
|
+
mt as useChatSearch,
|
|
779
|
+
De as useChatThread,
|
|
780
|
+
Xe as useCreateChannel,
|
|
781
|
+
ft as useCreateGroupDm,
|
|
782
|
+
Ve as useDebouncedMemberQuery,
|
|
783
|
+
dt as useDeleteMessage,
|
|
784
|
+
lt as useEditMessage,
|
|
785
|
+
rt as useEntityRoomLink,
|
|
786
|
+
st as useMarkRoomRead,
|
|
735
787
|
L as useMyPreferences,
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
788
|
+
ge as useNotificationSoundPreference,
|
|
789
|
+
et as useOpenRoomRegistration,
|
|
790
|
+
kt as useOutbox,
|
|
791
|
+
We as usePagedMembers,
|
|
792
|
+
ct as usePeerReadAt,
|
|
793
|
+
tt as useRecordBrowserTimezone,
|
|
794
|
+
St as useRecordRoomTypes,
|
|
795
|
+
He as useRoomMembership,
|
|
796
|
+
yt as useRoomPins,
|
|
797
|
+
Ee as useSendChatMessage,
|
|
798
|
+
pe as useSetMyPreferences,
|
|
799
|
+
gt as useTogglePin,
|
|
800
|
+
ut as useToggleReaction,
|
|
801
|
+
it as useTypingIndicator,
|
|
802
|
+
nt as useUnreadChirp,
|
|
803
|
+
Je as useUserSearch
|
|
751
804
|
};
|