@liveblocks/react 2.15.1 → 2.16.0-toolbars1
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 +6 -4
- package/dist/_private.d.ts +6 -4
- package/dist/_private.js +11 -6
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +10 -5
- package/dist/_private.mjs.map +1 -1
- package/dist/{chunk-WV5AI4AE.js → chunk-FKSXNQBA.js} +2 -2
- package/dist/chunk-FKSXNQBA.js.map +1 -0
- package/dist/{chunk-GMKB6I6V.mjs → chunk-FQKGWA7O.mjs} +487 -697
- package/dist/chunk-FQKGWA7O.mjs.map +1 -0
- package/dist/{chunk-NUDMG62P.js → chunk-VJYVOAD5.js} +493 -703
- package/dist/chunk-VJYVOAD5.js.map +1 -0
- package/dist/{chunk-UX3CG7ZS.mjs → chunk-XGO3ZXGZ.mjs} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{room-XbmI0Hoh.d.mts → room-ne1TCZyH.d.mts} +125 -160
- package/dist/{room-XbmI0Hoh.d.ts → room-ne1TCZyH.d.ts} +125 -160
- package/dist/suspense.d.mts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +4 -4
- package/dist/suspense.js.map +1 -1
- package/dist/suspense.mjs +2 -2
- package/package.json +5 -5
- package/dist/chunk-GMKB6I6V.mjs.map +0 -1
- package/dist/chunk-NUDMG62P.js.map +0 -1
- package/dist/chunk-WV5AI4AE.js.map +0 -1
- /package/dist/{chunk-UX3CG7ZS.mjs.map → chunk-XGO3ZXGZ.mjs.map} +0 -0
|
@@ -85,6 +85,18 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
|
|
|
85
85
|
return value;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
// src/use-signal.ts
|
|
89
|
+
var identity = (value) => value;
|
|
90
|
+
function useSignal(signal, selector, isEqual) {
|
|
91
|
+
return useSyncExternalStoreWithSelector(
|
|
92
|
+
signal.subscribe,
|
|
93
|
+
signal.get,
|
|
94
|
+
signal.get,
|
|
95
|
+
_nullishCoalesce(selector, () => ( identity)),
|
|
96
|
+
isEqual
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
88
100
|
// src/liveblocks.tsx
|
|
89
101
|
|
|
90
102
|
|
|
@@ -121,19 +133,30 @@ var config = {
|
|
|
121
133
|
NOTIFICATION_SETTINGS_MAX_STALE_TIME: 5 * SECONDS
|
|
122
134
|
};
|
|
123
135
|
|
|
124
|
-
// src/lib/
|
|
136
|
+
// src/lib/AsyncResult.ts
|
|
137
|
+
var ASYNC_LOADING = Object.freeze({ isLoading: true });
|
|
138
|
+
var ASYNC_ERR = (error) => Object.freeze({ isLoading: false, error });
|
|
139
|
+
function ASYNC_OK(fieldOrData, data) {
|
|
140
|
+
if (arguments.length === 1) {
|
|
141
|
+
return Object.freeze({ isLoading: false, data: fieldOrData });
|
|
142
|
+
} else {
|
|
143
|
+
return Object.freeze({ isLoading: false, [fieldOrData]: data });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
125
146
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
147
|
+
// src/lib/itertools.ts
|
|
148
|
+
function find(it, predicate) {
|
|
149
|
+
for (const item of it) {
|
|
150
|
+
if (predicate(item)) return item;
|
|
129
151
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
return void 0;
|
|
153
|
+
}
|
|
154
|
+
function count(it, predicate) {
|
|
155
|
+
let total = 0;
|
|
156
|
+
for (const item of it) {
|
|
157
|
+
if (predicate(item)) total++;
|
|
133
158
|
}
|
|
134
|
-
return
|
|
135
|
-
(key) => Object.prototype.hasOwnProperty.call(b, key) && _core.shallow.call(void 0, a[key], b[key])
|
|
136
|
-
);
|
|
159
|
+
return total;
|
|
137
160
|
}
|
|
138
161
|
|
|
139
162
|
// src/lib/use-initial.ts
|
|
@@ -211,6 +234,7 @@ var use = (
|
|
|
211
234
|
|
|
212
235
|
|
|
213
236
|
|
|
237
|
+
|
|
214
238
|
// src/lib/autobind.ts
|
|
215
239
|
function autobind(self) {
|
|
216
240
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -228,27 +252,26 @@ function autobind(self) {
|
|
|
228
252
|
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
229
253
|
}
|
|
230
254
|
|
|
231
|
-
// src/lib/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
255
|
+
// src/lib/shallow2.ts
|
|
256
|
+
|
|
257
|
+
function shallow2(a, b) {
|
|
258
|
+
if (!_core.isPlainObject.call(void 0, a) || !_core.isPlainObject.call(void 0, b)) {
|
|
259
|
+
return _core.shallow.call(void 0, a, b);
|
|
235
260
|
}
|
|
236
|
-
|
|
261
|
+
const keysA = Object.keys(a);
|
|
262
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
return keysA.every(
|
|
266
|
+
(key) => Object.prototype.hasOwnProperty.call(b, key) && _core.shallow.call(void 0, a[key], b[key])
|
|
267
|
+
);
|
|
237
268
|
}
|
|
238
269
|
|
|
239
270
|
// src/ThreadDB.ts
|
|
240
271
|
|
|
241
272
|
|
|
242
|
-
// src/lib/guards.ts
|
|
243
|
-
|
|
244
|
-
function isStartsWith(blob) {
|
|
245
|
-
return _core.isPlainObject.call(void 0, blob) && isString(blob.startsWith);
|
|
246
|
-
}
|
|
247
|
-
function isString(value) {
|
|
248
|
-
return typeof value === "string";
|
|
249
|
-
}
|
|
250
|
-
|
|
251
273
|
// src/lib/querying.ts
|
|
274
|
+
|
|
252
275
|
function makeThreadsFilter(query) {
|
|
253
276
|
return (thread) => matchesQuery(thread, query) && matchesMetadata(thread, query);
|
|
254
277
|
}
|
|
@@ -268,8 +291,8 @@ function matchesMetadata(thread, q) {
|
|
|
268
291
|
);
|
|
269
292
|
}
|
|
270
293
|
function matchesOperator(value, op) {
|
|
271
|
-
if (
|
|
272
|
-
return
|
|
294
|
+
if (_core.isStartsWithOperator.call(void 0, op)) {
|
|
295
|
+
return typeof value === "string" && value.startsWith(op.startsWith);
|
|
273
296
|
} else {
|
|
274
297
|
return value === op;
|
|
275
298
|
}
|
|
@@ -355,12 +378,12 @@ var ThreadDB = class _ThreadDB {
|
|
|
355
378
|
this.upsert(thread);
|
|
356
379
|
}
|
|
357
380
|
}
|
|
358
|
-
applyDelta(
|
|
381
|
+
applyDelta(newThreads, deletedThreads) {
|
|
359
382
|
_core.batch.call(void 0, () => {
|
|
360
|
-
for (const thread of
|
|
383
|
+
for (const thread of newThreads) {
|
|
361
384
|
this.upsertIfNewer(thread);
|
|
362
385
|
}
|
|
363
|
-
for (const { id, deletedAt } of
|
|
386
|
+
for (const { id, deletedAt } of deletedThreads) {
|
|
364
387
|
const existing = this.getEvenIfDeleted(id);
|
|
365
388
|
if (!existing) continue;
|
|
366
389
|
this.delete(id, deletedAt);
|
|
@@ -401,16 +424,10 @@ var ThreadDB = class _ThreadDB {
|
|
|
401
424
|
|
|
402
425
|
// src/umbrella-store.ts
|
|
403
426
|
function makeRoomThreadsQueryKey(roomId, query) {
|
|
404
|
-
return
|
|
427
|
+
return _core.stringify.call(void 0, [roomId, _nullishCoalesce(query, () => ( {}))]);
|
|
405
428
|
}
|
|
406
429
|
function makeUserThreadsQueryKey(query) {
|
|
407
|
-
return
|
|
408
|
-
}
|
|
409
|
-
function makeNotificationSettingsQueryKey(roomId) {
|
|
410
|
-
return `${roomId}:NOTIFICATION_SETTINGS`;
|
|
411
|
-
}
|
|
412
|
-
function makeVersionsQueryKey(roomId) {
|
|
413
|
-
return `${roomId}-VERSIONS`;
|
|
430
|
+
return _core.stringify.call(void 0, _nullishCoalesce(query, () => ( {})));
|
|
414
431
|
}
|
|
415
432
|
function usify(promise) {
|
|
416
433
|
if ("status" in promise) {
|
|
@@ -431,53 +448,50 @@ function usify(promise) {
|
|
|
431
448
|
return usable;
|
|
432
449
|
}
|
|
433
450
|
var noop2 = Promise.resolve();
|
|
434
|
-
var ASYNC_LOADING = Object.freeze({ isLoading: true });
|
|
435
451
|
var PaginatedResource = class {
|
|
452
|
+
#signal;
|
|
436
453
|
|
|
437
|
-
#eventSource;
|
|
438
454
|
#fetchPage;
|
|
439
|
-
#paginationState;
|
|
440
|
-
// Should be null while in loading or error state!
|
|
441
455
|
#pendingFetchMore;
|
|
442
456
|
constructor(fetchPage) {
|
|
443
|
-
this.#
|
|
457
|
+
this.#signal = new (0, _core.Signal)(ASYNC_LOADING);
|
|
444
458
|
this.#fetchPage = fetchPage;
|
|
445
|
-
this.#eventSource = _core.makeEventSource.call(void 0, );
|
|
446
459
|
this.#pendingFetchMore = null;
|
|
447
|
-
this.
|
|
460
|
+
this.signal = this.#signal.asReadonly();
|
|
448
461
|
autobind(this);
|
|
449
462
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this.#
|
|
463
|
+
get() {
|
|
464
|
+
return this.#signal.get();
|
|
465
|
+
}
|
|
466
|
+
#patch(patch) {
|
|
467
|
+
const state = this.#signal.get();
|
|
468
|
+
if (state.data === void 0) return;
|
|
469
|
+
this.#signal.set(ASYNC_OK({ ...state.data, ...patch }));
|
|
455
470
|
}
|
|
456
471
|
async #fetchMore() {
|
|
457
|
-
const state = this.#
|
|
458
|
-
if (!_optionalChain([state, '
|
|
472
|
+
const state = this.#signal.get();
|
|
473
|
+
if (!_optionalChain([state, 'access', _3 => _3.data, 'optionalAccess', _4 => _4.cursor]) || state.data.isFetchingMore) {
|
|
459
474
|
return;
|
|
460
475
|
}
|
|
461
|
-
this.#
|
|
476
|
+
this.#patch({ isFetchingMore: true });
|
|
462
477
|
try {
|
|
463
|
-
const nextCursor = await this.#fetchPage(state.cursor);
|
|
464
|
-
this.#
|
|
478
|
+
const nextCursor = await this.#fetchPage(state.data.cursor);
|
|
479
|
+
this.#patch({
|
|
465
480
|
cursor: nextCursor,
|
|
481
|
+
hasFetchedAll: nextCursor === null,
|
|
466
482
|
fetchMoreError: void 0,
|
|
467
483
|
isFetchingMore: false
|
|
468
484
|
});
|
|
469
485
|
} catch (err) {
|
|
470
|
-
this.#
|
|
486
|
+
this.#patch({
|
|
471
487
|
isFetchingMore: false,
|
|
472
488
|
fetchMoreError: err
|
|
473
489
|
});
|
|
474
490
|
}
|
|
475
491
|
}
|
|
476
492
|
fetchMore() {
|
|
477
|
-
const state = this.#
|
|
478
|
-
if (_optionalChain([state, 'optionalAccess',
|
|
479
|
-
return noop2;
|
|
480
|
-
}
|
|
493
|
+
const state = this.#signal.get();
|
|
494
|
+
if (!_optionalChain([state, 'access', _5 => _5.data, 'optionalAccess', _6 => _6.cursor])) return noop2;
|
|
481
495
|
if (!this.#pendingFetchMore) {
|
|
482
496
|
this.#pendingFetchMore = this.#fetchMore().finally(() => {
|
|
483
497
|
this.#pendingFetchMore = null;
|
|
@@ -485,31 +499,12 @@ var PaginatedResource = class {
|
|
|
485
499
|
}
|
|
486
500
|
return this.#pendingFetchMore;
|
|
487
501
|
}
|
|
488
|
-
get() {
|
|
489
|
-
const usable = this.#cachedPromise;
|
|
490
|
-
if (usable === null || usable.status === "pending") {
|
|
491
|
-
return ASYNC_LOADING;
|
|
492
|
-
}
|
|
493
|
-
if (usable.status === "rejected") {
|
|
494
|
-
return { isLoading: false, error: usable.reason };
|
|
495
|
-
}
|
|
496
|
-
const state = this.#paginationState;
|
|
497
|
-
return {
|
|
498
|
-
isLoading: false,
|
|
499
|
-
data: {
|
|
500
|
-
fetchMore: this.fetchMore,
|
|
501
|
-
isFetchingMore: state.isFetchingMore,
|
|
502
|
-
fetchMoreError: state.fetchMoreError,
|
|
503
|
-
hasFetchedAll: state.cursor === null
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
502
|
#cachedPromise = null;
|
|
508
503
|
waitUntilLoaded() {
|
|
509
504
|
if (this.#cachedPromise) {
|
|
510
505
|
return this.#cachedPromise;
|
|
511
506
|
}
|
|
512
|
-
const
|
|
507
|
+
const initialPageFetch$ = _core.autoRetry.call(void 0,
|
|
513
508
|
() => this.#fetchPage(
|
|
514
509
|
/* cursor */
|
|
515
510
|
void 0
|
|
@@ -517,67 +512,64 @@ var PaginatedResource = class {
|
|
|
517
512
|
5,
|
|
518
513
|
[5e3, 5e3, 1e4, 15e3]
|
|
519
514
|
);
|
|
520
|
-
const promise = usify(
|
|
521
|
-
initialFetcher.then((cursor) => {
|
|
522
|
-
this.#paginationState = {
|
|
523
|
-
cursor,
|
|
524
|
-
isFetchingMore: false,
|
|
525
|
-
fetchMoreError: void 0
|
|
526
|
-
};
|
|
527
|
-
})
|
|
528
|
-
);
|
|
515
|
+
const promise = usify(initialPageFetch$);
|
|
529
516
|
promise.then(
|
|
530
|
-
() =>
|
|
531
|
-
|
|
532
|
-
|
|
517
|
+
(cursor) => {
|
|
518
|
+
this.#signal.set(
|
|
519
|
+
ASYNC_OK({
|
|
520
|
+
cursor,
|
|
521
|
+
hasFetchedAll: cursor === null,
|
|
522
|
+
isFetchingMore: false,
|
|
523
|
+
fetchMoreError: void 0,
|
|
524
|
+
fetchMore: this.fetchMore
|
|
525
|
+
})
|
|
526
|
+
);
|
|
527
|
+
},
|
|
528
|
+
(err) => {
|
|
529
|
+
this.#signal.set(ASYNC_ERR(err));
|
|
533
530
|
setTimeout(() => {
|
|
534
531
|
this.#cachedPromise = null;
|
|
535
|
-
this.#
|
|
532
|
+
this.#signal.set(ASYNC_LOADING);
|
|
536
533
|
}, 5e3);
|
|
537
534
|
}
|
|
538
535
|
);
|
|
539
536
|
this.#cachedPromise = promise;
|
|
540
|
-
return
|
|
537
|
+
return this.#cachedPromise;
|
|
541
538
|
}
|
|
542
539
|
};
|
|
543
540
|
var SinglePageResource = class {
|
|
541
|
+
#signal;
|
|
544
542
|
|
|
545
|
-
#eventSource;
|
|
546
543
|
#fetchPage;
|
|
547
544
|
constructor(fetchPage) {
|
|
545
|
+
this.#signal = new (0, _core.Signal)(ASYNC_LOADING);
|
|
546
|
+
this.signal = this.#signal.asReadonly();
|
|
548
547
|
this.#fetchPage = fetchPage;
|
|
549
|
-
this.#eventSource = _core.makeEventSource.call(void 0, );
|
|
550
|
-
this.observable = this.#eventSource.observable;
|
|
551
548
|
autobind(this);
|
|
552
549
|
}
|
|
553
550
|
get() {
|
|
554
|
-
|
|
555
|
-
if (usable === null || usable.status === "pending") {
|
|
556
|
-
return ASYNC_LOADING;
|
|
557
|
-
} else if (usable.status === "rejected") {
|
|
558
|
-
return { isLoading: false, error: usable.reason };
|
|
559
|
-
} else {
|
|
560
|
-
return { isLoading: false, data: void 0 };
|
|
561
|
-
}
|
|
551
|
+
return this.#signal.get();
|
|
562
552
|
}
|
|
563
553
|
#cachedPromise = null;
|
|
564
554
|
waitUntilLoaded() {
|
|
565
555
|
if (this.#cachedPromise) {
|
|
566
556
|
return this.#cachedPromise;
|
|
567
557
|
}
|
|
568
|
-
const initialFetcher = _core.autoRetry.call(void 0,
|
|
558
|
+
const initialFetcher$ = _core.autoRetry.call(void 0,
|
|
569
559
|
() => this.#fetchPage(),
|
|
570
560
|
5,
|
|
571
561
|
[5e3, 5e3, 1e4, 15e3]
|
|
572
562
|
);
|
|
573
|
-
const promise = usify(initialFetcher);
|
|
563
|
+
const promise = usify(initialFetcher$);
|
|
574
564
|
promise.then(
|
|
575
|
-
() => this.#eventSource.notify(),
|
|
576
565
|
() => {
|
|
577
|
-
this.#
|
|
566
|
+
this.#signal.set(ASYNC_OK(void 0));
|
|
567
|
+
},
|
|
568
|
+
(err) => {
|
|
569
|
+
this.#signal.set(ASYNC_ERR(err));
|
|
578
570
|
setTimeout(() => {
|
|
579
571
|
this.#cachedPromise = null;
|
|
580
|
-
this.#
|
|
572
|
+
this.#signal.set(ASYNC_LOADING);
|
|
581
573
|
}, 5e3);
|
|
582
574
|
}
|
|
583
575
|
);
|
|
@@ -610,10 +602,10 @@ function createStore_forNotifications() {
|
|
|
610
602
|
function clear() {
|
|
611
603
|
signal.mutate((lut) => lut.clear());
|
|
612
604
|
}
|
|
613
|
-
function applyDelta(
|
|
605
|
+
function applyDelta(newNotifications, deletedNotifications) {
|
|
614
606
|
signal.mutate((lut) => {
|
|
615
607
|
let mutated = false;
|
|
616
|
-
for (const n of
|
|
608
|
+
for (const n of newNotifications) {
|
|
617
609
|
const existing = lut.get(n.id);
|
|
618
610
|
if (existing) {
|
|
619
611
|
const result = compareInboxNotifications(existing, n);
|
|
@@ -644,6 +636,11 @@ function createStore_forNotifications() {
|
|
|
644
636
|
return true;
|
|
645
637
|
});
|
|
646
638
|
}
|
|
639
|
+
function upsert(notification) {
|
|
640
|
+
signal.mutate((lut) => {
|
|
641
|
+
lut.set(notification.id, notification);
|
|
642
|
+
});
|
|
643
|
+
}
|
|
647
644
|
return {
|
|
648
645
|
signal: signal.asReadonly(),
|
|
649
646
|
// Mutations
|
|
@@ -653,66 +650,70 @@ function createStore_forNotifications() {
|
|
|
653
650
|
applyDelta,
|
|
654
651
|
clear,
|
|
655
652
|
updateAssociatedNotification,
|
|
656
|
-
|
|
657
|
-
force_set: (mutationCallback) => signal.mutate(mutationCallback),
|
|
658
|
-
invalidate: () => signal.mutate()
|
|
653
|
+
upsert
|
|
659
654
|
};
|
|
660
655
|
}
|
|
661
|
-
function createStore_forRoomNotificationSettings() {
|
|
662
|
-
const
|
|
656
|
+
function createStore_forRoomNotificationSettings(updates) {
|
|
657
|
+
const baseSignal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
663
658
|
function update(roomId, settings) {
|
|
664
|
-
|
|
659
|
+
baseSignal.mutate((lut) => {
|
|
665
660
|
lut.set(roomId, settings);
|
|
666
661
|
});
|
|
667
662
|
}
|
|
668
663
|
return {
|
|
669
|
-
signal:
|
|
664
|
+
signal: _core.DerivedSignal.from(
|
|
665
|
+
baseSignal,
|
|
666
|
+
updates,
|
|
667
|
+
(base, updates2) => applyOptimisticUpdates_forSettings(base, updates2)
|
|
668
|
+
),
|
|
670
669
|
// Mutations
|
|
671
|
-
update
|
|
672
|
-
// XXX_vincent Remove this eventually
|
|
673
|
-
invalidate: () => signal.mutate()
|
|
670
|
+
update
|
|
674
671
|
};
|
|
675
672
|
}
|
|
676
673
|
function createStore_forHistoryVersions() {
|
|
677
|
-
const
|
|
674
|
+
const baseSignal = new (0, _core.MutableSignal)(
|
|
675
|
+
new (0, _core.DefaultMap)(() => /* @__PURE__ */ new Map())
|
|
676
|
+
);
|
|
678
677
|
function update(roomId, versions) {
|
|
679
|
-
|
|
680
|
-
const versionsById =
|
|
678
|
+
baseSignal.mutate((lut) => {
|
|
679
|
+
const versionsById = lut.getOrCreate(roomId);
|
|
681
680
|
for (const version of versions) {
|
|
682
681
|
versionsById.set(version.id, version);
|
|
683
682
|
}
|
|
684
683
|
});
|
|
685
684
|
}
|
|
686
685
|
return {
|
|
687
|
-
signal:
|
|
686
|
+
signal: _core.DerivedSignal.from(
|
|
687
|
+
baseSignal,
|
|
688
|
+
(hv) => Object.fromEntries(
|
|
689
|
+
[...hv].map(([roomId, versions]) => [
|
|
690
|
+
roomId,
|
|
691
|
+
Object.fromEntries(versions)
|
|
692
|
+
])
|
|
693
|
+
)
|
|
694
|
+
),
|
|
688
695
|
// Mutations
|
|
689
|
-
update
|
|
690
|
-
// XXX_vincent Remove these eventually
|
|
691
|
-
force_set: (callback) => signal.mutate(callback),
|
|
692
|
-
invalidate: () => signal.mutate()
|
|
696
|
+
update
|
|
693
697
|
};
|
|
694
698
|
}
|
|
695
699
|
function createStore_forPermissionHints() {
|
|
696
|
-
const signal = new (0, _core.
|
|
700
|
+
const signal = new (0, _core.MutableSignal)(
|
|
701
|
+
new (0, _core.DefaultMap)(() => /* @__PURE__ */ new Set())
|
|
702
|
+
);
|
|
697
703
|
function update(newHints) {
|
|
698
|
-
signal.
|
|
699
|
-
const permissionsByRoom = { ...prev };
|
|
704
|
+
signal.mutate((lut) => {
|
|
700
705
|
for (const [roomId, newPermissions] of Object.entries(newHints)) {
|
|
701
|
-
const existing =
|
|
706
|
+
const existing = lut.getOrCreate(roomId);
|
|
702
707
|
for (const permission of newPermissions) {
|
|
703
708
|
existing.add(permission);
|
|
704
709
|
}
|
|
705
|
-
permissionsByRoom[roomId] = existing;
|
|
706
710
|
}
|
|
707
|
-
return permissionsByRoom;
|
|
708
711
|
});
|
|
709
712
|
}
|
|
710
713
|
return {
|
|
711
714
|
signal: signal.asReadonly(),
|
|
712
715
|
// Mutations
|
|
713
|
-
update
|
|
714
|
-
// XXX_vincent Remove this eventually
|
|
715
|
-
invalidate: () => signal.set((store) => ({ ...store }))
|
|
716
|
+
update
|
|
716
717
|
};
|
|
717
718
|
}
|
|
718
719
|
function createStore_forOptimistic(client) {
|
|
@@ -736,9 +737,7 @@ function createStore_forOptimistic(client) {
|
|
|
736
737
|
signal: signal.asReadonly(),
|
|
737
738
|
// Mutations
|
|
738
739
|
add,
|
|
739
|
-
remove
|
|
740
|
-
// XXX_vincent Remove this eventually
|
|
741
|
-
invalidate: () => signal.set((store) => [...store])
|
|
740
|
+
remove
|
|
742
741
|
};
|
|
743
742
|
}
|
|
744
743
|
var UmbrellaStore = class {
|
|
@@ -788,48 +787,37 @@ var UmbrellaStore = class {
|
|
|
788
787
|
// threads and notifications separately, but the threadifications signal will
|
|
789
788
|
// be updated whenever either of them change.
|
|
790
789
|
//
|
|
791
|
-
// XXX_vincent APIs like getRoomThreadsLoadingState should really also be modeled as output signals.
|
|
792
|
-
//
|
|
793
790
|
|
|
794
791
|
// Notifications
|
|
795
792
|
#notificationsLastRequestedAt = null;
|
|
796
793
|
// 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.
|
|
797
|
-
#
|
|
794
|
+
#notificationsPaginationState;
|
|
798
795
|
// Room Threads
|
|
799
796
|
#roomThreadsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
800
|
-
#roomThreads = /* @__PURE__ */ new Map();
|
|
801
797
|
// User Threads
|
|
802
798
|
#userThreadsLastRequestedAt = null;
|
|
803
|
-
#userThreads = /* @__PURE__ */ new Map();
|
|
804
799
|
// Room versions
|
|
805
|
-
#roomVersions = /* @__PURE__ */ new Map();
|
|
806
800
|
#roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
807
|
-
// Room notification settings
|
|
808
|
-
#roomNotificationSettings = /* @__PURE__ */ new Map();
|
|
809
801
|
constructor(client) {
|
|
810
802
|
this.#client = client[_core.kInternal].as();
|
|
811
803
|
this.optimisticUpdates = createStore_forOptimistic(this.#client);
|
|
812
804
|
this.permissionHints = createStore_forPermissionHints();
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
this.#notificationsLastRequestedAt
|
|
805
|
+
this.#notificationsPaginationState = new PaginatedResource(
|
|
806
|
+
async (cursor) => {
|
|
807
|
+
const result = await this.#client.getInboxNotifications({ cursor });
|
|
808
|
+
this.updateThreadifications(result.threads, result.inboxNotifications);
|
|
809
|
+
if (this.#notificationsLastRequestedAt === null) {
|
|
810
|
+
this.#notificationsLastRequestedAt = result.requestedAt;
|
|
811
|
+
}
|
|
812
|
+
const nextCursor = result.nextCursor;
|
|
813
|
+
return nextCursor;
|
|
818
814
|
}
|
|
819
|
-
const nextCursor = result.nextCursor;
|
|
820
|
-
return nextCursor;
|
|
821
|
-
};
|
|
822
|
-
this.#notifications = new PaginatedResource(inboxFetcher);
|
|
823
|
-
this.#notifications.observable.subscribe(
|
|
824
|
-
() => (
|
|
825
|
-
// Note that the store itself does not change, but it's only vehicle at
|
|
826
|
-
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
827
|
-
this.invalidateEntireStore()
|
|
828
|
-
)
|
|
829
815
|
);
|
|
830
816
|
this.threads = new ThreadDB();
|
|
831
817
|
this.notifications = createStore_forNotifications();
|
|
832
|
-
this.roomNotificationSettings = createStore_forRoomNotificationSettings(
|
|
818
|
+
this.roomNotificationSettings = createStore_forRoomNotificationSettings(
|
|
819
|
+
this.optimisticUpdates.signal
|
|
820
|
+
);
|
|
833
821
|
this.historyVersions = createStore_forHistoryVersions();
|
|
834
822
|
const threadifications = _core.DerivedSignal.from(
|
|
835
823
|
this.threads.signal,
|
|
@@ -837,13 +825,7 @@ var UmbrellaStore = class {
|
|
|
837
825
|
this.optimisticUpdates.signal,
|
|
838
826
|
(ts, ns, updates) => applyOptimisticUpdates_forThreadifications(ts, ns, updates)
|
|
839
827
|
);
|
|
840
|
-
const threads = _core.DerivedSignal.from(
|
|
841
|
-
threadifications,
|
|
842
|
-
(s) => ({
|
|
843
|
-
threadsDB: s.threadsDB
|
|
844
|
-
}),
|
|
845
|
-
_core.shallow
|
|
846
|
-
);
|
|
828
|
+
const threads = _core.DerivedSignal.from(threadifications, (s) => s.threadsDB);
|
|
847
829
|
const notifications = _core.DerivedSignal.from(
|
|
848
830
|
threadifications,
|
|
849
831
|
(s) => ({
|
|
@@ -852,177 +834,180 @@ var UmbrellaStore = class {
|
|
|
852
834
|
}),
|
|
853
835
|
_core.shallow
|
|
854
836
|
);
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
837
|
+
const loadingUserThreads = new (0, _core.DefaultMap)(
|
|
838
|
+
(queryKey) => {
|
|
839
|
+
const query = _core.unstringify.call(void 0, queryKey);
|
|
840
|
+
const resource = new PaginatedResource(async (cursor) => {
|
|
841
|
+
const result = await this.#client[_core.kInternal].httpClient.getUserThreads_experimental({
|
|
842
|
+
cursor,
|
|
843
|
+
query
|
|
844
|
+
});
|
|
845
|
+
this.updateThreadifications(
|
|
846
|
+
result.threads,
|
|
847
|
+
result.inboxNotifications
|
|
848
|
+
);
|
|
849
|
+
this.permissionHints.update(result.permissionHints);
|
|
850
|
+
if (this.#userThreadsLastRequestedAt === null) {
|
|
851
|
+
this.#userThreadsLastRequestedAt = result.requestedAt;
|
|
852
|
+
}
|
|
853
|
+
return result.nextCursor;
|
|
854
|
+
});
|
|
855
|
+
const signal = _core.DerivedSignal.from(() => {
|
|
856
|
+
const result = resource.get();
|
|
857
|
+
if (result.isLoading || result.error) {
|
|
858
|
+
return result;
|
|
859
|
+
}
|
|
860
|
+
const threads2 = this.outputs.threads.get().findMany(
|
|
861
|
+
void 0,
|
|
862
|
+
// Do _not_ filter by roomId
|
|
863
|
+
_nullishCoalesce(query, () => ( {})),
|
|
864
|
+
"desc"
|
|
865
|
+
);
|
|
866
|
+
const page = result.data;
|
|
867
|
+
return {
|
|
868
|
+
isLoading: false,
|
|
869
|
+
threads: threads2,
|
|
870
|
+
hasFetchedAll: page.hasFetchedAll,
|
|
871
|
+
isFetchingMore: page.isFetchingMore,
|
|
872
|
+
fetchMoreError: page.fetchMoreError,
|
|
873
|
+
fetchMore: page.fetchMore
|
|
874
|
+
};
|
|
875
|
+
}, shallow2);
|
|
876
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
877
|
+
}
|
|
859
878
|
);
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
879
|
+
const loadingRoomThreads = new (0, _core.DefaultMap)(
|
|
880
|
+
(queryKey) => {
|
|
881
|
+
const [roomId, query] = _core.unstringify.call(void 0, queryKey);
|
|
882
|
+
const resource = new PaginatedResource(async (cursor) => {
|
|
883
|
+
const result = await this.#client[_core.kInternal].httpClient.getThreads({
|
|
884
|
+
roomId,
|
|
885
|
+
cursor,
|
|
886
|
+
query
|
|
887
|
+
});
|
|
888
|
+
this.updateThreadifications(
|
|
889
|
+
result.threads,
|
|
890
|
+
result.inboxNotifications
|
|
891
|
+
);
|
|
892
|
+
this.permissionHints.update(result.permissionHints);
|
|
893
|
+
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
894
|
+
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
895
|
+
this.#roomThreadsLastRequestedAtByRoom.set(
|
|
896
|
+
roomId,
|
|
897
|
+
result.requestedAt
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
return result.nextCursor;
|
|
901
|
+
});
|
|
902
|
+
const signal = _core.DerivedSignal.from(() => {
|
|
903
|
+
const result = resource.get();
|
|
904
|
+
if (result.isLoading || result.error) {
|
|
905
|
+
return result;
|
|
906
|
+
}
|
|
907
|
+
const threads2 = this.outputs.threads.get().findMany(roomId, _nullishCoalesce(query, () => ( {})), "asc");
|
|
908
|
+
const page = result.data;
|
|
909
|
+
return {
|
|
910
|
+
isLoading: false,
|
|
911
|
+
threads: threads2,
|
|
912
|
+
hasFetchedAll: page.hasFetchedAll,
|
|
913
|
+
isFetchingMore: page.isFetchingMore,
|
|
914
|
+
fetchMoreError: page.fetchMoreError,
|
|
915
|
+
fetchMore: page.fetchMore
|
|
916
|
+
};
|
|
917
|
+
}, shallow2);
|
|
918
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
919
|
+
}
|
|
920
|
+
);
|
|
921
|
+
const loadingNotifications = {
|
|
922
|
+
signal: _core.DerivedSignal.from(() => {
|
|
923
|
+
const resource = this.#notificationsPaginationState;
|
|
924
|
+
const result = resource.get();
|
|
925
|
+
if (result.isLoading || result.error) {
|
|
926
|
+
return result;
|
|
927
|
+
}
|
|
928
|
+
const page = result.data;
|
|
929
|
+
return {
|
|
930
|
+
isLoading: false,
|
|
931
|
+
inboxNotifications: this.outputs.notifications.get().sortedNotifications,
|
|
932
|
+
hasFetchedAll: page.hasFetchedAll,
|
|
933
|
+
isFetchingMore: page.isFetchingMore,
|
|
934
|
+
fetchMoreError: page.fetchMoreError,
|
|
935
|
+
fetchMore: page.fetchMore
|
|
936
|
+
};
|
|
937
|
+
}),
|
|
938
|
+
waitUntilLoaded: this.#notificationsPaginationState.waitUntilLoaded
|
|
939
|
+
};
|
|
940
|
+
const settingsByRoomId = new (0, _core.DefaultMap)((roomId) => {
|
|
941
|
+
const resource = new SinglePageResource(async () => {
|
|
942
|
+
const room = this.#client.getRoom(roomId);
|
|
943
|
+
if (room === null) {
|
|
944
|
+
throw new (0, _core.HttpError)(
|
|
945
|
+
`Room '${roomId}' is not available on client`,
|
|
946
|
+
479
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
const result = await room.getNotificationSettings();
|
|
950
|
+
this.roomNotificationSettings.update(roomId, result);
|
|
951
|
+
});
|
|
952
|
+
const signal = _core.DerivedSignal.from(() => {
|
|
953
|
+
const result = resource.get();
|
|
954
|
+
if (result.isLoading || result.error) {
|
|
955
|
+
return result;
|
|
956
|
+
} else {
|
|
957
|
+
return ASYNC_OK(
|
|
958
|
+
"settings",
|
|
959
|
+
_core.nn.call(void 0, this.roomNotificationSettings.signal.get()[roomId])
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
}, _core.shallow);
|
|
963
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
964
|
+
});
|
|
965
|
+
const versionsByRoomId = new (0, _core.DefaultMap)(
|
|
966
|
+
(roomId) => {
|
|
967
|
+
const resource = new SinglePageResource(async () => {
|
|
968
|
+
const room = this.#client.getRoom(roomId);
|
|
969
|
+
if (room === null) {
|
|
970
|
+
throw new (0, _core.HttpError)(
|
|
971
|
+
`Room '${roomId}' is not available on client`,
|
|
972
|
+
479
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
const result = await room[_core.kInternal].listTextVersions();
|
|
976
|
+
this.historyVersions.update(roomId, result.versions);
|
|
977
|
+
const lastRequestedAt = this.#roomVersionsLastRequestedAtByRoom.get(roomId);
|
|
978
|
+
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
979
|
+
this.#roomVersionsLastRequestedAtByRoom.set(
|
|
980
|
+
roomId,
|
|
981
|
+
result.requestedAt
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
const signal = _core.DerivedSignal.from(() => {
|
|
986
|
+
const result = resource.get();
|
|
987
|
+
if (result.isLoading || result.error) {
|
|
988
|
+
return result;
|
|
989
|
+
} else {
|
|
990
|
+
return ASYNC_OK(
|
|
991
|
+
"versions",
|
|
992
|
+
Object.values(_nullishCoalesce(this.historyVersions.signal.get()[roomId], () => ( {})))
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
}, _core.shallow);
|
|
996
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
997
|
+
}
|
|
868
998
|
);
|
|
869
999
|
this.outputs = {
|
|
870
1000
|
threadifications,
|
|
871
1001
|
threads,
|
|
1002
|
+
loadingRoomThreads,
|
|
1003
|
+
loadingUserThreads,
|
|
872
1004
|
notifications,
|
|
1005
|
+
loadingNotifications,
|
|
873
1006
|
settingsByRoomId,
|
|
874
1007
|
versionsByRoomId
|
|
875
1008
|
};
|
|
876
1009
|
autobind(this);
|
|
877
1010
|
}
|
|
878
|
-
get1_both() {
|
|
879
|
-
return this.outputs.threadifications.get();
|
|
880
|
-
}
|
|
881
|
-
subscribe1_both(callback) {
|
|
882
|
-
return this.outputs.threadifications.subscribe(callback);
|
|
883
|
-
}
|
|
884
|
-
get1_threads() {
|
|
885
|
-
return this.outputs.threads.get();
|
|
886
|
-
}
|
|
887
|
-
subscribe1_threads(callback) {
|
|
888
|
-
return this.outputs.threads.subscribe(callback);
|
|
889
|
-
}
|
|
890
|
-
get1_notifications() {
|
|
891
|
-
return this.outputs.notifications.get();
|
|
892
|
-
}
|
|
893
|
-
subscribe1_notifications(callback) {
|
|
894
|
-
return this.outputs.notifications.subscribe(callback);
|
|
895
|
-
}
|
|
896
|
-
get2() {
|
|
897
|
-
return this.outputs.settingsByRoomId.get();
|
|
898
|
-
}
|
|
899
|
-
subscribe2(callback) {
|
|
900
|
-
return this.outputs.settingsByRoomId.subscribe(callback);
|
|
901
|
-
}
|
|
902
|
-
get3() {
|
|
903
|
-
return this.outputs.versionsByRoomId.get();
|
|
904
|
-
}
|
|
905
|
-
subscribe3(callback) {
|
|
906
|
-
return this.outputs.versionsByRoomId.subscribe(callback);
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Returns the async result of the given query and room id. If the query is success,
|
|
910
|
-
* then it will return the threads that match that provided query and room id.
|
|
911
|
-
*
|
|
912
|
-
*/
|
|
913
|
-
getRoomThreadsLoadingState(roomId, query) {
|
|
914
|
-
const queryKey = makeRoomThreadsQueryKey(roomId, query);
|
|
915
|
-
const paginatedResource = this.#roomThreads.get(queryKey);
|
|
916
|
-
if (paginatedResource === void 0) {
|
|
917
|
-
return ASYNC_LOADING;
|
|
918
|
-
}
|
|
919
|
-
const asyncResult = paginatedResource.get();
|
|
920
|
-
if (asyncResult.isLoading || asyncResult.error) {
|
|
921
|
-
return asyncResult;
|
|
922
|
-
}
|
|
923
|
-
const threads = this.get1_threads().threadsDB.findMany(
|
|
924
|
-
roomId,
|
|
925
|
-
_nullishCoalesce(query, () => ( {})),
|
|
926
|
-
"asc"
|
|
927
|
-
);
|
|
928
|
-
const page = asyncResult.data;
|
|
929
|
-
return {
|
|
930
|
-
isLoading: false,
|
|
931
|
-
threads,
|
|
932
|
-
hasFetchedAll: page.hasFetchedAll,
|
|
933
|
-
isFetchingMore: page.isFetchingMore,
|
|
934
|
-
fetchMoreError: page.fetchMoreError,
|
|
935
|
-
fetchMore: page.fetchMore
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
getUserThreadsLoadingState(query) {
|
|
939
|
-
const queryKey = makeUserThreadsQueryKey(query);
|
|
940
|
-
const paginatedResource = this.#userThreads.get(queryKey);
|
|
941
|
-
if (paginatedResource === void 0) {
|
|
942
|
-
return ASYNC_LOADING;
|
|
943
|
-
}
|
|
944
|
-
const asyncResult = paginatedResource.get();
|
|
945
|
-
if (asyncResult.isLoading || asyncResult.error) {
|
|
946
|
-
return asyncResult;
|
|
947
|
-
}
|
|
948
|
-
const threads = this.get1_threads().threadsDB.findMany(
|
|
949
|
-
void 0,
|
|
950
|
-
// Do _not_ filter by roomId
|
|
951
|
-
_nullishCoalesce(query, () => ( {})),
|
|
952
|
-
"desc"
|
|
953
|
-
);
|
|
954
|
-
const page = asyncResult.data;
|
|
955
|
-
return {
|
|
956
|
-
isLoading: false,
|
|
957
|
-
threads,
|
|
958
|
-
hasFetchedAll: page.hasFetchedAll,
|
|
959
|
-
isFetchingMore: page.isFetchingMore,
|
|
960
|
-
fetchMoreError: page.fetchMoreError,
|
|
961
|
-
fetchMore: page.fetchMore
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
965
|
-
getInboxNotificationsLoadingState() {
|
|
966
|
-
const asyncResult = this.#notifications.get();
|
|
967
|
-
if (asyncResult.isLoading || asyncResult.error) {
|
|
968
|
-
return asyncResult;
|
|
969
|
-
}
|
|
970
|
-
const page = asyncResult.data;
|
|
971
|
-
return {
|
|
972
|
-
isLoading: false,
|
|
973
|
-
inboxNotifications: this.get1_notifications().sortedNotifications,
|
|
974
|
-
hasFetchedAll: page.hasFetchedAll,
|
|
975
|
-
isFetchingMore: page.isFetchingMore,
|
|
976
|
-
fetchMoreError: page.fetchMoreError,
|
|
977
|
-
fetchMore: page.fetchMore
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
981
|
-
// XXX_vincent This should really be a derived Signal!
|
|
982
|
-
getNotificationSettingsLoadingState(roomId) {
|
|
983
|
-
const queryKey = makeNotificationSettingsQueryKey(roomId);
|
|
984
|
-
const resource = this.#roomNotificationSettings.get(queryKey);
|
|
985
|
-
if (resource === void 0) {
|
|
986
|
-
return ASYNC_LOADING;
|
|
987
|
-
}
|
|
988
|
-
const asyncResult = resource.get();
|
|
989
|
-
if (asyncResult.isLoading || asyncResult.error) {
|
|
990
|
-
return asyncResult;
|
|
991
|
-
}
|
|
992
|
-
return {
|
|
993
|
-
isLoading: false,
|
|
994
|
-
settings: _core.nn.call(void 0, this.get2()[roomId])
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
getRoomVersionsLoadingState(roomId) {
|
|
998
|
-
const queryKey = makeVersionsQueryKey(roomId);
|
|
999
|
-
const resource = this.#roomVersions.get(queryKey);
|
|
1000
|
-
if (resource === void 0) {
|
|
1001
|
-
return ASYNC_LOADING;
|
|
1002
|
-
}
|
|
1003
|
-
const asyncResult = resource.get();
|
|
1004
|
-
if (asyncResult.isLoading || asyncResult.error) {
|
|
1005
|
-
return asyncResult;
|
|
1006
|
-
}
|
|
1007
|
-
return {
|
|
1008
|
-
isLoading: false,
|
|
1009
|
-
versions: Object.values(_nullishCoalesce(this.get3()[roomId], () => ( {})))
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
/** @internal - Only call this method from unit tests. */
|
|
1013
|
-
force_set_versions(callback) {
|
|
1014
|
-
_core.batch.call(void 0, () => {
|
|
1015
|
-
this.historyVersions.force_set(callback);
|
|
1016
|
-
this.invalidateEntireStore();
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
/** @internal - Only call this method from unit tests. */
|
|
1020
|
-
force_set_notifications(callback) {
|
|
1021
|
-
_core.batch.call(void 0, () => {
|
|
1022
|
-
this.notifications.force_set(callback);
|
|
1023
|
-
this.invalidateEntireStore();
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
1011
|
/**
|
|
1027
1012
|
* Updates an existing inbox notification with a new value, replacing the
|
|
1028
1013
|
* corresponding optimistic update.
|
|
@@ -1164,7 +1149,7 @@ var UmbrellaStore = class {
|
|
|
1164
1149
|
}
|
|
1165
1150
|
updateThreadifications(threads, notifications, deletedThreads = [], deletedNotifications = []) {
|
|
1166
1151
|
_core.batch.call(void 0, () => {
|
|
1167
|
-
this.threads.applyDelta(
|
|
1152
|
+
this.threads.applyDelta(threads, deletedThreads);
|
|
1168
1153
|
this.notifications.applyDelta(notifications, deletedNotifications);
|
|
1169
1154
|
});
|
|
1170
1155
|
}
|
|
@@ -1197,39 +1182,6 @@ var UmbrellaStore = class {
|
|
|
1197
1182
|
result.inboxNotifications.deleted
|
|
1198
1183
|
);
|
|
1199
1184
|
}
|
|
1200
|
-
waitUntilNotificationsLoaded() {
|
|
1201
|
-
return this.#notifications.waitUntilLoaded();
|
|
1202
|
-
}
|
|
1203
|
-
waitUntilRoomThreadsLoaded(roomId, query) {
|
|
1204
|
-
const threadsFetcher = async (cursor) => {
|
|
1205
|
-
const result = await this.#client[_core.kInternal].httpClient.getThreads({
|
|
1206
|
-
roomId,
|
|
1207
|
-
cursor,
|
|
1208
|
-
query
|
|
1209
|
-
});
|
|
1210
|
-
this.updateThreadifications(result.threads, result.inboxNotifications);
|
|
1211
|
-
this.permissionHints.update(result.permissionHints);
|
|
1212
|
-
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
1213
|
-
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
1214
|
-
this.#roomThreadsLastRequestedAtByRoom.set(roomId, result.requestedAt);
|
|
1215
|
-
}
|
|
1216
|
-
return result.nextCursor;
|
|
1217
|
-
};
|
|
1218
|
-
const queryKey = makeRoomThreadsQueryKey(roomId, query);
|
|
1219
|
-
let paginatedResource = this.#roomThreads.get(queryKey);
|
|
1220
|
-
if (paginatedResource === void 0) {
|
|
1221
|
-
paginatedResource = new PaginatedResource(threadsFetcher);
|
|
1222
|
-
}
|
|
1223
|
-
paginatedResource.observable.subscribe(
|
|
1224
|
-
() => (
|
|
1225
|
-
// Note that the store itself does not change, but it's only vehicle at
|
|
1226
|
-
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1227
|
-
this.invalidateEntireStore()
|
|
1228
|
-
)
|
|
1229
|
-
);
|
|
1230
|
-
this.#roomThreads.set(queryKey, paginatedResource);
|
|
1231
|
-
return paginatedResource.waitUntilLoaded();
|
|
1232
|
-
}
|
|
1233
1185
|
async fetchRoomThreadsDeltaUpdate(roomId, signal) {
|
|
1234
1186
|
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
1235
1187
|
if (lastRequestedAt === void 0) {
|
|
@@ -1251,45 +1203,6 @@ var UmbrellaStore = class {
|
|
|
1251
1203
|
this.#roomThreadsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1252
1204
|
}
|
|
1253
1205
|
}
|
|
1254
|
-
waitUntilUserThreadsLoaded(query) {
|
|
1255
|
-
const queryKey = makeUserThreadsQueryKey(query);
|
|
1256
|
-
const threadsFetcher = async (cursor) => {
|
|
1257
|
-
const result = await this.#client[_core.kInternal].httpClient.getUserThreads_experimental({
|
|
1258
|
-
cursor,
|
|
1259
|
-
query
|
|
1260
|
-
});
|
|
1261
|
-
this.updateThreadifications(result.threads, result.inboxNotifications);
|
|
1262
|
-
this.permissionHints.update(result.permissionHints);
|
|
1263
|
-
if (this.#userThreadsLastRequestedAt === null) {
|
|
1264
|
-
this.#userThreadsLastRequestedAt = result.requestedAt;
|
|
1265
|
-
}
|
|
1266
|
-
return result.nextCursor;
|
|
1267
|
-
};
|
|
1268
|
-
let paginatedResource = this.#userThreads.get(queryKey);
|
|
1269
|
-
if (paginatedResource === void 0) {
|
|
1270
|
-
paginatedResource = new PaginatedResource(threadsFetcher);
|
|
1271
|
-
}
|
|
1272
|
-
paginatedResource.observable.subscribe(
|
|
1273
|
-
() => (
|
|
1274
|
-
// Note that the store itself does not change, but it's only vehicle at
|
|
1275
|
-
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1276
|
-
this.invalidateEntireStore()
|
|
1277
|
-
)
|
|
1278
|
-
);
|
|
1279
|
-
this.#userThreads.set(queryKey, paginatedResource);
|
|
1280
|
-
return paginatedResource.waitUntilLoaded();
|
|
1281
|
-
}
|
|
1282
|
-
// XXX_vincent We should really be going over all call sites, and replace this call
|
|
1283
|
-
// with a more specific invalidation!
|
|
1284
|
-
invalidateEntireStore() {
|
|
1285
|
-
_core.batch.call(void 0, () => {
|
|
1286
|
-
this.historyVersions.invalidate();
|
|
1287
|
-
this.notifications.invalidate();
|
|
1288
|
-
this.optimisticUpdates.invalidate();
|
|
1289
|
-
this.permissionHints.invalidate();
|
|
1290
|
-
this.roomNotificationSettings.invalidate();
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
1206
|
async fetchUserThreadsDeltaUpdate(signal) {
|
|
1294
1207
|
const lastRequestedAt = this.#userThreadsLastRequestedAt;
|
|
1295
1208
|
if (lastRequestedAt === null) {
|
|
@@ -1310,40 +1223,6 @@ var UmbrellaStore = class {
|
|
|
1310
1223
|
);
|
|
1311
1224
|
this.permissionHints.update(result.permissionHints);
|
|
1312
1225
|
}
|
|
1313
|
-
waitUntilRoomVersionsLoaded(roomId) {
|
|
1314
|
-
const queryKey = makeVersionsQueryKey(roomId);
|
|
1315
|
-
let resource = this.#roomVersions.get(queryKey);
|
|
1316
|
-
if (resource === void 0) {
|
|
1317
|
-
const versionsFetcher = async () => {
|
|
1318
|
-
const room = this.#client.getRoom(roomId);
|
|
1319
|
-
if (room === null) {
|
|
1320
|
-
throw new (0, _core.HttpError)(
|
|
1321
|
-
`Room '${roomId}' is not available on client`,
|
|
1322
|
-
479
|
|
1323
|
-
);
|
|
1324
|
-
}
|
|
1325
|
-
const result = await room[_core.kInternal].listTextVersions();
|
|
1326
|
-
this.historyVersions.update(roomId, result.versions);
|
|
1327
|
-
const lastRequestedAt = this.#roomVersionsLastRequestedAtByRoom.get(roomId);
|
|
1328
|
-
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
1329
|
-
this.#roomVersionsLastRequestedAtByRoom.set(
|
|
1330
|
-
roomId,
|
|
1331
|
-
result.requestedAt
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
|
-
};
|
|
1335
|
-
resource = new SinglePageResource(versionsFetcher);
|
|
1336
|
-
}
|
|
1337
|
-
resource.observable.subscribe(
|
|
1338
|
-
() => (
|
|
1339
|
-
// Note that the store itself does not change, but it's only vehicle at
|
|
1340
|
-
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1341
|
-
this.invalidateEntireStore()
|
|
1342
|
-
)
|
|
1343
|
-
);
|
|
1344
|
-
this.#roomVersions.set(queryKey, resource);
|
|
1345
|
-
return resource.waitUntilLoaded();
|
|
1346
|
-
}
|
|
1347
1226
|
async fetchRoomVersionsDeltaUpdate(roomId, signal) {
|
|
1348
1227
|
const lastRequestedAt = this.#roomVersionsLastRequestedAtByRoom.get(roomId);
|
|
1349
1228
|
if (lastRequestedAt === void 0) {
|
|
@@ -1362,33 +1241,6 @@ var UmbrellaStore = class {
|
|
|
1362
1241
|
this.#roomVersionsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1363
1242
|
}
|
|
1364
1243
|
}
|
|
1365
|
-
waitUntilRoomNotificationSettingsLoaded(roomId) {
|
|
1366
|
-
const queryKey = makeNotificationSettingsQueryKey(roomId);
|
|
1367
|
-
let resource = this.#roomNotificationSettings.get(queryKey);
|
|
1368
|
-
if (resource === void 0) {
|
|
1369
|
-
const notificationSettingsFetcher = async () => {
|
|
1370
|
-
const room = this.#client.getRoom(roomId);
|
|
1371
|
-
if (room === null) {
|
|
1372
|
-
throw new (0, _core.HttpError)(
|
|
1373
|
-
`Room '${roomId}' is not available on client`,
|
|
1374
|
-
479
|
|
1375
|
-
);
|
|
1376
|
-
}
|
|
1377
|
-
const result = await room.getNotificationSettings();
|
|
1378
|
-
this.roomNotificationSettings.update(roomId, result);
|
|
1379
|
-
};
|
|
1380
|
-
resource = new SinglePageResource(notificationSettingsFetcher);
|
|
1381
|
-
}
|
|
1382
|
-
resource.observable.subscribe(
|
|
1383
|
-
() => (
|
|
1384
|
-
// Note that the store itself does not change, but it's only vehicle at
|
|
1385
|
-
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1386
|
-
this.invalidateEntireStore()
|
|
1387
|
-
)
|
|
1388
|
-
);
|
|
1389
|
-
this.#roomNotificationSettings.set(queryKey, resource);
|
|
1390
|
-
return resource.waitUntilLoaded();
|
|
1391
|
-
}
|
|
1392
1244
|
async refreshRoomNotificationSettings(roomId, signal) {
|
|
1393
1245
|
const room = _core.nn.call(void 0,
|
|
1394
1246
|
this.#client.getRoom(roomId),
|
|
@@ -1620,7 +1472,7 @@ function applyUpsertComment(thread, comment) {
|
|
|
1620
1472
|
updatedAt: new Date(
|
|
1621
1473
|
Math.max(
|
|
1622
1474
|
thread.updatedAt.getTime(),
|
|
1623
|
-
_optionalChain([comment, 'access',
|
|
1475
|
+
_optionalChain([comment, 'access', _7 => _7.editedAt, 'optionalAccess', _8 => _8.getTime, 'call', _9 => _9()]) || comment.createdAt.getTime()
|
|
1624
1476
|
)
|
|
1625
1477
|
),
|
|
1626
1478
|
comments: updatedComments
|
|
@@ -1760,32 +1612,26 @@ function missingRoomInfoError(roomId) {
|
|
|
1760
1612
|
`resolveRoomsInfo didn't return anything for room '${roomId}'`
|
|
1761
1613
|
);
|
|
1762
1614
|
}
|
|
1763
|
-
function
|
|
1615
|
+
function identity2(x) {
|
|
1764
1616
|
return x;
|
|
1765
1617
|
}
|
|
1766
1618
|
var _umbrellaStores = /* @__PURE__ */ new WeakMap();
|
|
1767
1619
|
var _extras = /* @__PURE__ */ new WeakMap();
|
|
1768
1620
|
var _bundles = /* @__PURE__ */ new WeakMap();
|
|
1769
|
-
function selectUnreadInboxNotificationsCount(inboxNotifications) {
|
|
1770
|
-
let count = 0;
|
|
1771
|
-
for (const notification of inboxNotifications) {
|
|
1772
|
-
if (notification.readAt === null || notification.readAt < notification.notifiedAt) {
|
|
1773
|
-
count++;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
return count;
|
|
1777
|
-
}
|
|
1778
1621
|
function selectorFor_useUnreadInboxNotificationsCount(result) {
|
|
1779
1622
|
if (!result.inboxNotifications) {
|
|
1780
1623
|
return result;
|
|
1781
1624
|
}
|
|
1782
|
-
return
|
|
1783
|
-
|
|
1784
|
-
count
|
|
1785
|
-
|
|
1625
|
+
return ASYNC_OK(
|
|
1626
|
+
"count",
|
|
1627
|
+
count(
|
|
1628
|
+
result.inboxNotifications,
|
|
1629
|
+
(n) => n.readAt === null || n.readAt < n.notifiedAt
|
|
1630
|
+
)
|
|
1631
|
+
);
|
|
1786
1632
|
}
|
|
1787
1633
|
function selectorFor_useUser(state, userId) {
|
|
1788
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
1634
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _10 => _10.isLoading])) {
|
|
1789
1635
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
1790
1636
|
}
|
|
1791
1637
|
if (state.error) {
|
|
@@ -1803,7 +1649,7 @@ function selectorFor_useUser(state, userId) {
|
|
|
1803
1649
|
};
|
|
1804
1650
|
}
|
|
1805
1651
|
function selectorFor_useRoomInfo(state, roomId) {
|
|
1806
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
1652
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _11 => _11.isLoading])) {
|
|
1807
1653
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
1808
1654
|
}
|
|
1809
1655
|
if (state.error) {
|
|
@@ -1889,7 +1735,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1889
1735
|
const shared = createSharedContext(client);
|
|
1890
1736
|
const bundle = {
|
|
1891
1737
|
LiveblocksProvider: LiveblocksProvider2,
|
|
1892
|
-
useInboxNotifications: () => useInboxNotifications_withClient(client,
|
|
1738
|
+
useInboxNotifications: () => useInboxNotifications_withClient(client, identity2, _core.shallow),
|
|
1893
1739
|
useUnreadInboxNotificationsCount: () => useUnreadInboxNotificationsCount_withClient(client),
|
|
1894
1740
|
useMarkInboxNotificationAsRead: useMarkInboxNotificationAsRead2,
|
|
1895
1741
|
useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
|
|
@@ -1915,9 +1761,17 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1915
1761
|
}
|
|
1916
1762
|
function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
1917
1763
|
const { store, notificationsPoller: poller } = getLiveblocksExtrasForClient(client);
|
|
1918
|
-
_react.useEffect.call(void 0,
|
|
1919
|
-
void store.
|
|
1920
|
-
|
|
1764
|
+
_react.useEffect.call(void 0,
|
|
1765
|
+
() => void store.outputs.loadingNotifications.waitUntilLoaded()
|
|
1766
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
1767
|
+
//
|
|
1768
|
+
// It is important to call waitUntil on *every* render.
|
|
1769
|
+
// This is harmless though, on most renders, except:
|
|
1770
|
+
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
1771
|
+
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
1772
|
+
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
1773
|
+
// *next* render after that, a *new* fetch/promise will get created.
|
|
1774
|
+
);
|
|
1921
1775
|
_react.useEffect.call(void 0, () => {
|
|
1922
1776
|
poller.inc();
|
|
1923
1777
|
poller.pollNowIfStale();
|
|
@@ -1925,18 +1779,16 @@ function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
|
1925
1779
|
poller.dec();
|
|
1926
1780
|
};
|
|
1927
1781
|
}, [poller]);
|
|
1928
|
-
return
|
|
1929
|
-
store.
|
|
1930
|
-
store.getInboxNotificationsLoadingState,
|
|
1931
|
-
store.getInboxNotificationsLoadingState,
|
|
1782
|
+
return useSignal(
|
|
1783
|
+
store.outputs.loadingNotifications.signal,
|
|
1932
1784
|
selector,
|
|
1933
1785
|
isEqual
|
|
1934
1786
|
);
|
|
1935
1787
|
}
|
|
1936
1788
|
function useInboxNotificationsSuspense_withClient(client) {
|
|
1937
1789
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
1938
|
-
use(store.
|
|
1939
|
-
const result = useInboxNotifications_withClient(client,
|
|
1790
|
+
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
1791
|
+
const result = useInboxNotifications_withClient(client, identity2, _core.shallow);
|
|
1940
1792
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
1941
1793
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
1942
1794
|
return result;
|
|
@@ -1950,7 +1802,7 @@ function useUnreadInboxNotificationsCount_withClient(client) {
|
|
|
1950
1802
|
}
|
|
1951
1803
|
function useUnreadInboxNotificationsCountSuspense_withClient(client) {
|
|
1952
1804
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
1953
|
-
use(store.
|
|
1805
|
+
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
1954
1806
|
const result = useUnreadInboxNotificationsCount_withClient(client);
|
|
1955
1807
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
1956
1808
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
@@ -2042,34 +1894,31 @@ function useDeleteAllInboxNotifications_withClient(client) {
|
|
|
2042
1894
|
}
|
|
2043
1895
|
function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
2044
1896
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
(
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
)
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
getter,
|
|
2065
|
-
getter,
|
|
2066
|
-
selector
|
|
1897
|
+
return useSignal(
|
|
1898
|
+
store.outputs.threadifications,
|
|
1899
|
+
_react.useCallback.call(void 0,
|
|
1900
|
+
(state) => {
|
|
1901
|
+
const inboxNotification = _nullishCoalesce(state.notificationsById[inboxNotificationId], () => ( _core.raise.call(void 0,
|
|
1902
|
+
`Inbox notification with ID "${inboxNotificationId}" not found`
|
|
1903
|
+
)));
|
|
1904
|
+
if (inboxNotification.kind !== "thread") {
|
|
1905
|
+
_core.raise.call(void 0,
|
|
1906
|
+
`Inbox notification with ID "${inboxNotificationId}" is not of kind "thread"`
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
const thread = _nullishCoalesce(state.threadsDB.get(inboxNotification.threadId), () => ( _core.raise.call(void 0,
|
|
1910
|
+
`Thread with ID "${inboxNotification.threadId}" not found, this inbox notification might not be of kind "thread"`
|
|
1911
|
+
)));
|
|
1912
|
+
return thread;
|
|
1913
|
+
},
|
|
1914
|
+
[inboxNotificationId]
|
|
1915
|
+
)
|
|
2067
1916
|
);
|
|
2068
1917
|
}
|
|
2069
1918
|
function useUser_withClient(client, userId) {
|
|
2070
1919
|
const usersStore = client[_core.kInternal].usersStore;
|
|
2071
1920
|
const getUserState = _react.useCallback.call(void 0,
|
|
2072
|
-
() => usersStore.
|
|
1921
|
+
() => usersStore.getItemState(userId),
|
|
2073
1922
|
[usersStore, userId]
|
|
2074
1923
|
);
|
|
2075
1924
|
const selector = _react.useCallback.call(void 0,
|
|
@@ -2083,20 +1932,29 @@ function useUser_withClient(client, userId) {
|
|
|
2083
1932
|
selector,
|
|
2084
1933
|
_core.shallow
|
|
2085
1934
|
);
|
|
2086
|
-
_react.useEffect.call(void 0,
|
|
2087
|
-
void usersStore.
|
|
2088
|
-
|
|
1935
|
+
_react.useEffect.call(void 0,
|
|
1936
|
+
() => void usersStore.enqueue(userId)
|
|
1937
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
1938
|
+
//
|
|
1939
|
+
// It is important to call usersStore.enqueue on *every* render.
|
|
1940
|
+
// This is harmless though, on most renders, except:
|
|
1941
|
+
// 1. The very first render, in which case we'll want to trigger evaluation
|
|
1942
|
+
// of the userId.
|
|
1943
|
+
// 2. All other subsequent renders now are a no-op (from the implementation
|
|
1944
|
+
// of .enqueue)
|
|
1945
|
+
// 3. If ever the userId gets invalidated, the user would be fetched again.
|
|
1946
|
+
);
|
|
2089
1947
|
return result;
|
|
2090
1948
|
}
|
|
2091
1949
|
function useUserSuspense_withClient(client, userId) {
|
|
2092
1950
|
const usersStore = client[_core.kInternal].usersStore;
|
|
2093
1951
|
const getUserState = _react.useCallback.call(void 0,
|
|
2094
|
-
() => usersStore.
|
|
1952
|
+
() => usersStore.getItemState(userId),
|
|
2095
1953
|
[usersStore, userId]
|
|
2096
1954
|
);
|
|
2097
1955
|
const userState = getUserState();
|
|
2098
1956
|
if (!userState || userState.isLoading) {
|
|
2099
|
-
throw usersStore.
|
|
1957
|
+
throw usersStore.enqueue(userId);
|
|
2100
1958
|
}
|
|
2101
1959
|
if (userState.error) {
|
|
2102
1960
|
throw userState.error;
|
|
@@ -2121,7 +1979,7 @@ function useUserSuspense_withClient(client, userId) {
|
|
|
2121
1979
|
function useRoomInfo_withClient(client, roomId) {
|
|
2122
1980
|
const roomsInfoStore = client[_core.kInternal].roomsInfoStore;
|
|
2123
1981
|
const getRoomInfoState = _react.useCallback.call(void 0,
|
|
2124
|
-
() => roomsInfoStore.
|
|
1982
|
+
() => roomsInfoStore.getItemState(roomId),
|
|
2125
1983
|
[roomsInfoStore, roomId]
|
|
2126
1984
|
);
|
|
2127
1985
|
const selector = _react.useCallback.call(void 0,
|
|
@@ -2135,20 +1993,29 @@ function useRoomInfo_withClient(client, roomId) {
|
|
|
2135
1993
|
selector,
|
|
2136
1994
|
_core.shallow
|
|
2137
1995
|
);
|
|
2138
|
-
_react.useEffect.call(void 0,
|
|
2139
|
-
void roomsInfoStore.
|
|
2140
|
-
|
|
1996
|
+
_react.useEffect.call(void 0,
|
|
1997
|
+
() => void roomsInfoStore.enqueue(roomId)
|
|
1998
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
1999
|
+
//
|
|
2000
|
+
// It is important to call roomsInfoStore.enqueue on *every* render.
|
|
2001
|
+
// This is harmless though, on most renders, except:
|
|
2002
|
+
// 1. The very first render, in which case we'll want to trigger evaluation
|
|
2003
|
+
// of the roomId.
|
|
2004
|
+
// 2. All other subsequent renders now are a no-op (from the implementation
|
|
2005
|
+
// of .enqueue)
|
|
2006
|
+
// 3. If ever the roomId gets invalidated, the room info would be fetched again.
|
|
2007
|
+
);
|
|
2141
2008
|
return result;
|
|
2142
2009
|
}
|
|
2143
2010
|
function useRoomInfoSuspense_withClient(client, roomId) {
|
|
2144
2011
|
const roomsInfoStore = client[_core.kInternal].roomsInfoStore;
|
|
2145
2012
|
const getRoomInfoState = _react.useCallback.call(void 0,
|
|
2146
|
-
() => roomsInfoStore.
|
|
2013
|
+
() => roomsInfoStore.getItemState(roomId),
|
|
2147
2014
|
[roomsInfoStore, roomId]
|
|
2148
2015
|
);
|
|
2149
2016
|
const roomInfoState = getRoomInfoState();
|
|
2150
2017
|
if (!roomInfoState || roomInfoState.isLoading) {
|
|
2151
|
-
throw roomsInfoStore.
|
|
2018
|
+
throw roomsInfoStore.enqueue(roomId);
|
|
2152
2019
|
}
|
|
2153
2020
|
if (roomInfoState.error) {
|
|
2154
2021
|
throw roomInfoState.error;
|
|
@@ -2195,7 +2062,7 @@ function createSharedContext(client) {
|
|
|
2195
2062
|
}
|
|
2196
2063
|
function useEnsureNoLiveblocksProvider(options) {
|
|
2197
2064
|
const existing = useClientOrNull();
|
|
2198
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
2065
|
+
if (!_optionalChain([options, 'optionalAccess', _12 => _12.allowNesting]) && existing !== null) {
|
|
2199
2066
|
throw new Error(
|
|
2200
2067
|
"You cannot nest multiple LiveblocksProvider instances in the same React tree."
|
|
2201
2068
|
);
|
|
@@ -2243,17 +2110,12 @@ function LiveblocksProvider(props) {
|
|
|
2243
2110
|
function createLiveblocksContext(client) {
|
|
2244
2111
|
return getOrCreateContextBundle(client);
|
|
2245
2112
|
}
|
|
2246
|
-
function useUserThreads_experimental(options = {
|
|
2247
|
-
query: {
|
|
2248
|
-
metadata: {}
|
|
2249
|
-
}
|
|
2250
|
-
}) {
|
|
2113
|
+
function useUserThreads_experimental(options = {}) {
|
|
2251
2114
|
const client = useClient();
|
|
2252
2115
|
const { store, userThreadsPoller: poller } = getLiveblocksExtrasForClient(client);
|
|
2116
|
+
const queryKey = makeUserThreadsQueryKey(options.query);
|
|
2253
2117
|
_react.useEffect.call(void 0,
|
|
2254
|
-
() =>
|
|
2255
|
-
void store.waitUntilUserThreadsLoaded(options.query);
|
|
2256
|
-
}
|
|
2118
|
+
() => void store.outputs.loadingUserThreads.getOrCreate(queryKey).waitUntilLoaded()
|
|
2257
2119
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
2258
2120
|
//
|
|
2259
2121
|
// It is important to call waitUntil on *every* render.
|
|
@@ -2270,34 +2132,22 @@ function useUserThreads_experimental(options = {
|
|
|
2270
2132
|
poller.dec();
|
|
2271
2133
|
};
|
|
2272
2134
|
}, [poller]);
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
[store, options.query]
|
|
2276
|
-
);
|
|
2277
|
-
return useSyncExternalStoreWithSelector(
|
|
2278
|
-
store.subscribe1_threads,
|
|
2279
|
-
getter,
|
|
2280
|
-
getter,
|
|
2281
|
-
identity,
|
|
2282
|
-
shallow2
|
|
2283
|
-
// NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
|
|
2135
|
+
return useSignal(
|
|
2136
|
+
store.outputs.loadingUserThreads.getOrCreate(queryKey).signal
|
|
2284
2137
|
);
|
|
2285
2138
|
}
|
|
2286
|
-
function useUserThreadsSuspense_experimental(options = {
|
|
2287
|
-
query: {
|
|
2288
|
-
metadata: {}
|
|
2289
|
-
}
|
|
2290
|
-
}) {
|
|
2139
|
+
function useUserThreadsSuspense_experimental(options = {}) {
|
|
2291
2140
|
const client = useClient();
|
|
2292
2141
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
2293
|
-
|
|
2142
|
+
const queryKey = makeUserThreadsQueryKey(options.query);
|
|
2143
|
+
use(store.outputs.loadingUserThreads.getOrCreate(queryKey).waitUntilLoaded());
|
|
2294
2144
|
const result = useUserThreads_experimental(options);
|
|
2295
2145
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
2296
2146
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
2297
2147
|
return result;
|
|
2298
2148
|
}
|
|
2299
2149
|
function useInboxNotifications() {
|
|
2300
|
-
return useInboxNotifications_withClient(useClient(),
|
|
2150
|
+
return useInboxNotifications_withClient(useClient(), identity2, _core.shallow);
|
|
2301
2151
|
}
|
|
2302
2152
|
function useInboxNotificationsSuspense() {
|
|
2303
2153
|
return useInboxNotificationsSuspense_withClient(useClient());
|
|
@@ -2346,7 +2196,7 @@ var _useUserSuspense = useUserSuspense;
|
|
|
2346
2196
|
var _useUserThreads_experimental = useUserThreads_experimental;
|
|
2347
2197
|
var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
|
|
2348
2198
|
function useSyncStatus_withClient(client, options) {
|
|
2349
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2199
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.smooth]), () => ( false)));
|
|
2350
2200
|
if (smooth) {
|
|
2351
2201
|
return useSyncStatusSmooth_withClient(client);
|
|
2352
2202
|
} else {
|
|
@@ -2484,18 +2334,6 @@ var UpdateNotificationSettingsError = class extends Error {
|
|
|
2484
2334
|
}
|
|
2485
2335
|
};
|
|
2486
2336
|
|
|
2487
|
-
// src/use-signal.ts
|
|
2488
|
-
var identity2 = (value) => value;
|
|
2489
|
-
function useSignal(signal, selector, isEqual) {
|
|
2490
|
-
return useSyncExternalStoreWithSelector(
|
|
2491
|
-
signal.subscribe,
|
|
2492
|
-
signal.get,
|
|
2493
|
-
signal.get,
|
|
2494
|
-
_nullishCoalesce(selector, () => ( identity2)),
|
|
2495
|
-
isEqual
|
|
2496
|
-
);
|
|
2497
|
-
}
|
|
2498
|
-
|
|
2499
2337
|
// src/room.tsx
|
|
2500
2338
|
var _client = require('@liveblocks/client');
|
|
2501
2339
|
|
|
@@ -2518,6 +2356,7 @@ var _client = require('@liveblocks/client');
|
|
|
2518
2356
|
|
|
2519
2357
|
|
|
2520
2358
|
|
|
2359
|
+
|
|
2521
2360
|
|
|
2522
2361
|
|
|
2523
2362
|
// src/use-scroll-to-comment-on-load-effect.ts
|
|
@@ -2602,7 +2441,7 @@ function getCurrentUserId(client) {
|
|
|
2602
2441
|
}
|
|
2603
2442
|
function handleApiError(err) {
|
|
2604
2443
|
const message = `Request failed with status ${err.status}: ${err.message}`;
|
|
2605
|
-
if (_optionalChain([err, 'access',
|
|
2444
|
+
if (_optionalChain([err, 'access', _14 => _14.details, 'optionalAccess', _15 => _15.error]) === "FORBIDDEN") {
|
|
2606
2445
|
const detailedMessage = [message, err.details.suggestion, err.details.docs].filter(Boolean).join("\n");
|
|
2607
2446
|
_core.console.error(detailedMessage);
|
|
2608
2447
|
}
|
|
@@ -2642,73 +2481,59 @@ function makeRoomExtrasForClient(client) {
|
|
|
2642
2481
|
}
|
|
2643
2482
|
throw innerError;
|
|
2644
2483
|
}
|
|
2645
|
-
const threadsPollersByRoomId =
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
}
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
let poller = roomNotificationSettingsPollersByRoomId.get(roomId);
|
|
2688
|
-
if (!poller) {
|
|
2689
|
-
poller = _core.makePoller.call(void 0,
|
|
2690
|
-
async (signal) => {
|
|
2691
|
-
try {
|
|
2692
|
-
return await store.refreshRoomNotificationSettings(roomId, signal);
|
|
2693
|
-
} catch (err) {
|
|
2694
|
-
_core.console.warn(`Polling notification settings for '${roomId}' failed: ${String(err)}`);
|
|
2695
|
-
throw err;
|
|
2696
|
-
}
|
|
2697
|
-
},
|
|
2698
|
-
config.NOTIFICATION_SETTINGS_POLL_INTERVAL,
|
|
2699
|
-
{ maxStaleTimeMs: config.NOTIFICATION_SETTINGS_MAX_STALE_TIME }
|
|
2700
|
-
);
|
|
2701
|
-
roomNotificationSettingsPollersByRoomId.set(roomId, poller);
|
|
2702
|
-
}
|
|
2703
|
-
return poller;
|
|
2704
|
-
}
|
|
2484
|
+
const threadsPollersByRoomId = new (0, _core.DefaultMap)(
|
|
2485
|
+
(roomId) => _core.makePoller.call(void 0,
|
|
2486
|
+
async (signal) => {
|
|
2487
|
+
try {
|
|
2488
|
+
return await store.fetchRoomThreadsDeltaUpdate(roomId, signal);
|
|
2489
|
+
} catch (err) {
|
|
2490
|
+
_core.console.warn(`Polling new threads for '${roomId}' failed: ${String(err)}`);
|
|
2491
|
+
throw err;
|
|
2492
|
+
}
|
|
2493
|
+
},
|
|
2494
|
+
config.ROOM_THREADS_POLL_INTERVAL,
|
|
2495
|
+
{ maxStaleTimeMs: config.ROOM_THREADS_MAX_STALE_TIME }
|
|
2496
|
+
)
|
|
2497
|
+
);
|
|
2498
|
+
const versionsPollersByRoomId = new (0, _core.DefaultMap)(
|
|
2499
|
+
(roomId) => _core.makePoller.call(void 0,
|
|
2500
|
+
async (signal) => {
|
|
2501
|
+
try {
|
|
2502
|
+
return await store.fetchRoomVersionsDeltaUpdate(roomId, signal);
|
|
2503
|
+
} catch (err) {
|
|
2504
|
+
_core.console.warn(`Polling new history versions for '${roomId}' failed: ${String(err)}`);
|
|
2505
|
+
throw err;
|
|
2506
|
+
}
|
|
2507
|
+
},
|
|
2508
|
+
config.HISTORY_VERSIONS_POLL_INTERVAL,
|
|
2509
|
+
{ maxStaleTimeMs: config.HISTORY_VERSIONS_MAX_STALE_TIME }
|
|
2510
|
+
)
|
|
2511
|
+
);
|
|
2512
|
+
const roomNotificationSettingsPollersByRoomId = new (0, _core.DefaultMap)(
|
|
2513
|
+
(roomId) => _core.makePoller.call(void 0,
|
|
2514
|
+
async (signal) => {
|
|
2515
|
+
try {
|
|
2516
|
+
return await store.refreshRoomNotificationSettings(roomId, signal);
|
|
2517
|
+
} catch (err) {
|
|
2518
|
+
_core.console.warn(`Polling notification settings for '${roomId}' failed: ${String(err)}`);
|
|
2519
|
+
throw err;
|
|
2520
|
+
}
|
|
2521
|
+
},
|
|
2522
|
+
config.NOTIFICATION_SETTINGS_POLL_INTERVAL,
|
|
2523
|
+
{ maxStaleTimeMs: config.NOTIFICATION_SETTINGS_MAX_STALE_TIME }
|
|
2524
|
+
)
|
|
2525
|
+
);
|
|
2705
2526
|
return {
|
|
2706
2527
|
store,
|
|
2707
2528
|
commentsErrorEventSource: commentsErrorEventSource.observable,
|
|
2708
2529
|
onMutationFailure,
|
|
2709
|
-
getOrCreateThreadsPollerForRoomId
|
|
2710
|
-
|
|
2711
|
-
|
|
2530
|
+
getOrCreateThreadsPollerForRoomId: threadsPollersByRoomId.getOrCreate.bind(
|
|
2531
|
+
threadsPollersByRoomId
|
|
2532
|
+
),
|
|
2533
|
+
getOrCreateVersionsPollerForRoomId: versionsPollersByRoomId.getOrCreate.bind(versionsPollersByRoomId),
|
|
2534
|
+
getOrCreateNotificationsSettingsPollerForRoomId: roomNotificationSettingsPollersByRoomId.getOrCreate.bind(
|
|
2535
|
+
roomNotificationSettingsPollersByRoomId
|
|
2536
|
+
)
|
|
2712
2537
|
};
|
|
2713
2538
|
}
|
|
2714
2539
|
function makeRoomContextBundle(client) {
|
|
@@ -2852,7 +2677,7 @@ function RoomProviderInner(props) {
|
|
|
2852
2677
|
"RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required"
|
|
2853
2678
|
);
|
|
2854
2679
|
}
|
|
2855
|
-
if (
|
|
2680
|
+
if (typeof roomId !== "string") {
|
|
2856
2681
|
throw new Error("RoomProvider id property should be a string.");
|
|
2857
2682
|
}
|
|
2858
2683
|
const majorReactVersion = parseInt(_react.version) || 1;
|
|
@@ -2887,7 +2712,7 @@ function RoomProviderInner(props) {
|
|
|
2887
2712
|
return;
|
|
2888
2713
|
}
|
|
2889
2714
|
const { thread, inboxNotification: maybeNotification } = info;
|
|
2890
|
-
const existingThread = store.
|
|
2715
|
+
const existingThread = store.outputs.threads.get().getEvenIfDeleted(message.threadId);
|
|
2891
2716
|
switch (message.type) {
|
|
2892
2717
|
case _core.ServerMsgCode.COMMENT_EDITED:
|
|
2893
2718
|
case _core.ServerMsgCode.THREAD_METADATA_UPDATED:
|
|
@@ -3005,7 +2830,7 @@ function useMentionSuggestionsCache() {
|
|
|
3005
2830
|
return client[_core.kInternal].mentionSuggestionsCache;
|
|
3006
2831
|
}
|
|
3007
2832
|
function useStorageStatus(options) {
|
|
3008
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2833
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.smooth]), () => ( false)));
|
|
3009
2834
|
if (smooth) {
|
|
3010
2835
|
return useStorageStatusSmooth();
|
|
3011
2836
|
} else {
|
|
@@ -3258,18 +3083,15 @@ function useMutation(callback, deps) {
|
|
|
3258
3083
|
[room, ...deps]
|
|
3259
3084
|
);
|
|
3260
3085
|
}
|
|
3261
|
-
function useThreads(options = {
|
|
3262
|
-
query: { metadata: {} }
|
|
3263
|
-
}) {
|
|
3086
|
+
function useThreads(options = {}) {
|
|
3264
3087
|
const { scrollOnLoad = true } = options;
|
|
3265
3088
|
const client = useClient();
|
|
3266
3089
|
const room = useRoom();
|
|
3267
3090
|
const { store, getOrCreateThreadsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3091
|
+
const queryKey = makeRoomThreadsQueryKey(room.id, options.query);
|
|
3268
3092
|
const poller = getOrCreateThreadsPollerForRoomId(room.id);
|
|
3269
3093
|
_react.useEffect.call(void 0,
|
|
3270
|
-
() =>
|
|
3271
|
-
void store.waitUntilRoomThreadsLoaded(room.id, options.query);
|
|
3272
|
-
}
|
|
3094
|
+
() => void store.outputs.loadingRoomThreads.getOrCreate(queryKey).waitUntilLoaded()
|
|
3273
3095
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
3274
3096
|
//
|
|
3275
3097
|
// It is important to call waitUntil on *every* render.
|
|
@@ -3284,20 +3106,11 @@ function useThreads(options = {
|
|
|
3284
3106
|
poller.pollNowIfStale();
|
|
3285
3107
|
return () => poller.dec();
|
|
3286
3108
|
}, [poller]);
|
|
3287
|
-
const
|
|
3288
|
-
|
|
3289
|
-
[store, room.id, options.query]
|
|
3109
|
+
const result = useSignal(
|
|
3110
|
+
store.outputs.loadingRoomThreads.getOrCreate(queryKey).signal
|
|
3290
3111
|
);
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
getter,
|
|
3294
|
-
getter,
|
|
3295
|
-
identity3,
|
|
3296
|
-
shallow2
|
|
3297
|
-
// NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
|
|
3298
|
-
);
|
|
3299
|
-
useScrollToCommentOnLoadEffect(scrollOnLoad, state);
|
|
3300
|
-
return state;
|
|
3112
|
+
useScrollToCommentOnLoadEffect(scrollOnLoad, result);
|
|
3113
|
+
return result;
|
|
3301
3114
|
}
|
|
3302
3115
|
function useCommentsErrorListener(callback) {
|
|
3303
3116
|
const client = useClient();
|
|
@@ -3347,7 +3160,7 @@ function useCreateRoomThread(roomId) {
|
|
|
3347
3160
|
thread: newThread,
|
|
3348
3161
|
roomId
|
|
3349
3162
|
});
|
|
3350
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3163
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _17 => _17.map, 'call', _18 => _18((attachment) => attachment.id)]);
|
|
3351
3164
|
client[_core.kInternal].httpClient.createThread({
|
|
3352
3165
|
roomId,
|
|
3353
3166
|
threadId,
|
|
@@ -3385,8 +3198,8 @@ function useDeleteRoomThread(roomId) {
|
|
|
3385
3198
|
(threadId) => {
|
|
3386
3199
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3387
3200
|
const userId = getCurrentUserId(client);
|
|
3388
|
-
const existing = store.
|
|
3389
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
3201
|
+
const existing = store.outputs.threads.get().get(threadId);
|
|
3202
|
+
if (_optionalChain([existing, 'optionalAccess', _19 => _19.comments, 'optionalAccess', _20 => _20[0], 'optionalAccess', _21 => _21.userId]) !== userId) {
|
|
3390
3203
|
throw new Error("Only the thread creator can delete the thread");
|
|
3391
3204
|
}
|
|
3392
3205
|
const optimisticId = store.optimisticUpdates.add({
|
|
@@ -3473,7 +3286,7 @@ function useCreateRoomComment(roomId) {
|
|
|
3473
3286
|
type: "create-comment",
|
|
3474
3287
|
comment
|
|
3475
3288
|
});
|
|
3476
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3289
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _22 => _22.map, 'call', _23 => _23((attachment) => attachment.id)]);
|
|
3477
3290
|
client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3478
3291
|
(newComment) => {
|
|
3479
3292
|
store.createComment(newComment, optimisticId);
|
|
@@ -3503,7 +3316,7 @@ function useEditRoomComment(roomId) {
|
|
|
3503
3316
|
({ threadId, commentId, body, attachments }) => {
|
|
3504
3317
|
const editedAt = /* @__PURE__ */ new Date();
|
|
3505
3318
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3506
|
-
const existing = store.
|
|
3319
|
+
const existing = store.outputs.threads.get().getEvenIfDeleted(threadId);
|
|
3507
3320
|
if (existing === void 0) {
|
|
3508
3321
|
_core.console.warn(
|
|
3509
3322
|
`Internal unexpected behavior. Cannot edit comment in thread "${threadId}" because the thread does not exist in the cache.`
|
|
@@ -3528,7 +3341,7 @@ function useEditRoomComment(roomId) {
|
|
|
3528
3341
|
attachments: _nullishCoalesce(attachments, () => ( []))
|
|
3529
3342
|
}
|
|
3530
3343
|
});
|
|
3531
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3344
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _24 => _24.map, 'call', _25 => _25((attachment) => attachment.id)]);
|
|
3532
3345
|
client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3533
3346
|
(editedComment) => {
|
|
3534
3347
|
store.editComment(threadId, optimisticId, editedComment);
|
|
@@ -3680,7 +3493,7 @@ function useMarkRoomThreadAsRead(roomId) {
|
|
|
3680
3493
|
(threadId) => {
|
|
3681
3494
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3682
3495
|
const inboxNotification = Object.values(
|
|
3683
|
-
store.
|
|
3496
|
+
store.outputs.notifications.get().notificationsById
|
|
3684
3497
|
).find(
|
|
3685
3498
|
(inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
|
|
3686
3499
|
);
|
|
@@ -3818,9 +3631,7 @@ function useRoomNotificationSettings() {
|
|
|
3818
3631
|
const { store, getOrCreateNotificationsSettingsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3819
3632
|
const poller = getOrCreateNotificationsSettingsPollerForRoomId(room.id);
|
|
3820
3633
|
_react.useEffect.call(void 0,
|
|
3821
|
-
() =>
|
|
3822
|
-
void store.waitUntilRoomNotificationSettingsLoaded(room.id);
|
|
3823
|
-
}
|
|
3634
|
+
() => void store.outputs.settingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
|
|
3824
3635
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
3825
3636
|
//
|
|
3826
3637
|
// It is important to call waitUntil on *every* render.
|
|
@@ -3837,16 +3648,8 @@ function useRoomNotificationSettings() {
|
|
|
3837
3648
|
poller.dec();
|
|
3838
3649
|
};
|
|
3839
3650
|
}, [poller]);
|
|
3840
|
-
const
|
|
3841
|
-
|
|
3842
|
-
[store, room.id]
|
|
3843
|
-
);
|
|
3844
|
-
const settings = useSyncExternalStoreWithSelector(
|
|
3845
|
-
store.subscribe2,
|
|
3846
|
-
getter,
|
|
3847
|
-
getter,
|
|
3848
|
-
identity3,
|
|
3849
|
-
shallow2
|
|
3651
|
+
const settings = useSignal(
|
|
3652
|
+
store.outputs.settingsByRoomId.getOrCreate(room.id).signal
|
|
3850
3653
|
);
|
|
3851
3654
|
return _react.useMemo.call(void 0, () => {
|
|
3852
3655
|
return [settings, updateRoomNotificationSettings];
|
|
@@ -3856,7 +3659,7 @@ function useRoomNotificationSettingsSuspense() {
|
|
|
3856
3659
|
const client = useClient();
|
|
3857
3660
|
const store = getRoomExtrasForClient(client).store;
|
|
3858
3661
|
const room = useRoom();
|
|
3859
|
-
use(store.
|
|
3662
|
+
use(store.outputs.settingsByRoomId.getOrCreate(room.id).waitUntilLoaded());
|
|
3860
3663
|
const [settings, updateRoomNotificationSettings] = useRoomNotificationSettings();
|
|
3861
3664
|
_core.assert.call(void 0, !settings.error, "Did not expect error");
|
|
3862
3665
|
_core.assert.call(void 0, !settings.isLoading, "Did not expect loading");
|
|
@@ -3903,14 +3706,8 @@ function useHistoryVersions() {
|
|
|
3903
3706
|
poller.pollNowIfStale();
|
|
3904
3707
|
return () => poller.dec();
|
|
3905
3708
|
}, [poller]);
|
|
3906
|
-
const getter = _react.useCallback.call(void 0,
|
|
3907
|
-
() => store.getRoomVersionsLoadingState(room.id),
|
|
3908
|
-
[store, room.id]
|
|
3909
|
-
);
|
|
3910
3709
|
_react.useEffect.call(void 0,
|
|
3911
|
-
() =>
|
|
3912
|
-
void store.waitUntilRoomVersionsLoaded(room.id);
|
|
3913
|
-
}
|
|
3710
|
+
() => void store.outputs.versionsByRoomId.getOrCreate(room.id).waitUntilLoaded()
|
|
3914
3711
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
3915
3712
|
//
|
|
3916
3713
|
// It is important to call waitUntil on *every* render.
|
|
@@ -3920,20 +3717,13 @@ function useHistoryVersions() {
|
|
|
3920
3717
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3921
3718
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3922
3719
|
);
|
|
3923
|
-
|
|
3924
|
-
store.subscribe3,
|
|
3925
|
-
getter,
|
|
3926
|
-
getter,
|
|
3927
|
-
identity3,
|
|
3928
|
-
shallow2
|
|
3929
|
-
);
|
|
3930
|
-
return state;
|
|
3720
|
+
return useSignal(store.outputs.versionsByRoomId.getOrCreate(room.id).signal);
|
|
3931
3721
|
}
|
|
3932
3722
|
function useHistoryVersionsSuspense() {
|
|
3933
3723
|
const client = useClient();
|
|
3934
3724
|
const room = useRoom();
|
|
3935
3725
|
const store = getRoomExtrasForClient(client).store;
|
|
3936
|
-
use(store.
|
|
3726
|
+
use(store.outputs.versionsByRoomId.getOrCreate(room.id).waitUntilLoaded());
|
|
3937
3727
|
const result = useHistoryVersions();
|
|
3938
3728
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
3939
3729
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
@@ -4020,20 +3810,19 @@ function useStorageStatusSuspense(options) {
|
|
|
4020
3810
|
useSuspendUntilStorageReady();
|
|
4021
3811
|
return useStorageStatus(options);
|
|
4022
3812
|
}
|
|
4023
|
-
function useThreadsSuspense(options = {
|
|
4024
|
-
query: { metadata: {} }
|
|
4025
|
-
}) {
|
|
3813
|
+
function useThreadsSuspense(options = {}) {
|
|
4026
3814
|
const client = useClient();
|
|
4027
3815
|
const room = useRoom();
|
|
4028
3816
|
const { store } = getRoomExtrasForClient(client);
|
|
4029
|
-
|
|
3817
|
+
const queryKey = makeRoomThreadsQueryKey(room.id, options.query);
|
|
3818
|
+
use(store.outputs.loadingRoomThreads.getOrCreate(queryKey).waitUntilLoaded());
|
|
4030
3819
|
const result = useThreads(options);
|
|
4031
3820
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
4032
3821
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
4033
3822
|
return result;
|
|
4034
3823
|
}
|
|
4035
3824
|
function selectorFor_useAttachmentUrl(state) {
|
|
4036
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
3825
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _26 => _26.isLoading])) {
|
|
4037
3826
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
4038
3827
|
}
|
|
4039
3828
|
if (state.error) {
|
|
@@ -4053,11 +3842,11 @@ function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
|
4053
3842
|
const client = useClient();
|
|
4054
3843
|
const store = client[_core.kInternal].httpClient.getOrCreateAttachmentUrlsStore(roomId);
|
|
4055
3844
|
const getAttachmentUrlState = _react.useCallback.call(void 0,
|
|
4056
|
-
() => store.
|
|
3845
|
+
() => store.getItemState(attachmentId),
|
|
4057
3846
|
[store, attachmentId]
|
|
4058
3847
|
);
|
|
4059
3848
|
_react.useEffect.call(void 0, () => {
|
|
4060
|
-
void store.
|
|
3849
|
+
void store.enqueue(attachmentId);
|
|
4061
3850
|
}, [store, attachmentId]);
|
|
4062
3851
|
return useSyncExternalStoreWithSelector(
|
|
4063
3852
|
store.subscribe,
|
|
@@ -4071,12 +3860,12 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
4071
3860
|
const room = useRoom();
|
|
4072
3861
|
const { attachmentUrlsStore } = room[_core.kInternal];
|
|
4073
3862
|
const getAttachmentUrlState = _react.useCallback.call(void 0,
|
|
4074
|
-
() => attachmentUrlsStore.
|
|
3863
|
+
() => attachmentUrlsStore.getItemState(attachmentId),
|
|
4075
3864
|
[attachmentUrlsStore, attachmentId]
|
|
4076
3865
|
);
|
|
4077
3866
|
const attachmentUrlState = getAttachmentUrlState();
|
|
4078
3867
|
if (!attachmentUrlState || attachmentUrlState.isLoading) {
|
|
4079
|
-
throw attachmentUrlsStore.
|
|
3868
|
+
throw attachmentUrlsStore.enqueue(attachmentId);
|
|
4080
3869
|
}
|
|
4081
3870
|
if (attachmentUrlState.error) {
|
|
4082
3871
|
throw attachmentUrlState.error;
|
|
@@ -4095,12 +3884,13 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
4095
3884
|
error: void 0
|
|
4096
3885
|
};
|
|
4097
3886
|
}
|
|
3887
|
+
var NO_PERMISSIONS = /* @__PURE__ */ new Set();
|
|
4098
3888
|
function useRoomPermissions(roomId) {
|
|
4099
3889
|
const client = useClient();
|
|
4100
3890
|
const store = getRoomExtrasForClient(client).store;
|
|
4101
3891
|
return useSignal(
|
|
4102
3892
|
store.permissionHints.signal,
|
|
4103
|
-
(hints) => _nullishCoalesce(hints
|
|
3893
|
+
(hints) => _nullishCoalesce(hints.get(roomId), () => ( NO_PERMISSIONS))
|
|
4104
3894
|
);
|
|
4105
3895
|
}
|
|
4106
3896
|
function createRoomContext(client) {
|
|
@@ -4249,5 +4039,5 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
4249
4039
|
|
|
4250
4040
|
|
|
4251
4041
|
|
|
4252
|
-
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.
|
|
4253
|
-
//# sourceMappingURL=chunk-
|
|
4042
|
+
exports.RoomContext = RoomContext; exports.useRoomOrNull = useRoomOrNull; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; 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.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;
|
|
4043
|
+
//# sourceMappingURL=chunk-VJYVOAD5.js.map
|