@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,199 +1,262 @@
|
|
|
1
|
-
import { useQuery as
|
|
2
|
-
import { useState as C, useEffect as
|
|
3
|
-
import { useOptionalNivaroClient as
|
|
4
|
-
import { post as
|
|
1
|
+
import { useQuery as F } from "@tanstack/react-query";
|
|
2
|
+
import { useState as C, useEffect as v, useCallback as R, useMemo as j, useRef as A } from "react";
|
|
3
|
+
import { useOptionalNivaroClient as q } from "../context.js";
|
|
4
|
+
import { post as $, get as B } from "./commands.js";
|
|
5
|
+
import { trackActivity as N, onIdleChange as W, idleState as z } from "./idle.js";
|
|
5
6
|
import { useLiveEvent as E } from "./live.js";
|
|
6
|
-
import { useMyUserId as
|
|
7
|
-
import { useOptionalRealtime as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, [e == null ? void 0 : e.state, c]);
|
|
7
|
+
import { useMyUserId as M, useRecordSignalPeers as Q, useRecordSignalWhile as Y } from "./presence-signals.js";
|
|
8
|
+
import { useOptionalRealtime as P, useRealtimeStatus as G } from "./realtime.js";
|
|
9
|
+
let O = null, I = !1;
|
|
10
|
+
const T = /* @__PURE__ */ new Set();
|
|
11
|
+
function L() {
|
|
12
|
+
return typeof document > "u" ? !1 : z().is_idle;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
function D() {
|
|
15
|
+
if (I || typeof document > "u") return;
|
|
16
|
+
I = !0, N(), O = L() ? Date.now() : null;
|
|
17
|
+
const n = () => {
|
|
18
|
+
const r = L();
|
|
19
|
+
if (r !== (O != null)) {
|
|
20
|
+
O = r ? Date.now() : null;
|
|
21
|
+
for (const e of T)
|
|
22
|
+
try {
|
|
23
|
+
e(r);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener("visibilitychange", n), W(n);
|
|
29
|
+
}
|
|
30
|
+
function K() {
|
|
31
|
+
return D(), O != null;
|
|
32
|
+
}
|
|
33
|
+
function H(n) {
|
|
34
|
+
return D(), T.add(n), () => T.delete(n);
|
|
35
|
+
}
|
|
36
|
+
function _(n, r, e = Date.now()) {
|
|
37
|
+
return K() ? {
|
|
38
|
+
collection: n,
|
|
39
|
+
item: String(r),
|
|
40
|
+
hidden: !0,
|
|
41
|
+
hidden_ms: Math.max(0, e - (O ?? e))
|
|
42
|
+
} : { collection: n, item: String(r), hidden: !1 };
|
|
43
|
+
}
|
|
44
|
+
function J(n, r) {
|
|
45
|
+
const e = r ? String(r).toUpperCase() : null, i = /* @__PURE__ */ new Set(), s = [];
|
|
46
|
+
for (const t of n ?? []) {
|
|
47
|
+
if (!t || t.id == null) continue;
|
|
48
|
+
const u = String(t.id).toUpperCase();
|
|
49
|
+
u === e || i.has(u) || (i.add(u), s.push(t));
|
|
50
|
+
}
|
|
51
|
+
return s;
|
|
52
|
+
}
|
|
53
|
+
function V(n, r) {
|
|
54
|
+
const e = G(), i = A(!1), s = A(n);
|
|
55
|
+
s.current = n, v(() => {
|
|
56
|
+
r && ((e == null ? void 0 : e.state) === "reconnecting" ? i.current = !0 : i.current && (i.current = !1, s.current()));
|
|
57
|
+
}, [e == null ? void 0 : e.state, r]);
|
|
58
|
+
}
|
|
59
|
+
function le(n, r) {
|
|
60
|
+
const e = P(), i = M(), s = r == null ? "" : String(r), t = !!e && !!n && !!s && s !== "new", [u, w] = C([]), h = R(() => {
|
|
61
|
+
!t || !e || !n || (e.emit("record:join", { collection: n, item: s }), K() && e.emit("record:visibility", _(n, s)));
|
|
62
|
+
}, [e, n, s, t]);
|
|
63
|
+
return v(() => {
|
|
64
|
+
if (w([]), !t) return;
|
|
65
|
+
h();
|
|
66
|
+
const l = H(() => {
|
|
67
|
+
n && (e == null || e.emit("record:visibility", _(n, s)));
|
|
68
|
+
});
|
|
69
|
+
return () => {
|
|
70
|
+
l(), e == null || e.emit("record:leave", { collection: n, item: s });
|
|
71
|
+
};
|
|
72
|
+
}, [e, n, s, t, h]), V(h, t), E(
|
|
22
73
|
"record:viewers",
|
|
23
|
-
(
|
|
24
|
-
Array.isArray(
|
|
74
|
+
(l) => {
|
|
75
|
+
Array.isArray(l == null ? void 0 : l.viewers) && w(l.viewers);
|
|
25
76
|
},
|
|
26
77
|
{
|
|
27
78
|
enabled: t,
|
|
28
79
|
includeOwn: !0,
|
|
29
80
|
// An older server names no record: accept, as the hosts' own hooks do.
|
|
30
|
-
match: (
|
|
81
|
+
match: (l) => (l == null ? void 0 : l.collection) == null || (l == null ? void 0 : l.item) == null ? !0 : l.collection === n && String(l.item) === s
|
|
31
82
|
}
|
|
32
|
-
), { viewers: j(
|
|
33
|
-
() => l.filter((u) => !s || String(u.id).toUpperCase() !== s.toUpperCase()),
|
|
34
|
-
[l, s]
|
|
35
|
-
) };
|
|
83
|
+
), { viewers: j(() => J(u, i), [u, i]) };
|
|
36
84
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
|
|
85
|
+
function fe(n, r, e = {}) {
|
|
86
|
+
const i = P(), s = M(), t = r == null ? "" : String(r), u = !!i && !!n && !!t && t !== "new", [w, h] = C({});
|
|
87
|
+
v(() => h({}), [n, t]), E(
|
|
40
88
|
"field:editing",
|
|
41
89
|
(o) => {
|
|
42
|
-
typeof (o == null ? void 0 : o.field) == "string" &&
|
|
43
|
-
const
|
|
44
|
-
return
|
|
90
|
+
typeof (o == null ? void 0 : o.field) == "string" && h((b) => {
|
|
91
|
+
const p = { ...b }, m = o.user;
|
|
92
|
+
return m && (!s || String(m.id).toUpperCase() !== s.toUpperCase()) ? p[o.field] = m : delete p[o.field], p;
|
|
45
93
|
});
|
|
46
94
|
},
|
|
47
95
|
{
|
|
48
|
-
enabled:
|
|
96
|
+
enabled: u,
|
|
49
97
|
includeOwn: !0,
|
|
50
|
-
match: (o) => (o == null ? void 0 : o.collection) == null || (o == null ? void 0 : o.item) == null ? !0 : o.collection ===
|
|
98
|
+
match: (o) => (o == null ? void 0 : o.collection) == null || (o == null ? void 0 : o.item) == null ? !0 : o.collection === n && String(o.item) === t
|
|
51
99
|
}
|
|
52
100
|
);
|
|
53
|
-
const
|
|
101
|
+
const S = R(
|
|
54
102
|
(o) => {
|
|
55
|
-
|
|
103
|
+
u && o && (i == null || i.emit("field:focus", { field: o, collection: n, item: t }));
|
|
56
104
|
},
|
|
57
|
-
[
|
|
58
|
-
),
|
|
105
|
+
[i, n, t, u]
|
|
106
|
+
), l = R(
|
|
59
107
|
(o) => {
|
|
60
|
-
|
|
108
|
+
u && o && (i == null || i.emit("field:blur", { field: o, collection: n, item: t }));
|
|
61
109
|
},
|
|
62
|
-
[
|
|
110
|
+
[i, n, t, u]
|
|
63
111
|
);
|
|
64
|
-
return
|
|
65
|
-
if (!
|
|
66
|
-
const o = (
|
|
67
|
-
var
|
|
68
|
-
return (a = (
|
|
69
|
-
}, b = (
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
const
|
|
74
|
-
|
|
112
|
+
return v(() => {
|
|
113
|
+
if (!u || !e.capture || typeof document > "u") return;
|
|
114
|
+
const o = (m) => {
|
|
115
|
+
var c, g, a;
|
|
116
|
+
return (a = (g = (c = m.target) == null ? void 0 : c.closest) == null ? void 0 : g.call(c, "[data-field]")) == null ? void 0 : a.getAttribute("data-field");
|
|
117
|
+
}, b = (m) => {
|
|
118
|
+
const c = o(m);
|
|
119
|
+
c && S(c);
|
|
120
|
+
}, p = (m) => {
|
|
121
|
+
const c = o(m);
|
|
122
|
+
c && l(c);
|
|
75
123
|
};
|
|
76
|
-
return document.addEventListener("focusin", b), document.addEventListener("focusout",
|
|
77
|
-
document.removeEventListener("focusin", b), document.removeEventListener("focusout",
|
|
124
|
+
return document.addEventListener("focusin", b), document.addEventListener("focusout", p), () => {
|
|
125
|
+
document.removeEventListener("focusin", b), document.removeEventListener("focusout", p);
|
|
78
126
|
};
|
|
79
|
-
}, [
|
|
127
|
+
}, [u, e.capture, S, l]), { editing: w, focus: S, blur: l };
|
|
80
128
|
}
|
|
81
|
-
function
|
|
82
|
-
const e =
|
|
83
|
-
|
|
84
|
-
const t =
|
|
85
|
-
t.current && clearTimeout(t.current), t.current = null,
|
|
129
|
+
function ae(n, r) {
|
|
130
|
+
const e = Q(n, r, "note"), [i, s] = C(!1);
|
|
131
|
+
Y(n, r, "note", i);
|
|
132
|
+
const t = A(null), u = R((w) => {
|
|
133
|
+
t.current && clearTimeout(t.current), t.current = null, s(w), w && (t.current = setTimeout(() => s(!1), 6e3));
|
|
86
134
|
}, []);
|
|
87
|
-
return
|
|
135
|
+
return v(
|
|
88
136
|
() => () => {
|
|
89
137
|
t.current && clearTimeout(t.current);
|
|
90
138
|
},
|
|
91
139
|
[]
|
|
92
|
-
), { typing: e, setTyping:
|
|
140
|
+
), { typing: e, setTyping: u };
|
|
141
|
+
}
|
|
142
|
+
const X = {};
|
|
143
|
+
function k(n, r) {
|
|
144
|
+
return `${n}:${r}`;
|
|
93
145
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return
|
|
146
|
+
function Z(n) {
|
|
147
|
+
const r = n;
|
|
148
|
+
if (!(r != null && r.collection)) return [];
|
|
149
|
+
const e = String(r.collection), i = (s) => Array.isArray(s) ? s.map(String) : [];
|
|
150
|
+
return r.rows && typeof r.rows == "object" ? Object.entries(r.rows).map(([s, t]) => [
|
|
151
|
+
k(e, s),
|
|
152
|
+
i(t)
|
|
153
|
+
]) : r.item == null ? [] : [[k(e, String(r.item)), i(r.user_ids)]];
|
|
97
154
|
}
|
|
98
|
-
function
|
|
99
|
-
const
|
|
155
|
+
function ee(n) {
|
|
156
|
+
const r = q(), e = [...new Set(n.map((s) => s.toUpperCase()))].sort().join(","), { data: i } = F({
|
|
100
157
|
queryKey: ["presence-visible-people", e],
|
|
101
|
-
queryFn: () =>
|
|
102
|
-
|
|
103
|
-
).then((
|
|
104
|
-
enabled: !!
|
|
158
|
+
queryFn: () => r.request(
|
|
159
|
+
B(`/presence/people?ids=${encodeURIComponent(e.split(",").slice(0, 100).join(","))}`)
|
|
160
|
+
).then((s) => new Set((s.data ?? []).map((t) => String(t.user_id).toUpperCase()))).catch(() => /* @__PURE__ */ new Set()),
|
|
161
|
+
enabled: !!r && e.length > 0,
|
|
105
162
|
staleTime: 5 * 6e4
|
|
106
163
|
});
|
|
107
|
-
return e.length === 0 ? null :
|
|
164
|
+
return e.length === 0 ? null : i ?? null;
|
|
108
165
|
}
|
|
109
|
-
function U(
|
|
110
|
-
const
|
|
111
|
-
for (const
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
const t =
|
|
115
|
-
|
|
166
|
+
function U(n) {
|
|
167
|
+
const r = /* @__PURE__ */ new Map();
|
|
168
|
+
for (const i of n) {
|
|
169
|
+
const s = i.indexOf(":");
|
|
170
|
+
if (s <= 0) continue;
|
|
171
|
+
const t = i.slice(0, s), u = r.get(t) ?? [];
|
|
172
|
+
u.push(i.slice(s + 1)), r.set(t, u);
|
|
116
173
|
}
|
|
117
174
|
const e = [];
|
|
118
|
-
for (const [
|
|
119
|
-
for (let t = 0; t <
|
|
120
|
-
e.push({ collection:
|
|
175
|
+
for (const [i, s] of r)
|
|
176
|
+
for (let t = 0; t < s.length; t += 100)
|
|
177
|
+
e.push({ collection: i, items: s.slice(t, t + 100) });
|
|
121
178
|
return e;
|
|
122
179
|
}
|
|
123
|
-
function
|
|
124
|
-
const e =
|
|
180
|
+
function de(n, r = {}) {
|
|
181
|
+
const e = P(), i = q(), s = M(), t = r.enabled !== !1 && n.length > 0, u = n.filter((c) => c.collection && c.item != null).map((c) => k(c.collection, c.item)).join(""), [w, h] = C({}), [S, l] = C({}), o = A(/* @__PURE__ */ new Set()), b = R(() => {
|
|
125
182
|
if (!(!e || !t))
|
|
126
|
-
for (const
|
|
183
|
+
for (const c of U(o.current)) e.emit("presence:watch", c);
|
|
127
184
|
}, [e, t]);
|
|
128
|
-
|
|
185
|
+
v(() => {
|
|
129
186
|
if (!e || !t) return;
|
|
130
|
-
const
|
|
131
|
-
o.current =
|
|
132
|
-
for (const f of U(
|
|
187
|
+
const c = new Set(u.split("").filter(Boolean)), g = [...c].filter((f) => !o.current.has(f)), a = [...o.current].filter((f) => !c.has(f));
|
|
188
|
+
o.current = c;
|
|
189
|
+
for (const f of U(g)) e.emit("presence:watch", f);
|
|
133
190
|
if (a.length) {
|
|
134
191
|
for (const f of U(a)) e.emit("presence:unwatch", f);
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
for (const
|
|
138
|
-
return
|
|
192
|
+
h((f) => {
|
|
193
|
+
const y = { ...f };
|
|
194
|
+
for (const d of a) delete y[d];
|
|
195
|
+
return y;
|
|
139
196
|
});
|
|
140
197
|
}
|
|
141
|
-
}, [e,
|
|
198
|
+
}, [e, u, t]), v(() => {
|
|
142
199
|
if (e)
|
|
143
200
|
return () => {
|
|
144
|
-
o.current.size && e.emit("presence:unwatch", {}), o.current = /* @__PURE__ */ new Set(),
|
|
201
|
+
o.current.size && e.emit("presence:unwatch", {}), o.current = /* @__PURE__ */ new Set(), h({});
|
|
145
202
|
};
|
|
146
|
-
}, [e]),
|
|
203
|
+
}, [e]), V(b, !!e && t), E(
|
|
147
204
|
"presence:rows",
|
|
148
|
-
(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
205
|
+
(c) => {
|
|
206
|
+
const g = Z(c);
|
|
207
|
+
g.length !== 0 && h((a) => {
|
|
208
|
+
const f = { ...a };
|
|
209
|
+
for (const [y, d] of g)
|
|
210
|
+
d.length ? f[y] = d : delete f[y];
|
|
211
|
+
return f;
|
|
154
212
|
});
|
|
155
213
|
},
|
|
156
214
|
{ enabled: !!e && t, includeOwn: !0 }
|
|
157
|
-
),
|
|
158
|
-
if (e || !
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
return { collection:
|
|
215
|
+
), v(() => {
|
|
216
|
+
if (e || !i || !t) return;
|
|
217
|
+
const c = r.pollMs ?? 3e4, g = u.split("").filter(Boolean).slice(0, 100).map((d) => {
|
|
218
|
+
const x = d.indexOf(":");
|
|
219
|
+
return { collection: d.slice(0, x), item_id: d.slice(x + 1) };
|
|
162
220
|
});
|
|
163
221
|
let a = !0;
|
|
164
222
|
const f = () => {
|
|
165
|
-
|
|
166
|
-
a &&
|
|
223
|
+
i.request($("/presence/record-viewers", { pairs: g })).then((d) => {
|
|
224
|
+
a && l(d.data ?? {});
|
|
167
225
|
}).catch(() => {
|
|
168
226
|
});
|
|
169
227
|
};
|
|
170
228
|
f();
|
|
171
|
-
const
|
|
229
|
+
const y = c > 0 ? setInterval(f, c) : null;
|
|
172
230
|
return () => {
|
|
173
|
-
a = !1,
|
|
231
|
+
a = !1, y && clearInterval(y);
|
|
174
232
|
};
|
|
175
|
-
}, [e,
|
|
176
|
-
const
|
|
233
|
+
}, [e, i, u, t, r.pollMs]);
|
|
234
|
+
const p = j(() => [...new Set(Object.values(w).flat())], [w]), m = ee(p);
|
|
177
235
|
return j(() => {
|
|
178
|
-
if (!t) return
|
|
179
|
-
const
|
|
236
|
+
if (!t) return X;
|
|
237
|
+
const c = {}, g = s == null ? void 0 : s.toUpperCase();
|
|
180
238
|
if (e)
|
|
181
|
-
for (const [a, f] of Object.entries(
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
ids:
|
|
185
|
-
count:
|
|
239
|
+
for (const [a, f] of Object.entries(w)) {
|
|
240
|
+
const y = f.filter((d) => d.toUpperCase() !== g);
|
|
241
|
+
y.length !== 0 && (c[a] = {
|
|
242
|
+
ids: m ? y.filter((d) => m.has(d.toUpperCase())) : [],
|
|
243
|
+
count: y.length
|
|
186
244
|
});
|
|
187
245
|
}
|
|
188
246
|
else
|
|
189
|
-
for (const [a, f] of Object.entries(
|
|
190
|
-
return
|
|
191
|
-
}, [t, e,
|
|
247
|
+
for (const [a, f] of Object.entries(S)) f > 0 && (c[a] = { ids: [], count: f });
|
|
248
|
+
return c;
|
|
249
|
+
}, [t, e, w, S, m, s]);
|
|
192
250
|
}
|
|
193
251
|
export {
|
|
194
|
-
|
|
195
|
-
H as
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
252
|
+
J as distinctOtherViewers,
|
|
253
|
+
H as onRecordTabAway,
|
|
254
|
+
K as recordTabAway,
|
|
255
|
+
_ as recordVisibilityPayload,
|
|
256
|
+
k as rowPresenceKey,
|
|
257
|
+
Z as rowPresenceUpdates,
|
|
258
|
+
fe as useFieldFocus,
|
|
259
|
+
le as usePresence,
|
|
260
|
+
de as useRowPresence,
|
|
261
|
+
ae as useTyping
|
|
199
262
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useQueryClient as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useLiveEvent as
|
|
4
|
-
import { forgetSettledReads as
|
|
5
|
-
const
|
|
6
|
-
let
|
|
7
|
-
function
|
|
1
|
+
import { useQueryClient as w } from "@tanstack/react-query";
|
|
2
|
+
import { useRef as v, useEffect as y } from "react";
|
|
3
|
+
import { useLiveEvent as a } from "./live.js";
|
|
4
|
+
import { forgetSettledReads as S } from "./request-gate.js";
|
|
5
|
+
const E = "nvr-prefs";
|
|
6
|
+
let o = null;
|
|
7
|
+
function g(t) {
|
|
8
8
|
if (typeof BroadcastChannel > "u") return null;
|
|
9
|
-
if (!
|
|
9
|
+
if (!o)
|
|
10
10
|
try {
|
|
11
|
-
|
|
11
|
+
o = new BroadcastChannel(`${E}:${t}`);
|
|
12
12
|
} catch {
|
|
13
|
-
|
|
13
|
+
o = null;
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return o;
|
|
16
16
|
}
|
|
17
|
-
let
|
|
18
|
-
function k(
|
|
19
|
-
if (
|
|
20
|
-
|
|
17
|
+
let f = "";
|
|
18
|
+
function k(t) {
|
|
19
|
+
if (t !== f) {
|
|
20
|
+
f = t;
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
o == null || o.close();
|
|
23
23
|
} catch {
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
o = null;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
function q() {
|
|
29
|
-
return
|
|
29
|
+
return f.endsWith(":as");
|
|
30
30
|
}
|
|
31
|
-
function L(
|
|
32
|
-
var
|
|
31
|
+
function L(t = []) {
|
|
32
|
+
var n;
|
|
33
33
|
try {
|
|
34
|
-
(
|
|
34
|
+
(n = g(f)) == null || n.postMessage({ keys: t });
|
|
35
35
|
} catch {
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const b = /* @__PURE__ */ new Set([
|
|
39
39
|
"users",
|
|
40
40
|
"people-search",
|
|
41
41
|
"people-cards",
|
|
@@ -52,7 +52,7 @@ const E = /* @__PURE__ */ new Set([
|
|
|
52
52
|
"users-list-for-approvals",
|
|
53
53
|
"presence-visible-people",
|
|
54
54
|
"team-members"
|
|
55
|
-
]),
|
|
55
|
+
]), M = /* @__PURE__ */ new Set([
|
|
56
56
|
"user-card",
|
|
57
57
|
"user-avatar",
|
|
58
58
|
"user-name",
|
|
@@ -60,21 +60,28 @@ const E = /* @__PURE__ */ new Set([
|
|
|
60
60
|
"user",
|
|
61
61
|
"activity-chip-user",
|
|
62
62
|
"nvr-directory-entry",
|
|
63
|
-
"nvr-profile-card"
|
|
63
|
+
"nvr-profile-card",
|
|
64
|
+
// The people page header (ProfileView; Low shared 3): keyed by id, or 'me' + the row read.
|
|
65
|
+
"nvr-profile-user"
|
|
64
66
|
]);
|
|
65
|
-
function C(n,
|
|
66
|
-
const
|
|
67
|
-
if (typeof
|
|
68
|
-
if (
|
|
69
|
-
if (!
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
return (typeof
|
|
67
|
+
function C(t, n, i) {
|
|
68
|
+
const u = t[0];
|
|
69
|
+
if (typeof u != "string") return !1;
|
|
70
|
+
if (b.has(u)) return !0;
|
|
71
|
+
if (!M.has(u)) return !1;
|
|
72
|
+
if (!n) return !0;
|
|
73
|
+
let c = t[1];
|
|
74
|
+
return c === "me" && (c = i == null ? void 0 : i.id), (typeof c == "string" || typeof c == "number") && n.has(String(c).toUpperCase());
|
|
73
75
|
}
|
|
74
|
-
function m(
|
|
75
|
-
setTimeout(
|
|
76
|
+
function m(t, n = 1200) {
|
|
77
|
+
setTimeout(t, Math.floor(Math.random() * n));
|
|
76
78
|
}
|
|
77
|
-
const
|
|
79
|
+
const p = [
|
|
80
|
+
["notification-count"],
|
|
81
|
+
["notifications"],
|
|
82
|
+
["my-work"],
|
|
83
|
+
["my-work-count"]
|
|
84
|
+
], K = [["nvr-chat-rooms"], ["nvr-chat-record-room"]], T = {
|
|
78
85
|
"saved-views": [["cbv-views"], ["cbv-view-count"]],
|
|
79
86
|
"saved-searches": [["global-search-saved"]],
|
|
80
87
|
overview: [
|
|
@@ -82,57 +89,63 @@ const M = [["notification-count"], ["notifications"], ["my-work"]], T = [["nvr-c
|
|
|
82
89
|
["overview", "pinned-widgets"]
|
|
83
90
|
]
|
|
84
91
|
};
|
|
85
|
-
function P(
|
|
86
|
-
const
|
|
87
|
-
i.current =
|
|
92
|
+
function P(t = {}) {
|
|
93
|
+
const n = w(), i = v(t.onPrefsChanged);
|
|
94
|
+
i.current = t.onPrefsChanged, a(
|
|
95
|
+
"notification:retired",
|
|
96
|
+
() => {
|
|
97
|
+
for (const e of p) n.invalidateQueries({ queryKey: e });
|
|
98
|
+
},
|
|
99
|
+
{ includeOwn: !0, debounceMs: 1e3 }
|
|
100
|
+
), a(
|
|
88
101
|
"read:changed",
|
|
89
102
|
(e) => {
|
|
90
|
-
const r = (e == null ? void 0 : e.kind) === "chat" ?
|
|
91
|
-
for (const s of r)
|
|
103
|
+
const r = (e == null ? void 0 : e.kind) === "chat" ? K : p;
|
|
104
|
+
for (const s of r) n.invalidateQueries({ queryKey: s });
|
|
92
105
|
},
|
|
93
106
|
// Counts: a burst of reads (mark-all) is one re-read, not one per event.
|
|
94
107
|
{ includeOwn: !0, debounceMs: 2e3 }
|
|
95
108
|
);
|
|
96
|
-
const
|
|
109
|
+
const u = v(() => {
|
|
97
110
|
});
|
|
98
|
-
|
|
111
|
+
u.current = () => {
|
|
99
112
|
var e;
|
|
100
|
-
|
|
101
|
-
},
|
|
113
|
+
n.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), n.invalidateQueries({ queryKey: ["presence-online"] }), n.invalidateQueries({ queryKey: ["nvr-nav-favorites"] }), (e = i.current) == null || e.call(i);
|
|
114
|
+
}, a(
|
|
102
115
|
"prefs:changed",
|
|
103
116
|
(e) => {
|
|
104
117
|
const r = Array.isArray(e == null ? void 0 : e.keys) ? e.keys : null;
|
|
105
|
-
r && r.length > 0 && r.every((s) => s === "watch_list") ||
|
|
118
|
+
r && r.length > 0 && r.every((s) => s === "watch_list") || u.current();
|
|
106
119
|
},
|
|
107
120
|
{ includeOwn: !0, debounceMs: 250 }
|
|
108
|
-
),
|
|
121
|
+
), a(
|
|
109
122
|
"mine:changed",
|
|
110
123
|
(e) => {
|
|
111
|
-
for (const r of
|
|
112
|
-
|
|
124
|
+
for (const r of T[String(e == null ? void 0 : e.kind)] ?? [])
|
|
125
|
+
n.invalidateQueries({ queryKey: r, refetchType: "active" });
|
|
113
126
|
},
|
|
114
127
|
{ includeOwn: !0, debounceMs: 300 }
|
|
115
|
-
),
|
|
128
|
+
), a(
|
|
116
129
|
"pins:changed",
|
|
117
|
-
() => m(() => void
|
|
130
|
+
() => m(() => void n.invalidateQueries({ queryKey: ["collection-pins"] })),
|
|
118
131
|
{ includeOwn: !0, debounceMs: 500 }
|
|
119
132
|
);
|
|
120
|
-
const
|
|
121
|
-
|
|
133
|
+
const c = v(t.onAccessChanged);
|
|
134
|
+
c.current = t.onAccessChanged, a(
|
|
122
135
|
"access:changed",
|
|
123
136
|
(e) => {
|
|
124
137
|
e != null && e.perms && m(() => {
|
|
125
138
|
var r;
|
|
126
|
-
|
|
139
|
+
S(), (r = c.current ?? i.current) == null || r(), n.invalidateQueries({ refetchType: "active" });
|
|
127
140
|
});
|
|
128
141
|
},
|
|
129
142
|
{ includeOwn: !0, debounceMs: 400 }
|
|
130
143
|
);
|
|
131
|
-
const
|
|
132
|
-
|
|
144
|
+
const d = v(null);
|
|
145
|
+
a(
|
|
133
146
|
"people:changed",
|
|
134
147
|
(e) => {
|
|
135
|
-
const r = Array.isArray(e == null ? void 0 : e.user_ids) ? e.user_ids.map((l) => String(l).toUpperCase()) : null, s =
|
|
148
|
+
const r = Array.isArray(e == null ? void 0 : e.user_ids) ? e.user_ids.map((l) => String(l).toUpperCase()) : null, s = d.current;
|
|
136
149
|
if (s) {
|
|
137
150
|
if (!r) s.ids = null;
|
|
138
151
|
else if (s.ids) for (const l of r) s.ids.add(l);
|
|
@@ -142,28 +155,28 @@ function P(n = {}) {
|
|
|
142
155
|
ids: r ? new Set(r) : null,
|
|
143
156
|
timer: setTimeout(
|
|
144
157
|
() => {
|
|
145
|
-
|
|
158
|
+
d.current = null, n.invalidateQueries({
|
|
146
159
|
refetchType: "active",
|
|
147
|
-
predicate: (l) => C(l.queryKey, h.ids)
|
|
160
|
+
predicate: (l) => C(l.queryKey, h.ids, l.state.data)
|
|
148
161
|
});
|
|
149
162
|
},
|
|
150
163
|
300 + Math.floor(Math.random() * 800)
|
|
151
164
|
)
|
|
152
165
|
};
|
|
153
|
-
|
|
166
|
+
d.current = h;
|
|
154
167
|
},
|
|
155
168
|
{ includeOwn: !0 }
|
|
156
169
|
), y(
|
|
157
170
|
() => () => {
|
|
158
|
-
|
|
171
|
+
d.current && clearTimeout(d.current.timer);
|
|
159
172
|
},
|
|
160
173
|
[]
|
|
161
174
|
), y(() => {
|
|
162
|
-
const e =
|
|
175
|
+
const e = g(f);
|
|
163
176
|
if (!e) return;
|
|
164
177
|
let r = null;
|
|
165
178
|
const s = () => {
|
|
166
|
-
r && clearTimeout(r), r = setTimeout(() =>
|
|
179
|
+
r && clearTimeout(r), r = setTimeout(() => u.current(), 100);
|
|
167
180
|
};
|
|
168
181
|
return e.addEventListener("message", s), () => {
|
|
169
182
|
e.removeEventListener("message", s), r && clearTimeout(r);
|
|
@@ -171,9 +184,9 @@ function P(n = {}) {
|
|
|
171
184
|
}, []);
|
|
172
185
|
}
|
|
173
186
|
export {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
187
|
+
T as MINE_KEYS,
|
|
188
|
+
b as PEOPLE_LIST_KEYS,
|
|
189
|
+
M as PERSON_KEYS,
|
|
177
190
|
L as announceLocalPrefs,
|
|
178
191
|
k as configureUserSync,
|
|
179
192
|
C as peopleQueryMatches,
|