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