@liveblocks/react 2.14.0 → 2.15.0
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/_private.d.mts +10 -4
- package/dist/_private.d.ts +10 -4
- package/dist/_private.js +27 -14
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +30 -17
- package/dist/_private.mjs.map +1 -1
- package/dist/chunk-36VCTTYL.js +23 -0
- package/dist/chunk-36VCTTYL.js.map +1 -0
- package/dist/chunk-4HZJQXE5.mjs +23 -0
- package/dist/chunk-4HZJQXE5.mjs.map +1 -0
- package/dist/{chunk-BRCWZCNY.mjs → chunk-NZZCQLBR.mjs} +934 -701
- package/dist/chunk-NZZCQLBR.mjs.map +1 -0
- package/dist/{chunk-X4DDEZYL.js → chunk-UKPVXB7D.js} +924 -691
- package/dist/chunk-UKPVXB7D.js.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +2 -2
- package/dist/{room-Rl_QnQMY.d.mts → room-XbmI0Hoh.d.mts} +134 -116
- package/dist/{room-Rl_QnQMY.d.ts → room-XbmI0Hoh.d.ts} +134 -116
- package/dist/suspense.d.mts +2 -1
- package/dist/suspense.d.ts +2 -1
- package/dist/suspense.js +4 -4
- package/dist/suspense.mjs +2 -2
- package/package.json +4 -6
- package/dist/chunk-BRCWZCNY.mjs.map +0 -1
- package/dist/chunk-IQJWVOHM.mjs +0 -22
- package/dist/chunk-IQJWVOHM.mjs.map +0 -1
- package/dist/chunk-L2RWXPYA.js +0 -22
- package/dist/chunk-L2RWXPYA.js.map +0 -1
- package/dist/chunk-X4DDEZYL.js.map +0 -1
|
@@ -1,14 +1,90 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
2
|
-
var _react = require('react');
|
|
3
|
-
var RoomContext =
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/contexts.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
var RoomContext = _react.createContext.call(void 0, null);
|
|
4
4
|
function useRoomOrNull() {
|
|
5
|
-
return
|
|
5
|
+
return _react.useContext.call(void 0, RoomContext);
|
|
6
6
|
}
|
|
7
7
|
function useIsInsideRoom() {
|
|
8
8
|
const room = useRoomOrNull();
|
|
9
9
|
return room !== null;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// src/use-sync-external-store-with-selector.ts
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function is(x, y) {
|
|
21
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
22
|
+
}
|
|
23
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
24
|
+
const instRef = _react.useRef.call(void 0, null);
|
|
25
|
+
let inst;
|
|
26
|
+
if (instRef.current === null) {
|
|
27
|
+
inst = {
|
|
28
|
+
hasValue: false,
|
|
29
|
+
value: null
|
|
30
|
+
};
|
|
31
|
+
instRef.current = inst;
|
|
32
|
+
} else {
|
|
33
|
+
inst = instRef.current;
|
|
34
|
+
}
|
|
35
|
+
const [getSelection, getServerSelection] = _react.useMemo.call(void 0, () => {
|
|
36
|
+
let hasMemo = false;
|
|
37
|
+
let memoizedSnapshot;
|
|
38
|
+
let memoizedSelection;
|
|
39
|
+
const memoizedSelector = (nextSnapshot) => {
|
|
40
|
+
if (!hasMemo) {
|
|
41
|
+
hasMemo = true;
|
|
42
|
+
memoizedSnapshot = nextSnapshot;
|
|
43
|
+
const nextSelection2 = selector(nextSnapshot);
|
|
44
|
+
if (isEqual !== void 0) {
|
|
45
|
+
if (inst.hasValue) {
|
|
46
|
+
const currentSelection = inst.value;
|
|
47
|
+
if (isEqual(currentSelection, nextSelection2)) {
|
|
48
|
+
memoizedSelection = currentSelection;
|
|
49
|
+
return currentSelection;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
memoizedSelection = nextSelection2;
|
|
54
|
+
return nextSelection2;
|
|
55
|
+
}
|
|
56
|
+
const prevSnapshot = memoizedSnapshot;
|
|
57
|
+
const prevSelection = memoizedSelection;
|
|
58
|
+
if (is(prevSnapshot, nextSnapshot)) {
|
|
59
|
+
return prevSelection;
|
|
60
|
+
}
|
|
61
|
+
const nextSelection = selector(nextSnapshot);
|
|
62
|
+
if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
|
|
63
|
+
memoizedSnapshot = nextSnapshot;
|
|
64
|
+
return prevSelection;
|
|
65
|
+
}
|
|
66
|
+
memoizedSnapshot = nextSnapshot;
|
|
67
|
+
memoizedSelection = nextSelection;
|
|
68
|
+
return nextSelection;
|
|
69
|
+
};
|
|
70
|
+
const maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
|
|
71
|
+
const getSnapshotWithSelector = () => memoizedSelector(getSnapshot());
|
|
72
|
+
const getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : () => memoizedSelector(maybeGetServerSnapshot());
|
|
73
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
74
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]);
|
|
75
|
+
const value = _react.useSyncExternalStore.call(void 0,
|
|
76
|
+
subscribe,
|
|
77
|
+
getSelection,
|
|
78
|
+
getServerSelection
|
|
79
|
+
);
|
|
80
|
+
_react.useEffect.call(void 0, () => {
|
|
81
|
+
inst.hasValue = true;
|
|
82
|
+
inst.value = value;
|
|
83
|
+
}, [value]);
|
|
84
|
+
_react.useDebugValue.call(void 0, value);
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
|
|
12
88
|
// src/liveblocks.tsx
|
|
13
89
|
|
|
14
90
|
|
|
@@ -25,8 +101,8 @@ var _core = require('@liveblocks/core');
|
|
|
25
101
|
|
|
26
102
|
|
|
27
103
|
|
|
28
|
-
|
|
29
|
-
|
|
104
|
+
|
|
105
|
+
|
|
30
106
|
|
|
31
107
|
// src/config.ts
|
|
32
108
|
var SECONDS = 1e3;
|
|
@@ -132,6 +208,8 @@ var use = (
|
|
|
132
208
|
|
|
133
209
|
|
|
134
210
|
|
|
211
|
+
|
|
212
|
+
|
|
135
213
|
// src/lib/autobind.ts
|
|
136
214
|
function autobind(self) {
|
|
137
215
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -149,6 +227,14 @@ function autobind(self) {
|
|
|
149
227
|
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
150
228
|
}
|
|
151
229
|
|
|
230
|
+
// src/lib/itertools.ts
|
|
231
|
+
function find(it, predicate) {
|
|
232
|
+
for (const item of it) {
|
|
233
|
+
if (predicate(item)) return item;
|
|
234
|
+
}
|
|
235
|
+
return void 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
152
238
|
// src/ThreadDB.ts
|
|
153
239
|
|
|
154
240
|
|
|
@@ -202,36 +288,35 @@ function sanitizeThread(thread) {
|
|
|
202
288
|
return thread;
|
|
203
289
|
}
|
|
204
290
|
var ThreadDB = class _ThreadDB {
|
|
205
|
-
|
|
291
|
+
#byId;
|
|
292
|
+
#asc;
|
|
293
|
+
#desc;
|
|
294
|
+
// This signal will be notified on every mutation
|
|
295
|
+
|
|
206
296
|
constructor() {
|
|
207
|
-
this
|
|
297
|
+
this.#asc = _core.SortedList.from([], (t1, t2) => {
|
|
208
298
|
const d1 = t1.createdAt;
|
|
209
299
|
const d2 = t2.createdAt;
|
|
210
300
|
return d1 < d2 ? true : d1 === d2 ? t1.id < t2.id : false;
|
|
211
301
|
});
|
|
212
|
-
this
|
|
302
|
+
this.#desc = _core.SortedList.from([], (t1, t2) => {
|
|
213
303
|
const d2 = t2.updatedAt;
|
|
214
304
|
const d1 = t1.updatedAt;
|
|
215
305
|
return d2 < d1 ? true : d2 === d1 ? t2.id < t1.id : false;
|
|
216
306
|
});
|
|
217
|
-
this
|
|
218
|
-
this.
|
|
307
|
+
this.#byId = /* @__PURE__ */ new Map();
|
|
308
|
+
this.signal = new (0, _core.MutableSignal)(this);
|
|
219
309
|
}
|
|
220
310
|
//
|
|
221
311
|
// Public APIs
|
|
222
312
|
//
|
|
223
313
|
clone() {
|
|
224
314
|
const newPool = new _ThreadDB();
|
|
225
|
-
newPool
|
|
226
|
-
newPool
|
|
227
|
-
newPool
|
|
228
|
-
newPool._version = this._version;
|
|
315
|
+
newPool.#byId = new Map(this.#byId);
|
|
316
|
+
newPool.#asc = this.#asc.clone();
|
|
317
|
+
newPool.#desc = this.#desc.clone();
|
|
229
318
|
return newPool;
|
|
230
319
|
}
|
|
231
|
-
/** Gets the transaction count for this DB. Increments any time the DB is modified. */
|
|
232
|
-
get version() {
|
|
233
|
-
return this._version;
|
|
234
|
-
}
|
|
235
320
|
/** Returns an existing thread by ID. Will never return a deleted thread. */
|
|
236
321
|
get(threadId) {
|
|
237
322
|
const thread = this.getEvenIfDeleted(threadId);
|
|
@@ -239,24 +324,26 @@ var ThreadDB = class _ThreadDB {
|
|
|
239
324
|
}
|
|
240
325
|
/** Returns the (possibly deleted) thread by ID. */
|
|
241
326
|
getEvenIfDeleted(threadId) {
|
|
242
|
-
return this.
|
|
327
|
+
return this.#byId.get(threadId);
|
|
243
328
|
}
|
|
244
329
|
/** Adds or updates a thread in the DB. If the newly given thread is a deleted one, it will get deleted. */
|
|
245
330
|
upsert(thread) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (toRemove
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
331
|
+
this.signal.mutate(() => {
|
|
332
|
+
thread = sanitizeThread(thread);
|
|
333
|
+
const id = thread.id;
|
|
334
|
+
const toRemove = this.#byId.get(id);
|
|
335
|
+
if (toRemove) {
|
|
336
|
+
if (toRemove.deletedAt) return false;
|
|
337
|
+
this.#asc.remove(toRemove);
|
|
338
|
+
this.#desc.remove(toRemove);
|
|
339
|
+
}
|
|
340
|
+
if (!thread.deletedAt) {
|
|
341
|
+
this.#asc.add(thread);
|
|
342
|
+
this.#desc.add(thread);
|
|
343
|
+
}
|
|
344
|
+
this.#byId.set(id, thread);
|
|
345
|
+
return true;
|
|
346
|
+
});
|
|
260
347
|
}
|
|
261
348
|
/** Like .upsert(), except it won't update if a thread by this ID already exists. */
|
|
262
349
|
// TODO Consider renaming this to just .upsert(). I'm not sure if we really
|
|
@@ -267,12 +354,24 @@ var ThreadDB = class _ThreadDB {
|
|
|
267
354
|
this.upsert(thread);
|
|
268
355
|
}
|
|
269
356
|
}
|
|
357
|
+
applyDelta(updates) {
|
|
358
|
+
_core.batch.call(void 0, () => {
|
|
359
|
+
for (const thread of updates.newThreads) {
|
|
360
|
+
this.upsertIfNewer(thread);
|
|
361
|
+
}
|
|
362
|
+
for (const { id, deletedAt } of updates.deletedThreads) {
|
|
363
|
+
const existing = this.getEvenIfDeleted(id);
|
|
364
|
+
if (!existing) continue;
|
|
365
|
+
this.delete(id, deletedAt);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
270
369
|
/**
|
|
271
370
|
* Marks a thread as deleted. It will no longer pop up in .findMany()
|
|
272
371
|
* queries, but it can still be accessed via `.getEvenIfDeleted()`.
|
|
273
372
|
*/
|
|
274
373
|
delete(threadId, deletedAt) {
|
|
275
|
-
const existing = this.
|
|
374
|
+
const existing = this.#byId.get(threadId);
|
|
276
375
|
if (existing && !existing.deletedAt) {
|
|
277
376
|
this.upsert({ ...existing, deletedAt, updatedAt: deletedAt });
|
|
278
377
|
}
|
|
@@ -289,7 +388,7 @@ var ThreadDB = class _ThreadDB {
|
|
|
289
388
|
* Will never return deleted threads in the result.
|
|
290
389
|
*/
|
|
291
390
|
findMany(roomId, query, direction) {
|
|
292
|
-
const index = direction === "desc" ? this
|
|
391
|
+
const index = direction === "desc" ? this.#desc : this.#asc;
|
|
293
392
|
const crit = [];
|
|
294
393
|
if (roomId !== void 0) {
|
|
295
394
|
crit.push((t) => t.roomId === roomId);
|
|
@@ -297,12 +396,6 @@ var ThreadDB = class _ThreadDB {
|
|
|
297
396
|
crit.push(makeThreadsFilter(query));
|
|
298
397
|
return Array.from(index.filter((t) => crit.every((pred) => pred(t))));
|
|
299
398
|
}
|
|
300
|
-
//
|
|
301
|
-
// Private APIs
|
|
302
|
-
//
|
|
303
|
-
touch() {
|
|
304
|
-
++this._version;
|
|
305
|
-
}
|
|
306
399
|
};
|
|
307
400
|
|
|
308
401
|
// src/umbrella-store.ts
|
|
@@ -339,62 +432,67 @@ function usify(promise) {
|
|
|
339
432
|
var noop2 = Promise.resolve();
|
|
340
433
|
var ASYNC_LOADING = Object.freeze({ isLoading: true });
|
|
341
434
|
var PaginatedResource = class {
|
|
435
|
+
|
|
436
|
+
#eventSource;
|
|
437
|
+
#fetchPage;
|
|
438
|
+
#paginationState;
|
|
439
|
+
// Should be null while in loading or error state!
|
|
440
|
+
#pendingFetchMore;
|
|
342
441
|
constructor(fetchPage) {
|
|
343
|
-
this
|
|
344
|
-
this
|
|
345
|
-
this
|
|
346
|
-
this
|
|
347
|
-
this.
|
|
348
|
-
this.observable = this._eventSource.observable;
|
|
442
|
+
this.#paginationState = null;
|
|
443
|
+
this.#fetchPage = fetchPage;
|
|
444
|
+
this.#eventSource = _core.makeEventSource.call(void 0, );
|
|
445
|
+
this.#pendingFetchMore = null;
|
|
446
|
+
this.observable = this.#eventSource.observable;
|
|
349
447
|
autobind(this);
|
|
350
448
|
}
|
|
351
|
-
patchPaginationState(patch) {
|
|
352
|
-
const state = this
|
|
449
|
+
#patchPaginationState(patch) {
|
|
450
|
+
const state = this.#paginationState;
|
|
353
451
|
if (state === null) return;
|
|
354
|
-
this
|
|
355
|
-
this.
|
|
452
|
+
this.#paginationState = { ...state, ...patch };
|
|
453
|
+
this.#eventSource.notify();
|
|
356
454
|
}
|
|
357
|
-
async
|
|
358
|
-
const state = this
|
|
455
|
+
async #fetchMore() {
|
|
456
|
+
const state = this.#paginationState;
|
|
359
457
|
if (!_optionalChain([state, 'optionalAccess', _3 => _3.cursor])) {
|
|
360
458
|
return;
|
|
361
459
|
}
|
|
362
|
-
this
|
|
460
|
+
this.#patchPaginationState({ isFetchingMore: true });
|
|
363
461
|
try {
|
|
364
|
-
const nextCursor = await this
|
|
365
|
-
this
|
|
462
|
+
const nextCursor = await this.#fetchPage(state.cursor);
|
|
463
|
+
this.#patchPaginationState({
|
|
366
464
|
cursor: nextCursor,
|
|
367
465
|
fetchMoreError: void 0,
|
|
368
466
|
isFetchingMore: false
|
|
369
467
|
});
|
|
370
468
|
} catch (err) {
|
|
371
|
-
this
|
|
469
|
+
this.#patchPaginationState({
|
|
372
470
|
isFetchingMore: false,
|
|
373
471
|
fetchMoreError: err
|
|
374
472
|
});
|
|
375
473
|
}
|
|
376
474
|
}
|
|
377
475
|
fetchMore() {
|
|
378
|
-
const state = this
|
|
476
|
+
const state = this.#paginationState;
|
|
379
477
|
if (_optionalChain([state, 'optionalAccess', _4 => _4.cursor]) === null) {
|
|
380
478
|
return noop2;
|
|
381
479
|
}
|
|
382
|
-
if (!this
|
|
383
|
-
this
|
|
384
|
-
this
|
|
480
|
+
if (!this.#pendingFetchMore) {
|
|
481
|
+
this.#pendingFetchMore = this.#fetchMore().finally(() => {
|
|
482
|
+
this.#pendingFetchMore = null;
|
|
385
483
|
});
|
|
386
484
|
}
|
|
387
|
-
return this
|
|
485
|
+
return this.#pendingFetchMore;
|
|
388
486
|
}
|
|
389
487
|
get() {
|
|
390
|
-
const usable = this
|
|
488
|
+
const usable = this.#cachedPromise;
|
|
391
489
|
if (usable === null || usable.status === "pending") {
|
|
392
490
|
return ASYNC_LOADING;
|
|
393
491
|
}
|
|
394
492
|
if (usable.status === "rejected") {
|
|
395
493
|
return { isLoading: false, error: usable.reason };
|
|
396
494
|
}
|
|
397
|
-
const state = this
|
|
495
|
+
const state = this.#paginationState;
|
|
398
496
|
return {
|
|
399
497
|
isLoading: false,
|
|
400
498
|
data: {
|
|
@@ -405,12 +503,13 @@ var PaginatedResource = class {
|
|
|
405
503
|
}
|
|
406
504
|
};
|
|
407
505
|
}
|
|
506
|
+
#cachedPromise = null;
|
|
408
507
|
waitUntilLoaded() {
|
|
409
|
-
if (this
|
|
410
|
-
return this
|
|
508
|
+
if (this.#cachedPromise) {
|
|
509
|
+
return this.#cachedPromise;
|
|
411
510
|
}
|
|
412
511
|
const initialFetcher = _core.autoRetry.call(void 0,
|
|
413
|
-
() => this
|
|
512
|
+
() => this.#fetchPage(
|
|
414
513
|
/* cursor */
|
|
415
514
|
void 0
|
|
416
515
|
),
|
|
@@ -419,7 +518,7 @@ var PaginatedResource = class {
|
|
|
419
518
|
);
|
|
420
519
|
const promise = usify(
|
|
421
520
|
initialFetcher.then((cursor) => {
|
|
422
|
-
this
|
|
521
|
+
this.#paginationState = {
|
|
423
522
|
cursor,
|
|
424
523
|
isFetchingMore: false,
|
|
425
524
|
fetchMoreError: void 0
|
|
@@ -427,129 +526,375 @@ var PaginatedResource = class {
|
|
|
427
526
|
})
|
|
428
527
|
);
|
|
429
528
|
promise.then(
|
|
430
|
-
() => this.
|
|
529
|
+
() => this.#eventSource.notify(),
|
|
431
530
|
() => {
|
|
432
|
-
this.
|
|
531
|
+
this.#eventSource.notify();
|
|
433
532
|
setTimeout(() => {
|
|
434
|
-
this
|
|
435
|
-
this.
|
|
533
|
+
this.#cachedPromise = null;
|
|
534
|
+
this.#eventSource.notify();
|
|
436
535
|
}, 5e3);
|
|
437
536
|
}
|
|
438
537
|
);
|
|
439
|
-
this
|
|
538
|
+
this.#cachedPromise = promise;
|
|
440
539
|
return promise;
|
|
441
540
|
}
|
|
442
541
|
};
|
|
443
542
|
var SinglePageResource = class {
|
|
543
|
+
|
|
544
|
+
#eventSource;
|
|
545
|
+
#fetchPage;
|
|
444
546
|
constructor(fetchPage) {
|
|
445
|
-
this
|
|
446
|
-
this
|
|
447
|
-
this.
|
|
448
|
-
this.observable = this._eventSource.observable;
|
|
547
|
+
this.#fetchPage = fetchPage;
|
|
548
|
+
this.#eventSource = _core.makeEventSource.call(void 0, );
|
|
549
|
+
this.observable = this.#eventSource.observable;
|
|
449
550
|
autobind(this);
|
|
450
551
|
}
|
|
451
552
|
get() {
|
|
452
|
-
const usable = this
|
|
553
|
+
const usable = this.#cachedPromise;
|
|
453
554
|
if (usable === null || usable.status === "pending") {
|
|
454
555
|
return ASYNC_LOADING;
|
|
455
|
-
}
|
|
456
|
-
if (usable.status === "rejected") {
|
|
556
|
+
} else if (usable.status === "rejected") {
|
|
457
557
|
return { isLoading: false, error: usable.reason };
|
|
558
|
+
} else {
|
|
559
|
+
return { isLoading: false, data: void 0 };
|
|
458
560
|
}
|
|
459
|
-
return {
|
|
460
|
-
isLoading: false,
|
|
461
|
-
data: void 0
|
|
462
|
-
};
|
|
463
561
|
}
|
|
562
|
+
#cachedPromise = null;
|
|
464
563
|
waitUntilLoaded() {
|
|
465
|
-
if (this
|
|
466
|
-
return this
|
|
564
|
+
if (this.#cachedPromise) {
|
|
565
|
+
return this.#cachedPromise;
|
|
467
566
|
}
|
|
468
567
|
const initialFetcher = _core.autoRetry.call(void 0,
|
|
469
|
-
() => this
|
|
568
|
+
() => this.#fetchPage(),
|
|
470
569
|
5,
|
|
471
570
|
[5e3, 5e3, 1e4, 15e3]
|
|
472
571
|
);
|
|
473
572
|
const promise = usify(initialFetcher);
|
|
474
573
|
promise.then(
|
|
475
|
-
() => this.
|
|
574
|
+
() => this.#eventSource.notify(),
|
|
476
575
|
() => {
|
|
477
|
-
this.
|
|
576
|
+
this.#eventSource.notify();
|
|
478
577
|
setTimeout(() => {
|
|
479
|
-
this
|
|
480
|
-
this.
|
|
578
|
+
this.#cachedPromise = null;
|
|
579
|
+
this.#eventSource.notify();
|
|
481
580
|
}, 5e3);
|
|
482
581
|
}
|
|
483
582
|
);
|
|
484
|
-
this
|
|
583
|
+
this.#cachedPromise = promise;
|
|
485
584
|
return promise;
|
|
486
585
|
}
|
|
487
586
|
};
|
|
587
|
+
function createStore_forNotifications() {
|
|
588
|
+
const signal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
589
|
+
function markRead(notificationId, readAt) {
|
|
590
|
+
signal.mutate((lut) => {
|
|
591
|
+
const existing = lut.get(notificationId);
|
|
592
|
+
if (!existing) {
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
lut.set(notificationId, { ...existing, readAt });
|
|
596
|
+
return true;
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
function markAllRead(readAt) {
|
|
600
|
+
return signal.mutate((lut) => {
|
|
601
|
+
for (const n of lut.values()) {
|
|
602
|
+
n.readAt = readAt;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
function deleteOne(inboxNotificationId) {
|
|
607
|
+
signal.mutate((lut) => lut.delete(inboxNotificationId));
|
|
608
|
+
}
|
|
609
|
+
function clear() {
|
|
610
|
+
signal.mutate((lut) => lut.clear());
|
|
611
|
+
}
|
|
612
|
+
function applyDelta(newInboxNotifications, deletedNotifications) {
|
|
613
|
+
signal.mutate((lut) => {
|
|
614
|
+
let mutated = false;
|
|
615
|
+
for (const n of newInboxNotifications) {
|
|
616
|
+
const existing = lut.get(n.id);
|
|
617
|
+
if (existing) {
|
|
618
|
+
const result = compareInboxNotifications(existing, n);
|
|
619
|
+
if (result === 1) continue;
|
|
620
|
+
}
|
|
621
|
+
lut.set(n.id, n);
|
|
622
|
+
mutated = true;
|
|
623
|
+
}
|
|
624
|
+
for (const n of deletedNotifications) {
|
|
625
|
+
lut.delete(n.id);
|
|
626
|
+
mutated = true;
|
|
627
|
+
}
|
|
628
|
+
return mutated;
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
function updateAssociatedNotification(newComment) {
|
|
632
|
+
signal.mutate((lut) => {
|
|
633
|
+
const existing = find(
|
|
634
|
+
lut.values(),
|
|
635
|
+
(notification) => notification.kind === "thread" && notification.threadId === newComment.threadId
|
|
636
|
+
);
|
|
637
|
+
if (!existing) return false;
|
|
638
|
+
lut.set(existing.id, {
|
|
639
|
+
...existing,
|
|
640
|
+
notifiedAt: newComment.createdAt,
|
|
641
|
+
readAt: newComment.createdAt
|
|
642
|
+
});
|
|
643
|
+
return true;
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
signal: signal.asReadonly(),
|
|
648
|
+
// Mutations
|
|
649
|
+
markAllRead,
|
|
650
|
+
markRead,
|
|
651
|
+
delete: deleteOne,
|
|
652
|
+
applyDelta,
|
|
653
|
+
clear,
|
|
654
|
+
updateAssociatedNotification,
|
|
655
|
+
// XXX_vincent Remove this eventually
|
|
656
|
+
force_set: (mutationCallback) => signal.mutate(mutationCallback),
|
|
657
|
+
invalidate: () => signal.mutate()
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
function createStore_forRoomNotificationSettings() {
|
|
661
|
+
const signal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
662
|
+
function update(roomId, settings) {
|
|
663
|
+
signal.mutate((lut) => {
|
|
664
|
+
lut.set(roomId, settings);
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
signal: signal.asReadonly(),
|
|
669
|
+
// Mutations
|
|
670
|
+
update,
|
|
671
|
+
// XXX_vincent Remove this eventually
|
|
672
|
+
invalidate: () => signal.mutate()
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function createStore_forHistoryVersions() {
|
|
676
|
+
const signal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
677
|
+
function update(roomId, versions) {
|
|
678
|
+
signal.mutate((lut) => {
|
|
679
|
+
const versionsById = _nullishCoalesce(lut.get(roomId), () => ( (lut.set(roomId, /* @__PURE__ */ new Map()), lut.get(roomId))));
|
|
680
|
+
for (const version of versions) {
|
|
681
|
+
versionsById.set(version.id, version);
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
return {
|
|
686
|
+
signal: signal.asReadonly(),
|
|
687
|
+
// Mutations
|
|
688
|
+
update,
|
|
689
|
+
// XXX_vincent Remove these eventually
|
|
690
|
+
force_set: (callback) => signal.mutate(callback),
|
|
691
|
+
invalidate: () => signal.mutate()
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function createStore_forPermissionHints() {
|
|
695
|
+
const signal = new (0, _core.Signal)({});
|
|
696
|
+
function update(newHints) {
|
|
697
|
+
signal.set((prev) => {
|
|
698
|
+
const permissionsByRoom = { ...prev };
|
|
699
|
+
for (const [roomId, newPermissions] of Object.entries(newHints)) {
|
|
700
|
+
const existing = _nullishCoalesce(permissionsByRoom[roomId], () => ( /* @__PURE__ */ new Set()));
|
|
701
|
+
for (const permission of newPermissions) {
|
|
702
|
+
existing.add(permission);
|
|
703
|
+
}
|
|
704
|
+
permissionsByRoom[roomId] = existing;
|
|
705
|
+
}
|
|
706
|
+
return permissionsByRoom;
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
return {
|
|
710
|
+
signal: signal.asReadonly(),
|
|
711
|
+
// Mutations
|
|
712
|
+
update,
|
|
713
|
+
// XXX_vincent Remove this eventually
|
|
714
|
+
invalidate: () => signal.set((store) => ({ ...store }))
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function createStore_forOptimistic(client) {
|
|
718
|
+
const signal = new (0, _core.Signal)([]);
|
|
719
|
+
const syncSource = client[_core.kInternal].createSyncSource();
|
|
720
|
+
signal.subscribe(
|
|
721
|
+
() => syncSource.setSyncStatus(
|
|
722
|
+
signal.get().length > 0 ? "synchronizing" : "synchronized"
|
|
723
|
+
)
|
|
724
|
+
);
|
|
725
|
+
function add(optimisticUpdate) {
|
|
726
|
+
const id = _core.nanoid.call(void 0, );
|
|
727
|
+
const newUpdate = { ...optimisticUpdate, id };
|
|
728
|
+
signal.set((state) => [...state, newUpdate]);
|
|
729
|
+
return id;
|
|
730
|
+
}
|
|
731
|
+
function remove(optimisticId) {
|
|
732
|
+
signal.set((state) => state.filter((ou) => ou.id !== optimisticId));
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
signal: signal.asReadonly(),
|
|
736
|
+
// Mutations
|
|
737
|
+
add,
|
|
738
|
+
remove,
|
|
739
|
+
// XXX_vincent Remove this eventually
|
|
740
|
+
invalidate: () => signal.set((store) => [...store])
|
|
741
|
+
};
|
|
742
|
+
}
|
|
488
743
|
var UmbrellaStore = class {
|
|
744
|
+
#client;
|
|
745
|
+
//
|
|
746
|
+
// Internally, the UmbrellaStore keeps track of a few source signals that can
|
|
747
|
+
// be set and mutated individually. When any of those are mutated then the
|
|
748
|
+
// clean "external state" is recomputed.
|
|
749
|
+
//
|
|
750
|
+
// Mutate inputs... ...observe clean/consistent output!
|
|
751
|
+
//
|
|
752
|
+
// .-> Base ThreadDB ---------+ +----> Clean threads by ID (Part 1)
|
|
753
|
+
// / | |
|
|
754
|
+
// mutate ----> Base Notifications --+ | | +--> Clean notifications (Part 1)
|
|
755
|
+
// \ | | | | & notifications by ID
|
|
756
|
+
// | \ | | Apply | |
|
|
757
|
+
// | `-> OptimisticUpdates --+--+--> Optimistic --+-+--> Notification Settings (Part 2)
|
|
758
|
+
// \ | Updates |
|
|
759
|
+
// `------- etc etc ---------+ +--> History Versions (Part 3)
|
|
760
|
+
// ^
|
|
761
|
+
// |
|
|
762
|
+
// | ^ ^
|
|
763
|
+
// Signal | |
|
|
764
|
+
// or DerivedSignal DerivedSignals
|
|
765
|
+
// MutableSignal
|
|
766
|
+
//
|
|
767
|
+
//
|
|
768
|
+
// Input signals.
|
|
769
|
+
// (Can be mutated directly.)
|
|
770
|
+
//
|
|
771
|
+
// XXX_vincent Now that we have createStore_forX, we should probably also change
|
|
772
|
+
// `threads` to this pattern, ie create a createStore_forThreads helper as
|
|
773
|
+
// well. It almost works like that already anyway!
|
|
774
|
+
|
|
775
|
+
// Exposes its signal under `.signal` prop
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
// prettier-ignore
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
//
|
|
783
|
+
// Output signals.
|
|
784
|
+
// (Readonly, clean, consistent. With optimistic updates applied.)
|
|
785
|
+
//
|
|
786
|
+
// Note that the output of threadifications signal is the same as the ones for
|
|
787
|
+
// threads and notifications separately, but the threadifications signal will
|
|
788
|
+
// be updated whenever either of them change.
|
|
789
|
+
//
|
|
790
|
+
// XXX_vincent APIs like getRoomThreadsLoadingState should really also be modeled as output signals.
|
|
791
|
+
//
|
|
792
|
+
|
|
793
|
+
// Notifications
|
|
794
|
+
#notificationsLastRequestedAt = null;
|
|
795
|
+
// Keeps track of when we successfully requested an inbox notifications update for the last time. Will be `null` as long as the first successful fetch hasn't happened yet.
|
|
796
|
+
#notifications;
|
|
797
|
+
// Room Threads
|
|
798
|
+
#roomThreadsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
799
|
+
#roomThreads = /* @__PURE__ */ new Map();
|
|
800
|
+
// User Threads
|
|
801
|
+
#userThreadsLastRequestedAt = null;
|
|
802
|
+
#userThreads = /* @__PURE__ */ new Map();
|
|
803
|
+
// Room versions
|
|
804
|
+
#roomVersions = /* @__PURE__ */ new Map();
|
|
805
|
+
#roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
806
|
+
// Room notification settings
|
|
807
|
+
#roomNotificationSettings = /* @__PURE__ */ new Map();
|
|
489
808
|
constructor(client) {
|
|
490
|
-
this
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
493
|
-
// Notifications
|
|
494
|
-
this._notificationsLastRequestedAt = null;
|
|
495
|
-
// Room Threads
|
|
496
|
-
this._roomThreadsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
497
|
-
this._roomThreads = /* @__PURE__ */ new Map();
|
|
498
|
-
// User Threads
|
|
499
|
-
this._userThreadsLastRequestedAt = null;
|
|
500
|
-
this._userThreads = /* @__PURE__ */ new Map();
|
|
501
|
-
// Room versions
|
|
502
|
-
this._roomVersions = /* @__PURE__ */ new Map();
|
|
503
|
-
this._roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
504
|
-
// Room notification settings
|
|
505
|
-
this._roomNotificationSettings = /* @__PURE__ */ new Map();
|
|
506
|
-
this._client = client[_core.kInternal].as();
|
|
507
|
-
this._syncSource = this._client[_core.kInternal].createSyncSource();
|
|
809
|
+
this.#client = client[_core.kInternal].as();
|
|
810
|
+
this.optimisticUpdates = createStore_forOptimistic(this.#client);
|
|
811
|
+
this.permissionHints = createStore_forPermissionHints();
|
|
508
812
|
const inboxFetcher = async (cursor) => {
|
|
509
|
-
const result = await this.
|
|
510
|
-
this.
|
|
511
|
-
|
|
512
|
-
result.
|
|
513
|
-
);
|
|
514
|
-
if (this._notificationsLastRequestedAt === null) {
|
|
515
|
-
this._notificationsLastRequestedAt = result.requestedAt;
|
|
813
|
+
const result = await this.#client.getInboxNotifications({ cursor });
|
|
814
|
+
this.updateThreadifications(result.threads, result.inboxNotifications);
|
|
815
|
+
if (this.#notificationsLastRequestedAt === null) {
|
|
816
|
+
this.#notificationsLastRequestedAt = result.requestedAt;
|
|
516
817
|
}
|
|
517
818
|
const nextCursor = result.nextCursor;
|
|
518
819
|
return nextCursor;
|
|
519
820
|
};
|
|
520
|
-
this
|
|
521
|
-
this.
|
|
821
|
+
this.#notifications = new PaginatedResource(inboxFetcher);
|
|
822
|
+
this.#notifications.observable.subscribe(
|
|
522
823
|
() => (
|
|
523
824
|
// Note that the store itself does not change, but it's only vehicle at
|
|
524
825
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
525
|
-
this.
|
|
826
|
+
this.invalidateEntireStore()
|
|
526
827
|
)
|
|
527
828
|
);
|
|
528
|
-
this.
|
|
529
|
-
this.
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
829
|
+
this.threads = new ThreadDB();
|
|
830
|
+
this.notifications = createStore_forNotifications();
|
|
831
|
+
this.roomNotificationSettings = createStore_forRoomNotificationSettings();
|
|
832
|
+
this.historyVersions = createStore_forHistoryVersions();
|
|
833
|
+
const threadifications = _core.DerivedSignal.from(
|
|
834
|
+
this.threads.signal,
|
|
835
|
+
this.notifications.signal,
|
|
836
|
+
this.optimisticUpdates.signal,
|
|
837
|
+
(ts, ns, updates) => applyOptimisticUpdates_forThreadifications(ts, ns, updates)
|
|
838
|
+
);
|
|
839
|
+
const threads = _core.DerivedSignal.from(threadifications, (s) => ({
|
|
840
|
+
threadsDB: s.threadsDB
|
|
841
|
+
}));
|
|
842
|
+
const notifications = _core.DerivedSignal.from(threadifications, (s) => ({
|
|
843
|
+
sortedNotifications: s.sortedNotifications,
|
|
844
|
+
notificationsById: s.notificationsById
|
|
845
|
+
}));
|
|
846
|
+
const settingsByRoomId = _core.DerivedSignal.from(
|
|
847
|
+
this.roomNotificationSettings.signal,
|
|
848
|
+
this.optimisticUpdates.signal,
|
|
849
|
+
(settings, updates) => applyOptimisticUpdates_forSettings(settings, updates)
|
|
850
|
+
);
|
|
851
|
+
const versionsByRoomId = _core.DerivedSignal.from(
|
|
852
|
+
this.historyVersions.signal,
|
|
853
|
+
(hv) => Object.fromEntries(
|
|
854
|
+
[...hv].map(([roomId, versions]) => [
|
|
855
|
+
roomId,
|
|
856
|
+
Object.fromEntries(versions)
|
|
857
|
+
])
|
|
858
|
+
)
|
|
859
|
+
);
|
|
860
|
+
this.outputs = {
|
|
861
|
+
threadifications,
|
|
862
|
+
threads,
|
|
863
|
+
notifications,
|
|
864
|
+
settingsByRoomId,
|
|
865
|
+
versionsByRoomId
|
|
866
|
+
};
|
|
536
867
|
autobind(this);
|
|
537
868
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
869
|
+
get1_both() {
|
|
870
|
+
return this.outputs.threadifications.get();
|
|
871
|
+
}
|
|
872
|
+
subscribe1_both(callback) {
|
|
873
|
+
return this.outputs.threadifications.subscribe(callback);
|
|
874
|
+
}
|
|
875
|
+
get1_threads() {
|
|
876
|
+
return this.outputs.threads.get();
|
|
877
|
+
}
|
|
878
|
+
subscribe1_threads(callback) {
|
|
879
|
+
return this.outputs.threads.subscribe(callback);
|
|
547
880
|
}
|
|
548
|
-
|
|
549
|
-
return this.
|
|
881
|
+
get1_notifications() {
|
|
882
|
+
return this.outputs.notifications.get();
|
|
550
883
|
}
|
|
551
|
-
|
|
552
|
-
return this.
|
|
884
|
+
subscribe1_notifications(callback) {
|
|
885
|
+
return this.outputs.notifications.subscribe(callback);
|
|
886
|
+
}
|
|
887
|
+
get2() {
|
|
888
|
+
return this.outputs.settingsByRoomId.get();
|
|
889
|
+
}
|
|
890
|
+
subscribe2(callback) {
|
|
891
|
+
return this.outputs.settingsByRoomId.subscribe(callback);
|
|
892
|
+
}
|
|
893
|
+
get3() {
|
|
894
|
+
return this.outputs.versionsByRoomId.get();
|
|
895
|
+
}
|
|
896
|
+
subscribe3(callback) {
|
|
897
|
+
return this.outputs.versionsByRoomId.subscribe(callback);
|
|
553
898
|
}
|
|
554
899
|
/**
|
|
555
900
|
* Returns the async result of the given query and room id. If the query is success,
|
|
@@ -558,7 +903,7 @@ var UmbrellaStore = class {
|
|
|
558
903
|
*/
|
|
559
904
|
getRoomThreadsLoadingState(roomId, query) {
|
|
560
905
|
const queryKey = makeRoomThreadsQueryKey(roomId, query);
|
|
561
|
-
const paginatedResource = this.
|
|
906
|
+
const paginatedResource = this.#roomThreads.get(queryKey);
|
|
562
907
|
if (paginatedResource === void 0) {
|
|
563
908
|
return ASYNC_LOADING;
|
|
564
909
|
}
|
|
@@ -566,7 +911,7 @@ var UmbrellaStore = class {
|
|
|
566
911
|
if (asyncResult.isLoading || asyncResult.error) {
|
|
567
912
|
return asyncResult;
|
|
568
913
|
}
|
|
569
|
-
const threads = this.
|
|
914
|
+
const threads = this.get1_threads().threadsDB.findMany(
|
|
570
915
|
roomId,
|
|
571
916
|
_nullishCoalesce(query, () => ( {})),
|
|
572
917
|
"asc"
|
|
@@ -583,7 +928,7 @@ var UmbrellaStore = class {
|
|
|
583
928
|
}
|
|
584
929
|
getUserThreadsLoadingState(query) {
|
|
585
930
|
const queryKey = makeUserThreadsQueryKey(query);
|
|
586
|
-
const paginatedResource = this.
|
|
931
|
+
const paginatedResource = this.#userThreads.get(queryKey);
|
|
587
932
|
if (paginatedResource === void 0) {
|
|
588
933
|
return ASYNC_LOADING;
|
|
589
934
|
}
|
|
@@ -591,7 +936,7 @@ var UmbrellaStore = class {
|
|
|
591
936
|
if (asyncResult.isLoading || asyncResult.error) {
|
|
592
937
|
return asyncResult;
|
|
593
938
|
}
|
|
594
|
-
const threads = this.
|
|
939
|
+
const threads = this.get1_threads().threadsDB.findMany(
|
|
595
940
|
void 0,
|
|
596
941
|
// Do _not_ filter by roomId
|
|
597
942
|
_nullishCoalesce(query, () => ( {})),
|
|
@@ -609,14 +954,14 @@ var UmbrellaStore = class {
|
|
|
609
954
|
}
|
|
610
955
|
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
611
956
|
getInboxNotificationsLoadingState() {
|
|
612
|
-
const asyncResult = this.
|
|
957
|
+
const asyncResult = this.#notifications.get();
|
|
613
958
|
if (asyncResult.isLoading || asyncResult.error) {
|
|
614
959
|
return asyncResult;
|
|
615
960
|
}
|
|
616
961
|
const page = asyncResult.data;
|
|
617
962
|
return {
|
|
618
963
|
isLoading: false,
|
|
619
|
-
inboxNotifications: this.
|
|
964
|
+
inboxNotifications: this.get1_notifications().sortedNotifications,
|
|
620
965
|
hasFetchedAll: page.hasFetchedAll,
|
|
621
966
|
isFetchingMore: page.isFetchingMore,
|
|
622
967
|
fetchMoreError: page.fetchMoreError,
|
|
@@ -624,9 +969,10 @@ var UmbrellaStore = class {
|
|
|
624
969
|
};
|
|
625
970
|
}
|
|
626
971
|
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
972
|
+
// XXX_vincent This should really be a derived Signal!
|
|
627
973
|
getNotificationSettingsLoadingState(roomId) {
|
|
628
974
|
const queryKey = makeNotificationSettingsQueryKey(roomId);
|
|
629
|
-
const resource = this.
|
|
975
|
+
const resource = this.#roomNotificationSettings.get(queryKey);
|
|
630
976
|
if (resource === void 0) {
|
|
631
977
|
return ASYNC_LOADING;
|
|
632
978
|
}
|
|
@@ -636,12 +982,12 @@ var UmbrellaStore = class {
|
|
|
636
982
|
}
|
|
637
983
|
return {
|
|
638
984
|
isLoading: false,
|
|
639
|
-
settings: _core.nn.call(void 0, this.
|
|
985
|
+
settings: _core.nn.call(void 0, this.get2()[roomId])
|
|
640
986
|
};
|
|
641
987
|
}
|
|
642
988
|
getRoomVersionsLoadingState(roomId) {
|
|
643
989
|
const queryKey = makeVersionsQueryKey(roomId);
|
|
644
|
-
const resource = this.
|
|
990
|
+
const resource = this.#roomVersions.get(queryKey);
|
|
645
991
|
if (resource === void 0) {
|
|
646
992
|
return ASYNC_LOADING;
|
|
647
993
|
}
|
|
@@ -651,134 +997,68 @@ var UmbrellaStore = class {
|
|
|
651
997
|
}
|
|
652
998
|
return {
|
|
653
999
|
isLoading: false,
|
|
654
|
-
versions: Object.values(_nullishCoalesce(this.
|
|
1000
|
+
versions: Object.values(_nullishCoalesce(this.get3()[roomId], () => ( {})))
|
|
655
1001
|
};
|
|
656
1002
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
// Direct low-level cache mutations ------------------------------------------------- {{{
|
|
664
|
-
mutateThreadsDB(mutate) {
|
|
665
|
-
const db = this._rawThreadsDB;
|
|
666
|
-
const old = db.version;
|
|
667
|
-
mutate(db);
|
|
668
|
-
if (old !== db.version) {
|
|
669
|
-
this._store.set((state) => ({ ...state }));
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
updateInboxNotificationsCache(mapFn) {
|
|
673
|
-
this._store.set((state) => {
|
|
674
|
-
const inboxNotifications = mapFn(state.notificationsById);
|
|
675
|
-
return inboxNotifications !== state.notificationsById ? { ...state, notificationsById: inboxNotifications } : state;
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
setNotificationSettings(roomId, settings) {
|
|
679
|
-
this._store.set((state) => ({
|
|
680
|
-
...state,
|
|
681
|
-
settingsByRoomId: {
|
|
682
|
-
...state.settingsByRoomId,
|
|
683
|
-
[roomId]: settings
|
|
684
|
-
}
|
|
685
|
-
}));
|
|
686
|
-
}
|
|
687
|
-
updateRoomVersions(roomId, versions) {
|
|
688
|
-
this._store.set((state) => {
|
|
689
|
-
const versionsById = Object.fromEntries(
|
|
690
|
-
versions.map((version2) => [version2.id, version2])
|
|
691
|
-
);
|
|
692
|
-
return {
|
|
693
|
-
...state,
|
|
694
|
-
versionsByRoomId: {
|
|
695
|
-
...state.versionsByRoomId,
|
|
696
|
-
[roomId]: {
|
|
697
|
-
// Merge with existing versions for the room, or start with an empty object
|
|
698
|
-
..._nullishCoalesce(state.versionsByRoomId[roomId], () => ( {})),
|
|
699
|
-
...versionsById
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
updateOptimisticUpdatesCache(mapFn) {
|
|
706
|
-
this._store.set((state) => {
|
|
707
|
-
const optimisticUpdates = mapFn(state.optimisticUpdates);
|
|
708
|
-
this._syncSource.setSyncStatus(
|
|
709
|
-
optimisticUpdates.length > 0 ? "synchronizing" : "synchronized"
|
|
710
|
-
);
|
|
711
|
-
return { ...state, optimisticUpdates };
|
|
1003
|
+
/** @internal - Only call this method from unit tests. */
|
|
1004
|
+
force_set_versions(callback) {
|
|
1005
|
+
_core.batch.call(void 0, () => {
|
|
1006
|
+
this.historyVersions.force_set(callback);
|
|
1007
|
+
this.invalidateEntireStore();
|
|
712
1008
|
});
|
|
713
1009
|
}
|
|
714
|
-
// ---------------------------------------------------------------------------------- }}}
|
|
715
1010
|
/** @internal - Only call this method from unit tests. */
|
|
716
|
-
|
|
717
|
-
|
|
1011
|
+
force_set_notifications(callback) {
|
|
1012
|
+
_core.batch.call(void 0, () => {
|
|
1013
|
+
this.notifications.force_set(callback);
|
|
1014
|
+
this.invalidateEntireStore();
|
|
1015
|
+
});
|
|
718
1016
|
}
|
|
719
1017
|
/**
|
|
720
1018
|
* Updates an existing inbox notification with a new value, replacing the
|
|
721
1019
|
* corresponding optimistic update.
|
|
722
1020
|
*
|
|
723
|
-
* This will not update anything if the inbox notification ID isn't found
|
|
724
|
-
* the cache.
|
|
1021
|
+
* This will not update anything if the inbox notification ID isn't found.
|
|
725
1022
|
*/
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
this.
|
|
729
|
-
this.
|
|
730
|
-
const existing = cache[inboxNotificationId];
|
|
731
|
-
if (!existing) {
|
|
732
|
-
return cache;
|
|
733
|
-
}
|
|
734
|
-
const inboxNotifications = {
|
|
735
|
-
...cache,
|
|
736
|
-
[inboxNotificationId]: callback(existing)
|
|
737
|
-
};
|
|
738
|
-
return inboxNotifications;
|
|
739
|
-
});
|
|
1023
|
+
markInboxNotificationRead(inboxNotificationId, readAt, optimisticId) {
|
|
1024
|
+
_core.batch.call(void 0, () => {
|
|
1025
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1026
|
+
this.notifications.markRead(inboxNotificationId, readAt);
|
|
740
1027
|
});
|
|
741
1028
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
updateAllInboxNotifications(optimisticUpdateId, mapFn) {
|
|
747
|
-
this._store.batch(() => {
|
|
748
|
-
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
749
|
-
this.updateInboxNotificationsCache((cache) => _core.mapValues.call(void 0, cache, mapFn));
|
|
1029
|
+
markAllInboxNotificationsRead(optimisticId, readAt) {
|
|
1030
|
+
_core.batch.call(void 0, () => {
|
|
1031
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1032
|
+
this.notifications.markAllRead(readAt);
|
|
750
1033
|
});
|
|
751
1034
|
}
|
|
752
1035
|
/**
|
|
753
1036
|
* Deletes an existing inbox notification, replacing the corresponding
|
|
754
1037
|
* optimistic update.
|
|
755
1038
|
*/
|
|
756
|
-
deleteInboxNotification(inboxNotificationId,
|
|
757
|
-
|
|
758
|
-
this.
|
|
759
|
-
this.
|
|
760
|
-
const { [inboxNotificationId]: removed, ...newCache } = cache;
|
|
761
|
-
return removed === void 0 ? cache : newCache;
|
|
762
|
-
});
|
|
1039
|
+
deleteInboxNotification(inboxNotificationId, optimisticId) {
|
|
1040
|
+
_core.batch.call(void 0, () => {
|
|
1041
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1042
|
+
this.notifications.delete(inboxNotificationId);
|
|
763
1043
|
});
|
|
764
1044
|
}
|
|
765
1045
|
/**
|
|
766
1046
|
* Deletes *all* inbox notifications, replacing the corresponding optimistic
|
|
767
1047
|
* update.
|
|
768
1048
|
*/
|
|
769
|
-
deleteAllInboxNotifications(
|
|
770
|
-
|
|
771
|
-
this.
|
|
772
|
-
this.
|
|
1049
|
+
deleteAllInboxNotifications(optimisticId) {
|
|
1050
|
+
_core.batch.call(void 0, () => {
|
|
1051
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1052
|
+
this.notifications.clear();
|
|
773
1053
|
});
|
|
774
1054
|
}
|
|
775
1055
|
/**
|
|
776
1056
|
* Creates an new thread, replacing the corresponding optimistic update.
|
|
777
1057
|
*/
|
|
778
|
-
createThread(
|
|
779
|
-
|
|
780
|
-
this.
|
|
781
|
-
this.
|
|
1058
|
+
createThread(optimisticId, thread) {
|
|
1059
|
+
_core.batch.call(void 0, () => {
|
|
1060
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1061
|
+
this.threads.upsert(thread);
|
|
782
1062
|
});
|
|
783
1063
|
}
|
|
784
1064
|
/**
|
|
@@ -786,44 +1066,43 @@ var UmbrellaStore = class {
|
|
|
786
1066
|
* optimistic update.
|
|
787
1067
|
*
|
|
788
1068
|
* This will not update anything if:
|
|
789
|
-
* - The thread ID isn't found
|
|
790
|
-
* - The thread ID was already deleted
|
|
791
|
-
* - The thread ID
|
|
792
|
-
*
|
|
1069
|
+
* - The thread ID isn't found; or
|
|
1070
|
+
* - The thread ID was already deleted; or
|
|
1071
|
+
* - The thread ID was updated more recently than the optimistic update's
|
|
1072
|
+
* timestamp (if given)
|
|
793
1073
|
*/
|
|
794
|
-
updateThread(threadId,
|
|
795
|
-
|
|
796
|
-
if (
|
|
797
|
-
this.
|
|
1074
|
+
#updateThread(threadId, optimisticId, callback, updatedAt) {
|
|
1075
|
+
_core.batch.call(void 0, () => {
|
|
1076
|
+
if (optimisticId !== null) {
|
|
1077
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
798
1078
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
});
|
|
1079
|
+
const db = this.threads;
|
|
1080
|
+
const existing = db.get(threadId);
|
|
1081
|
+
if (!existing) return;
|
|
1082
|
+
if (!!updatedAt && existing.updatedAt > updatedAt) return;
|
|
1083
|
+
db.upsert(callback(existing));
|
|
805
1084
|
});
|
|
806
1085
|
}
|
|
807
|
-
patchThread(threadId,
|
|
808
|
-
return this
|
|
1086
|
+
patchThread(threadId, optimisticId, patch, updatedAt) {
|
|
1087
|
+
return this.#updateThread(
|
|
809
1088
|
threadId,
|
|
810
|
-
|
|
1089
|
+
optimisticId,
|
|
811
1090
|
(thread) => ({ ...thread, ..._core.compactObject.call(void 0, patch) }),
|
|
812
1091
|
updatedAt
|
|
813
1092
|
);
|
|
814
1093
|
}
|
|
815
|
-
addReaction(threadId,
|
|
816
|
-
this
|
|
1094
|
+
addReaction(threadId, optimisticId, commentId, reaction, createdAt) {
|
|
1095
|
+
this.#updateThread(
|
|
817
1096
|
threadId,
|
|
818
|
-
|
|
1097
|
+
optimisticId,
|
|
819
1098
|
(thread) => applyAddReaction(thread, commentId, reaction),
|
|
820
1099
|
createdAt
|
|
821
1100
|
);
|
|
822
1101
|
}
|
|
823
|
-
removeReaction(threadId,
|
|
824
|
-
this
|
|
1102
|
+
removeReaction(threadId, optimisticId, commentId, emoji, userId, removedAt) {
|
|
1103
|
+
this.#updateThread(
|
|
825
1104
|
threadId,
|
|
826
|
-
|
|
1105
|
+
optimisticId,
|
|
827
1106
|
(thread) => applyRemoveReaction(thread, commentId, emoji, userId, removedAt),
|
|
828
1107
|
removedAt
|
|
829
1108
|
);
|
|
@@ -833,13 +1112,13 @@ var UmbrellaStore = class {
|
|
|
833
1112
|
* replacing the corresponding optimistic update.
|
|
834
1113
|
*
|
|
835
1114
|
* This will not update anything if:
|
|
836
|
-
* - The thread ID isn't found
|
|
837
|
-
* - The thread ID was already deleted
|
|
1115
|
+
* - The thread ID isn't found; or
|
|
1116
|
+
* - The thread ID was already deleted
|
|
838
1117
|
*/
|
|
839
|
-
deleteThread(threadId,
|
|
840
|
-
return this
|
|
1118
|
+
deleteThread(threadId, optimisticId) {
|
|
1119
|
+
return this.#updateThread(
|
|
841
1120
|
threadId,
|
|
842
|
-
|
|
1121
|
+
optimisticId,
|
|
843
1122
|
// A deletion is actually an update of the deletedAt property internally
|
|
844
1123
|
(thread) => ({ ...thread, updatedAt: /* @__PURE__ */ new Date(), deletedAt: /* @__PURE__ */ new Date() })
|
|
845
1124
|
);
|
|
@@ -848,107 +1127,61 @@ var UmbrellaStore = class {
|
|
|
848
1127
|
* Creates an existing comment and ensures the associated notification is
|
|
849
1128
|
* updated correctly, replacing the corresponding optimistic update.
|
|
850
1129
|
*/
|
|
851
|
-
createComment(newComment,
|
|
852
|
-
|
|
853
|
-
this.
|
|
854
|
-
const existingThread = this.
|
|
1130
|
+
createComment(newComment, optimisticId) {
|
|
1131
|
+
_core.batch.call(void 0, () => {
|
|
1132
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1133
|
+
const existingThread = this.threads.get(newComment.threadId);
|
|
855
1134
|
if (!existingThread) {
|
|
856
1135
|
return;
|
|
857
1136
|
}
|
|
858
|
-
this.
|
|
859
|
-
|
|
860
|
-
);
|
|
861
|
-
this.updateInboxNotificationsCache((cache) => {
|
|
862
|
-
const existingNotification = Object.values(cache).find(
|
|
863
|
-
(notification) => notification.kind === "thread" && notification.threadId === newComment.threadId
|
|
864
|
-
);
|
|
865
|
-
if (!existingNotification) {
|
|
866
|
-
return cache;
|
|
867
|
-
}
|
|
868
|
-
return {
|
|
869
|
-
...cache,
|
|
870
|
-
[existingNotification.id]: {
|
|
871
|
-
...existingNotification,
|
|
872
|
-
notifiedAt: newComment.createdAt,
|
|
873
|
-
readAt: newComment.createdAt
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
});
|
|
1137
|
+
this.threads.upsert(applyUpsertComment(existingThread, newComment));
|
|
1138
|
+
this.notifications.updateAssociatedNotification(newComment);
|
|
877
1139
|
});
|
|
878
1140
|
}
|
|
879
|
-
editComment(threadId,
|
|
880
|
-
return this
|
|
1141
|
+
editComment(threadId, optimisticId, editedComment) {
|
|
1142
|
+
return this.#updateThread(
|
|
881
1143
|
threadId,
|
|
882
|
-
|
|
1144
|
+
optimisticId,
|
|
883
1145
|
(thread) => applyUpsertComment(thread, editedComment)
|
|
884
1146
|
);
|
|
885
1147
|
}
|
|
886
|
-
deleteComment(threadId,
|
|
887
|
-
return this
|
|
1148
|
+
deleteComment(threadId, optimisticId, commentId, deletedAt) {
|
|
1149
|
+
return this.#updateThread(
|
|
888
1150
|
threadId,
|
|
889
|
-
|
|
1151
|
+
optimisticId,
|
|
890
1152
|
(thread) => applyDeleteComment(thread, commentId, deletedAt),
|
|
891
1153
|
deletedAt
|
|
892
1154
|
);
|
|
893
1155
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
this.
|
|
897
|
-
|
|
898
|
-
this.updateInboxNotificationsCache((cache) => ({
|
|
899
|
-
...cache,
|
|
900
|
-
[inboxNotification.id]: inboxNotification
|
|
901
|
-
}));
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads = [], deletedInboxNotifications = []) {
|
|
906
|
-
this._store.batch(() => {
|
|
907
|
-
this.mutateThreadsDB(
|
|
908
|
-
(db) => applyThreadDeltaUpdates(db, { newThreads: threads, deletedThreads })
|
|
909
|
-
);
|
|
910
|
-
this.updateInboxNotificationsCache(
|
|
911
|
-
(cache) => applyNotificationsUpdates(cache, {
|
|
912
|
-
newInboxNotifications: inboxNotifications,
|
|
913
|
-
deletedNotifications: deletedInboxNotifications
|
|
914
|
-
})
|
|
915
|
-
);
|
|
1156
|
+
updateThreadifications(threads, notifications, deletedThreads = [], deletedNotifications = []) {
|
|
1157
|
+
_core.batch.call(void 0, () => {
|
|
1158
|
+
this.threads.applyDelta({ newThreads: threads, deletedThreads });
|
|
1159
|
+
this.notifications.applyDelta(notifications, deletedNotifications);
|
|
916
1160
|
});
|
|
917
1161
|
}
|
|
918
1162
|
/**
|
|
919
1163
|
* Updates existing notification setting for a room with a new value,
|
|
920
1164
|
* replacing the corresponding optimistic update.
|
|
921
1165
|
*/
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
this.
|
|
925
|
-
this.
|
|
1166
|
+
updateRoomNotificationSettings(roomId, optimisticId, settings) {
|
|
1167
|
+
_core.batch.call(void 0, () => {
|
|
1168
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1169
|
+
this.roomNotificationSettings.update(roomId, settings);
|
|
926
1170
|
});
|
|
927
1171
|
}
|
|
928
|
-
addOptimisticUpdate(optimisticUpdate) {
|
|
929
|
-
const id = _core.nanoid.call(void 0, );
|
|
930
|
-
const newUpdate = { ...optimisticUpdate, id };
|
|
931
|
-
this.updateOptimisticUpdatesCache((cache) => [...cache, newUpdate]);
|
|
932
|
-
return id;
|
|
933
|
-
}
|
|
934
|
-
removeOptimisticUpdate(optimisticUpdateId) {
|
|
935
|
-
this.updateOptimisticUpdatesCache(
|
|
936
|
-
(cache) => cache.filter((ou) => ou.id !== optimisticUpdateId)
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
1172
|
async fetchNotificationsDeltaUpdate(signal) {
|
|
940
|
-
const lastRequestedAt = this
|
|
1173
|
+
const lastRequestedAt = this.#notificationsLastRequestedAt;
|
|
941
1174
|
if (lastRequestedAt === null) {
|
|
942
1175
|
return;
|
|
943
1176
|
}
|
|
944
|
-
const result = await this.
|
|
1177
|
+
const result = await this.#client.getInboxNotificationsSince({
|
|
945
1178
|
since: lastRequestedAt,
|
|
946
1179
|
signal
|
|
947
1180
|
});
|
|
948
1181
|
if (lastRequestedAt < result.requestedAt) {
|
|
949
|
-
this
|
|
1182
|
+
this.#notificationsLastRequestedAt = result.requestedAt;
|
|
950
1183
|
}
|
|
951
|
-
this.
|
|
1184
|
+
this.updateThreadifications(
|
|
952
1185
|
result.threads.updated,
|
|
953
1186
|
result.inboxNotifications.updated,
|
|
954
1187
|
result.threads.deleted,
|
|
@@ -956,42 +1189,25 @@ var UmbrellaStore = class {
|
|
|
956
1189
|
);
|
|
957
1190
|
}
|
|
958
1191
|
waitUntilNotificationsLoaded() {
|
|
959
|
-
return this.
|
|
960
|
-
}
|
|
961
|
-
updateRoomPermissions(permissions) {
|
|
962
|
-
const permissionsByRoom = { ...this._store.get().permissionsByRoom };
|
|
963
|
-
Object.entries(permissions).forEach(([roomId, newPermissions]) => {
|
|
964
|
-
const existingPermissions = _nullishCoalesce(permissionsByRoom[roomId], () => ( /* @__PURE__ */ new Set()));
|
|
965
|
-
newPermissions.forEach(
|
|
966
|
-
(permission) => existingPermissions.add(permission)
|
|
967
|
-
);
|
|
968
|
-
permissionsByRoom[roomId] = existingPermissions;
|
|
969
|
-
});
|
|
970
|
-
this._store.set((state) => ({
|
|
971
|
-
...state,
|
|
972
|
-
permissionsByRoom
|
|
973
|
-
}));
|
|
1192
|
+
return this.#notifications.waitUntilLoaded();
|
|
974
1193
|
}
|
|
975
1194
|
waitUntilRoomThreadsLoaded(roomId, query) {
|
|
976
1195
|
const threadsFetcher = async (cursor) => {
|
|
977
|
-
const result = await this
|
|
1196
|
+
const result = await this.#client[_core.kInternal].httpClient.getThreads({
|
|
978
1197
|
roomId,
|
|
979
1198
|
cursor,
|
|
980
1199
|
query
|
|
981
1200
|
});
|
|
982
|
-
this.
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
);
|
|
986
|
-
this.updateRoomPermissions(result.permissionHints);
|
|
987
|
-
const lastRequestedAt = this._roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
1201
|
+
this.updateThreadifications(result.threads, result.inboxNotifications);
|
|
1202
|
+
this.permissionHints.update(result.permissionHints);
|
|
1203
|
+
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
988
1204
|
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
989
|
-
this.
|
|
1205
|
+
this.#roomThreadsLastRequestedAtByRoom.set(roomId, result.requestedAt);
|
|
990
1206
|
}
|
|
991
1207
|
return result.nextCursor;
|
|
992
1208
|
};
|
|
993
1209
|
const queryKey = makeRoomThreadsQueryKey(roomId, query);
|
|
994
|
-
let paginatedResource = this.
|
|
1210
|
+
let paginatedResource = this.#roomThreads.get(queryKey);
|
|
995
1211
|
if (paginatedResource === void 0) {
|
|
996
1212
|
paginatedResource = new PaginatedResource(threadsFetcher);
|
|
997
1213
|
}
|
|
@@ -999,51 +1215,48 @@ var UmbrellaStore = class {
|
|
|
999
1215
|
() => (
|
|
1000
1216
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1001
1217
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1002
|
-
this.
|
|
1218
|
+
this.invalidateEntireStore()
|
|
1003
1219
|
)
|
|
1004
1220
|
);
|
|
1005
|
-
this.
|
|
1221
|
+
this.#roomThreads.set(queryKey, paginatedResource);
|
|
1006
1222
|
return paginatedResource.waitUntilLoaded();
|
|
1007
1223
|
}
|
|
1008
1224
|
async fetchRoomThreadsDeltaUpdate(roomId, signal) {
|
|
1009
|
-
const lastRequestedAt = this.
|
|
1225
|
+
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
1010
1226
|
if (lastRequestedAt === void 0) {
|
|
1011
1227
|
return;
|
|
1012
1228
|
}
|
|
1013
|
-
const updates = await this
|
|
1229
|
+
const updates = await this.#client[_core.kInternal].httpClient.getThreadsSince({
|
|
1014
1230
|
roomId,
|
|
1015
1231
|
since: lastRequestedAt,
|
|
1016
1232
|
signal
|
|
1017
1233
|
});
|
|
1018
|
-
this.
|
|
1234
|
+
this.updateThreadifications(
|
|
1019
1235
|
updates.threads.updated,
|
|
1020
1236
|
updates.inboxNotifications.updated,
|
|
1021
1237
|
updates.threads.deleted,
|
|
1022
1238
|
updates.inboxNotifications.deleted
|
|
1023
1239
|
);
|
|
1024
|
-
this.
|
|
1240
|
+
this.permissionHints.update(updates.permissionHints);
|
|
1025
1241
|
if (lastRequestedAt < updates.requestedAt) {
|
|
1026
|
-
this.
|
|
1242
|
+
this.#roomThreadsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1027
1243
|
}
|
|
1028
1244
|
}
|
|
1029
1245
|
waitUntilUserThreadsLoaded(query) {
|
|
1030
1246
|
const queryKey = makeUserThreadsQueryKey(query);
|
|
1031
1247
|
const threadsFetcher = async (cursor) => {
|
|
1032
|
-
const result = await this
|
|
1248
|
+
const result = await this.#client[_core.kInternal].httpClient.getUserThreads_experimental({
|
|
1033
1249
|
cursor,
|
|
1034
1250
|
query
|
|
1035
1251
|
});
|
|
1036
|
-
this.
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
this.updateRoomPermissions(result.permissionHints);
|
|
1041
|
-
if (this._userThreadsLastRequestedAt === null) {
|
|
1042
|
-
this._userThreadsLastRequestedAt = result.requestedAt;
|
|
1252
|
+
this.updateThreadifications(result.threads, result.inboxNotifications);
|
|
1253
|
+
this.permissionHints.update(result.permissionHints);
|
|
1254
|
+
if (this.#userThreadsLastRequestedAt === null) {
|
|
1255
|
+
this.#userThreadsLastRequestedAt = result.requestedAt;
|
|
1043
1256
|
}
|
|
1044
1257
|
return result.nextCursor;
|
|
1045
1258
|
};
|
|
1046
|
-
let paginatedResource = this.
|
|
1259
|
+
let paginatedResource = this.#userThreads.get(queryKey);
|
|
1047
1260
|
if (paginatedResource === void 0) {
|
|
1048
1261
|
paginatedResource = new PaginatedResource(threadsFetcher);
|
|
1049
1262
|
}
|
|
@@ -1051,38 +1264,49 @@ var UmbrellaStore = class {
|
|
|
1051
1264
|
() => (
|
|
1052
1265
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1053
1266
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1054
|
-
this.
|
|
1267
|
+
this.invalidateEntireStore()
|
|
1055
1268
|
)
|
|
1056
1269
|
);
|
|
1057
|
-
this.
|
|
1270
|
+
this.#userThreads.set(queryKey, paginatedResource);
|
|
1058
1271
|
return paginatedResource.waitUntilLoaded();
|
|
1059
1272
|
}
|
|
1273
|
+
// XXX_vincent We should really be going over all call sites, and replace this call
|
|
1274
|
+
// with a more specific invalidation!
|
|
1275
|
+
invalidateEntireStore() {
|
|
1276
|
+
_core.batch.call(void 0, () => {
|
|
1277
|
+
this.historyVersions.invalidate();
|
|
1278
|
+
this.notifications.invalidate();
|
|
1279
|
+
this.optimisticUpdates.invalidate();
|
|
1280
|
+
this.permissionHints.invalidate();
|
|
1281
|
+
this.roomNotificationSettings.invalidate();
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1060
1284
|
async fetchUserThreadsDeltaUpdate(signal) {
|
|
1061
|
-
const lastRequestedAt = this
|
|
1285
|
+
const lastRequestedAt = this.#userThreadsLastRequestedAt;
|
|
1062
1286
|
if (lastRequestedAt === null) {
|
|
1063
1287
|
return;
|
|
1064
1288
|
}
|
|
1065
|
-
const result = await this
|
|
1289
|
+
const result = await this.#client[_core.kInternal].httpClient.getUserThreadsSince_experimental({
|
|
1066
1290
|
since: lastRequestedAt,
|
|
1067
1291
|
signal
|
|
1068
1292
|
});
|
|
1069
1293
|
if (lastRequestedAt < result.requestedAt) {
|
|
1070
|
-
this
|
|
1294
|
+
this.#notificationsLastRequestedAt = result.requestedAt;
|
|
1071
1295
|
}
|
|
1072
|
-
this.
|
|
1296
|
+
this.updateThreadifications(
|
|
1073
1297
|
result.threads.updated,
|
|
1074
1298
|
result.inboxNotifications.updated,
|
|
1075
1299
|
result.threads.deleted,
|
|
1076
1300
|
result.inboxNotifications.deleted
|
|
1077
1301
|
);
|
|
1078
|
-
this.
|
|
1302
|
+
this.permissionHints.update(result.permissionHints);
|
|
1079
1303
|
}
|
|
1080
1304
|
waitUntilRoomVersionsLoaded(roomId) {
|
|
1081
1305
|
const queryKey = makeVersionsQueryKey(roomId);
|
|
1082
|
-
let resource = this.
|
|
1306
|
+
let resource = this.#roomVersions.get(queryKey);
|
|
1083
1307
|
if (resource === void 0) {
|
|
1084
1308
|
const versionsFetcher = async () => {
|
|
1085
|
-
const room = this.
|
|
1309
|
+
const room = this.#client.getRoom(roomId);
|
|
1086
1310
|
if (room === null) {
|
|
1087
1311
|
throw new (0, _core.HttpError)(
|
|
1088
1312
|
`Room '${roomId}' is not available on client`,
|
|
@@ -1090,10 +1314,10 @@ var UmbrellaStore = class {
|
|
|
1090
1314
|
);
|
|
1091
1315
|
}
|
|
1092
1316
|
const result = await room[_core.kInternal].listTextVersions();
|
|
1093
|
-
this.
|
|
1094
|
-
const lastRequestedAt = this.
|
|
1317
|
+
this.historyVersions.update(roomId, result.versions);
|
|
1318
|
+
const lastRequestedAt = this.#roomVersionsLastRequestedAtByRoom.get(roomId);
|
|
1095
1319
|
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
1096
|
-
this.
|
|
1320
|
+
this.#roomVersionsLastRequestedAtByRoom.set(
|
|
1097
1321
|
roomId,
|
|
1098
1322
|
result.requestedAt
|
|
1099
1323
|
);
|
|
@@ -1105,36 +1329,36 @@ var UmbrellaStore = class {
|
|
|
1105
1329
|
() => (
|
|
1106
1330
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1107
1331
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1108
|
-
this.
|
|
1332
|
+
this.invalidateEntireStore()
|
|
1109
1333
|
)
|
|
1110
1334
|
);
|
|
1111
|
-
this.
|
|
1335
|
+
this.#roomVersions.set(queryKey, resource);
|
|
1112
1336
|
return resource.waitUntilLoaded();
|
|
1113
1337
|
}
|
|
1114
1338
|
async fetchRoomVersionsDeltaUpdate(roomId, signal) {
|
|
1115
|
-
const lastRequestedAt = this.
|
|
1339
|
+
const lastRequestedAt = this.#roomVersionsLastRequestedAtByRoom.get(roomId);
|
|
1116
1340
|
if (lastRequestedAt === void 0) {
|
|
1117
1341
|
return;
|
|
1118
1342
|
}
|
|
1119
1343
|
const room = _core.nn.call(void 0,
|
|
1120
|
-
this.
|
|
1344
|
+
this.#client.getRoom(roomId),
|
|
1121
1345
|
`Room with id ${roomId} is not available on client`
|
|
1122
1346
|
);
|
|
1123
1347
|
const updates = await room[_core.kInternal].listTextVersionsSince({
|
|
1124
1348
|
since: lastRequestedAt,
|
|
1125
1349
|
signal
|
|
1126
1350
|
});
|
|
1127
|
-
this.
|
|
1351
|
+
this.historyVersions.update(roomId, updates.versions);
|
|
1128
1352
|
if (lastRequestedAt < updates.requestedAt) {
|
|
1129
|
-
this.
|
|
1353
|
+
this.#roomVersionsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1130
1354
|
}
|
|
1131
1355
|
}
|
|
1132
1356
|
waitUntilRoomNotificationSettingsLoaded(roomId) {
|
|
1133
1357
|
const queryKey = makeNotificationSettingsQueryKey(roomId);
|
|
1134
|
-
let resource = this.
|
|
1358
|
+
let resource = this.#roomNotificationSettings.get(queryKey);
|
|
1135
1359
|
if (resource === void 0) {
|
|
1136
1360
|
const notificationSettingsFetcher = async () => {
|
|
1137
|
-
const room = this.
|
|
1361
|
+
const room = this.#client.getRoom(roomId);
|
|
1138
1362
|
if (room === null) {
|
|
1139
1363
|
throw new (0, _core.HttpError)(
|
|
1140
1364
|
`Room '${roomId}' is not available on client`,
|
|
@@ -1142,7 +1366,7 @@ var UmbrellaStore = class {
|
|
|
1142
1366
|
);
|
|
1143
1367
|
}
|
|
1144
1368
|
const result = await room.getNotificationSettings();
|
|
1145
|
-
this.
|
|
1369
|
+
this.roomNotificationSettings.update(roomId, result);
|
|
1146
1370
|
};
|
|
1147
1371
|
resource = new SinglePageResource(notificationSettingsFetcher);
|
|
1148
1372
|
}
|
|
@@ -1150,28 +1374,25 @@ var UmbrellaStore = class {
|
|
|
1150
1374
|
() => (
|
|
1151
1375
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1152
1376
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1153
|
-
this.
|
|
1377
|
+
this.invalidateEntireStore()
|
|
1154
1378
|
)
|
|
1155
1379
|
);
|
|
1156
|
-
this.
|
|
1380
|
+
this.#roomNotificationSettings.set(queryKey, resource);
|
|
1157
1381
|
return resource.waitUntilLoaded();
|
|
1158
1382
|
}
|
|
1159
1383
|
async refreshRoomNotificationSettings(roomId, signal) {
|
|
1160
1384
|
const room = _core.nn.call(void 0,
|
|
1161
|
-
this.
|
|
1385
|
+
this.#client.getRoom(roomId),
|
|
1162
1386
|
`Room with id ${roomId} is not available on client`
|
|
1163
1387
|
);
|
|
1164
1388
|
const result = await room.getNotificationSettings({ signal });
|
|
1165
|
-
this.
|
|
1389
|
+
this.roomNotificationSettings.update(roomId, result);
|
|
1166
1390
|
}
|
|
1167
1391
|
};
|
|
1168
|
-
function
|
|
1169
|
-
const threadsDB =
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
settingsByRoomId: { ...state.settingsByRoomId }
|
|
1173
|
-
};
|
|
1174
|
-
for (const optimisticUpdate of state.optimisticUpdates) {
|
|
1392
|
+
function applyOptimisticUpdates_forThreadifications(baseThreadsDB, notificationsLUT, optimisticUpdates) {
|
|
1393
|
+
const threadsDB = baseThreadsDB.clone();
|
|
1394
|
+
let notificationsById = Object.fromEntries(notificationsLUT);
|
|
1395
|
+
for (const optimisticUpdate of optimisticUpdates) {
|
|
1175
1396
|
switch (optimisticUpdate.type) {
|
|
1176
1397
|
case "create-thread": {
|
|
1177
1398
|
threadsDB.upsert(optimisticUpdate.thread);
|
|
@@ -1209,15 +1430,13 @@ function internalToExternalState(state, rawThreadsDB) {
|
|
|
1209
1430
|
const thread = threadsDB.get(optimisticUpdate.comment.threadId);
|
|
1210
1431
|
if (thread === void 0) break;
|
|
1211
1432
|
threadsDB.upsert(applyUpsertComment(thread, optimisticUpdate.comment));
|
|
1212
|
-
const inboxNotification = Object.values(
|
|
1213
|
-
computed.notificationsById
|
|
1214
|
-
).find(
|
|
1433
|
+
const inboxNotification = Object.values(notificationsById).find(
|
|
1215
1434
|
(notification) => notification.kind === "thread" && notification.threadId === thread.id
|
|
1216
1435
|
);
|
|
1217
1436
|
if (inboxNotification === void 0) {
|
|
1218
1437
|
break;
|
|
1219
1438
|
}
|
|
1220
|
-
|
|
1439
|
+
notificationsById[inboxNotification.id] = {
|
|
1221
1440
|
...inboxNotification,
|
|
1222
1441
|
notifiedAt: optimisticUpdate.comment.createdAt,
|
|
1223
1442
|
readAt: optimisticUpdate.comment.createdAt
|
|
@@ -1280,23 +1499,23 @@ function internalToExternalState(state, rawThreadsDB) {
|
|
|
1280
1499
|
break;
|
|
1281
1500
|
}
|
|
1282
1501
|
case "mark-inbox-notification-as-read": {
|
|
1283
|
-
const ibn =
|
|
1502
|
+
const ibn = notificationsById[optimisticUpdate.inboxNotificationId];
|
|
1284
1503
|
if (ibn === void 0) {
|
|
1285
1504
|
break;
|
|
1286
1505
|
}
|
|
1287
|
-
|
|
1506
|
+
notificationsById[optimisticUpdate.inboxNotificationId] = {
|
|
1288
1507
|
...ibn,
|
|
1289
1508
|
readAt: optimisticUpdate.readAt
|
|
1290
1509
|
};
|
|
1291
1510
|
break;
|
|
1292
1511
|
}
|
|
1293
1512
|
case "mark-all-inbox-notifications-as-read": {
|
|
1294
|
-
for (const id in
|
|
1295
|
-
const ibn =
|
|
1513
|
+
for (const id in notificationsById) {
|
|
1514
|
+
const ibn = notificationsById[id];
|
|
1296
1515
|
if (ibn === void 0) {
|
|
1297
1516
|
break;
|
|
1298
1517
|
}
|
|
1299
|
-
|
|
1518
|
+
notificationsById[id] = {
|
|
1300
1519
|
...ibn,
|
|
1301
1520
|
readAt: optimisticUpdate.readAt
|
|
1302
1521
|
};
|
|
@@ -1304,64 +1523,44 @@ function internalToExternalState(state, rawThreadsDB) {
|
|
|
1304
1523
|
break;
|
|
1305
1524
|
}
|
|
1306
1525
|
case "delete-inbox-notification": {
|
|
1307
|
-
delete
|
|
1526
|
+
delete notificationsById[optimisticUpdate.inboxNotificationId];
|
|
1308
1527
|
break;
|
|
1309
1528
|
}
|
|
1310
1529
|
case "delete-all-inbox-notifications": {
|
|
1311
|
-
|
|
1530
|
+
notificationsById = {};
|
|
1312
1531
|
break;
|
|
1313
1532
|
}
|
|
1314
|
-
case "update-notification-settings": {
|
|
1315
|
-
const settings = computed.settingsByRoomId[optimisticUpdate.roomId];
|
|
1316
|
-
if (settings === void 0) {
|
|
1317
|
-
break;
|
|
1318
|
-
}
|
|
1319
|
-
computed.settingsByRoomId[optimisticUpdate.roomId] = {
|
|
1320
|
-
...settings,
|
|
1321
|
-
...optimisticUpdate.settings
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
1533
|
}
|
|
1325
1534
|
}
|
|
1326
|
-
const
|
|
1535
|
+
const sortedNotifications = (
|
|
1327
1536
|
// Sort so that the most recent notifications are first
|
|
1328
|
-
Object.values(
|
|
1537
|
+
Object.values(notificationsById).filter(
|
|
1329
1538
|
(ibn) => ibn.kind === "thread" ? threadsDB.get(ibn.threadId) !== void 0 : true
|
|
1330
1539
|
).sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime())
|
|
1331
1540
|
);
|
|
1332
1541
|
return {
|
|
1333
|
-
|
|
1334
|
-
notificationsById
|
|
1335
|
-
|
|
1336
|
-
threadsDB,
|
|
1337
|
-
versionsByRoomId: state.versionsByRoomId
|
|
1542
|
+
sortedNotifications,
|
|
1543
|
+
notificationsById,
|
|
1544
|
+
threadsDB
|
|
1338
1545
|
};
|
|
1339
1546
|
}
|
|
1340
|
-
function
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
existingNotification,
|
|
1355
|
-
notification
|
|
1356
|
-
);
|
|
1357
|
-
if (result === 1) return;
|
|
1547
|
+
function applyOptimisticUpdates_forSettings(settingsLUT, optimisticUpdates) {
|
|
1548
|
+
const settingsByRoomId = Object.fromEntries(settingsLUT);
|
|
1549
|
+
for (const optimisticUpdate of optimisticUpdates) {
|
|
1550
|
+
switch (optimisticUpdate.type) {
|
|
1551
|
+
case "update-notification-settings": {
|
|
1552
|
+
const settings = settingsByRoomId[optimisticUpdate.roomId];
|
|
1553
|
+
if (settings === void 0) {
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
settingsByRoomId[optimisticUpdate.roomId] = {
|
|
1557
|
+
...settings,
|
|
1558
|
+
...optimisticUpdate.settings
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1358
1561
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
updates.deletedNotifications.forEach(
|
|
1362
|
-
({ id }) => delete updatedInboxNotifications[id]
|
|
1363
|
-
);
|
|
1364
|
-
return updatedInboxNotifications;
|
|
1562
|
+
}
|
|
1563
|
+
return settingsByRoomId;
|
|
1365
1564
|
}
|
|
1366
1565
|
function compareInboxNotifications(inboxNotificationA, inboxNotificationB) {
|
|
1367
1566
|
if (inboxNotificationA.notifiedAt > inboxNotificationB.notifiedAt) {
|
|
@@ -1542,6 +1741,7 @@ function upsertReaction(reactions, reaction) {
|
|
|
1542
1741
|
}
|
|
1543
1742
|
|
|
1544
1743
|
// src/liveblocks.tsx
|
|
1744
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
1545
1745
|
var ClientContext = _react.createContext.call(void 0, null);
|
|
1546
1746
|
function missingUserError(userId) {
|
|
1547
1747
|
return new Error(`resolveUsers didn't return anything for user '${userId}'`);
|
|
@@ -1675,7 +1875,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1675
1875
|
const useDeleteAllInboxNotifications2 = () => useDeleteAllInboxNotifications_withClient(client);
|
|
1676
1876
|
function LiveblocksProvider2(props) {
|
|
1677
1877
|
useEnsureNoLiveblocksProvider();
|
|
1678
|
-
return /* @__PURE__ */
|
|
1878
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: client, children: props.children });
|
|
1679
1879
|
}
|
|
1680
1880
|
const shared = createSharedContext(client);
|
|
1681
1881
|
const bundle = {
|
|
@@ -1716,8 +1916,8 @@ function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
|
1716
1916
|
poller.dec();
|
|
1717
1917
|
};
|
|
1718
1918
|
}, [poller]);
|
|
1719
|
-
return
|
|
1720
|
-
store.
|
|
1919
|
+
return useSyncExternalStoreWithSelector(
|
|
1920
|
+
store.subscribe1_threads,
|
|
1721
1921
|
store.getInboxNotificationsLoadingState,
|
|
1722
1922
|
store.getInboxNotificationsLoadingState,
|
|
1723
1923
|
selector,
|
|
@@ -1752,21 +1952,21 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
1752
1952
|
(inboxNotificationId) => {
|
|
1753
1953
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
1754
1954
|
const readAt = /* @__PURE__ */ new Date();
|
|
1755
|
-
const
|
|
1955
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
1756
1956
|
type: "mark-inbox-notification-as-read",
|
|
1757
1957
|
inboxNotificationId,
|
|
1758
1958
|
readAt
|
|
1759
1959
|
});
|
|
1760
1960
|
client.markInboxNotificationAsRead(inboxNotificationId).then(
|
|
1761
1961
|
() => {
|
|
1762
|
-
store.
|
|
1962
|
+
store.markInboxNotificationRead(
|
|
1763
1963
|
inboxNotificationId,
|
|
1764
|
-
|
|
1765
|
-
|
|
1964
|
+
readAt,
|
|
1965
|
+
optimisticId
|
|
1766
1966
|
);
|
|
1767
1967
|
},
|
|
1768
1968
|
() => {
|
|
1769
|
-
store.
|
|
1969
|
+
store.optimisticUpdates.remove(optimisticId);
|
|
1770
1970
|
}
|
|
1771
1971
|
);
|
|
1772
1972
|
},
|
|
@@ -1777,19 +1977,16 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
|
1777
1977
|
return _react.useCallback.call(void 0, () => {
|
|
1778
1978
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
1779
1979
|
const readAt = /* @__PURE__ */ new Date();
|
|
1780
|
-
const
|
|
1980
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
1781
1981
|
type: "mark-all-inbox-notifications-as-read",
|
|
1782
1982
|
readAt
|
|
1783
1983
|
});
|
|
1784
1984
|
client.markAllInboxNotificationsAsRead().then(
|
|
1785
1985
|
() => {
|
|
1786
|
-
store.
|
|
1787
|
-
optimisticUpdateId,
|
|
1788
|
-
(inboxNotification) => ({ ...inboxNotification, readAt })
|
|
1789
|
-
);
|
|
1986
|
+
store.markAllInboxNotificationsRead(optimisticId, readAt);
|
|
1790
1987
|
},
|
|
1791
1988
|
() => {
|
|
1792
|
-
store.
|
|
1989
|
+
store.optimisticUpdates.remove(optimisticId);
|
|
1793
1990
|
}
|
|
1794
1991
|
);
|
|
1795
1992
|
}, [client]);
|
|
@@ -1799,20 +1996,17 @@ function useDeleteInboxNotification_withClient(client) {
|
|
|
1799
1996
|
(inboxNotificationId) => {
|
|
1800
1997
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
1801
1998
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
1802
|
-
const
|
|
1999
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
1803
2000
|
type: "delete-inbox-notification",
|
|
1804
2001
|
inboxNotificationId,
|
|
1805
2002
|
deletedAt
|
|
1806
2003
|
});
|
|
1807
2004
|
client.deleteInboxNotification(inboxNotificationId).then(
|
|
1808
2005
|
() => {
|
|
1809
|
-
store.deleteInboxNotification(
|
|
1810
|
-
inboxNotificationId,
|
|
1811
|
-
optimisticUpdateId
|
|
1812
|
-
);
|
|
2006
|
+
store.deleteInboxNotification(inboxNotificationId, optimisticId);
|
|
1813
2007
|
},
|
|
1814
2008
|
() => {
|
|
1815
|
-
store.
|
|
2009
|
+
store.optimisticUpdates.remove(optimisticId);
|
|
1816
2010
|
}
|
|
1817
2011
|
);
|
|
1818
2012
|
},
|
|
@@ -1823,23 +2017,23 @@ function useDeleteAllInboxNotifications_withClient(client) {
|
|
|
1823
2017
|
return _react.useCallback.call(void 0, () => {
|
|
1824
2018
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
1825
2019
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
1826
|
-
const
|
|
2020
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
1827
2021
|
type: "delete-all-inbox-notifications",
|
|
1828
2022
|
deletedAt
|
|
1829
2023
|
});
|
|
1830
2024
|
client.deleteAllInboxNotifications().then(
|
|
1831
2025
|
() => {
|
|
1832
|
-
store.deleteAllInboxNotifications(
|
|
2026
|
+
store.deleteAllInboxNotifications(optimisticId);
|
|
1833
2027
|
},
|
|
1834
2028
|
() => {
|
|
1835
|
-
store.
|
|
2029
|
+
store.optimisticUpdates.remove(optimisticId);
|
|
1836
2030
|
}
|
|
1837
2031
|
);
|
|
1838
2032
|
}, [client]);
|
|
1839
2033
|
}
|
|
1840
2034
|
function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
1841
2035
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
1842
|
-
const getter = store.
|
|
2036
|
+
const getter = store.get1_both;
|
|
1843
2037
|
const selector = _react.useCallback.call(void 0,
|
|
1844
2038
|
(state) => {
|
|
1845
2039
|
const inboxNotification = _nullishCoalesce(state.notificationsById[inboxNotificationId], () => ( _core.raise.call(void 0, `Inbox notification with ID "${inboxNotificationId}" not found`)));
|
|
@@ -1855,8 +2049,8 @@ function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
|
1855
2049
|
},
|
|
1856
2050
|
[inboxNotificationId]
|
|
1857
2051
|
);
|
|
1858
|
-
return
|
|
1859
|
-
store.
|
|
2052
|
+
return useSyncExternalStoreWithSelector(
|
|
2053
|
+
store.subscribe1_both,
|
|
1860
2054
|
// Re-evaluate if we need to update any time the notification changes over time
|
|
1861
2055
|
getter,
|
|
1862
2056
|
getter,
|
|
@@ -1873,7 +2067,7 @@ function useUser_withClient(client, userId) {
|
|
|
1873
2067
|
(state) => selectorFor_useUser(state, userId),
|
|
1874
2068
|
[userId]
|
|
1875
2069
|
);
|
|
1876
|
-
const result =
|
|
2070
|
+
const result = useSyncExternalStoreWithSelector(
|
|
1877
2071
|
usersStore.subscribe,
|
|
1878
2072
|
getUserState,
|
|
1879
2073
|
getUserState,
|
|
@@ -1901,7 +2095,7 @@ function useUserSuspense_withClient(client, userId) {
|
|
|
1901
2095
|
if (!userState.data) {
|
|
1902
2096
|
throw missingUserError(userId);
|
|
1903
2097
|
}
|
|
1904
|
-
const state =
|
|
2098
|
+
const state = _react.useSyncExternalStore.call(void 0,
|
|
1905
2099
|
usersStore.subscribe,
|
|
1906
2100
|
getUserState,
|
|
1907
2101
|
getUserState
|
|
@@ -1925,7 +2119,7 @@ function useRoomInfo_withClient(client, roomId) {
|
|
|
1925
2119
|
(state) => selectorFor_useRoomInfo(state, roomId),
|
|
1926
2120
|
[roomId]
|
|
1927
2121
|
);
|
|
1928
|
-
const result =
|
|
2122
|
+
const result = useSyncExternalStoreWithSelector(
|
|
1929
2123
|
roomsInfoStore.subscribe,
|
|
1930
2124
|
getRoomInfoState,
|
|
1931
2125
|
getRoomInfoState,
|
|
@@ -1953,7 +2147,7 @@ function useRoomInfoSuspense_withClient(client, roomId) {
|
|
|
1953
2147
|
if (!roomInfoState.data) {
|
|
1954
2148
|
throw missingRoomInfoError(roomId);
|
|
1955
2149
|
}
|
|
1956
|
-
const state =
|
|
2150
|
+
const state = _react.useSyncExternalStore.call(void 0,
|
|
1957
2151
|
roomsInfoStore.subscribe,
|
|
1958
2152
|
getRoomInfoState,
|
|
1959
2153
|
getRoomInfoState
|
|
@@ -2006,7 +2200,7 @@ function useClient() {
|
|
|
2006
2200
|
}
|
|
2007
2201
|
function LiveblocksProviderWithClient(props) {
|
|
2008
2202
|
useEnsureNoLiveblocksProvider(props);
|
|
2009
|
-
return /* @__PURE__ */
|
|
2203
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: props.client, children: props.children });
|
|
2010
2204
|
}
|
|
2011
2205
|
function LiveblocksProvider(props) {
|
|
2012
2206
|
const { children, ...o } = props;
|
|
@@ -2035,7 +2229,7 @@ function LiveblocksProvider(props) {
|
|
|
2035
2229
|
)
|
|
2036
2230
|
};
|
|
2037
2231
|
const client = _react.useMemo.call(void 0, () => _core.createClient.call(void 0, options), []);
|
|
2038
|
-
return /* @__PURE__ */
|
|
2232
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LiveblocksProviderWithClient, { client, children });
|
|
2039
2233
|
}
|
|
2040
2234
|
function createLiveblocksContext(client) {
|
|
2041
2235
|
return getOrCreateContextBundle(client);
|
|
@@ -2071,8 +2265,8 @@ function useUserThreads_experimental(options = {
|
|
|
2071
2265
|
() => store.getUserThreadsLoadingState(options.query),
|
|
2072
2266
|
[store, options.query]
|
|
2073
2267
|
);
|
|
2074
|
-
return
|
|
2075
|
-
store.
|
|
2268
|
+
return useSyncExternalStoreWithSelector(
|
|
2269
|
+
store.subscribe1_threads,
|
|
2076
2270
|
getter,
|
|
2077
2271
|
getter,
|
|
2078
2272
|
identity,
|
|
@@ -2151,7 +2345,7 @@ function useSyncStatus_withClient(client, options) {
|
|
|
2151
2345
|
}
|
|
2152
2346
|
}
|
|
2153
2347
|
function useSyncStatusImmediate_withClient(client) {
|
|
2154
|
-
return
|
|
2348
|
+
return _react.useSyncExternalStore.call(void 0,
|
|
2155
2349
|
client.events.syncStatus.subscribe,
|
|
2156
2350
|
client.getSyncStatus,
|
|
2157
2351
|
client.getSyncStatus
|
|
@@ -2159,9 +2353,9 @@ function useSyncStatusImmediate_withClient(client) {
|
|
|
2159
2353
|
}
|
|
2160
2354
|
function useSyncStatusSmooth_withClient(client) {
|
|
2161
2355
|
const getter = client.getSyncStatus;
|
|
2162
|
-
const [status, setStatus] =
|
|
2356
|
+
const [status, setStatus] = _react.useState.call(void 0, getter);
|
|
2163
2357
|
const oldStatus = useLatest(getter());
|
|
2164
|
-
|
|
2358
|
+
_react.useEffect.call(void 0, () => {
|
|
2165
2359
|
let timeoutId;
|
|
2166
2360
|
const unsub = client.events.syncStatus.subscribe(() => {
|
|
2167
2361
|
const newStatus = getter();
|
|
@@ -2281,8 +2475,26 @@ var UpdateNotificationSettingsError = class extends Error {
|
|
|
2281
2475
|
}
|
|
2282
2476
|
};
|
|
2283
2477
|
|
|
2478
|
+
// src/use-signal.ts
|
|
2479
|
+
var identity2 = (value) => value;
|
|
2480
|
+
function useSignal(signal, selector, isEqual) {
|
|
2481
|
+
return useSyncExternalStoreWithSelector(
|
|
2482
|
+
signal.subscribe,
|
|
2483
|
+
signal.get,
|
|
2484
|
+
signal.get,
|
|
2485
|
+
_nullishCoalesce(selector, () => ( identity2)),
|
|
2486
|
+
isEqual
|
|
2487
|
+
);
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2284
2490
|
// src/room.tsx
|
|
2285
|
-
var
|
|
2491
|
+
var _client = require('@liveblocks/client');
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
|
|
2286
2498
|
|
|
2287
2499
|
|
|
2288
2500
|
|
|
@@ -2319,7 +2531,7 @@ function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
|
|
|
2319
2531
|
comment.scrollIntoView();
|
|
2320
2532
|
}
|
|
2321
2533
|
function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
2322
|
-
|
|
2534
|
+
_react.useEffect.call(void 0,
|
|
2323
2535
|
() => {
|
|
2324
2536
|
handleScrollToCommentOnLoad(shouldScrollOnLoad, state);
|
|
2325
2537
|
},
|
|
@@ -2329,24 +2541,10 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
|
2329
2541
|
}
|
|
2330
2542
|
|
|
2331
2543
|
// src/room.tsx
|
|
2544
|
+
|
|
2332
2545
|
var noop3 = () => {
|
|
2333
2546
|
};
|
|
2334
|
-
var
|
|
2335
|
-
var missing_unstable_batchedUpdates = (reactVersion, roomId) => `We noticed you\u2019re using React ${reactVersion}. Please pass unstable_batchedUpdates at the RoomProvider level until you\u2019re ready to upgrade to React 18:
|
|
2336
|
-
|
|
2337
|
-
import { unstable_batchedUpdates } from "react-dom"; // or "react-native"
|
|
2338
|
-
|
|
2339
|
-
<RoomProvider id=${JSON.stringify(
|
|
2340
|
-
roomId
|
|
2341
|
-
)} ... unstable_batchedUpdates={unstable_batchedUpdates}>
|
|
2342
|
-
...
|
|
2343
|
-
</RoomProvider>
|
|
2344
|
-
|
|
2345
|
-
Why? Please see https://liveblocks.io/docs/platform/troubleshooting#stale-props-zombie-child for more information`;
|
|
2346
|
-
var superfluous_unstable_batchedUpdates = "You don\u2019t need to pass unstable_batchedUpdates to RoomProvider anymore, since you\u2019re on React 18+ already.";
|
|
2347
|
-
function useSyncExternalStore2(s, gs, gss) {
|
|
2348
|
-
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity2);
|
|
2349
|
-
}
|
|
2547
|
+
var identity3 = (x) => x;
|
|
2350
2548
|
var STABLE_EMPTY_LIST = Object.freeze([]);
|
|
2351
2549
|
function alwaysEmptyList() {
|
|
2352
2550
|
return STABLE_EMPTY_LIST;
|
|
@@ -2387,7 +2585,7 @@ function makeMutationContext(room) {
|
|
|
2387
2585
|
};
|
|
2388
2586
|
}
|
|
2389
2587
|
function getCurrentUserId(client) {
|
|
2390
|
-
const userId = client[_core.kInternal].
|
|
2588
|
+
const userId = client[_core.kInternal].currentUserId.get();
|
|
2391
2589
|
if (userId === void 0) {
|
|
2392
2590
|
return "anonymous";
|
|
2393
2591
|
}
|
|
@@ -2422,8 +2620,8 @@ function getRoomExtrasForClient(client) {
|
|
|
2422
2620
|
function makeRoomExtrasForClient(client) {
|
|
2423
2621
|
const store = getUmbrellaStoreForClient(client);
|
|
2424
2622
|
const commentsErrorEventSource = _core.makeEventSource.call(void 0, );
|
|
2425
|
-
function onMutationFailure(innerError,
|
|
2426
|
-
store.
|
|
2623
|
+
function onMutationFailure(innerError, optimisticId, createPublicError) {
|
|
2624
|
+
store.optimisticUpdates.remove(optimisticId);
|
|
2427
2625
|
if (innerError instanceof _core.HttpError) {
|
|
2428
2626
|
const error = handleApiError(innerError);
|
|
2429
2627
|
commentsErrorEventSource.notify(createPublicError(error));
|
|
@@ -2506,7 +2704,7 @@ function makeRoomExtrasForClient(client) {
|
|
|
2506
2704
|
}
|
|
2507
2705
|
function makeRoomContextBundle(client) {
|
|
2508
2706
|
function RoomProvider_withImplicitLiveblocksProvider(props) {
|
|
2509
|
-
return /* @__PURE__ */
|
|
2707
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LiveblocksProviderWithClient, { client, allowNesting: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RoomProvider, { ...props }) });
|
|
2510
2708
|
}
|
|
2511
2709
|
const shared = createSharedContext(client);
|
|
2512
2710
|
const bundle = {
|
|
@@ -2610,10 +2808,10 @@ function makeRoomContextBundle(client) {
|
|
|
2610
2808
|
}
|
|
2611
2809
|
function RoomProvider(props) {
|
|
2612
2810
|
const client = useClient();
|
|
2613
|
-
const [cache] =
|
|
2811
|
+
const [cache] = _react.useState.call(void 0,
|
|
2614
2812
|
() => /* @__PURE__ */ new Map()
|
|
2615
2813
|
);
|
|
2616
|
-
const stableEnterRoom =
|
|
2814
|
+
const stableEnterRoom = _react.useCallback.call(void 0,
|
|
2617
2815
|
(roomId, options) => {
|
|
2618
2816
|
const cached = cache.get(roomId);
|
|
2619
2817
|
if (cached) return cached;
|
|
@@ -2628,7 +2826,7 @@ function RoomProvider(props) {
|
|
|
2628
2826
|
},
|
|
2629
2827
|
[client, cache]
|
|
2630
2828
|
);
|
|
2631
|
-
return /* @__PURE__ */
|
|
2829
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2632
2830
|
RoomProviderInner,
|
|
2633
2831
|
{
|
|
2634
2832
|
...props,
|
|
@@ -2648,31 +2846,26 @@ function RoomProviderInner(props) {
|
|
|
2648
2846
|
if (!isString(roomId)) {
|
|
2649
2847
|
throw new Error("RoomProvider id property should be a string.");
|
|
2650
2848
|
}
|
|
2651
|
-
const majorReactVersion = parseInt(
|
|
2652
|
-
const
|
|
2849
|
+
const majorReactVersion = parseInt(_react.version) || 1;
|
|
2850
|
+
const requiredVersion = 18;
|
|
2653
2851
|
_core.errorIf.call(void 0,
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
);
|
|
2657
|
-
_core.deprecateIf.call(void 0,
|
|
2658
|
-
!oldReactVersion && props.unstable_batchedUpdates !== void 0,
|
|
2659
|
-
superfluous_unstable_batchedUpdates
|
|
2852
|
+
majorReactVersion < requiredVersion,
|
|
2853
|
+
`React ${requiredVersion} or higher is required (you\u2019re on ${_react.version})`
|
|
2660
2854
|
);
|
|
2661
2855
|
}
|
|
2662
2856
|
const frozenProps = useInitial({
|
|
2663
2857
|
initialPresence: props.initialPresence,
|
|
2664
2858
|
initialStorage: props.initialStorage,
|
|
2665
|
-
unstable_batchedUpdates: props.unstable_batchedUpdates,
|
|
2666
2859
|
autoConnect: _nullishCoalesce(props.autoConnect, () => ( typeof window !== "undefined"))
|
|
2667
2860
|
});
|
|
2668
|
-
const [{ room }, setRoomLeavePair] =
|
|
2861
|
+
const [{ room }, setRoomLeavePair] = _react.useState.call(void 0,
|
|
2669
2862
|
() => stableEnterRoom(roomId, {
|
|
2670
2863
|
...frozenProps,
|
|
2671
2864
|
autoConnect: false
|
|
2672
2865
|
// Deliberately using false here on the first render, see below
|
|
2673
2866
|
})
|
|
2674
2867
|
);
|
|
2675
|
-
|
|
2868
|
+
_react.useEffect.call(void 0, () => {
|
|
2676
2869
|
const { store } = getRoomExtrasForClient(client);
|
|
2677
2870
|
async function handleCommentEvent(message) {
|
|
2678
2871
|
if (message.type === _core.ServerMsgCode.THREAD_DELETED) {
|
|
@@ -2684,8 +2877,8 @@ function RoomProviderInner(props) {
|
|
|
2684
2877
|
store.deleteThread(message.threadId, null);
|
|
2685
2878
|
return;
|
|
2686
2879
|
}
|
|
2687
|
-
const { thread, inboxNotification } = info;
|
|
2688
|
-
const existingThread = store.
|
|
2880
|
+
const { thread, inboxNotification: maybeNotification } = info;
|
|
2881
|
+
const existingThread = store.get1_threads().threadsDB.getEvenIfDeleted(message.threadId);
|
|
2689
2882
|
switch (message.type) {
|
|
2690
2883
|
case _core.ServerMsgCode.COMMENT_EDITED:
|
|
2691
2884
|
case _core.ServerMsgCode.THREAD_METADATA_UPDATED:
|
|
@@ -2694,10 +2887,16 @@ function RoomProviderInner(props) {
|
|
|
2694
2887
|
case _core.ServerMsgCode.COMMENT_REACTION_REMOVED:
|
|
2695
2888
|
case _core.ServerMsgCode.COMMENT_DELETED:
|
|
2696
2889
|
if (!existingThread) break;
|
|
2697
|
-
store.
|
|
2890
|
+
store.updateThreadifications(
|
|
2891
|
+
[thread],
|
|
2892
|
+
maybeNotification ? [maybeNotification] : []
|
|
2893
|
+
);
|
|
2698
2894
|
break;
|
|
2699
2895
|
case _core.ServerMsgCode.COMMENT_CREATED:
|
|
2700
|
-
store.
|
|
2896
|
+
store.updateThreadifications(
|
|
2897
|
+
[thread],
|
|
2898
|
+
maybeNotification ? [maybeNotification] : []
|
|
2899
|
+
);
|
|
2701
2900
|
break;
|
|
2702
2901
|
default:
|
|
2703
2902
|
break;
|
|
@@ -2707,7 +2906,7 @@ function RoomProviderInner(props) {
|
|
|
2707
2906
|
(message) => void handleCommentEvent(message)
|
|
2708
2907
|
);
|
|
2709
2908
|
}, [client, room]);
|
|
2710
|
-
|
|
2909
|
+
_react.useEffect.call(void 0, () => {
|
|
2711
2910
|
const pair = stableEnterRoom(roomId, frozenProps);
|
|
2712
2911
|
setRoomLeavePair(pair);
|
|
2713
2912
|
const { room: room2, leave } = pair;
|
|
@@ -2718,7 +2917,7 @@ function RoomProviderInner(props) {
|
|
|
2718
2917
|
leave();
|
|
2719
2918
|
};
|
|
2720
2919
|
}, [roomId, frozenProps, stableEnterRoom]);
|
|
2721
|
-
return /* @__PURE__ */
|
|
2920
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RoomContext.Provider, { value: room, children: props.children });
|
|
2722
2921
|
}
|
|
2723
2922
|
function useRoom() {
|
|
2724
2923
|
const room = useRoomOrNull();
|
|
@@ -2732,12 +2931,12 @@ function useStatus() {
|
|
|
2732
2931
|
const subscribe = room.events.status.subscribe;
|
|
2733
2932
|
const getSnapshot = room.getStatus;
|
|
2734
2933
|
const getServerSnapshot = room.getStatus;
|
|
2735
|
-
return
|
|
2934
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
|
|
2736
2935
|
}
|
|
2737
2936
|
function useReportTextEditor(editor, rootKey) {
|
|
2738
|
-
const isReported =
|
|
2937
|
+
const isReported = _react.useRef.call(void 0, false);
|
|
2739
2938
|
const room = useRoom();
|
|
2740
|
-
|
|
2939
|
+
_react.useEffect.call(void 0, () => {
|
|
2741
2940
|
if (isReported.current) {
|
|
2742
2941
|
return;
|
|
2743
2942
|
}
|
|
@@ -2750,6 +2949,52 @@ function useReportTextEditor(editor, rootKey) {
|
|
|
2750
2949
|
return unsubscribe;
|
|
2751
2950
|
}, [room, editor, rootKey]);
|
|
2752
2951
|
}
|
|
2952
|
+
function useYjsProvider() {
|
|
2953
|
+
const room = useRoom();
|
|
2954
|
+
const subscribe = _react.useCallback.call(void 0,
|
|
2955
|
+
(onStoreChange) => {
|
|
2956
|
+
return room[_core.kInternal].yjsProviderDidChange.subscribe(onStoreChange);
|
|
2957
|
+
},
|
|
2958
|
+
[room]
|
|
2959
|
+
);
|
|
2960
|
+
const getSnapshot = _react.useCallback.call(void 0, () => {
|
|
2961
|
+
return room[_core.kInternal].getYjsProvider();
|
|
2962
|
+
}, [room]);
|
|
2963
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
|
2964
|
+
}
|
|
2965
|
+
function useCreateTextMention() {
|
|
2966
|
+
const room = useRoom();
|
|
2967
|
+
return _react.useCallback.call(void 0,
|
|
2968
|
+
(userId, mentionId) => {
|
|
2969
|
+
room[_core.kInternal].createTextMention(userId, mentionId).catch((err) => {
|
|
2970
|
+
_core.console.error(
|
|
2971
|
+
`Cannot create text mention for user '${userId}' and mention '${mentionId}'`,
|
|
2972
|
+
err
|
|
2973
|
+
);
|
|
2974
|
+
});
|
|
2975
|
+
},
|
|
2976
|
+
[room]
|
|
2977
|
+
);
|
|
2978
|
+
}
|
|
2979
|
+
function useDeleteTextMention() {
|
|
2980
|
+
const room = useRoom();
|
|
2981
|
+
return _react.useCallback.call(void 0,
|
|
2982
|
+
(mentionId) => {
|
|
2983
|
+
room[_core.kInternal].deleteTextMention(mentionId).catch((err) => {
|
|
2984
|
+
_core.console.error(`Cannot delete text mention '${mentionId}'`, err);
|
|
2985
|
+
});
|
|
2986
|
+
},
|
|
2987
|
+
[room]
|
|
2988
|
+
);
|
|
2989
|
+
}
|
|
2990
|
+
function useResolveMentionSuggestions() {
|
|
2991
|
+
const client = useClient();
|
|
2992
|
+
return client[_core.kInternal].resolveMentionSuggestions;
|
|
2993
|
+
}
|
|
2994
|
+
function useMentionSuggestionsCache() {
|
|
2995
|
+
const client = useClient();
|
|
2996
|
+
return client[_core.kInternal].mentionSuggestionsCache;
|
|
2997
|
+
}
|
|
2753
2998
|
function useStorageStatus(options) {
|
|
2754
2999
|
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14.smooth]), () => ( false)));
|
|
2755
3000
|
if (smooth) {
|
|
@@ -2763,13 +3008,13 @@ function useStorageStatusImmediate() {
|
|
|
2763
3008
|
const subscribe = room.events.storageStatus.subscribe;
|
|
2764
3009
|
const getSnapshot = room.getStorageStatus;
|
|
2765
3010
|
const getServerSnapshot = room.getStorageStatus;
|
|
2766
|
-
return
|
|
3011
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
|
|
2767
3012
|
}
|
|
2768
3013
|
function useStorageStatusSmooth() {
|
|
2769
3014
|
const room = useRoom();
|
|
2770
|
-
const [status, setStatus] =
|
|
3015
|
+
const [status, setStatus] = _react.useState.call(void 0, room.getStorageStatus);
|
|
2771
3016
|
const oldStatus = useLatest(room.getStorageStatus());
|
|
2772
|
-
|
|
3017
|
+
_react.useEffect.call(void 0, () => {
|
|
2773
3018
|
let timeoutId;
|
|
2774
3019
|
const unsub = room.events.storageStatus.subscribe((newStatus) => {
|
|
2775
3020
|
if (oldStatus.current === "synchronizing" && newStatus === "synchronized") {
|
|
@@ -2791,7 +3036,7 @@ function useBatch() {
|
|
|
2791
3036
|
}
|
|
2792
3037
|
function useBroadcastEvent() {
|
|
2793
3038
|
const room = useRoom();
|
|
2794
|
-
return
|
|
3039
|
+
return _react.useCallback.call(void 0,
|
|
2795
3040
|
(event, options = { shouldQueueEventIfNotReady: false }) => {
|
|
2796
3041
|
room.broadcastEvent(event, options);
|
|
2797
3042
|
},
|
|
@@ -2801,7 +3046,7 @@ function useBroadcastEvent() {
|
|
|
2801
3046
|
function useOthersListener(callback) {
|
|
2802
3047
|
const room = useRoom();
|
|
2803
3048
|
const savedCallback = useLatest(callback);
|
|
2804
|
-
|
|
3049
|
+
_react.useEffect.call(void 0,
|
|
2805
3050
|
() => room.events.others.subscribe((event) => savedCallback.current(event)),
|
|
2806
3051
|
[room, savedCallback]
|
|
2807
3052
|
);
|
|
@@ -2809,7 +3054,7 @@ function useOthersListener(callback) {
|
|
|
2809
3054
|
function useLostConnectionListener(callback) {
|
|
2810
3055
|
const room = useRoom();
|
|
2811
3056
|
const savedCallback = useLatest(callback);
|
|
2812
|
-
|
|
3057
|
+
_react.useEffect.call(void 0,
|
|
2813
3058
|
() => room.events.lostConnection.subscribe(
|
|
2814
3059
|
(event) => savedCallback.current(event)
|
|
2815
3060
|
),
|
|
@@ -2819,7 +3064,7 @@ function useLostConnectionListener(callback) {
|
|
|
2819
3064
|
function useErrorListener(callback) {
|
|
2820
3065
|
const room = useRoom();
|
|
2821
3066
|
const savedCallback = useLatest(callback);
|
|
2822
|
-
|
|
3067
|
+
_react.useEffect.call(void 0,
|
|
2823
3068
|
() => room.events.error.subscribe((e) => savedCallback.current(e)),
|
|
2824
3069
|
[room, savedCallback]
|
|
2825
3070
|
);
|
|
@@ -2827,7 +3072,7 @@ function useErrorListener(callback) {
|
|
|
2827
3072
|
function useEventListener(callback) {
|
|
2828
3073
|
const room = useRoom();
|
|
2829
3074
|
const savedCallback = useLatest(callback);
|
|
2830
|
-
|
|
3075
|
+
_react.useEffect.call(void 0, () => {
|
|
2831
3076
|
const listener = (eventData) => {
|
|
2832
3077
|
savedCallback.current(eventData);
|
|
2833
3078
|
};
|
|
@@ -2847,25 +3092,25 @@ function useCanUndo() {
|
|
|
2847
3092
|
const room = useRoom();
|
|
2848
3093
|
const subscribe = room.events.history.subscribe;
|
|
2849
3094
|
const canUndo = room.history.canUndo;
|
|
2850
|
-
return
|
|
3095
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, canUndo, canUndo);
|
|
2851
3096
|
}
|
|
2852
3097
|
function useCanRedo() {
|
|
2853
3098
|
const room = useRoom();
|
|
2854
3099
|
const subscribe = room.events.history.subscribe;
|
|
2855
3100
|
const canRedo = room.history.canRedo;
|
|
2856
|
-
return
|
|
3101
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, canRedo, canRedo);
|
|
2857
3102
|
}
|
|
2858
3103
|
function useSelf(maybeSelector, isEqual) {
|
|
2859
3104
|
const room = useRoom();
|
|
2860
3105
|
const subscribe = room.events.self.subscribe;
|
|
2861
3106
|
const getSnapshot = room.getSelf;
|
|
2862
|
-
const selector = _nullishCoalesce(maybeSelector, () => (
|
|
2863
|
-
const wrappedSelector =
|
|
3107
|
+
const selector = _nullishCoalesce(maybeSelector, () => ( identity3));
|
|
3108
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2864
3109
|
(me) => me !== null ? selector(me) : null,
|
|
2865
3110
|
[selector]
|
|
2866
3111
|
);
|
|
2867
3112
|
const getServerSnapshot = alwaysNull;
|
|
2868
|
-
return
|
|
3113
|
+
return useSyncExternalStoreWithSelector(
|
|
2869
3114
|
subscribe,
|
|
2870
3115
|
getSnapshot,
|
|
2871
3116
|
getServerSnapshot,
|
|
@@ -2877,7 +3122,7 @@ function useMyPresence() {
|
|
|
2877
3122
|
const room = useRoom();
|
|
2878
3123
|
const subscribe = room.events.myPresence.subscribe;
|
|
2879
3124
|
const getSnapshot = room.getPresence;
|
|
2880
|
-
const presence =
|
|
3125
|
+
const presence = _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
|
2881
3126
|
const setPresence = room.updatePresence;
|
|
2882
3127
|
return [presence, setPresence];
|
|
2883
3128
|
}
|
|
@@ -2889,20 +3134,20 @@ function useOthers(selector, isEqual) {
|
|
|
2889
3134
|
const subscribe = room.events.others.subscribe;
|
|
2890
3135
|
const getSnapshot = room.getOthers;
|
|
2891
3136
|
const getServerSnapshot = alwaysEmptyList;
|
|
2892
|
-
return
|
|
3137
|
+
return useSyncExternalStoreWithSelector(
|
|
2893
3138
|
subscribe,
|
|
2894
3139
|
getSnapshot,
|
|
2895
3140
|
getServerSnapshot,
|
|
2896
|
-
_nullishCoalesce(selector, () => (
|
|
3141
|
+
_nullishCoalesce(selector, () => ( identity3)),
|
|
2897
3142
|
isEqual
|
|
2898
3143
|
);
|
|
2899
3144
|
}
|
|
2900
3145
|
function useOthersMapped(itemSelector, itemIsEqual) {
|
|
2901
|
-
const wrappedSelector =
|
|
3146
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2902
3147
|
(others) => others.map((other) => [other.connectionId, itemSelector(other)]),
|
|
2903
3148
|
[itemSelector]
|
|
2904
3149
|
);
|
|
2905
|
-
const wrappedIsEqual =
|
|
3150
|
+
const wrappedIsEqual = _react.useCallback.call(void 0,
|
|
2906
3151
|
(a, b) => {
|
|
2907
3152
|
const eq = _nullishCoalesce(itemIsEqual, () => ( Object.is));
|
|
2908
3153
|
return a.length === b.length && a.every((atuple, index) => {
|
|
@@ -2915,18 +3160,18 @@ function useOthersMapped(itemSelector, itemIsEqual) {
|
|
|
2915
3160
|
return useOthers(wrappedSelector, wrappedIsEqual);
|
|
2916
3161
|
}
|
|
2917
3162
|
function useOthersConnectionIds() {
|
|
2918
|
-
return useOthers(selectorFor_useOthersConnectionIds,
|
|
3163
|
+
return useOthers(selectorFor_useOthersConnectionIds, _client.shallow);
|
|
2919
3164
|
}
|
|
2920
3165
|
var NOT_FOUND = Symbol();
|
|
2921
3166
|
function useOther(connectionId, selector, isEqual) {
|
|
2922
|
-
const wrappedSelector =
|
|
3167
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2923
3168
|
(others) => {
|
|
2924
3169
|
const other2 = others.find((other3) => other3.connectionId === connectionId);
|
|
2925
3170
|
return other2 !== void 0 ? selector(other2) : NOT_FOUND;
|
|
2926
3171
|
},
|
|
2927
3172
|
[connectionId, selector]
|
|
2928
3173
|
);
|
|
2929
|
-
const wrappedIsEqual =
|
|
3174
|
+
const wrappedIsEqual = _react.useCallback.call(void 0,
|
|
2930
3175
|
(prev, curr) => {
|
|
2931
3176
|
if (prev === NOT_FOUND || curr === NOT_FOUND) {
|
|
2932
3177
|
return prev === curr;
|
|
@@ -2949,7 +3194,7 @@ function useMutableStorageRoot() {
|
|
|
2949
3194
|
const subscribe = room.events.storageDidLoad.subscribeOnce;
|
|
2950
3195
|
const getSnapshot = room.getStorageSnapshot;
|
|
2951
3196
|
const getServerSnapshot = alwaysNull;
|
|
2952
|
-
return
|
|
3197
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
|
|
2953
3198
|
}
|
|
2954
3199
|
function useStorageRoot() {
|
|
2955
3200
|
return [useMutableStorageRoot()];
|
|
@@ -2957,15 +3202,15 @@ function useStorageRoot() {
|
|
|
2957
3202
|
function useStorage(selector, isEqual) {
|
|
2958
3203
|
const room = useRoom();
|
|
2959
3204
|
const rootOrNull = useMutableStorageRoot();
|
|
2960
|
-
const wrappedSelector =
|
|
3205
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2961
3206
|
(rootOrNull2) => rootOrNull2 !== null ? selector(rootOrNull2) : null,
|
|
2962
3207
|
[selector]
|
|
2963
3208
|
);
|
|
2964
|
-
const subscribe =
|
|
3209
|
+
const subscribe = _react.useCallback.call(void 0,
|
|
2965
3210
|
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop3,
|
|
2966
3211
|
[room, rootOrNull]
|
|
2967
3212
|
);
|
|
2968
|
-
const getSnapshot =
|
|
3213
|
+
const getSnapshot = _react.useCallback.call(void 0, () => {
|
|
2969
3214
|
if (rootOrNull === null) {
|
|
2970
3215
|
return null;
|
|
2971
3216
|
} else {
|
|
@@ -2975,7 +3220,7 @@ function useStorage(selector, isEqual) {
|
|
|
2975
3220
|
}
|
|
2976
3221
|
}, [rootOrNull]);
|
|
2977
3222
|
const getServerSnapshot = alwaysNull;
|
|
2978
|
-
return
|
|
3223
|
+
return useSyncExternalStoreWithSelector(
|
|
2979
3224
|
subscribe,
|
|
2980
3225
|
getSnapshot,
|
|
2981
3226
|
getServerSnapshot,
|
|
@@ -2985,7 +3230,7 @@ function useStorage(selector, isEqual) {
|
|
|
2985
3230
|
}
|
|
2986
3231
|
function useMutation(callback, deps) {
|
|
2987
3232
|
const room = useRoom();
|
|
2988
|
-
return
|
|
3233
|
+
return _react.useMemo.call(void 0,
|
|
2989
3234
|
() => {
|
|
2990
3235
|
return (...args) => (
|
|
2991
3236
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -3012,7 +3257,7 @@ function useThreads(options = {
|
|
|
3012
3257
|
const room = useRoom();
|
|
3013
3258
|
const { store, getOrCreateThreadsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3014
3259
|
const poller = getOrCreateThreadsPollerForRoomId(room.id);
|
|
3015
|
-
|
|
3260
|
+
_react.useEffect.call(void 0,
|
|
3016
3261
|
() => {
|
|
3017
3262
|
void store.waitUntilRoomThreadsLoaded(room.id, options.query);
|
|
3018
3263
|
}
|
|
@@ -3025,20 +3270,20 @@ function useThreads(options = {
|
|
|
3025
3270
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3026
3271
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3027
3272
|
);
|
|
3028
|
-
|
|
3273
|
+
_react.useEffect.call(void 0, () => {
|
|
3029
3274
|
poller.inc();
|
|
3030
3275
|
poller.pollNowIfStale();
|
|
3031
3276
|
return () => poller.dec();
|
|
3032
3277
|
}, [poller]);
|
|
3033
|
-
const getter =
|
|
3278
|
+
const getter = _react.useCallback.call(void 0,
|
|
3034
3279
|
() => store.getRoomThreadsLoadingState(room.id, options.query),
|
|
3035
3280
|
[store, room.id, options.query]
|
|
3036
3281
|
);
|
|
3037
|
-
const state =
|
|
3038
|
-
store.
|
|
3282
|
+
const state = useSyncExternalStoreWithSelector(
|
|
3283
|
+
store.subscribe1_threads,
|
|
3039
3284
|
getter,
|
|
3040
3285
|
getter,
|
|
3041
|
-
|
|
3286
|
+
identity3,
|
|
3042
3287
|
shallow2
|
|
3043
3288
|
// NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
|
|
3044
3289
|
);
|
|
@@ -3049,7 +3294,7 @@ function useCommentsErrorListener(callback) {
|
|
|
3049
3294
|
const client = useClient();
|
|
3050
3295
|
const savedCallback = useLatest(callback);
|
|
3051
3296
|
const { commentsErrorEventSource } = getRoomExtrasForClient(client);
|
|
3052
|
-
|
|
3297
|
+
_react.useEffect.call(void 0, () => {
|
|
3053
3298
|
return commentsErrorEventSource.subscribe(savedCallback.current);
|
|
3054
3299
|
}, [savedCallback, commentsErrorEventSource]);
|
|
3055
3300
|
}
|
|
@@ -3058,7 +3303,7 @@ function useCreateThread() {
|
|
|
3058
3303
|
}
|
|
3059
3304
|
function useCreateRoomThread(roomId) {
|
|
3060
3305
|
const client = useClient();
|
|
3061
|
-
return
|
|
3306
|
+
return _react.useCallback.call(void 0,
|
|
3062
3307
|
(options) => {
|
|
3063
3308
|
const body = options.body;
|
|
3064
3309
|
const metadata = _nullishCoalesce(options.metadata, () => ( {}));
|
|
@@ -3088,7 +3333,7 @@ function useCreateRoomThread(roomId) {
|
|
|
3088
3333
|
resolved: false
|
|
3089
3334
|
};
|
|
3090
3335
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3091
|
-
const
|
|
3336
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3092
3337
|
type: "create-thread",
|
|
3093
3338
|
thread: newThread,
|
|
3094
3339
|
roomId
|
|
@@ -3103,11 +3348,11 @@ function useCreateRoomThread(roomId) {
|
|
|
3103
3348
|
attachmentIds
|
|
3104
3349
|
}).then(
|
|
3105
3350
|
(thread) => {
|
|
3106
|
-
store.createThread(
|
|
3351
|
+
store.createThread(optimisticId, thread);
|
|
3107
3352
|
},
|
|
3108
3353
|
(err) => onMutationFailure(
|
|
3109
3354
|
err,
|
|
3110
|
-
|
|
3355
|
+
optimisticId,
|
|
3111
3356
|
(err2) => new CreateThreadError(err2, {
|
|
3112
3357
|
roomId,
|
|
3113
3358
|
threadId,
|
|
@@ -3127,15 +3372,15 @@ function useDeleteThread() {
|
|
|
3127
3372
|
}
|
|
3128
3373
|
function useDeleteRoomThread(roomId) {
|
|
3129
3374
|
const client = useClient();
|
|
3130
|
-
return
|
|
3375
|
+
return _react.useCallback.call(void 0,
|
|
3131
3376
|
(threadId) => {
|
|
3132
3377
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3133
3378
|
const userId = getCurrentUserId(client);
|
|
3134
|
-
const existing = store.
|
|
3379
|
+
const existing = store.get1_threads().threadsDB.get(threadId);
|
|
3135
3380
|
if (_optionalChain([existing, 'optionalAccess', _17 => _17.comments, 'optionalAccess', _18 => _18[0], 'optionalAccess', _19 => _19.userId]) !== userId) {
|
|
3136
3381
|
throw new Error("Only the thread creator can delete the thread");
|
|
3137
3382
|
}
|
|
3138
|
-
const
|
|
3383
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3139
3384
|
type: "delete-thread",
|
|
3140
3385
|
roomId,
|
|
3141
3386
|
threadId,
|
|
@@ -3143,11 +3388,11 @@ function useDeleteRoomThread(roomId) {
|
|
|
3143
3388
|
});
|
|
3144
3389
|
client[_core.kInternal].httpClient.deleteThread({ roomId, threadId }).then(
|
|
3145
3390
|
() => {
|
|
3146
|
-
store.deleteThread(threadId,
|
|
3391
|
+
store.deleteThread(threadId, optimisticId);
|
|
3147
3392
|
},
|
|
3148
3393
|
(err) => onMutationFailure(
|
|
3149
3394
|
err,
|
|
3150
|
-
|
|
3395
|
+
optimisticId,
|
|
3151
3396
|
(err2) => new DeleteThreadError(err2, { roomId, threadId })
|
|
3152
3397
|
)
|
|
3153
3398
|
);
|
|
@@ -3160,7 +3405,7 @@ function useEditThreadMetadata() {
|
|
|
3160
3405
|
}
|
|
3161
3406
|
function useEditRoomThreadMetadata(roomId) {
|
|
3162
3407
|
const client = useClient();
|
|
3163
|
-
return
|
|
3408
|
+
return _react.useCallback.call(void 0,
|
|
3164
3409
|
(options) => {
|
|
3165
3410
|
if (!options.metadata) {
|
|
3166
3411
|
return;
|
|
@@ -3169,7 +3414,7 @@ function useEditRoomThreadMetadata(roomId) {
|
|
|
3169
3414
|
const metadata = options.metadata;
|
|
3170
3415
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3171
3416
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3172
|
-
const
|
|
3417
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3173
3418
|
type: "edit-thread-metadata",
|
|
3174
3419
|
metadata,
|
|
3175
3420
|
threadId,
|
|
@@ -3178,16 +3423,11 @@ function useEditRoomThreadMetadata(roomId) {
|
|
|
3178
3423
|
client[_core.kInternal].httpClient.editThreadMetadata({ roomId, threadId, metadata }).then(
|
|
3179
3424
|
(metadata2) => (
|
|
3180
3425
|
// Replace the optimistic update by the real thing
|
|
3181
|
-
store.patchThread(
|
|
3182
|
-
threadId,
|
|
3183
|
-
optimisticUpdateId,
|
|
3184
|
-
{ metadata: metadata2 },
|
|
3185
|
-
updatedAt
|
|
3186
|
-
)
|
|
3426
|
+
store.patchThread(threadId, optimisticId, { metadata: metadata2 }, updatedAt)
|
|
3187
3427
|
),
|
|
3188
3428
|
(err) => onMutationFailure(
|
|
3189
3429
|
err,
|
|
3190
|
-
|
|
3430
|
+
optimisticId,
|
|
3191
3431
|
(error) => new EditThreadMetadataError(error, {
|
|
3192
3432
|
roomId,
|
|
3193
3433
|
threadId,
|
|
@@ -3204,7 +3444,7 @@ function useCreateComment() {
|
|
|
3204
3444
|
}
|
|
3205
3445
|
function useCreateRoomComment(roomId) {
|
|
3206
3446
|
const client = useClient();
|
|
3207
|
-
return
|
|
3447
|
+
return _react.useCallback.call(void 0,
|
|
3208
3448
|
({ threadId, body, attachments }) => {
|
|
3209
3449
|
const commentId = _core.createCommentId.call(void 0, );
|
|
3210
3450
|
const createdAt = /* @__PURE__ */ new Date();
|
|
@@ -3220,18 +3460,18 @@ function useCreateRoomComment(roomId) {
|
|
|
3220
3460
|
attachments: _nullishCoalesce(attachments, () => ( []))
|
|
3221
3461
|
};
|
|
3222
3462
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3223
|
-
const
|
|
3463
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3224
3464
|
type: "create-comment",
|
|
3225
3465
|
comment
|
|
3226
3466
|
});
|
|
3227
3467
|
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _20 => _20.map, 'call', _21 => _21((attachment) => attachment.id)]);
|
|
3228
3468
|
client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3229
3469
|
(newComment) => {
|
|
3230
|
-
store.createComment(newComment,
|
|
3470
|
+
store.createComment(newComment, optimisticId);
|
|
3231
3471
|
},
|
|
3232
3472
|
(err) => onMutationFailure(
|
|
3233
3473
|
err,
|
|
3234
|
-
|
|
3474
|
+
optimisticId,
|
|
3235
3475
|
(err2) => new CreateCommentError(err2, {
|
|
3236
3476
|
roomId,
|
|
3237
3477
|
threadId,
|
|
@@ -3250,11 +3490,11 @@ function useEditComment() {
|
|
|
3250
3490
|
}
|
|
3251
3491
|
function useEditRoomComment(roomId) {
|
|
3252
3492
|
const client = useClient();
|
|
3253
|
-
return
|
|
3493
|
+
return _react.useCallback.call(void 0,
|
|
3254
3494
|
({ threadId, commentId, body, attachments }) => {
|
|
3255
3495
|
const editedAt = /* @__PURE__ */ new Date();
|
|
3256
3496
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3257
|
-
const existing = store.
|
|
3497
|
+
const existing = store.get1_threads().threadsDB.getEvenIfDeleted(threadId);
|
|
3258
3498
|
if (existing === void 0) {
|
|
3259
3499
|
_core.console.warn(
|
|
3260
3500
|
`Internal unexpected behavior. Cannot edit comment in thread "${threadId}" because the thread does not exist in the cache.`
|
|
@@ -3270,7 +3510,7 @@ function useEditRoomComment(roomId) {
|
|
|
3270
3510
|
);
|
|
3271
3511
|
return;
|
|
3272
3512
|
}
|
|
3273
|
-
const
|
|
3513
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3274
3514
|
type: "edit-comment",
|
|
3275
3515
|
comment: {
|
|
3276
3516
|
...comment,
|
|
@@ -3282,11 +3522,11 @@ function useEditRoomComment(roomId) {
|
|
|
3282
3522
|
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _22 => _22.map, 'call', _23 => _23((attachment) => attachment.id)]);
|
|
3283
3523
|
client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3284
3524
|
(editedComment) => {
|
|
3285
|
-
store.editComment(threadId,
|
|
3525
|
+
store.editComment(threadId, optimisticId, editedComment);
|
|
3286
3526
|
},
|
|
3287
3527
|
(err) => onMutationFailure(
|
|
3288
3528
|
err,
|
|
3289
|
-
|
|
3529
|
+
optimisticId,
|
|
3290
3530
|
(error) => new EditCommentError(error, {
|
|
3291
3531
|
roomId,
|
|
3292
3532
|
threadId,
|
|
@@ -3304,11 +3544,11 @@ function useDeleteComment() {
|
|
|
3304
3544
|
}
|
|
3305
3545
|
function useDeleteRoomComment(roomId) {
|
|
3306
3546
|
const client = useClient();
|
|
3307
|
-
return
|
|
3547
|
+
return _react.useCallback.call(void 0,
|
|
3308
3548
|
({ threadId, commentId }) => {
|
|
3309
3549
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
3310
3550
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3311
|
-
const
|
|
3551
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3312
3552
|
type: "delete-comment",
|
|
3313
3553
|
threadId,
|
|
3314
3554
|
commentId,
|
|
@@ -3317,16 +3557,11 @@ function useDeleteRoomComment(roomId) {
|
|
|
3317
3557
|
});
|
|
3318
3558
|
client[_core.kInternal].httpClient.deleteComment({ roomId, threadId, commentId }).then(
|
|
3319
3559
|
() => {
|
|
3320
|
-
store.deleteComment(
|
|
3321
|
-
threadId,
|
|
3322
|
-
optimisticUpdateId,
|
|
3323
|
-
commentId,
|
|
3324
|
-
deletedAt
|
|
3325
|
-
);
|
|
3560
|
+
store.deleteComment(threadId, optimisticId, commentId, deletedAt);
|
|
3326
3561
|
},
|
|
3327
3562
|
(err) => onMutationFailure(
|
|
3328
3563
|
err,
|
|
3329
|
-
|
|
3564
|
+
optimisticId,
|
|
3330
3565
|
(error) => new DeleteCommentError(error, {
|
|
3331
3566
|
roomId,
|
|
3332
3567
|
threadId,
|
|
@@ -3343,12 +3578,12 @@ function useAddReaction() {
|
|
|
3343
3578
|
}
|
|
3344
3579
|
function useAddRoomCommentReaction(roomId) {
|
|
3345
3580
|
const client = useClient();
|
|
3346
|
-
return
|
|
3581
|
+
return _react.useCallback.call(void 0,
|
|
3347
3582
|
({ threadId, commentId, emoji }) => {
|
|
3348
3583
|
const createdAt = /* @__PURE__ */ new Date();
|
|
3349
3584
|
const userId = getCurrentUserId(client);
|
|
3350
3585
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3351
|
-
const
|
|
3586
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3352
3587
|
type: "add-reaction",
|
|
3353
3588
|
threadId,
|
|
3354
3589
|
commentId,
|
|
@@ -3362,7 +3597,7 @@ function useAddRoomCommentReaction(roomId) {
|
|
|
3362
3597
|
(addedReaction) => {
|
|
3363
3598
|
store.addReaction(
|
|
3364
3599
|
threadId,
|
|
3365
|
-
|
|
3600
|
+
optimisticId,
|
|
3366
3601
|
commentId,
|
|
3367
3602
|
addedReaction,
|
|
3368
3603
|
createdAt
|
|
@@ -3370,7 +3605,7 @@ function useAddRoomCommentReaction(roomId) {
|
|
|
3370
3605
|
},
|
|
3371
3606
|
(err) => onMutationFailure(
|
|
3372
3607
|
err,
|
|
3373
|
-
|
|
3608
|
+
optimisticId,
|
|
3374
3609
|
(error) => new AddReactionError(error, {
|
|
3375
3610
|
roomId,
|
|
3376
3611
|
threadId,
|
|
@@ -3388,12 +3623,12 @@ function useRemoveReaction() {
|
|
|
3388
3623
|
}
|
|
3389
3624
|
function useRemoveRoomCommentReaction(roomId) {
|
|
3390
3625
|
const client = useClient();
|
|
3391
|
-
return
|
|
3626
|
+
return _react.useCallback.call(void 0,
|
|
3392
3627
|
({ threadId, commentId, emoji }) => {
|
|
3393
3628
|
const userId = getCurrentUserId(client);
|
|
3394
3629
|
const removedAt = /* @__PURE__ */ new Date();
|
|
3395
3630
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3396
|
-
const
|
|
3631
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3397
3632
|
type: "remove-reaction",
|
|
3398
3633
|
threadId,
|
|
3399
3634
|
commentId,
|
|
@@ -3405,7 +3640,7 @@ function useRemoveRoomCommentReaction(roomId) {
|
|
|
3405
3640
|
() => {
|
|
3406
3641
|
store.removeReaction(
|
|
3407
3642
|
threadId,
|
|
3408
|
-
|
|
3643
|
+
optimisticId,
|
|
3409
3644
|
commentId,
|
|
3410
3645
|
emoji,
|
|
3411
3646
|
userId,
|
|
@@ -3414,7 +3649,7 @@ function useRemoveRoomCommentReaction(roomId) {
|
|
|
3414
3649
|
},
|
|
3415
3650
|
(err) => onMutationFailure(
|
|
3416
3651
|
err,
|
|
3417
|
-
|
|
3652
|
+
optimisticId,
|
|
3418
3653
|
(error) => new RemoveReactionError(error, {
|
|
3419
3654
|
roomId,
|
|
3420
3655
|
threadId,
|
|
@@ -3432,17 +3667,17 @@ function useMarkThreadAsRead() {
|
|
|
3432
3667
|
}
|
|
3433
3668
|
function useMarkRoomThreadAsRead(roomId) {
|
|
3434
3669
|
const client = useClient();
|
|
3435
|
-
return
|
|
3670
|
+
return _react.useCallback.call(void 0,
|
|
3436
3671
|
(threadId) => {
|
|
3437
3672
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3438
3673
|
const inboxNotification = Object.values(
|
|
3439
|
-
store.
|
|
3674
|
+
store.get1_notifications().notificationsById
|
|
3440
3675
|
).find(
|
|
3441
3676
|
(inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
|
|
3442
3677
|
);
|
|
3443
3678
|
if (!inboxNotification) return;
|
|
3444
3679
|
const now = /* @__PURE__ */ new Date();
|
|
3445
|
-
const
|
|
3680
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3446
3681
|
type: "mark-inbox-notification-as-read",
|
|
3447
3682
|
inboxNotificationId: inboxNotification.id,
|
|
3448
3683
|
readAt: now
|
|
@@ -3452,16 +3687,16 @@ function useMarkRoomThreadAsRead(roomId) {
|
|
|
3452
3687
|
inboxNotificationId: inboxNotification.id
|
|
3453
3688
|
}).then(
|
|
3454
3689
|
() => {
|
|
3455
|
-
store.
|
|
3690
|
+
store.markInboxNotificationRead(
|
|
3456
3691
|
inboxNotification.id,
|
|
3457
|
-
|
|
3458
|
-
|
|
3692
|
+
now,
|
|
3693
|
+
optimisticId
|
|
3459
3694
|
);
|
|
3460
3695
|
},
|
|
3461
3696
|
(err) => {
|
|
3462
3697
|
onMutationFailure(
|
|
3463
3698
|
err,
|
|
3464
|
-
|
|
3699
|
+
optimisticId,
|
|
3465
3700
|
(error) => new MarkInboxNotificationAsReadError(error, {
|
|
3466
3701
|
inboxNotificationId: inboxNotification.id
|
|
3467
3702
|
})
|
|
@@ -3478,11 +3713,11 @@ function useMarkThreadAsResolved() {
|
|
|
3478
3713
|
}
|
|
3479
3714
|
function useMarkRoomThreadAsResolved(roomId) {
|
|
3480
3715
|
const client = useClient();
|
|
3481
|
-
return
|
|
3716
|
+
return _react.useCallback.call(void 0,
|
|
3482
3717
|
(threadId) => {
|
|
3483
3718
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3484
3719
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3485
|
-
const
|
|
3720
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3486
3721
|
type: "mark-thread-as-resolved",
|
|
3487
3722
|
threadId,
|
|
3488
3723
|
updatedAt
|
|
@@ -3491,14 +3726,14 @@ function useMarkRoomThreadAsResolved(roomId) {
|
|
|
3491
3726
|
() => {
|
|
3492
3727
|
store.patchThread(
|
|
3493
3728
|
threadId,
|
|
3494
|
-
|
|
3729
|
+
optimisticId,
|
|
3495
3730
|
{ resolved: true },
|
|
3496
3731
|
updatedAt
|
|
3497
3732
|
);
|
|
3498
3733
|
},
|
|
3499
3734
|
(err) => onMutationFailure(
|
|
3500
3735
|
err,
|
|
3501
|
-
|
|
3736
|
+
optimisticId,
|
|
3502
3737
|
(error) => new MarkThreadAsResolvedError(error, {
|
|
3503
3738
|
roomId,
|
|
3504
3739
|
threadId
|
|
@@ -3514,11 +3749,11 @@ function useMarkThreadAsUnresolved() {
|
|
|
3514
3749
|
}
|
|
3515
3750
|
function useMarkRoomThreadAsUnresolved(roomId) {
|
|
3516
3751
|
const client = useClient();
|
|
3517
|
-
return
|
|
3752
|
+
return _react.useCallback.call(void 0,
|
|
3518
3753
|
(threadId) => {
|
|
3519
3754
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3520
3755
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3521
|
-
const
|
|
3756
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3522
3757
|
type: "mark-thread-as-unresolved",
|
|
3523
3758
|
threadId,
|
|
3524
3759
|
updatedAt
|
|
@@ -3527,14 +3762,14 @@ function useMarkRoomThreadAsUnresolved(roomId) {
|
|
|
3527
3762
|
() => {
|
|
3528
3763
|
store.patchThread(
|
|
3529
3764
|
threadId,
|
|
3530
|
-
|
|
3765
|
+
optimisticId,
|
|
3531
3766
|
{ resolved: false },
|
|
3532
3767
|
updatedAt
|
|
3533
3768
|
);
|
|
3534
3769
|
},
|
|
3535
3770
|
(err) => onMutationFailure(
|
|
3536
3771
|
err,
|
|
3537
|
-
|
|
3772
|
+
optimisticId,
|
|
3538
3773
|
(error) => new MarkThreadAsUnresolvedError(error, {
|
|
3539
3774
|
roomId,
|
|
3540
3775
|
threadId
|
|
@@ -3548,9 +3783,10 @@ function useMarkRoomThreadAsUnresolved(roomId) {
|
|
|
3548
3783
|
function useThreadSubscription(threadId) {
|
|
3549
3784
|
const client = useClient();
|
|
3550
3785
|
const { store } = getRoomExtrasForClient(client);
|
|
3551
|
-
const
|
|
3786
|
+
const signal = store.outputs.threadifications;
|
|
3787
|
+
const selector = _react.useCallback.call(void 0,
|
|
3552
3788
|
(state) => {
|
|
3553
|
-
const notification = state.
|
|
3789
|
+
const notification = state.sortedNotifications.find(
|
|
3554
3790
|
(inboxNotification) => inboxNotification.kind === "thread" && inboxNotification.threadId === threadId
|
|
3555
3791
|
);
|
|
3556
3792
|
const thread = state.threadsDB.get(threadId);
|
|
@@ -3564,12 +3800,7 @@ function useThreadSubscription(threadId) {
|
|
|
3564
3800
|
},
|
|
3565
3801
|
[threadId]
|
|
3566
3802
|
);
|
|
3567
|
-
return
|
|
3568
|
-
store.subscribe,
|
|
3569
|
-
store.getFullState,
|
|
3570
|
-
store.getFullState,
|
|
3571
|
-
selector
|
|
3572
|
-
);
|
|
3803
|
+
return useSignal(signal, selector, _client.shallow);
|
|
3573
3804
|
}
|
|
3574
3805
|
function useRoomNotificationSettings() {
|
|
3575
3806
|
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
@@ -3577,7 +3808,7 @@ function useRoomNotificationSettings() {
|
|
|
3577
3808
|
const room = useRoom();
|
|
3578
3809
|
const { store, getOrCreateNotificationsSettingsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3579
3810
|
const poller = getOrCreateNotificationsSettingsPollerForRoomId(room.id);
|
|
3580
|
-
|
|
3811
|
+
_react.useEffect.call(void 0,
|
|
3581
3812
|
() => {
|
|
3582
3813
|
void store.waitUntilRoomNotificationSettingsLoaded(room.id);
|
|
3583
3814
|
}
|
|
@@ -3590,25 +3821,25 @@ function useRoomNotificationSettings() {
|
|
|
3590
3821
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3591
3822
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3592
3823
|
);
|
|
3593
|
-
|
|
3824
|
+
_react.useEffect.call(void 0, () => {
|
|
3594
3825
|
poller.inc();
|
|
3595
3826
|
poller.pollNowIfStale();
|
|
3596
3827
|
return () => {
|
|
3597
3828
|
poller.dec();
|
|
3598
3829
|
};
|
|
3599
3830
|
}, [poller]);
|
|
3600
|
-
const getter =
|
|
3831
|
+
const getter = _react.useCallback.call(void 0,
|
|
3601
3832
|
() => store.getNotificationSettingsLoadingState(room.id),
|
|
3602
3833
|
[store, room.id]
|
|
3603
3834
|
);
|
|
3604
|
-
const settings =
|
|
3605
|
-
store.
|
|
3835
|
+
const settings = useSyncExternalStoreWithSelector(
|
|
3836
|
+
store.subscribe2,
|
|
3606
3837
|
getter,
|
|
3607
3838
|
getter,
|
|
3608
|
-
|
|
3839
|
+
identity3,
|
|
3609
3840
|
shallow2
|
|
3610
3841
|
);
|
|
3611
|
-
return
|
|
3842
|
+
return _react.useMemo.call(void 0, () => {
|
|
3612
3843
|
return [settings, updateRoomNotificationSettings];
|
|
3613
3844
|
}, [settings, updateRoomNotificationSettings]);
|
|
3614
3845
|
}
|
|
@@ -3620,16 +3851,16 @@ function useRoomNotificationSettingsSuspense() {
|
|
|
3620
3851
|
const [settings, updateRoomNotificationSettings] = useRoomNotificationSettings();
|
|
3621
3852
|
_core.assert.call(void 0, !settings.error, "Did not expect error");
|
|
3622
3853
|
_core.assert.call(void 0, !settings.isLoading, "Did not expect loading");
|
|
3623
|
-
return
|
|
3854
|
+
return _react.useMemo.call(void 0, () => {
|
|
3624
3855
|
return [settings, updateRoomNotificationSettings];
|
|
3625
3856
|
}, [settings, updateRoomNotificationSettings]);
|
|
3626
3857
|
}
|
|
3627
3858
|
function useHistoryVersionData(versionId) {
|
|
3628
|
-
const [state, setState] =
|
|
3859
|
+
const [state, setState] = _react.useState.call(void 0, {
|
|
3629
3860
|
isLoading: true
|
|
3630
3861
|
});
|
|
3631
3862
|
const room = useRoom();
|
|
3632
|
-
|
|
3863
|
+
_react.useEffect.call(void 0, () => {
|
|
3633
3864
|
setState({ isLoading: true });
|
|
3634
3865
|
const load = async () => {
|
|
3635
3866
|
try {
|
|
@@ -3658,16 +3889,16 @@ function useHistoryVersions() {
|
|
|
3658
3889
|
const room = useRoom();
|
|
3659
3890
|
const { store, getOrCreateVersionsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3660
3891
|
const poller = getOrCreateVersionsPollerForRoomId(room.id);
|
|
3661
|
-
|
|
3892
|
+
_react.useEffect.call(void 0, () => {
|
|
3662
3893
|
poller.inc();
|
|
3663
3894
|
poller.pollNowIfStale();
|
|
3664
3895
|
return () => poller.dec();
|
|
3665
3896
|
}, [poller]);
|
|
3666
|
-
const getter =
|
|
3897
|
+
const getter = _react.useCallback.call(void 0,
|
|
3667
3898
|
() => store.getRoomVersionsLoadingState(room.id),
|
|
3668
3899
|
[store, room.id]
|
|
3669
3900
|
);
|
|
3670
|
-
|
|
3901
|
+
_react.useEffect.call(void 0,
|
|
3671
3902
|
() => {
|
|
3672
3903
|
void store.waitUntilRoomVersionsLoaded(room.id);
|
|
3673
3904
|
}
|
|
@@ -3680,11 +3911,11 @@ function useHistoryVersions() {
|
|
|
3680
3911
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3681
3912
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3682
3913
|
);
|
|
3683
|
-
const state =
|
|
3684
|
-
store.
|
|
3914
|
+
const state = useSyncExternalStoreWithSelector(
|
|
3915
|
+
store.subscribe3,
|
|
3685
3916
|
getter,
|
|
3686
3917
|
getter,
|
|
3687
|
-
|
|
3918
|
+
identity3,
|
|
3688
3919
|
shallow2
|
|
3689
3920
|
);
|
|
3690
3921
|
return state;
|
|
@@ -3702,25 +3933,21 @@ function useHistoryVersionsSuspense() {
|
|
|
3702
3933
|
function useUpdateRoomNotificationSettings() {
|
|
3703
3934
|
const client = useClient();
|
|
3704
3935
|
const room = useRoom();
|
|
3705
|
-
return
|
|
3936
|
+
return _react.useCallback.call(void 0,
|
|
3706
3937
|
(settings) => {
|
|
3707
3938
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3708
|
-
const
|
|
3939
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3709
3940
|
type: "update-notification-settings",
|
|
3710
3941
|
roomId: room.id,
|
|
3711
3942
|
settings
|
|
3712
3943
|
});
|
|
3713
3944
|
room.updateNotificationSettings(settings).then(
|
|
3714
3945
|
(settings2) => {
|
|
3715
|
-
store.
|
|
3716
|
-
room.id,
|
|
3717
|
-
optimisticUpdateId,
|
|
3718
|
-
settings2
|
|
3719
|
-
);
|
|
3946
|
+
store.updateRoomNotificationSettings(room.id, optimisticId, settings2);
|
|
3720
3947
|
},
|
|
3721
3948
|
(err) => onMutationFailure(
|
|
3722
3949
|
err,
|
|
3723
|
-
|
|
3950
|
+
optimisticId,
|
|
3724
3951
|
(error) => new UpdateNotificationSettingsError(error, {
|
|
3725
3952
|
roomId: room.id
|
|
3726
3953
|
})
|
|
@@ -3816,25 +4043,25 @@ function useAttachmentUrl(attachmentId) {
|
|
|
3816
4043
|
function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
3817
4044
|
const client = useClient();
|
|
3818
4045
|
const store = client[_core.kInternal].httpClient.getOrCreateAttachmentUrlsStore(roomId);
|
|
3819
|
-
const getAttachmentUrlState =
|
|
4046
|
+
const getAttachmentUrlState = _react.useCallback.call(void 0,
|
|
3820
4047
|
() => store.getState(attachmentId),
|
|
3821
4048
|
[store, attachmentId]
|
|
3822
4049
|
);
|
|
3823
|
-
|
|
4050
|
+
_react.useEffect.call(void 0, () => {
|
|
3824
4051
|
void store.get(attachmentId);
|
|
3825
4052
|
}, [store, attachmentId]);
|
|
3826
|
-
return
|
|
4053
|
+
return useSyncExternalStoreWithSelector(
|
|
3827
4054
|
store.subscribe,
|
|
3828
4055
|
getAttachmentUrlState,
|
|
3829
4056
|
getAttachmentUrlState,
|
|
3830
4057
|
selectorFor_useAttachmentUrl,
|
|
3831
|
-
|
|
4058
|
+
_client.shallow
|
|
3832
4059
|
);
|
|
3833
4060
|
}
|
|
3834
4061
|
function useAttachmentUrlSuspense(attachmentId) {
|
|
3835
4062
|
const room = useRoom();
|
|
3836
4063
|
const { attachmentUrlsStore } = room[_core.kInternal];
|
|
3837
|
-
const getAttachmentUrlState =
|
|
4064
|
+
const getAttachmentUrlState = _react.useCallback.call(void 0,
|
|
3838
4065
|
() => attachmentUrlsStore.getState(attachmentId),
|
|
3839
4066
|
[attachmentUrlsStore, attachmentId]
|
|
3840
4067
|
);
|
|
@@ -3845,7 +4072,7 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
3845
4072
|
if (attachmentUrlState.error) {
|
|
3846
4073
|
throw attachmentUrlState.error;
|
|
3847
4074
|
}
|
|
3848
|
-
const state =
|
|
4075
|
+
const state = _react.useSyncExternalStore.call(void 0,
|
|
3849
4076
|
attachmentUrlsStore.subscribe,
|
|
3850
4077
|
getAttachmentUrlState,
|
|
3851
4078
|
getAttachmentUrlState
|
|
@@ -3862,11 +4089,10 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
3862
4089
|
function useRoomPermissions(roomId) {
|
|
3863
4090
|
const client = useClient();
|
|
3864
4091
|
const store = getRoomExtrasForClient(client).store;
|
|
3865
|
-
return
|
|
3866
|
-
store.
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
), () => ( /* @__PURE__ */ new Set()));
|
|
4092
|
+
return useSignal(
|
|
4093
|
+
store.permissionHints.signal,
|
|
4094
|
+
(hints) => _nullishCoalesce(hints[roomId], () => ( /* @__PURE__ */ new Set()))
|
|
4095
|
+
);
|
|
3870
4096
|
}
|
|
3871
4097
|
function createRoomContext(client) {
|
|
3872
4098
|
return getOrCreateRoomContextBundle(client);
|
|
@@ -4007,5 +4233,12 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
4007
4233
|
|
|
4008
4234
|
|
|
4009
4235
|
|
|
4010
|
-
|
|
4011
|
-
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
|
|
4239
|
+
|
|
4240
|
+
|
|
4241
|
+
|
|
4242
|
+
|
|
4243
|
+
exports.RoomContext = RoomContext; exports.useRoomOrNull = useRoomOrNull; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.ClientContext = ClientContext; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports.useSyncStatus = useSyncStatus; exports.CreateThreadError = CreateThreadError; exports.useSignal = useSignal; exports.useStatus = useStatus; exports.useReportTextEditor = useReportTextEditor; exports.useYjsProvider = useYjsProvider; exports.useCreateTextMention = useCreateTextMention; exports.useDeleteTextMention = useDeleteTextMention; exports.useResolveMentionSuggestions = useResolveMentionSuggestions; exports.useMentionSuggestionsCache = useMentionSuggestionsCache; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useErrorListener = useErrorListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCommentsErrorListener = useCommentsErrorListener; exports.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useRoomNotificationSettings = _useRoomNotificationSettings; exports._useRoomNotificationSettingsSuspense = _useRoomNotificationSettingsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
|
|
4244
|
+
//# sourceMappingURL=chunk-UKPVXB7D.js.map
|