@liveblocks/react 2.7.1 → 2.7.2
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/{chunk-XK5NTOJJ.mjs → chunk-QC6HYSYS.mjs} +227 -252
- package/dist/chunk-QC6HYSYS.mjs.map +1 -0
- package/dist/{chunk-TNEGW2UU.js → chunk-TGC7HD5F.js} +237 -262
- package/dist/chunk-TGC7HD5F.js.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +1 -1
- package/dist/{suspense-ZevLSpFZ.d.mts → suspense-dtola__O.d.mts} +16 -7
- package/dist/{suspense-ZevLSpFZ.d.ts → suspense-dtola__O.d.ts} +16 -7
- package/dist/suspense.d.mts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +3 -3
- package/dist/suspense.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-TNEGW2UU.js.map +0 -1
- package/dist/chunk-XK5NTOJJ.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.7.
|
|
3
|
+
var PKG_VERSION = "2.7.2";
|
|
4
4
|
var PKG_FORMAT = "cjs";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -198,6 +198,16 @@ var use = (
|
|
|
198
198
|
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
|
|
202
|
+
var QUERY_STATE_LOADING = Object.freeze({ isLoading: true });
|
|
203
|
+
var QUERY_STATE_OK = Object.freeze({ isLoading: false, data: void 0 });
|
|
204
|
+
var INBOX_NOTIFICATIONS_QUERY = "INBOX_NOTIFICATIONS";
|
|
205
|
+
function makeNotificationSettingsQueryKey(roomId) {
|
|
206
|
+
return `${roomId}:NOTIFICATION_SETTINGS`;
|
|
207
|
+
}
|
|
208
|
+
function makeVersionsQueryKey(roomId) {
|
|
209
|
+
return `${roomId}-VERSIONS`;
|
|
210
|
+
}
|
|
201
211
|
var UmbrellaStore = class {
|
|
202
212
|
constructor() {
|
|
203
213
|
this._prevState = null;
|
|
@@ -212,8 +222,7 @@ var UmbrellaStore = class {
|
|
|
212
222
|
});
|
|
213
223
|
this.getThreads = this.getThreads.bind(this);
|
|
214
224
|
this.getInboxNotifications = this.getInboxNotifications.bind(this);
|
|
215
|
-
this.
|
|
216
|
-
this.getVersions = this.getVersions.bind(this);
|
|
225
|
+
this.getInboxNotificationsAsync = this.getInboxNotificationsAsync.bind(this);
|
|
217
226
|
this.subscribeThreads = this.subscribeThreads.bind(this);
|
|
218
227
|
this.subscribeInboxNotifications = this.subscribeInboxNotifications.bind(this);
|
|
219
228
|
this.subscribeNotificationSettings = this.subscribeNotificationSettings.bind(this);
|
|
@@ -225,7 +234,7 @@ var UmbrellaStore = class {
|
|
|
225
234
|
const rawState = this._store.get();
|
|
226
235
|
if (this._prevState !== rawState || this._stateCached === null) {
|
|
227
236
|
this._prevState = rawState;
|
|
228
|
-
this._stateCached =
|
|
237
|
+
this._stateCached = internalToExternalState(rawState);
|
|
229
238
|
}
|
|
230
239
|
return this._stateCached;
|
|
231
240
|
}
|
|
@@ -235,11 +244,47 @@ var UmbrellaStore = class {
|
|
|
235
244
|
getInboxNotifications() {
|
|
236
245
|
return this.get();
|
|
237
246
|
}
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
248
|
+
getInboxNotificationsAsync() {
|
|
249
|
+
const internalState = this._store.get();
|
|
250
|
+
const query = internalState.queries[INBOX_NOTIFICATIONS_QUERY];
|
|
251
|
+
if (query === void 0 || query.isLoading) {
|
|
252
|
+
return QUERY_STATE_LOADING;
|
|
253
|
+
}
|
|
254
|
+
if (query.error !== void 0) {
|
|
255
|
+
return query;
|
|
256
|
+
}
|
|
257
|
+
const inboxNotifications = this.get().inboxNotifications;
|
|
258
|
+
return { isLoading: false, inboxNotifications };
|
|
259
|
+
}
|
|
260
|
+
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
261
|
+
getNotificationSettingsAsync(roomId) {
|
|
262
|
+
const state = this.get();
|
|
263
|
+
const query = state.queries[makeNotificationSettingsQueryKey(roomId)];
|
|
264
|
+
if (query === void 0 || query.isLoading) {
|
|
265
|
+
return QUERY_STATE_LOADING;
|
|
266
|
+
}
|
|
267
|
+
if (query.error !== void 0) {
|
|
268
|
+
return query;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
isLoading: false,
|
|
272
|
+
settings: _core.nn.call(void 0, state.notificationSettingsByRoomId[roomId])
|
|
273
|
+
};
|
|
240
274
|
}
|
|
241
|
-
|
|
242
|
-
|
|
275
|
+
getVersionsAsync(roomId) {
|
|
276
|
+
const state = this.get();
|
|
277
|
+
const query = state.queries[makeVersionsQueryKey(roomId)];
|
|
278
|
+
if (query === void 0 || query.isLoading) {
|
|
279
|
+
return QUERY_STATE_LOADING;
|
|
280
|
+
}
|
|
281
|
+
if (query.error !== void 0) {
|
|
282
|
+
return query;
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
isLoading: false,
|
|
286
|
+
versions: _core.nn.call(void 0, state.versionsByRoomId[roomId])
|
|
287
|
+
};
|
|
243
288
|
}
|
|
244
289
|
/**
|
|
245
290
|
* @private Only used by the E2E test suite.
|
|
@@ -574,29 +619,29 @@ var UmbrellaStore = class {
|
|
|
574
619
|
// Query State APIs
|
|
575
620
|
//
|
|
576
621
|
setQueryLoading(queryKey) {
|
|
577
|
-
this.setQueryState(queryKey,
|
|
622
|
+
this.setQueryState(queryKey, QUERY_STATE_LOADING);
|
|
578
623
|
}
|
|
579
624
|
setQueryOK(queryKey) {
|
|
580
|
-
this.setQueryState(queryKey,
|
|
625
|
+
this.setQueryState(queryKey, QUERY_STATE_OK);
|
|
581
626
|
}
|
|
582
627
|
setQueryError(queryKey, error) {
|
|
583
628
|
this.setQueryState(queryKey, { isLoading: false, error });
|
|
584
629
|
}
|
|
585
630
|
};
|
|
586
|
-
function
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
631
|
+
function internalToExternalState(state) {
|
|
632
|
+
const computed = {
|
|
633
|
+
threadsById: { ...state.rawThreadsById },
|
|
634
|
+
inboxNotificationsById: { ...state.inboxNotificationsById },
|
|
635
|
+
notificationSettingsByRoomId: { ...state.notificationSettingsByRoomId }
|
|
591
636
|
};
|
|
592
637
|
for (const optimisticUpdate of state.optimisticUpdates) {
|
|
593
638
|
switch (optimisticUpdate.type) {
|
|
594
639
|
case "create-thread": {
|
|
595
|
-
|
|
640
|
+
computed.threadsById[optimisticUpdate.thread.id] = optimisticUpdate.thread;
|
|
596
641
|
break;
|
|
597
642
|
}
|
|
598
643
|
case "edit-thread-metadata": {
|
|
599
|
-
const thread =
|
|
644
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
600
645
|
if (thread === void 0) {
|
|
601
646
|
break;
|
|
602
647
|
}
|
|
@@ -606,7 +651,7 @@ function applyOptimisticUpdates(state) {
|
|
|
606
651
|
if (thread.updatedAt !== void 0 && thread.updatedAt > optimisticUpdate.updatedAt) {
|
|
607
652
|
break;
|
|
608
653
|
}
|
|
609
|
-
|
|
654
|
+
computed.threadsById[thread.id] = {
|
|
610
655
|
...thread,
|
|
611
656
|
updatedAt: optimisticUpdate.updatedAt,
|
|
612
657
|
metadata: {
|
|
@@ -617,49 +662,51 @@ function applyOptimisticUpdates(state) {
|
|
|
617
662
|
break;
|
|
618
663
|
}
|
|
619
664
|
case "mark-thread-as-resolved": {
|
|
620
|
-
const thread =
|
|
665
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
621
666
|
if (thread === void 0) {
|
|
622
667
|
break;
|
|
623
668
|
}
|
|
624
669
|
if (thread.deletedAt !== void 0) {
|
|
625
670
|
break;
|
|
626
671
|
}
|
|
627
|
-
|
|
672
|
+
computed.threadsById[thread.id] = {
|
|
628
673
|
...thread,
|
|
629
674
|
resolved: true
|
|
630
675
|
};
|
|
631
676
|
break;
|
|
632
677
|
}
|
|
633
678
|
case "mark-thread-as-unresolved": {
|
|
634
|
-
const thread =
|
|
679
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
635
680
|
if (thread === void 0) {
|
|
636
681
|
break;
|
|
637
682
|
}
|
|
638
683
|
if (thread.deletedAt !== void 0) {
|
|
639
684
|
break;
|
|
640
685
|
}
|
|
641
|
-
|
|
686
|
+
computed.threadsById[thread.id] = {
|
|
642
687
|
...thread,
|
|
643
688
|
resolved: false
|
|
644
689
|
};
|
|
645
690
|
break;
|
|
646
691
|
}
|
|
647
692
|
case "create-comment": {
|
|
648
|
-
const thread =
|
|
693
|
+
const thread = computed.threadsById[optimisticUpdate.comment.threadId];
|
|
649
694
|
if (thread === void 0) {
|
|
650
695
|
break;
|
|
651
696
|
}
|
|
652
|
-
|
|
697
|
+
computed.threadsById[thread.id] = applyUpsertComment(
|
|
653
698
|
thread,
|
|
654
699
|
optimisticUpdate.comment
|
|
655
700
|
);
|
|
656
|
-
const inboxNotification = Object.values(
|
|
701
|
+
const inboxNotification = Object.values(
|
|
702
|
+
computed.inboxNotificationsById
|
|
703
|
+
).find(
|
|
657
704
|
(notification) => notification.kind === "thread" && notification.threadId === thread.id
|
|
658
705
|
);
|
|
659
706
|
if (inboxNotification === void 0) {
|
|
660
707
|
break;
|
|
661
708
|
}
|
|
662
|
-
|
|
709
|
+
computed.inboxNotificationsById[inboxNotification.id] = {
|
|
663
710
|
...inboxNotification,
|
|
664
711
|
notifiedAt: optimisticUpdate.comment.createdAt,
|
|
665
712
|
readAt: optimisticUpdate.comment.createdAt
|
|
@@ -667,22 +714,22 @@ function applyOptimisticUpdates(state) {
|
|
|
667
714
|
break;
|
|
668
715
|
}
|
|
669
716
|
case "edit-comment": {
|
|
670
|
-
const thread =
|
|
717
|
+
const thread = computed.threadsById[optimisticUpdate.comment.threadId];
|
|
671
718
|
if (thread === void 0) {
|
|
672
719
|
break;
|
|
673
720
|
}
|
|
674
|
-
|
|
721
|
+
computed.threadsById[thread.id] = applyUpsertComment(
|
|
675
722
|
thread,
|
|
676
723
|
optimisticUpdate.comment
|
|
677
724
|
);
|
|
678
725
|
break;
|
|
679
726
|
}
|
|
680
727
|
case "delete-comment": {
|
|
681
|
-
const thread =
|
|
728
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
682
729
|
if (thread === void 0) {
|
|
683
730
|
break;
|
|
684
731
|
}
|
|
685
|
-
|
|
732
|
+
computed.threadsById[thread.id] = applyDeleteComment(
|
|
686
733
|
thread,
|
|
687
734
|
optimisticUpdate.commentId,
|
|
688
735
|
optimisticUpdate.deletedAt
|
|
@@ -690,12 +737,12 @@ function applyOptimisticUpdates(state) {
|
|
|
690
737
|
break;
|
|
691
738
|
}
|
|
692
739
|
case "delete-thread": {
|
|
693
|
-
const thread =
|
|
740
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
694
741
|
if (thread === void 0) {
|
|
695
742
|
break;
|
|
696
743
|
}
|
|
697
|
-
|
|
698
|
-
...
|
|
744
|
+
computed.threadsById[optimisticUpdate.threadId] = {
|
|
745
|
+
...thread,
|
|
699
746
|
deletedAt: optimisticUpdate.deletedAt,
|
|
700
747
|
updatedAt: optimisticUpdate.deletedAt,
|
|
701
748
|
comments: []
|
|
@@ -703,11 +750,11 @@ function applyOptimisticUpdates(state) {
|
|
|
703
750
|
break;
|
|
704
751
|
}
|
|
705
752
|
case "add-reaction": {
|
|
706
|
-
const thread =
|
|
753
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
707
754
|
if (thread === void 0) {
|
|
708
755
|
break;
|
|
709
756
|
}
|
|
710
|
-
|
|
757
|
+
computed.threadsById[thread.id] = applyAddReaction(
|
|
711
758
|
thread,
|
|
712
759
|
optimisticUpdate.commentId,
|
|
713
760
|
optimisticUpdate.reaction
|
|
@@ -715,11 +762,11 @@ function applyOptimisticUpdates(state) {
|
|
|
715
762
|
break;
|
|
716
763
|
}
|
|
717
764
|
case "remove-reaction": {
|
|
718
|
-
const thread =
|
|
765
|
+
const thread = computed.threadsById[optimisticUpdate.threadId];
|
|
719
766
|
if (thread === void 0) {
|
|
720
767
|
break;
|
|
721
768
|
}
|
|
722
|
-
|
|
769
|
+
computed.threadsById[thread.id] = applyRemoveReaction(
|
|
723
770
|
thread,
|
|
724
771
|
optimisticUpdate.commentId,
|
|
725
772
|
optimisticUpdate.emoji,
|
|
@@ -729,36 +776,41 @@ function applyOptimisticUpdates(state) {
|
|
|
729
776
|
break;
|
|
730
777
|
}
|
|
731
778
|
case "mark-inbox-notification-as-read": {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
}
|
|
779
|
+
const ibn = computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId];
|
|
780
|
+
if (ibn === void 0) {
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId] = { ...ibn, readAt: optimisticUpdate.readAt };
|
|
736
784
|
break;
|
|
737
785
|
}
|
|
738
786
|
case "mark-all-inbox-notifications-as-read": {
|
|
739
|
-
for (const id in
|
|
740
|
-
|
|
741
|
-
|
|
787
|
+
for (const id in computed.inboxNotificationsById) {
|
|
788
|
+
const ibn = computed.inboxNotificationsById[id];
|
|
789
|
+
if (ibn === void 0) {
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
computed.inboxNotificationsById[id] = {
|
|
793
|
+
...ibn,
|
|
742
794
|
readAt: optimisticUpdate.readAt
|
|
743
795
|
};
|
|
744
796
|
}
|
|
745
797
|
break;
|
|
746
798
|
}
|
|
747
799
|
case "delete-inbox-notification": {
|
|
748
|
-
|
|
749
|
-
[optimisticUpdate.inboxNotificationId]: _,
|
|
750
|
-
...inboxNotifications
|
|
751
|
-
} = output.inboxNotifications;
|
|
752
|
-
output.inboxNotifications = inboxNotifications;
|
|
800
|
+
delete computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId];
|
|
753
801
|
break;
|
|
754
802
|
}
|
|
755
803
|
case "delete-all-inbox-notifications": {
|
|
756
|
-
|
|
804
|
+
computed.inboxNotificationsById = {};
|
|
757
805
|
break;
|
|
758
806
|
}
|
|
759
807
|
case "update-notification-settings": {
|
|
760
|
-
|
|
761
|
-
|
|
808
|
+
const settings = computed.notificationSettingsByRoomId[optimisticUpdate.roomId];
|
|
809
|
+
if (settings === void 0) {
|
|
810
|
+
break;
|
|
811
|
+
}
|
|
812
|
+
computed.notificationSettingsByRoomId[optimisticUpdate.roomId] = {
|
|
813
|
+
...settings,
|
|
762
814
|
...optimisticUpdate.settings
|
|
763
815
|
};
|
|
764
816
|
}
|
|
@@ -766,23 +818,26 @@ function applyOptimisticUpdates(state) {
|
|
|
766
818
|
}
|
|
767
819
|
const cleanedThreads = (
|
|
768
820
|
// Don't expose any soft-deleted threads
|
|
769
|
-
Object.values(
|
|
770
|
-
(thread) =>
|
|
821
|
+
Object.values(computed.threadsById).filter((thread) => !thread.deletedAt).filter(
|
|
822
|
+
(thread) => (
|
|
823
|
+
// Only keep a thread if there is at least one non-deleted comment
|
|
824
|
+
thread.comments.some((c) => c.deletedAt === void 0)
|
|
825
|
+
)
|
|
771
826
|
)
|
|
772
827
|
);
|
|
773
828
|
const cleanedNotifications = (
|
|
774
829
|
// Sort so that the most recent notifications are first
|
|
775
|
-
Object.values(
|
|
776
|
-
(
|
|
777
|
-
)
|
|
830
|
+
Object.values(computed.inboxNotificationsById).filter(
|
|
831
|
+
(ibn) => ibn.kind === "thread" ? computed.threadsById[ibn.threadId] && _optionalChain([computed, 'access', _ => _.threadsById, 'access', _2 => _2[ibn.threadId], 'optionalAccess', _3 => _3.deletedAt]) === void 0 : true
|
|
832
|
+
).sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime())
|
|
778
833
|
);
|
|
779
834
|
return {
|
|
780
835
|
inboxNotifications: cleanedNotifications,
|
|
781
|
-
inboxNotificationsById:
|
|
782
|
-
notificationSettingsByRoomId:
|
|
836
|
+
inboxNotificationsById: computed.inboxNotificationsById,
|
|
837
|
+
notificationSettingsByRoomId: computed.notificationSettingsByRoomId,
|
|
783
838
|
queries: state.queries,
|
|
784
839
|
threads: cleanedThreads,
|
|
785
|
-
threadsById:
|
|
840
|
+
threadsById: computed.threadsById,
|
|
786
841
|
versionsByRoomId: state.versionsByRoomId
|
|
787
842
|
};
|
|
788
843
|
}
|
|
@@ -852,7 +907,7 @@ function applyUpsertComment(thread, comment) {
|
|
|
852
907
|
);
|
|
853
908
|
if (existingComment === void 0) {
|
|
854
909
|
const updatedAt = new Date(
|
|
855
|
-
Math.max(_optionalChain([thread, 'access',
|
|
910
|
+
Math.max(_optionalChain([thread, 'access', _4 => _4.updatedAt, 'optionalAccess', _5 => _5.getTime, 'call', _6 => _6()]) || 0, comment.createdAt.getTime())
|
|
856
911
|
);
|
|
857
912
|
const updatedThread = {
|
|
858
913
|
...thread,
|
|
@@ -872,8 +927,8 @@ function applyUpsertComment(thread, comment) {
|
|
|
872
927
|
...thread,
|
|
873
928
|
updatedAt: new Date(
|
|
874
929
|
Math.max(
|
|
875
|
-
_optionalChain([thread, 'access',
|
|
876
|
-
_optionalChain([comment, 'access',
|
|
930
|
+
_optionalChain([thread, 'access', _7 => _7.updatedAt, 'optionalAccess', _8 => _8.getTime, 'call', _9 => _9()]) || 0,
|
|
931
|
+
_optionalChain([comment, 'access', _10 => _10.editedAt, 'optionalAccess', _11 => _11.getTime, 'call', _12 => _12()]) || comment.createdAt.getTime()
|
|
877
932
|
)
|
|
878
933
|
),
|
|
879
934
|
comments: updatedComments
|
|
@@ -902,12 +957,11 @@ function applyDeleteComment(thread, commentId, deletedAt) {
|
|
|
902
957
|
body: void 0
|
|
903
958
|
} : comment
|
|
904
959
|
);
|
|
905
|
-
if (
|
|
960
|
+
if (updatedComments.every((comment) => comment.deletedAt !== void 0)) {
|
|
906
961
|
return {
|
|
907
962
|
...thread,
|
|
908
963
|
deletedAt,
|
|
909
|
-
updatedAt: deletedAt
|
|
910
|
-
comments: []
|
|
964
|
+
updatedAt: deletedAt
|
|
911
965
|
};
|
|
912
966
|
}
|
|
913
967
|
return {
|
|
@@ -938,7 +992,7 @@ function applyAddReaction(thread, commentId, reaction) {
|
|
|
938
992
|
return {
|
|
939
993
|
...thread,
|
|
940
994
|
updatedAt: new Date(
|
|
941
|
-
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access',
|
|
995
|
+
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _13 => _13.updatedAt, 'optionalAccess', _14 => _14.getTime, 'call', _15 => _15()]) || 0)
|
|
942
996
|
),
|
|
943
997
|
comments: updatedComments
|
|
944
998
|
};
|
|
@@ -971,7 +1025,7 @@ function applyRemoveReaction(thread, commentId, emoji, userId, removedAt) {
|
|
|
971
1025
|
return {
|
|
972
1026
|
...thread,
|
|
973
1027
|
updatedAt: new Date(
|
|
974
|
-
Math.max(removedAt.getTime(), _optionalChain([thread, 'access',
|
|
1028
|
+
Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _16 => _16.updatedAt, 'optionalAccess', _17 => _17.getTime, 'call', _18 => _18()]) || 0)
|
|
975
1029
|
),
|
|
976
1030
|
comments: updatedComments
|
|
977
1031
|
};
|
|
@@ -1011,59 +1065,34 @@ function missingRoomInfoError(roomId) {
|
|
|
1011
1065
|
`resolveRoomsInfo didn't return anything for room '${roomId}'`
|
|
1012
1066
|
);
|
|
1013
1067
|
}
|
|
1068
|
+
function identity(x) {
|
|
1069
|
+
return x;
|
|
1070
|
+
}
|
|
1014
1071
|
var _umbrellaStores = /* @__PURE__ */ new WeakMap();
|
|
1015
1072
|
var _extras = /* @__PURE__ */ new WeakMap();
|
|
1016
1073
|
var _bundles = /* @__PURE__ */ new WeakMap();
|
|
1017
1074
|
var POLLING_INTERVAL = 60 * 1e3;
|
|
1018
|
-
var INBOX_NOTIFICATIONS_QUERY = "INBOX_NOTIFICATIONS";
|
|
1019
1075
|
var USER_THREADS_QUERY = "USER_THREADS";
|
|
1020
|
-
function
|
|
1021
|
-
const query = state.queries[INBOX_NOTIFICATIONS_QUERY];
|
|
1022
|
-
if (query === void 0 || query.isLoading) {
|
|
1023
|
-
return {
|
|
1024
|
-
isLoading: true
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
if (query.error !== void 0) {
|
|
1028
|
-
return {
|
|
1029
|
-
error: query.error,
|
|
1030
|
-
isLoading: false
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
return {
|
|
1034
|
-
inboxNotifications: state.inboxNotifications,
|
|
1035
|
-
isLoading: false
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
function selectUnreadInboxNotificationsCount(state) {
|
|
1076
|
+
function selectUnreadInboxNotificationsCount(inboxNotifications) {
|
|
1039
1077
|
let count = 0;
|
|
1040
|
-
for (const notification of
|
|
1078
|
+
for (const notification of inboxNotifications) {
|
|
1041
1079
|
if (notification.readAt === null || notification.readAt < notification.notifiedAt) {
|
|
1042
1080
|
count++;
|
|
1043
1081
|
}
|
|
1044
1082
|
}
|
|
1045
1083
|
return count;
|
|
1046
1084
|
}
|
|
1047
|
-
function selectorFor_useUnreadInboxNotificationsCount(
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
return {
|
|
1051
|
-
isLoading: true
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
if (query.error !== void 0) {
|
|
1055
|
-
return {
|
|
1056
|
-
error: query.error,
|
|
1057
|
-
isLoading: false
|
|
1058
|
-
};
|
|
1085
|
+
function selectorFor_useUnreadInboxNotificationsCount(result) {
|
|
1086
|
+
if (!result.inboxNotifications) {
|
|
1087
|
+
return result;
|
|
1059
1088
|
}
|
|
1060
1089
|
return {
|
|
1061
1090
|
isLoading: false,
|
|
1062
|
-
count: selectUnreadInboxNotificationsCount(
|
|
1091
|
+
count: selectUnreadInboxNotificationsCount(result.inboxNotifications)
|
|
1063
1092
|
};
|
|
1064
1093
|
}
|
|
1065
1094
|
function selectorFor_useUser(state, userId) {
|
|
1066
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
1095
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _19 => _19.isLoading])) {
|
|
1067
1096
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
1068
1097
|
}
|
|
1069
1098
|
if (state.error) {
|
|
@@ -1081,7 +1110,7 @@ function selectorFor_useUser(state, userId) {
|
|
|
1081
1110
|
};
|
|
1082
1111
|
}
|
|
1083
1112
|
function selectorFor_useRoomInfo(state, roomId) {
|
|
1084
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
1113
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _20 => _20.isLoading])) {
|
|
1085
1114
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
1086
1115
|
}
|
|
1087
1116
|
if (state.error) {
|
|
@@ -1191,23 +1220,21 @@ function makeExtrasForClient(client) {
|
|
|
1191
1220
|
void waitUntilInboxNotificationsLoaded().catch(() => {
|
|
1192
1221
|
});
|
|
1193
1222
|
}
|
|
1194
|
-
function
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
};
|
|
1210
|
-
}, []);
|
|
1223
|
+
function startPolling() {
|
|
1224
|
+
pollerSubscribers++;
|
|
1225
|
+
poller.start(POLLING_INTERVAL);
|
|
1226
|
+
return () => {
|
|
1227
|
+
if (pollerSubscribers <= 0) {
|
|
1228
|
+
console.warn(
|
|
1229
|
+
`Internal unexpected behavior. Cannot decrease subscriber count for query "${INBOX_NOTIFICATIONS_QUERY}"`
|
|
1230
|
+
);
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
pollerSubscribers--;
|
|
1234
|
+
if (pollerSubscribers <= 0) {
|
|
1235
|
+
poller.stop();
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1211
1238
|
}
|
|
1212
1239
|
const userThreadsPoller = _core.makePoller.call(void 0, refreshUserThreads);
|
|
1213
1240
|
let isFetchingUserThreadsUpdates = false;
|
|
@@ -1292,7 +1319,7 @@ function makeExtrasForClient(client) {
|
|
|
1292
1319
|
}
|
|
1293
1320
|
return {
|
|
1294
1321
|
store,
|
|
1295
|
-
|
|
1322
|
+
startPolling,
|
|
1296
1323
|
waitUntilInboxNotificationsLoaded,
|
|
1297
1324
|
loadInboxNotifications,
|
|
1298
1325
|
incrementUserThreadsQuerySubscribers,
|
|
@@ -1337,16 +1364,14 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1337
1364
|
return bundle;
|
|
1338
1365
|
}
|
|
1339
1366
|
function useInboxNotifications_withClient(client) {
|
|
1340
|
-
const { loadInboxNotifications, store,
|
|
1341
|
-
_react.useEffect.call(void 0,
|
|
1342
|
-
|
|
1343
|
-
}, [loadInboxNotifications]);
|
|
1344
|
-
useEnableInboxNotificationsPolling();
|
|
1367
|
+
const { loadInboxNotifications, store, startPolling } = getExtrasForClient(client);
|
|
1368
|
+
_react.useEffect.call(void 0, loadInboxNotifications, [loadInboxNotifications]);
|
|
1369
|
+
_react.useEffect.call(void 0, startPolling, [startPolling]);
|
|
1345
1370
|
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
1346
1371
|
store.subscribeInboxNotifications,
|
|
1347
|
-
store.
|
|
1348
|
-
store.
|
|
1349
|
-
|
|
1372
|
+
store.getInboxNotificationsAsync,
|
|
1373
|
+
store.getInboxNotificationsAsync,
|
|
1374
|
+
identity,
|
|
1350
1375
|
_core.shallow
|
|
1351
1376
|
);
|
|
1352
1377
|
}
|
|
@@ -1359,15 +1384,13 @@ function useInboxNotificationsSuspense_withClient(client) {
|
|
|
1359
1384
|
return result;
|
|
1360
1385
|
}
|
|
1361
1386
|
function useUnreadInboxNotificationsCount_withClient(client) {
|
|
1362
|
-
const { store, loadInboxNotifications,
|
|
1363
|
-
_react.useEffect.call(void 0,
|
|
1364
|
-
|
|
1365
|
-
}, [loadInboxNotifications]);
|
|
1366
|
-
useEnableInboxNotificationsPolling();
|
|
1387
|
+
const { store, loadInboxNotifications, startPolling } = getExtrasForClient(client);
|
|
1388
|
+
_react.useEffect.call(void 0, loadInboxNotifications, [loadInboxNotifications]);
|
|
1389
|
+
_react.useEffect.call(void 0, startPolling, [startPolling]);
|
|
1367
1390
|
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
1368
1391
|
store.subscribeInboxNotifications,
|
|
1369
|
-
store.
|
|
1370
|
-
store.
|
|
1392
|
+
store.getInboxNotificationsAsync,
|
|
1393
|
+
store.getInboxNotificationsAsync,
|
|
1371
1394
|
selectorFor_useUnreadInboxNotificationsCount,
|
|
1372
1395
|
_core.shallow
|
|
1373
1396
|
);
|
|
@@ -1616,7 +1639,7 @@ function createSharedContext(client) {
|
|
|
1616
1639
|
}
|
|
1617
1640
|
function useEnsureNoLiveblocksProvider(options) {
|
|
1618
1641
|
const existing = useClientOrNull();
|
|
1619
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
1642
|
+
if (!_optionalChain([options, 'optionalAccess', _21 => _21.allowNesting]) && existing !== null) {
|
|
1620
1643
|
throw new Error(
|
|
1621
1644
|
"You cannot nest multiple LiveblocksProvider instances in the same React tree."
|
|
1622
1645
|
);
|
|
@@ -1927,7 +1950,6 @@ var _client = require('@liveblocks/client');
|
|
|
1927
1950
|
|
|
1928
1951
|
|
|
1929
1952
|
|
|
1930
|
-
|
|
1931
1953
|
// src/use-scroll-to-comment-on-load-effect.ts
|
|
1932
1954
|
|
|
1933
1955
|
function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
|
|
@@ -1961,7 +1983,7 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
|
1961
1983
|
var SMOOTH_DELAY = 1e3;
|
|
1962
1984
|
var noop2 = () => {
|
|
1963
1985
|
};
|
|
1964
|
-
var
|
|
1986
|
+
var identity2 = (x) => x;
|
|
1965
1987
|
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:
|
|
1966
1988
|
|
|
1967
1989
|
import { unstable_batchedUpdates } from "react-dom"; // or "react-native"
|
|
@@ -1975,13 +1997,10 @@ var missing_unstable_batchedUpdates = (reactVersion, roomId) => `We noticed you\
|
|
|
1975
1997
|
Why? Please see https://liveblocks.io/docs/platform/troubleshooting#stale-props-zombie-child for more information`;
|
|
1976
1998
|
var superfluous_unstable_batchedUpdates = "You don\u2019t need to pass unstable_batchedUpdates to RoomProvider anymore, since you\u2019re on React 18+ already.";
|
|
1977
1999
|
function useSyncExternalStore2(s, gs, gss) {
|
|
1978
|
-
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss,
|
|
2000
|
+
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity2);
|
|
1979
2001
|
}
|
|
1980
2002
|
var STABLE_EMPTY_LIST = Object.freeze([]);
|
|
1981
2003
|
var POLLING_INTERVAL2 = 5 * 60 * 1e3;
|
|
1982
|
-
function makeNotificationSettingsQueryKey(roomId) {
|
|
1983
|
-
return `${roomId}:NOTIFICATION_SETTINGS`;
|
|
1984
|
-
}
|
|
1985
2004
|
function alwaysEmptyList() {
|
|
1986
2005
|
return STABLE_EMPTY_LIST;
|
|
1987
2006
|
}
|
|
@@ -1991,10 +2010,6 @@ function alwaysNull() {
|
|
|
1991
2010
|
function selectorFor_useOthersConnectionIds(others) {
|
|
1992
2011
|
return others.map((user) => user.connectionId);
|
|
1993
2012
|
}
|
|
1994
|
-
function selectNotificationSettings(roomId, state) {
|
|
1995
|
-
const notificationSettings = state.notificationSettingsByRoomId;
|
|
1996
|
-
return _core.nn.call(void 0, notificationSettings[roomId]);
|
|
1997
|
-
}
|
|
1998
2013
|
function makeMutationContext(room) {
|
|
1999
2014
|
const cannotUseUntil = "This mutation cannot be used until";
|
|
2000
2015
|
const needsPresence = `${cannotUseUntil} connected to the Liveblocks room`;
|
|
@@ -2034,7 +2049,7 @@ function getCurrentUserId(room) {
|
|
|
2034
2049
|
}
|
|
2035
2050
|
function handleApiError(err) {
|
|
2036
2051
|
const message = `Request failed with status ${err.status}: ${err.message}`;
|
|
2037
|
-
if (_optionalChain([err, 'access',
|
|
2052
|
+
if (_optionalChain([err, 'access', _22 => _22.details, 'optionalAccess', _23 => _23.error]) === "FORBIDDEN") {
|
|
2038
2053
|
const detailedMessage = [message, err.details.suggestion, err.details.docs].filter(Boolean).join("\n");
|
|
2039
2054
|
_core.console.error(detailedMessage);
|
|
2040
2055
|
}
|
|
@@ -2123,7 +2138,7 @@ function makeExtrasForClient2(client) {
|
|
|
2123
2138
|
}
|
|
2124
2139
|
}
|
|
2125
2140
|
async function getRoomVersions(room, { retryCount } = { retryCount: 0 }) {
|
|
2126
|
-
const queryKey =
|
|
2141
|
+
const queryKey = makeVersionsQueryKey(room.id);
|
|
2127
2142
|
const existingRequest = requestsByQuery.get(queryKey);
|
|
2128
2143
|
if (existingRequest !== void 0) return existingRequest;
|
|
2129
2144
|
const request = room[_core.kInternal].listTextVersions();
|
|
@@ -2183,7 +2198,8 @@ function makeExtrasForClient2(client) {
|
|
|
2183
2198
|
}
|
|
2184
2199
|
return;
|
|
2185
2200
|
}
|
|
2186
|
-
async function getInboxNotificationSettings(room,
|
|
2201
|
+
async function getInboxNotificationSettings(room, { retryCount } = { retryCount: 0 }) {
|
|
2202
|
+
const queryKey = makeNotificationSettingsQueryKey(room.id);
|
|
2187
2203
|
const existingRequest = requestsByQuery.get(queryKey);
|
|
2188
2204
|
if (existingRequest !== void 0) return existingRequest;
|
|
2189
2205
|
try {
|
|
@@ -2195,7 +2211,7 @@ function makeExtrasForClient2(client) {
|
|
|
2195
2211
|
} catch (err) {
|
|
2196
2212
|
requestsByQuery.delete(queryKey);
|
|
2197
2213
|
retryError(() => {
|
|
2198
|
-
void getInboxNotificationSettings(room,
|
|
2214
|
+
void getInboxNotificationSettings(room, {
|
|
2199
2215
|
retryCount: retryCount + 1
|
|
2200
2216
|
});
|
|
2201
2217
|
}, retryCount);
|
|
@@ -2471,7 +2487,7 @@ function useStatus() {
|
|
|
2471
2487
|
return useSyncExternalStore2(subscribe, getSnapshot, getServerSnapshot);
|
|
2472
2488
|
}
|
|
2473
2489
|
function useStorageStatus(options) {
|
|
2474
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2490
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.smooth]), () => ( false)));
|
|
2475
2491
|
if (smooth) {
|
|
2476
2492
|
return useStorageStatusSmooth();
|
|
2477
2493
|
} else {
|
|
@@ -2579,7 +2595,7 @@ function useSelf(maybeSelector, isEqual) {
|
|
|
2579
2595
|
const room = useRoom();
|
|
2580
2596
|
const subscribe = room.events.self.subscribe;
|
|
2581
2597
|
const getSnapshot = room.getSelf;
|
|
2582
|
-
const selector = _nullishCoalesce(maybeSelector, () => (
|
|
2598
|
+
const selector = _nullishCoalesce(maybeSelector, () => ( identity2));
|
|
2583
2599
|
const wrappedSelector = React5.useCallback(
|
|
2584
2600
|
(me) => me !== null ? selector(me) : null,
|
|
2585
2601
|
[selector]
|
|
@@ -2613,7 +2629,7 @@ function useOthers(selector, isEqual) {
|
|
|
2613
2629
|
subscribe,
|
|
2614
2630
|
getSnapshot,
|
|
2615
2631
|
getServerSnapshot,
|
|
2616
|
-
_nullishCoalesce(selector, () => (
|
|
2632
|
+
_nullishCoalesce(selector, () => ( identity2)),
|
|
2617
2633
|
isEqual
|
|
2618
2634
|
);
|
|
2619
2635
|
}
|
|
@@ -2842,7 +2858,7 @@ function useDeleteThread() {
|
|
|
2842
2858
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2843
2859
|
const thread = store.getThreads().threadsById[threadId];
|
|
2844
2860
|
const userId = getCurrentUserId(room);
|
|
2845
|
-
if (_optionalChain([thread, 'optionalAccess',
|
|
2861
|
+
if (_optionalChain([thread, 'optionalAccess', _25 => _25.comments, 'optionalAccess', _26 => _26[0], 'optionalAccess', _27 => _27.userId]) !== userId) {
|
|
2846
2862
|
throw new Error("Only the thread creator can delete the thread");
|
|
2847
2863
|
}
|
|
2848
2864
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
@@ -3259,37 +3275,51 @@ function useThreadSubscription(threadId) {
|
|
|
3259
3275
|
);
|
|
3260
3276
|
}
|
|
3261
3277
|
function useRoomNotificationSettings() {
|
|
3278
|
+
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
3262
3279
|
const client = useClient();
|
|
3263
3280
|
const room = useRoom();
|
|
3264
3281
|
const { store } = getExtrasForClient2(client);
|
|
3282
|
+
const getter = React5.useCallback(
|
|
3283
|
+
() => store.getNotificationSettingsAsync(room.id),
|
|
3284
|
+
[store, room.id]
|
|
3285
|
+
);
|
|
3265
3286
|
React5.useEffect(() => {
|
|
3266
3287
|
const { getInboxNotificationSettings } = getExtrasForClient2(client);
|
|
3267
|
-
|
|
3268
|
-
void getInboxNotificationSettings(room, queryKey);
|
|
3288
|
+
void getInboxNotificationSettings(room);
|
|
3269
3289
|
}, [client, room]);
|
|
3290
|
+
const settings = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3291
|
+
store.subscribeNotificationSettings,
|
|
3292
|
+
getter,
|
|
3293
|
+
getter,
|
|
3294
|
+
identity2,
|
|
3295
|
+
_client.shallow
|
|
3296
|
+
);
|
|
3297
|
+
return React5.useMemo(() => {
|
|
3298
|
+
return [settings, updateRoomNotificationSettings];
|
|
3299
|
+
}, [settings, updateRoomNotificationSettings]);
|
|
3300
|
+
}
|
|
3301
|
+
function useRoomNotificationSettingsSuspense() {
|
|
3270
3302
|
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
3271
|
-
const
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
if (query.error !== void 0) {
|
|
3278
|
-
return { isLoading: false, error: query.error };
|
|
3279
|
-
}
|
|
3280
|
-
return {
|
|
3281
|
-
isLoading: false,
|
|
3282
|
-
settings: selectNotificationSettings(room.id, state)
|
|
3283
|
-
};
|
|
3284
|
-
},
|
|
3285
|
-
[room]
|
|
3303
|
+
const client = useClient();
|
|
3304
|
+
const room = useRoom();
|
|
3305
|
+
const { store } = getExtrasForClient2(client);
|
|
3306
|
+
const getter = React5.useCallback(
|
|
3307
|
+
() => store.getNotificationSettingsAsync(room.id),
|
|
3308
|
+
[store, room.id]
|
|
3286
3309
|
);
|
|
3287
3310
|
const settings = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3288
3311
|
store.subscribeNotificationSettings,
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3312
|
+
getter,
|
|
3313
|
+
getter,
|
|
3314
|
+
identity2,
|
|
3315
|
+
_client.shallow
|
|
3292
3316
|
);
|
|
3317
|
+
if (settings.isLoading) {
|
|
3318
|
+
const { getInboxNotificationSettings } = getExtrasForClient2(client);
|
|
3319
|
+
throw getInboxNotificationSettings(room);
|
|
3320
|
+
} else if (settings.error) {
|
|
3321
|
+
throw settings.error;
|
|
3322
|
+
}
|
|
3293
3323
|
return React5.useMemo(() => {
|
|
3294
3324
|
return [settings, updateRoomNotificationSettings];
|
|
3295
3325
|
}, [settings, updateRoomNotificationSettings]);
|
|
@@ -3326,34 +3356,44 @@ function useHistoryVersionData(versionId) {
|
|
|
3326
3356
|
function useHistoryVersions() {
|
|
3327
3357
|
const client = useClient();
|
|
3328
3358
|
const room = useRoom();
|
|
3329
|
-
const queryKey = getVersionsQueryKey(room.id);
|
|
3330
3359
|
const { store, getRoomVersions } = getExtrasForClient2(client);
|
|
3360
|
+
const getter = React5.useCallback(
|
|
3361
|
+
() => store.getVersionsAsync(room.id),
|
|
3362
|
+
[store, room.id]
|
|
3363
|
+
);
|
|
3331
3364
|
React5.useEffect(() => {
|
|
3332
3365
|
void getRoomVersions(room);
|
|
3333
3366
|
}, [room]);
|
|
3334
|
-
const
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3367
|
+
const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3368
|
+
store.subscribeVersions,
|
|
3369
|
+
getter,
|
|
3370
|
+
getter,
|
|
3371
|
+
identity2,
|
|
3372
|
+
_client.shallow
|
|
3373
|
+
);
|
|
3374
|
+
return state;
|
|
3375
|
+
}
|
|
3376
|
+
function useHistoryVersionsSuspense() {
|
|
3377
|
+
const client = useClient();
|
|
3378
|
+
const room = useRoom();
|
|
3379
|
+
const { store } = getExtrasForClient2(client);
|
|
3380
|
+
const getter = React5.useCallback(
|
|
3381
|
+
() => store.getVersionsAsync(room.id),
|
|
3382
|
+
[store, room.id]
|
|
3350
3383
|
);
|
|
3351
3384
|
const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3352
3385
|
store.subscribeVersions,
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3386
|
+
getter,
|
|
3387
|
+
getter,
|
|
3388
|
+
identity2,
|
|
3389
|
+
_client.shallow
|
|
3356
3390
|
);
|
|
3391
|
+
if (state.isLoading) {
|
|
3392
|
+
const { getRoomVersions } = getExtrasForClient2(client);
|
|
3393
|
+
throw getRoomVersions(room);
|
|
3394
|
+
} else if (state.error) {
|
|
3395
|
+
throw state.error;
|
|
3396
|
+
}
|
|
3357
3397
|
return state;
|
|
3358
3398
|
}
|
|
3359
3399
|
function useUpdateRoomNotificationSettings() {
|
|
@@ -3486,77 +3526,12 @@ function useThreadsSuspense(options = {
|
|
|
3486
3526
|
useScrollToCommentOnLoadEffect(scrollOnLoad, state);
|
|
3487
3527
|
return state;
|
|
3488
3528
|
}
|
|
3489
|
-
function useHistoryVersionsSuspense() {
|
|
3490
|
-
const client = useClient();
|
|
3491
|
-
const room = useRoom();
|
|
3492
|
-
const queryKey = getVersionsQueryKey(room.id);
|
|
3493
|
-
const { store, getRoomVersions } = getExtrasForClient2(client);
|
|
3494
|
-
const query = store.getVersions().queries[queryKey];
|
|
3495
|
-
if (query === void 0 || query.isLoading) {
|
|
3496
|
-
throw getRoomVersions(room);
|
|
3497
|
-
}
|
|
3498
|
-
if (query.error) {
|
|
3499
|
-
throw query.error;
|
|
3500
|
-
}
|
|
3501
|
-
const selector = React5.useCallback(
|
|
3502
|
-
(state2) => {
|
|
3503
|
-
return {
|
|
3504
|
-
versions: state2.versionsByRoomId[room.id],
|
|
3505
|
-
isLoading: false
|
|
3506
|
-
};
|
|
3507
|
-
},
|
|
3508
|
-
[room, queryKey]
|
|
3509
|
-
// eslint-disable-line react-hooks/exhaustive-deps
|
|
3510
|
-
);
|
|
3511
|
-
const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3512
|
-
store.subscribeVersions,
|
|
3513
|
-
store.getVersions,
|
|
3514
|
-
store.getVersions,
|
|
3515
|
-
selector
|
|
3516
|
-
);
|
|
3517
|
-
return state;
|
|
3518
|
-
}
|
|
3519
|
-
function useRoomNotificationSettingsSuspense() {
|
|
3520
|
-
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
3521
|
-
const client = useClient();
|
|
3522
|
-
const room = useRoom();
|
|
3523
|
-
const queryKey = makeNotificationSettingsQueryKey(room.id);
|
|
3524
|
-
const { store, getInboxNotificationSettings } = getExtrasForClient2(client);
|
|
3525
|
-
const query = store.getNotificationSettings().queries[queryKey];
|
|
3526
|
-
if (query === void 0 || query.isLoading) {
|
|
3527
|
-
throw getInboxNotificationSettings(room, queryKey);
|
|
3528
|
-
}
|
|
3529
|
-
if (query.error) {
|
|
3530
|
-
throw query.error;
|
|
3531
|
-
}
|
|
3532
|
-
const selector = React5.useCallback(
|
|
3533
|
-
(state) => {
|
|
3534
|
-
return {
|
|
3535
|
-
isLoading: false,
|
|
3536
|
-
settings: selectNotificationSettings(room.id, state)
|
|
3537
|
-
};
|
|
3538
|
-
},
|
|
3539
|
-
[room]
|
|
3540
|
-
);
|
|
3541
|
-
const settings = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3542
|
-
store.subscribeNotificationSettings,
|
|
3543
|
-
store.getNotificationSettings,
|
|
3544
|
-
store.getNotificationSettings,
|
|
3545
|
-
selector
|
|
3546
|
-
);
|
|
3547
|
-
return React5.useMemo(() => {
|
|
3548
|
-
return [settings, updateRoomNotificationSettings];
|
|
3549
|
-
}, [settings, updateRoomNotificationSettings]);
|
|
3550
|
-
}
|
|
3551
3529
|
function createRoomContext(client) {
|
|
3552
3530
|
return getOrCreateRoomContextBundle(client);
|
|
3553
3531
|
}
|
|
3554
3532
|
function generateQueryKey(roomId, options) {
|
|
3555
3533
|
return `${roomId}-${_core.stringify.call(void 0, _nullishCoalesce(options, () => ( {})))}`;
|
|
3556
3534
|
}
|
|
3557
|
-
function getVersionsQueryKey(roomId) {
|
|
3558
|
-
return `${roomId}-VERSIONS`;
|
|
3559
|
-
}
|
|
3560
3535
|
var _RoomProvider = RoomProvider;
|
|
3561
3536
|
var _useBroadcastEvent = useBroadcastEvent;
|
|
3562
3537
|
var _useOthersListener = useOthersListener;
|
|
@@ -3677,4 +3652,4 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
3677
3652
|
|
|
3678
3653
|
|
|
3679
3654
|
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense; exports.RoomContext = RoomContext; exports.ClientContext = ClientContext; exports.selectThreads = selectThreads; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; 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.CreateThreadError = CreateThreadError; exports.useStatus = useStatus; 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.useCreateComment = useCreateComment; exports.useEditComment = useEditComment; exports.useDeleteComment = useDeleteComment; exports.useRemoveReaction = useRemoveReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useRoomNotificationSettings = useRoomNotificationSettings; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; 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._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;
|
|
3680
|
-
//# sourceMappingURL=chunk-
|
|
3655
|
+
//# sourceMappingURL=chunk-TGC7HD5F.js.map
|