@liveblocks/react 2.24.0-deque1 → 2.24.0-sub1
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.cjs +7 -5
- package/dist/_private.cjs.map +1 -1
- package/dist/_private.d.cts +1 -1
- package/dist/_private.d.ts +1 -1
- package/dist/_private.js +3 -1
- package/dist/_private.js.map +1 -1
- package/dist/{chunk-L4OEDVVN.js → chunk-FBBBSMFI.js} +2 -2
- package/dist/{chunk-LFSDRNVE.cjs → chunk-JYG2E4EZ.cjs} +2 -2
- package/dist/{chunk-LFSDRNVE.cjs.map → chunk-JYG2E4EZ.cjs.map} +1 -1
- package/dist/{chunk-C337YEKB.cjs → chunk-VEO3XXA7.cjs} +467 -120
- package/dist/chunk-VEO3XXA7.cjs.map +1 -0
- package/dist/{chunk-URVBSXYW.js → chunk-ZWYRZR44.js} +469 -122
- package/dist/chunk-ZWYRZR44.js.map +1 -0
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/{room-CqmA66N2.d.cts → room-BHrloYUB.d.cts} +210 -70
- package/dist/{room-CqmA66N2.d.ts → room-BHrloYUB.d.ts} +210 -70
- package/dist/suspense.cjs +12 -4
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +11 -3
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-C337YEKB.cjs.map +0 -1
- package/dist/chunk-URVBSXYW.js.map +0 -1
- /package/dist/{chunk-L4OEDVVN.js.map → chunk-FBBBSMFI.js.map} +0 -0
|
@@ -132,8 +132,8 @@ var config = {
|
|
|
132
132
|
USER_THREADS_MAX_STALE_TIME: 30 * SECONDS,
|
|
133
133
|
HISTORY_VERSIONS_POLL_INTERVAL: 1 * MINUTES,
|
|
134
134
|
HISTORY_VERSIONS_MAX_STALE_TIME: 5 * SECONDS,
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL: 1 * MINUTES,
|
|
136
|
+
ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME: 5 * SECONDS,
|
|
137
137
|
USER_NOTIFICATION_SETTINGS_INTERVAL: 5 * MINUTES,
|
|
138
138
|
USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME: 1 * MINUTES
|
|
139
139
|
};
|
|
@@ -248,6 +248,9 @@ var use = (
|
|
|
248
248
|
|
|
249
249
|
|
|
250
250
|
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
251
254
|
|
|
252
255
|
// src/lib/autobind.ts
|
|
253
256
|
function autobind(self) {
|
|
@@ -431,7 +434,9 @@ var ThreadDB = class _ThreadDB {
|
|
|
431
434
|
if (roomId !== void 0) {
|
|
432
435
|
crit.push((t) => t.roomId === roomId);
|
|
433
436
|
}
|
|
434
|
-
|
|
437
|
+
if (query !== void 0) {
|
|
438
|
+
crit.push(makeThreadsFilter(query));
|
|
439
|
+
}
|
|
435
440
|
return Array.from(index.filter((t) => crit.every((pred) => pred(t))));
|
|
436
441
|
}
|
|
437
442
|
};
|
|
@@ -667,7 +672,45 @@ function createStore_forNotifications() {
|
|
|
667
672
|
upsert
|
|
668
673
|
};
|
|
669
674
|
}
|
|
670
|
-
function
|
|
675
|
+
function createStore_forSubscriptions(updates, threads) {
|
|
676
|
+
const baseSignal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
677
|
+
function applyDelta(newSubscriptions, deletedSubscriptions) {
|
|
678
|
+
baseSignal.mutate((lut) => {
|
|
679
|
+
let mutated = false;
|
|
680
|
+
for (const s of newSubscriptions) {
|
|
681
|
+
lut.set(_core.getSubscriptionKey.call(void 0, s), s);
|
|
682
|
+
mutated = true;
|
|
683
|
+
}
|
|
684
|
+
for (const s of deletedSubscriptions) {
|
|
685
|
+
lut.delete(_core.getSubscriptionKey.call(void 0, s));
|
|
686
|
+
mutated = true;
|
|
687
|
+
}
|
|
688
|
+
return mutated;
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
function create(subscription) {
|
|
692
|
+
baseSignal.mutate((lut) => {
|
|
693
|
+
lut.set(_core.getSubscriptionKey.call(void 0, subscription), subscription);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
function deleteOne(subscriptionKey) {
|
|
697
|
+
baseSignal.mutate((lut) => {
|
|
698
|
+
lut.delete(subscriptionKey);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
return {
|
|
702
|
+
signal: _core.DerivedSignal.from(
|
|
703
|
+
baseSignal,
|
|
704
|
+
updates,
|
|
705
|
+
(base, updates2) => applyOptimisticUpdates_forSubscriptions(base, threads, updates2)
|
|
706
|
+
),
|
|
707
|
+
// Mutations
|
|
708
|
+
applyDelta,
|
|
709
|
+
create,
|
|
710
|
+
delete: deleteOne
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
function createStore_forRoomSubscriptionSettings(updates) {
|
|
671
714
|
const baseSignal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
672
715
|
function update(roomId, settings) {
|
|
673
716
|
baseSignal.mutate((lut) => {
|
|
@@ -678,7 +721,7 @@ function createStore_forRoomNotificationSettings(updates) {
|
|
|
678
721
|
signal: _core.DerivedSignal.from(
|
|
679
722
|
baseSignal,
|
|
680
723
|
updates,
|
|
681
|
-
(base, updates2) =>
|
|
724
|
+
(base, updates2) => applyOptimisticUpdates_forRoomSubscriptionSettings(base, updates2)
|
|
682
725
|
),
|
|
683
726
|
// Mutations
|
|
684
727
|
update
|
|
@@ -730,9 +773,9 @@ function createStore_forPermissionHints() {
|
|
|
730
773
|
update
|
|
731
774
|
};
|
|
732
775
|
}
|
|
733
|
-
function
|
|
776
|
+
function createStore_forNotificationSettings(updates) {
|
|
734
777
|
const signal = new (0, _core.Signal)(
|
|
735
|
-
_core.
|
|
778
|
+
_core.createNotificationSettings.call(void 0, {})
|
|
736
779
|
);
|
|
737
780
|
function update(settings) {
|
|
738
781
|
signal.set(settings);
|
|
@@ -741,7 +784,7 @@ function createStore_forUserNotificationSettings(updates) {
|
|
|
741
784
|
signal: _core.DerivedSignal.from(
|
|
742
785
|
signal,
|
|
743
786
|
updates,
|
|
744
|
-
(base, updates2) =>
|
|
787
|
+
(base, updates2) => applyOptimisticUpdates_forNotificationSettings(base, updates2)
|
|
745
788
|
),
|
|
746
789
|
// Mutations
|
|
747
790
|
update
|
|
@@ -780,16 +823,18 @@ var UmbrellaStore = class {
|
|
|
780
823
|
//
|
|
781
824
|
// Mutate inputs... ...observe clean/consistent output!
|
|
782
825
|
//
|
|
783
|
-
// .-> Base ThreadDB ---------+
|
|
826
|
+
// .-> Base ThreadDB ---------+ +-------> Clean threads by ID (Part 1)
|
|
784
827
|
// / | |
|
|
785
|
-
// mutate ----> Base Notifications --+ | |
|
|
786
|
-
// \ | | | |
|
|
828
|
+
// mutate ----> Base Notifications --+ | | +-----> Clean notifications (Part 1)
|
|
829
|
+
// \ | | | | & notifications by ID
|
|
787
830
|
// | \ | | Apply | |
|
|
788
|
-
// | `-> OptimisticUpdates --+--+--> Optimistic
|
|
789
|
-
// \ | Updates |
|
|
790
|
-
// `------- etc etc ---------+ |
|
|
791
|
-
// ^ |
|
|
792
|
-
// |
|
|
831
|
+
// | `-> OptimisticUpdates --+--+--> Optimistic -+-+-+-+-> Subscriptions (Part 2)
|
|
832
|
+
// \ | Updates | | |
|
|
833
|
+
// `------- etc etc ---------+ | | +-> History Versions (Part 3)
|
|
834
|
+
// ^ | |
|
|
835
|
+
// | | +---> Room Subscription Settings (Part 4)
|
|
836
|
+
// | |
|
|
837
|
+
// | +-------> Notification Settings (Part 5)
|
|
793
838
|
// |
|
|
794
839
|
// |
|
|
795
840
|
// | ^ ^
|
|
@@ -808,6 +853,7 @@ var UmbrellaStore = class {
|
|
|
808
853
|
// Exposes its signal under `.signal` prop
|
|
809
854
|
|
|
810
855
|
|
|
856
|
+
|
|
811
857
|
// prettier-ignore
|
|
812
858
|
|
|
813
859
|
|
|
@@ -832,8 +878,8 @@ var UmbrellaStore = class {
|
|
|
832
878
|
#userThreadsLastRequestedAt = null;
|
|
833
879
|
// Room versions
|
|
834
880
|
#roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
835
|
-
//
|
|
836
|
-
#
|
|
881
|
+
// Notification Settings
|
|
882
|
+
#notificationSettings;
|
|
837
883
|
constructor(client) {
|
|
838
884
|
this.#client = client[_core.kInternal].as();
|
|
839
885
|
this.optimisticUpdates = createStore_forOptimistic(this.#client);
|
|
@@ -841,7 +887,11 @@ var UmbrellaStore = class {
|
|
|
841
887
|
this.#notificationsPaginationState = new PaginatedResource(
|
|
842
888
|
async (cursor) => {
|
|
843
889
|
const result = await this.#client.getInboxNotifications({ cursor });
|
|
844
|
-
this.updateThreadifications(
|
|
890
|
+
this.updateThreadifications(
|
|
891
|
+
result.threads,
|
|
892
|
+
result.inboxNotifications,
|
|
893
|
+
result.subscriptions
|
|
894
|
+
);
|
|
845
895
|
if (this.#notificationsLastRequestedAt === null) {
|
|
846
896
|
this.#notificationsLastRequestedAt = result.requestedAt;
|
|
847
897
|
}
|
|
@@ -849,19 +899,23 @@ var UmbrellaStore = class {
|
|
|
849
899
|
return nextCursor;
|
|
850
900
|
}
|
|
851
901
|
);
|
|
852
|
-
const
|
|
902
|
+
const notificationSettingsFetcher = async () => {
|
|
853
903
|
const result = await this.#client.getNotificationSettings();
|
|
854
|
-
this.
|
|
904
|
+
this.notificationSettings.update(result);
|
|
855
905
|
};
|
|
856
|
-
this.
|
|
906
|
+
this.notificationSettings = createStore_forNotificationSettings(
|
|
857
907
|
this.optimisticUpdates.signal
|
|
858
908
|
);
|
|
859
|
-
this.#
|
|
860
|
-
|
|
909
|
+
this.#notificationSettings = new SinglePageResource(
|
|
910
|
+
notificationSettingsFetcher
|
|
861
911
|
);
|
|
862
912
|
this.threads = new ThreadDB();
|
|
913
|
+
this.subscriptions = createStore_forSubscriptions(
|
|
914
|
+
this.optimisticUpdates.signal,
|
|
915
|
+
this.threads
|
|
916
|
+
);
|
|
863
917
|
this.notifications = createStore_forNotifications();
|
|
864
|
-
this.
|
|
918
|
+
this.roomSubscriptionSettings = createStore_forRoomSubscriptionSettings(
|
|
865
919
|
this.optimisticUpdates.signal
|
|
866
920
|
);
|
|
867
921
|
this.historyVersions = createStore_forHistoryVersions();
|
|
@@ -880,6 +934,14 @@ var UmbrellaStore = class {
|
|
|
880
934
|
}),
|
|
881
935
|
_core.shallow
|
|
882
936
|
);
|
|
937
|
+
const threadSubscriptions = _core.DerivedSignal.from(
|
|
938
|
+
notifications,
|
|
939
|
+
this.subscriptions.signal,
|
|
940
|
+
(n, s) => ({
|
|
941
|
+
subscriptions: s,
|
|
942
|
+
notifications: n.sortedNotifications
|
|
943
|
+
})
|
|
944
|
+
);
|
|
883
945
|
const loadingUserThreads = new (0, _core.DefaultMap)(
|
|
884
946
|
(queryKey) => {
|
|
885
947
|
const query = JSON.parse(queryKey);
|
|
@@ -890,7 +952,8 @@ var UmbrellaStore = class {
|
|
|
890
952
|
});
|
|
891
953
|
this.updateThreadifications(
|
|
892
954
|
result.threads,
|
|
893
|
-
result.inboxNotifications
|
|
955
|
+
result.inboxNotifications,
|
|
956
|
+
result.subscriptions
|
|
894
957
|
);
|
|
895
958
|
this.permissionHints.update(result.permissionHints);
|
|
896
959
|
if (this.#userThreadsLastRequestedAt === null) {
|
|
@@ -933,7 +996,8 @@ var UmbrellaStore = class {
|
|
|
933
996
|
});
|
|
934
997
|
this.updateThreadifications(
|
|
935
998
|
result.threads,
|
|
936
|
-
result.inboxNotifications
|
|
999
|
+
result.inboxNotifications,
|
|
1000
|
+
result.subscriptions
|
|
937
1001
|
);
|
|
938
1002
|
this.permissionHints.update(result.permissionHints);
|
|
939
1003
|
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
@@ -983,28 +1047,30 @@ var UmbrellaStore = class {
|
|
|
983
1047
|
}),
|
|
984
1048
|
waitUntilLoaded: this.#notificationsPaginationState.waitUntilLoaded
|
|
985
1049
|
};
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1050
|
+
const roomSubscriptionSettingsByRoomId = new (0, _core.DefaultMap)(
|
|
1051
|
+
(roomId) => {
|
|
1052
|
+
const resource = new SinglePageResource(async () => {
|
|
1053
|
+
const room = this.#client.getRoom(roomId);
|
|
1054
|
+
if (room === null) {
|
|
1055
|
+
throw new Error(`Room '${roomId}' is not available on client`);
|
|
1056
|
+
}
|
|
1057
|
+
const result = await room.getSubscriptionSettings();
|
|
1058
|
+
this.roomSubscriptionSettings.update(roomId, result);
|
|
1059
|
+
});
|
|
1060
|
+
const signal = _core.DerivedSignal.from(() => {
|
|
1061
|
+
const result = resource.get();
|
|
1062
|
+
if (result.isLoading || result.error) {
|
|
1063
|
+
return result;
|
|
1064
|
+
} else {
|
|
1065
|
+
return ASYNC_OK(
|
|
1066
|
+
"settings",
|
|
1067
|
+
_core.nn.call(void 0, this.roomSubscriptionSettings.signal.get()[roomId])
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
}, _core.shallow);
|
|
1071
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1072
|
+
}
|
|
1073
|
+
);
|
|
1008
1074
|
const versionsByRoomId = new (0, _core.DefaultMap)(
|
|
1009
1075
|
(roomId) => {
|
|
1010
1076
|
const resource = new SinglePageResource(async () => {
|
|
@@ -1036,18 +1102,18 @@ var UmbrellaStore = class {
|
|
|
1036
1102
|
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1037
1103
|
}
|
|
1038
1104
|
);
|
|
1039
|
-
const
|
|
1105
|
+
const notificationSettings = {
|
|
1040
1106
|
signal: _core.DerivedSignal.from(() => {
|
|
1041
|
-
const result = this.#
|
|
1107
|
+
const result = this.#notificationSettings.get();
|
|
1042
1108
|
if (result.isLoading || result.error) {
|
|
1043
1109
|
return result;
|
|
1044
1110
|
}
|
|
1045
1111
|
return ASYNC_OK(
|
|
1046
1112
|
"settings",
|
|
1047
|
-
_core.nn.call(void 0, this.
|
|
1113
|
+
_core.nn.call(void 0, this.notificationSettings.signal.get())
|
|
1048
1114
|
);
|
|
1049
1115
|
}, _core.shallow),
|
|
1050
|
-
waitUntilLoaded: this.#
|
|
1116
|
+
waitUntilLoaded: this.#notificationSettings.waitUntilLoaded
|
|
1051
1117
|
};
|
|
1052
1118
|
this.outputs = {
|
|
1053
1119
|
threadifications,
|
|
@@ -1056,9 +1122,10 @@ var UmbrellaStore = class {
|
|
|
1056
1122
|
loadingUserThreads,
|
|
1057
1123
|
notifications,
|
|
1058
1124
|
loadingNotifications,
|
|
1059
|
-
|
|
1125
|
+
roomSubscriptionSettingsByRoomId,
|
|
1060
1126
|
versionsByRoomId,
|
|
1061
|
-
|
|
1127
|
+
notificationSettings,
|
|
1128
|
+
threadSubscriptions
|
|
1062
1129
|
};
|
|
1063
1130
|
autobind(this);
|
|
1064
1131
|
}
|
|
@@ -1100,6 +1167,26 @@ var UmbrellaStore = class {
|
|
|
1100
1167
|
this.notifications.clear();
|
|
1101
1168
|
});
|
|
1102
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Creates a existing subscription, replacing the corresponding
|
|
1172
|
+
* optimistic update.
|
|
1173
|
+
*/
|
|
1174
|
+
createSubscription(subscription, optimisticId) {
|
|
1175
|
+
_core.batch.call(void 0, () => {
|
|
1176
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1177
|
+
this.subscriptions.create(subscription);
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Deletes an existing subscription, replacing the corresponding
|
|
1182
|
+
* optimistic update.
|
|
1183
|
+
*/
|
|
1184
|
+
deleteSubscription(subscriptionKey, optimisticId) {
|
|
1185
|
+
_core.batch.call(void 0, () => {
|
|
1186
|
+
this.optimisticUpdates.remove(optimisticId);
|
|
1187
|
+
this.subscriptions.delete(subscriptionKey);
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1103
1190
|
/**
|
|
1104
1191
|
* Creates an new thread, replacing the corresponding optimistic update.
|
|
1105
1192
|
*/
|
|
@@ -1201,20 +1288,21 @@ var UmbrellaStore = class {
|
|
|
1201
1288
|
deletedAt
|
|
1202
1289
|
);
|
|
1203
1290
|
}
|
|
1204
|
-
updateThreadifications(threads, notifications, deletedThreads = [], deletedNotifications = []) {
|
|
1291
|
+
updateThreadifications(threads, notifications, subscriptions, deletedThreads = [], deletedNotifications = [], deletedSubscriptions = []) {
|
|
1205
1292
|
_core.batch.call(void 0, () => {
|
|
1206
1293
|
this.threads.applyDelta(threads, deletedThreads);
|
|
1207
1294
|
this.notifications.applyDelta(notifications, deletedNotifications);
|
|
1295
|
+
this.subscriptions.applyDelta(subscriptions, deletedSubscriptions);
|
|
1208
1296
|
});
|
|
1209
1297
|
}
|
|
1210
1298
|
/**
|
|
1211
|
-
* Updates existing
|
|
1299
|
+
* Updates existing subscription settings for a room with a new value,
|
|
1212
1300
|
* replacing the corresponding optimistic update.
|
|
1213
1301
|
*/
|
|
1214
|
-
|
|
1302
|
+
updateRoomSubscriptionSettings(roomId, optimisticId, settings) {
|
|
1215
1303
|
_core.batch.call(void 0, () => {
|
|
1216
1304
|
this.optimisticUpdates.remove(optimisticId);
|
|
1217
|
-
this.
|
|
1305
|
+
this.roomSubscriptionSettings.update(roomId, settings);
|
|
1218
1306
|
});
|
|
1219
1307
|
}
|
|
1220
1308
|
async fetchNotificationsDeltaUpdate(signal) {
|
|
@@ -1232,8 +1320,10 @@ var UmbrellaStore = class {
|
|
|
1232
1320
|
this.updateThreadifications(
|
|
1233
1321
|
result.threads.updated,
|
|
1234
1322
|
result.inboxNotifications.updated,
|
|
1323
|
+
result.subscriptions.updated,
|
|
1235
1324
|
result.threads.deleted,
|
|
1236
|
-
result.inboxNotifications.deleted
|
|
1325
|
+
result.inboxNotifications.deleted,
|
|
1326
|
+
result.subscriptions.deleted
|
|
1237
1327
|
);
|
|
1238
1328
|
}
|
|
1239
1329
|
async fetchRoomThreadsDeltaUpdate(roomId, signal) {
|
|
@@ -1249,8 +1339,10 @@ var UmbrellaStore = class {
|
|
|
1249
1339
|
this.updateThreadifications(
|
|
1250
1340
|
updates.threads.updated,
|
|
1251
1341
|
updates.inboxNotifications.updated,
|
|
1342
|
+
updates.subscriptions.updated,
|
|
1252
1343
|
updates.threads.deleted,
|
|
1253
|
-
updates.inboxNotifications.deleted
|
|
1344
|
+
updates.inboxNotifications.deleted,
|
|
1345
|
+
updates.subscriptions.deleted
|
|
1254
1346
|
);
|
|
1255
1347
|
this.permissionHints.update(updates.permissionHints);
|
|
1256
1348
|
if (lastRequestedAt < updates.requestedAt) {
|
|
@@ -1272,8 +1364,10 @@ var UmbrellaStore = class {
|
|
|
1272
1364
|
this.updateThreadifications(
|
|
1273
1365
|
result.threads.updated,
|
|
1274
1366
|
result.inboxNotifications.updated,
|
|
1367
|
+
result.subscriptions.updated,
|
|
1275
1368
|
result.threads.deleted,
|
|
1276
|
-
result.inboxNotifications.deleted
|
|
1369
|
+
result.inboxNotifications.deleted,
|
|
1370
|
+
result.subscriptions.deleted
|
|
1277
1371
|
);
|
|
1278
1372
|
this.permissionHints.update(result.permissionHints);
|
|
1279
1373
|
}
|
|
@@ -1295,31 +1389,31 @@ var UmbrellaStore = class {
|
|
|
1295
1389
|
this.#roomVersionsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1296
1390
|
}
|
|
1297
1391
|
}
|
|
1298
|
-
async
|
|
1392
|
+
async refreshRoomSubscriptionSettings(roomId, signal) {
|
|
1299
1393
|
const room = _core.nn.call(void 0,
|
|
1300
1394
|
this.#client.getRoom(roomId),
|
|
1301
1395
|
`Room with id ${roomId} is not available on client`
|
|
1302
1396
|
);
|
|
1303
|
-
const result = await room.
|
|
1304
|
-
this.
|
|
1397
|
+
const result = await room.getSubscriptionSettings({ signal });
|
|
1398
|
+
this.roomSubscriptionSettings.update(roomId, result);
|
|
1305
1399
|
}
|
|
1306
1400
|
/**
|
|
1307
|
-
* Refresh
|
|
1401
|
+
* Refresh notification settings from poller
|
|
1308
1402
|
*/
|
|
1309
|
-
async
|
|
1403
|
+
async refreshNotificationSettings(signal) {
|
|
1310
1404
|
const result = await this.#client.getNotificationSettings({
|
|
1311
1405
|
signal
|
|
1312
1406
|
});
|
|
1313
|
-
this.
|
|
1407
|
+
this.notificationSettings.update(result);
|
|
1314
1408
|
}
|
|
1315
1409
|
/**
|
|
1316
|
-
* Updates
|
|
1410
|
+
* Updates notification settings with a new value, replacing the
|
|
1317
1411
|
* corresponding optimistic update.
|
|
1318
1412
|
*/
|
|
1319
|
-
|
|
1413
|
+
updateNotificationSettings_confirmOptimisticUpdate(settings, optimisticUpdateId) {
|
|
1320
1414
|
_core.batch.call(void 0, () => {
|
|
1321
1415
|
this.optimisticUpdates.remove(optimisticUpdateId);
|
|
1322
|
-
this.
|
|
1416
|
+
this.notificationSettings.update(settings);
|
|
1323
1417
|
});
|
|
1324
1418
|
}
|
|
1325
1419
|
};
|
|
@@ -1478,29 +1572,80 @@ function applyOptimisticUpdates_forThreadifications(baseThreadsDB, notifications
|
|
|
1478
1572
|
threadsDB
|
|
1479
1573
|
};
|
|
1480
1574
|
}
|
|
1481
|
-
function
|
|
1482
|
-
const
|
|
1575
|
+
function applyOptimisticUpdates_forRoomSubscriptionSettings(settingsLUT, optimisticUpdates) {
|
|
1576
|
+
const roomSubscriptionSettingsByRoomId = Object.fromEntries(settingsLUT);
|
|
1483
1577
|
for (const optimisticUpdate of optimisticUpdates) {
|
|
1484
1578
|
switch (optimisticUpdate.type) {
|
|
1485
|
-
case "update-
|
|
1486
|
-
const settings =
|
|
1579
|
+
case "update-room-subscription-settings": {
|
|
1580
|
+
const settings = roomSubscriptionSettingsByRoomId[optimisticUpdate.roomId];
|
|
1487
1581
|
if (settings === void 0) {
|
|
1488
1582
|
break;
|
|
1489
1583
|
}
|
|
1490
|
-
|
|
1584
|
+
roomSubscriptionSettingsByRoomId[optimisticUpdate.roomId] = {
|
|
1491
1585
|
...settings,
|
|
1492
1586
|
...optimisticUpdate.settings
|
|
1493
1587
|
};
|
|
1494
1588
|
}
|
|
1495
1589
|
}
|
|
1496
1590
|
}
|
|
1497
|
-
return
|
|
1591
|
+
return roomSubscriptionSettingsByRoomId;
|
|
1592
|
+
}
|
|
1593
|
+
function applyOptimisticUpdates_forSubscriptions(subscriptionsLUT, threads, optimisticUpdates) {
|
|
1594
|
+
const subscriptions = Object.fromEntries(subscriptionsLUT);
|
|
1595
|
+
for (const update of optimisticUpdates) {
|
|
1596
|
+
if (update.type === "update-room-subscription-settings") {
|
|
1597
|
+
if (update.settings.threads) {
|
|
1598
|
+
const roomThreads = threads.findMany(update.roomId, void 0, "desc");
|
|
1599
|
+
for (const thread of roomThreads) {
|
|
1600
|
+
const subscriptionKey = _core.getSubscriptionKey.call(void 0, "thread", thread.id);
|
|
1601
|
+
if (update.settings.threads === "all") {
|
|
1602
|
+
subscriptions[subscriptionKey] = {
|
|
1603
|
+
kind: "thread",
|
|
1604
|
+
subjectId: thread.id,
|
|
1605
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1606
|
+
};
|
|
1607
|
+
} else if (update.settings.threads === "none") {
|
|
1608
|
+
delete subscriptions[subscriptionKey];
|
|
1609
|
+
} else if (update.settings.threads === "replies_and_mentions") {
|
|
1610
|
+
let isParticipant = false;
|
|
1611
|
+
for (const comment of thread.comments) {
|
|
1612
|
+
if (comment.deletedAt) {
|
|
1613
|
+
continue;
|
|
1614
|
+
}
|
|
1615
|
+
if (comment.userId === update.userId) {
|
|
1616
|
+
isParticipant = true;
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
const mentionedIds = _core.getMentionedIdsFromCommentBody.call(void 0, comment.body);
|
|
1620
|
+
if (mentionedIds.includes(update.userId)) {
|
|
1621
|
+
isParticipant = true;
|
|
1622
|
+
break;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
if (isParticipant && !subscriptions[subscriptionKey]) {
|
|
1626
|
+
subscriptions[subscriptionKey] = {
|
|
1627
|
+
kind: "thread",
|
|
1628
|
+
subjectId: thread.id,
|
|
1629
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
} else {
|
|
1633
|
+
_core.assertNever.call(void 0,
|
|
1634
|
+
update.settings.threads,
|
|
1635
|
+
"Unexpected room subscription settings."
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
return subscriptions;
|
|
1498
1643
|
}
|
|
1499
|
-
function
|
|
1644
|
+
function applyOptimisticUpdates_forNotificationSettings(settings, optimisticUpdates) {
|
|
1500
1645
|
let outcoming = settings;
|
|
1501
1646
|
for (const update of optimisticUpdates) {
|
|
1502
|
-
if (update.type === "update-
|
|
1503
|
-
outcoming = _core.
|
|
1647
|
+
if (update.type === "update-notification-settings") {
|
|
1648
|
+
outcoming = _core.patchNotificationSettings.call(void 0, outcoming, update.settings);
|
|
1504
1649
|
}
|
|
1505
1650
|
}
|
|
1506
1651
|
return outcoming;
|
|
@@ -1798,13 +1943,13 @@ function makeLiveblocksExtrasForClient(client) {
|
|
|
1798
1943
|
config.USER_THREADS_POLL_INTERVAL,
|
|
1799
1944
|
{ maxStaleTimeMs: config.USER_THREADS_MAX_STALE_TIME }
|
|
1800
1945
|
);
|
|
1801
|
-
const
|
|
1946
|
+
const notificationSettingsPoller = _core.makePoller.call(void 0,
|
|
1802
1947
|
async (signal) => {
|
|
1803
1948
|
try {
|
|
1804
|
-
return await store.
|
|
1949
|
+
return await store.refreshNotificationSettings(signal);
|
|
1805
1950
|
} catch (err) {
|
|
1806
1951
|
console.warn(
|
|
1807
|
-
`Polling new
|
|
1952
|
+
`Polling new notification settings failed: ${String(err)}`
|
|
1808
1953
|
);
|
|
1809
1954
|
throw err;
|
|
1810
1955
|
}
|
|
@@ -1816,7 +1961,7 @@ function makeLiveblocksExtrasForClient(client) {
|
|
|
1816
1961
|
store,
|
|
1817
1962
|
notificationsPoller,
|
|
1818
1963
|
userThreadsPoller,
|
|
1819
|
-
|
|
1964
|
+
notificationSettingsPoller
|
|
1820
1965
|
};
|
|
1821
1966
|
}
|
|
1822
1967
|
function makeLiveblocksContextBundle(client) {
|
|
@@ -2044,12 +2189,12 @@ function useUpdateNotificationSettings_withClient(client) {
|
|
|
2044
2189
|
(settings) => {
|
|
2045
2190
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
2046
2191
|
const optimisticUpdateId = store.optimisticUpdates.add({
|
|
2047
|
-
type: "update-
|
|
2192
|
+
type: "update-notification-settings",
|
|
2048
2193
|
settings
|
|
2049
2194
|
});
|
|
2050
2195
|
client.updateNotificationSettings(settings).then(
|
|
2051
2196
|
(settings2) => {
|
|
2052
|
-
store.
|
|
2197
|
+
store.updateNotificationSettings_confirmOptimisticUpdate(
|
|
2053
2198
|
settings2,
|
|
2054
2199
|
optimisticUpdateId
|
|
2055
2200
|
);
|
|
@@ -2078,9 +2223,9 @@ function useUpdateNotificationSettings_withClient(client) {
|
|
|
2078
2223
|
}
|
|
2079
2224
|
function useNotificationSettings_withClient(client) {
|
|
2080
2225
|
const updateNotificationSettings = useUpdateNotificationSettings_withClient(client);
|
|
2081
|
-
const { store,
|
|
2226
|
+
const { store, notificationSettingsPoller: poller } = getLiveblocksExtrasForClient(client);
|
|
2082
2227
|
_react.useEffect.call(void 0, () => {
|
|
2083
|
-
void store.outputs.
|
|
2228
|
+
void store.outputs.notificationSettings.waitUntilLoaded();
|
|
2084
2229
|
});
|
|
2085
2230
|
_react.useEffect.call(void 0, () => {
|
|
2086
2231
|
poller.inc();
|
|
@@ -2089,7 +2234,7 @@ function useNotificationSettings_withClient(client) {
|
|
|
2089
2234
|
poller.dec();
|
|
2090
2235
|
};
|
|
2091
2236
|
}, [poller]);
|
|
2092
|
-
const result = useSignal(store.outputs.
|
|
2237
|
+
const result = useSignal(store.outputs.notificationSettings.signal);
|
|
2093
2238
|
return _react.useMemo.call(void 0, () => {
|
|
2094
2239
|
return [result, updateNotificationSettings];
|
|
2095
2240
|
}, [result, updateNotificationSettings]);
|
|
@@ -2097,7 +2242,7 @@ function useNotificationSettings_withClient(client) {
|
|
|
2097
2242
|
function useNotificationSettingsSuspense_withClient(client) {
|
|
2098
2243
|
ensureNotServerSide();
|
|
2099
2244
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
2100
|
-
use(store.outputs.
|
|
2245
|
+
use(store.outputs.notificationSettings.waitUntilLoaded());
|
|
2101
2246
|
const [result, updateNotificationSettings] = useNotificationSettings_withClient(client);
|
|
2102
2247
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
2103
2248
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
@@ -2469,6 +2614,7 @@ var _client = require('@liveblocks/client');
|
|
|
2469
2614
|
|
|
2470
2615
|
|
|
2471
2616
|
|
|
2617
|
+
|
|
2472
2618
|
|
|
2473
2619
|
|
|
2474
2620
|
// src/use-scroll-to-comment-on-load-effect.ts
|
|
@@ -2615,29 +2761,36 @@ function makeRoomExtrasForClient(client) {
|
|
|
2615
2761
|
{ maxStaleTimeMs: config.HISTORY_VERSIONS_MAX_STALE_TIME }
|
|
2616
2762
|
)
|
|
2617
2763
|
);
|
|
2618
|
-
const
|
|
2764
|
+
const roomSubscriptionSettingsPollersByRoomId = new (0, _core.DefaultMap)(
|
|
2619
2765
|
(roomId) => _core.makePoller.call(void 0,
|
|
2620
2766
|
async (signal) => {
|
|
2621
2767
|
try {
|
|
2622
|
-
return await store.
|
|
2768
|
+
return await store.refreshRoomSubscriptionSettings(roomId, signal);
|
|
2623
2769
|
} catch (err) {
|
|
2624
|
-
_core.console.warn(`Polling
|
|
2770
|
+
_core.console.warn(`Polling subscription settings for '${roomId}' failed: ${String(err)}`);
|
|
2625
2771
|
throw err;
|
|
2626
2772
|
}
|
|
2627
2773
|
},
|
|
2628
|
-
config.
|
|
2629
|
-
{ maxStaleTimeMs: config.
|
|
2774
|
+
config.ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL,
|
|
2775
|
+
{ maxStaleTimeMs: config.ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME }
|
|
2630
2776
|
)
|
|
2631
2777
|
);
|
|
2632
2778
|
return {
|
|
2633
2779
|
store,
|
|
2634
2780
|
onMutationFailure,
|
|
2781
|
+
pollThreadsForRoomId: (roomId) => {
|
|
2782
|
+
const threadsPoller = threadsPollersByRoomId.getOrCreate(roomId);
|
|
2783
|
+
if (threadsPoller) {
|
|
2784
|
+
threadsPoller.markAsStale();
|
|
2785
|
+
threadsPoller.pollNowIfStale();
|
|
2786
|
+
}
|
|
2787
|
+
},
|
|
2635
2788
|
getOrCreateThreadsPollerForRoomId: threadsPollersByRoomId.getOrCreate.bind(
|
|
2636
2789
|
threadsPollersByRoomId
|
|
2637
2790
|
),
|
|
2638
2791
|
getOrCreateVersionsPollerForRoomId: versionsPollersByRoomId.getOrCreate.bind(versionsPollersByRoomId),
|
|
2639
|
-
|
|
2640
|
-
|
|
2792
|
+
getOrCreateSubscriptionSettingsPollerForRoomId: roomSubscriptionSettingsPollersByRoomId.getOrCreate.bind(
|
|
2793
|
+
roomSubscriptionSettingsPollersByRoomId
|
|
2641
2794
|
)
|
|
2642
2795
|
};
|
|
2643
2796
|
}
|
|
@@ -2678,6 +2831,8 @@ function makeRoomContextBundle(client) {
|
|
|
2678
2831
|
useEditThreadMetadata,
|
|
2679
2832
|
useMarkThreadAsResolved,
|
|
2680
2833
|
useMarkThreadAsUnresolved,
|
|
2834
|
+
useSubscribeToThread,
|
|
2835
|
+
useUnsubscribeFromThread,
|
|
2681
2836
|
useCreateComment,
|
|
2682
2837
|
useEditComment,
|
|
2683
2838
|
useDeleteComment,
|
|
@@ -2689,7 +2844,9 @@ function makeRoomContextBundle(client) {
|
|
|
2689
2844
|
useHistoryVersions,
|
|
2690
2845
|
useHistoryVersionData,
|
|
2691
2846
|
useRoomNotificationSettings,
|
|
2847
|
+
useRoomSubscriptionSettings,
|
|
2692
2848
|
useUpdateRoomNotificationSettings,
|
|
2849
|
+
useUpdateRoomSubscriptionSettings,
|
|
2693
2850
|
...shared.classic,
|
|
2694
2851
|
suspense: {
|
|
2695
2852
|
RoomContext,
|
|
@@ -2723,6 +2880,8 @@ function makeRoomContextBundle(client) {
|
|
|
2723
2880
|
useEditThreadMetadata,
|
|
2724
2881
|
useMarkThreadAsResolved,
|
|
2725
2882
|
useMarkThreadAsUnresolved,
|
|
2883
|
+
useSubscribeToThread,
|
|
2884
|
+
useUnsubscribeFromThread,
|
|
2726
2885
|
useCreateComment,
|
|
2727
2886
|
useEditComment,
|
|
2728
2887
|
useDeleteComment,
|
|
@@ -2734,7 +2893,9 @@ function makeRoomContextBundle(client) {
|
|
|
2734
2893
|
// TODO: useHistoryVersionData: useHistoryVersionDataSuspense,
|
|
2735
2894
|
useHistoryVersions: useHistoryVersionsSuspense,
|
|
2736
2895
|
useRoomNotificationSettings: useRoomNotificationSettingsSuspense,
|
|
2896
|
+
useRoomSubscriptionSettings: useRoomSubscriptionSettingsSuspense,
|
|
2737
2897
|
useUpdateRoomNotificationSettings,
|
|
2898
|
+
useUpdateRoomSubscriptionSettings,
|
|
2738
2899
|
...shared.suspense
|
|
2739
2900
|
}
|
|
2740
2901
|
};
|
|
@@ -2813,7 +2974,11 @@ function RoomProviderInner(props) {
|
|
|
2813
2974
|
store.deleteThread(message.threadId, null);
|
|
2814
2975
|
return;
|
|
2815
2976
|
}
|
|
2816
|
-
const {
|
|
2977
|
+
const {
|
|
2978
|
+
thread,
|
|
2979
|
+
inboxNotification: maybeNotification,
|
|
2980
|
+
subscription: maybeSubscription
|
|
2981
|
+
} = info;
|
|
2817
2982
|
const existingThread = store.outputs.threads.get().getEvenIfDeleted(message.threadId);
|
|
2818
2983
|
switch (message.type) {
|
|
2819
2984
|
case _core.ServerMsgCode.COMMENT_EDITED:
|
|
@@ -2825,13 +2990,15 @@ function RoomProviderInner(props) {
|
|
|
2825
2990
|
if (!existingThread) break;
|
|
2826
2991
|
store.updateThreadifications(
|
|
2827
2992
|
[thread],
|
|
2828
|
-
maybeNotification ? [maybeNotification] : []
|
|
2993
|
+
maybeNotification ? [maybeNotification] : [],
|
|
2994
|
+
maybeSubscription ? [maybeSubscription] : []
|
|
2829
2995
|
);
|
|
2830
2996
|
break;
|
|
2831
2997
|
case _core.ServerMsgCode.COMMENT_CREATED:
|
|
2832
2998
|
store.updateThreadifications(
|
|
2833
2999
|
[thread],
|
|
2834
|
-
maybeNotification ? [maybeNotification] : []
|
|
3000
|
+
maybeNotification ? [maybeNotification] : [],
|
|
3001
|
+
maybeSubscription ? [maybeSubscription] : []
|
|
2835
3002
|
);
|
|
2836
3003
|
break;
|
|
2837
3004
|
default:
|
|
@@ -3680,25 +3847,103 @@ function useMarkRoomThreadAsUnresolved(roomId) {
|
|
|
3680
3847
|
[client, roomId]
|
|
3681
3848
|
);
|
|
3682
3849
|
}
|
|
3850
|
+
function useSubscribeToThread() {
|
|
3851
|
+
return useSubscribeToRoomThread(useRoom().id);
|
|
3852
|
+
}
|
|
3853
|
+
function useSubscribeToRoomThread(roomId) {
|
|
3854
|
+
const client = useClient();
|
|
3855
|
+
return _react.useCallback.call(void 0,
|
|
3856
|
+
(threadId) => {
|
|
3857
|
+
const subscribedAt = /* @__PURE__ */ new Date();
|
|
3858
|
+
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3859
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3860
|
+
type: "subscribe-to-thread",
|
|
3861
|
+
threadId,
|
|
3862
|
+
subscribedAt
|
|
3863
|
+
});
|
|
3864
|
+
client[_core.kInternal].httpClient.subscribeToThread({ roomId, threadId }).then(
|
|
3865
|
+
(subscription) => {
|
|
3866
|
+
store.createSubscription(subscription, optimisticId);
|
|
3867
|
+
},
|
|
3868
|
+
(err) => onMutationFailure(
|
|
3869
|
+
optimisticId,
|
|
3870
|
+
{ type: "SUBSCRIBE_TO_THREAD_ERROR", roomId, threadId },
|
|
3871
|
+
err
|
|
3872
|
+
)
|
|
3873
|
+
);
|
|
3874
|
+
},
|
|
3875
|
+
[client, roomId]
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3878
|
+
function useUnsubscribeFromThread() {
|
|
3879
|
+
return useUnsubscribeFromRoomThread(useRoom().id);
|
|
3880
|
+
}
|
|
3881
|
+
function useUnsubscribeFromRoomThread(roomId) {
|
|
3882
|
+
const client = useClient();
|
|
3883
|
+
return _react.useCallback.call(void 0,
|
|
3884
|
+
(threadId) => {
|
|
3885
|
+
const unsubscribedAt = /* @__PURE__ */ new Date();
|
|
3886
|
+
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3887
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
3888
|
+
type: "unsubscribe-from-thread",
|
|
3889
|
+
threadId,
|
|
3890
|
+
unsubscribedAt
|
|
3891
|
+
});
|
|
3892
|
+
client[_core.kInternal].httpClient.unsubscribeFromThread({ roomId, threadId }).then(
|
|
3893
|
+
() => {
|
|
3894
|
+
store.deleteSubscription(
|
|
3895
|
+
_core.getSubscriptionKey.call(void 0, "thread", threadId),
|
|
3896
|
+
optimisticId
|
|
3897
|
+
);
|
|
3898
|
+
},
|
|
3899
|
+
(err) => onMutationFailure(
|
|
3900
|
+
optimisticId,
|
|
3901
|
+
{ type: "UNSUBSCRIBE_FROM_THREAD_ERROR", roomId, threadId },
|
|
3902
|
+
err
|
|
3903
|
+
)
|
|
3904
|
+
);
|
|
3905
|
+
},
|
|
3906
|
+
[client, roomId]
|
|
3907
|
+
);
|
|
3908
|
+
}
|
|
3683
3909
|
function useThreadSubscription(threadId) {
|
|
3910
|
+
return useRoomThreadSubscription(useRoom().id, threadId);
|
|
3911
|
+
}
|
|
3912
|
+
function useRoomThreadSubscription(roomId, threadId) {
|
|
3684
3913
|
const client = useClient();
|
|
3685
3914
|
const { store } = getRoomExtrasForClient(client);
|
|
3686
|
-
const
|
|
3915
|
+
const subscriptionKey = _react.useMemo.call(void 0,
|
|
3916
|
+
() => _core.getSubscriptionKey.call(void 0, "thread", threadId),
|
|
3917
|
+
[threadId]
|
|
3918
|
+
);
|
|
3919
|
+
const subscribeToThread = useSubscribeToRoomThread(roomId);
|
|
3920
|
+
const unsubscribeFromThread = useUnsubscribeFromRoomThread(roomId);
|
|
3921
|
+
const subscribe = _react.useCallback.call(void 0,
|
|
3922
|
+
() => subscribeToThread(threadId),
|
|
3923
|
+
[subscribeToThread, threadId]
|
|
3924
|
+
);
|
|
3925
|
+
const unsubscribe = _react.useCallback.call(void 0,
|
|
3926
|
+
() => unsubscribeFromThread(threadId),
|
|
3927
|
+
[unsubscribeFromThread, threadId]
|
|
3928
|
+
);
|
|
3929
|
+
const signal = store.outputs.threadSubscriptions;
|
|
3687
3930
|
const selector = _react.useCallback.call(void 0,
|
|
3688
3931
|
(state) => {
|
|
3689
|
-
const
|
|
3932
|
+
const subscription = state.subscriptions[subscriptionKey];
|
|
3933
|
+
const notification = state.notifications.find(
|
|
3690
3934
|
(inboxNotification) => inboxNotification.kind === "thread" && inboxNotification.threadId === threadId
|
|
3691
3935
|
);
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
return { status: "not-subscribed" };
|
|
3936
|
+
if (subscription === void 0) {
|
|
3937
|
+
return { status: "not-subscribed", subscribe, unsubscribe };
|
|
3695
3938
|
}
|
|
3696
3939
|
return {
|
|
3697
3940
|
status: "subscribed",
|
|
3698
|
-
unreadSince: notification.readAt
|
|
3941
|
+
unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _33 => _33.readAt]), () => ( null)),
|
|
3942
|
+
subscribe,
|
|
3943
|
+
unsubscribe
|
|
3699
3944
|
};
|
|
3700
3945
|
},
|
|
3701
|
-
[threadId]
|
|
3946
|
+
[subscriptionKey, threadId, subscribe, unsubscribe]
|
|
3702
3947
|
);
|
|
3703
3948
|
return useSignal(signal, selector, _client.shallow);
|
|
3704
3949
|
}
|
|
@@ -3706,10 +3951,10 @@ function useRoomNotificationSettings() {
|
|
|
3706
3951
|
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
3707
3952
|
const client = useClient();
|
|
3708
3953
|
const room = useRoom();
|
|
3709
|
-
const { store,
|
|
3710
|
-
const poller =
|
|
3954
|
+
const { store, getOrCreateSubscriptionSettingsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3955
|
+
const poller = getOrCreateSubscriptionSettingsPollerForRoomId(room.id);
|
|
3711
3956
|
_react.useEffect.call(void 0,
|
|
3712
|
-
() => void store.outputs.
|
|
3957
|
+
() => void store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
|
|
3713
3958
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
3714
3959
|
//
|
|
3715
3960
|
// It is important to call waitUntil on *every* render.
|
|
@@ -3727,18 +3972,51 @@ function useRoomNotificationSettings() {
|
|
|
3727
3972
|
};
|
|
3728
3973
|
}, [poller]);
|
|
3729
3974
|
const settings = useSignal(
|
|
3730
|
-
store.outputs.
|
|
3975
|
+
store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
|
|
3731
3976
|
);
|
|
3732
3977
|
return _react.useMemo.call(void 0, () => {
|
|
3733
3978
|
return [settings, updateRoomNotificationSettings];
|
|
3734
3979
|
}, [settings, updateRoomNotificationSettings]);
|
|
3735
3980
|
}
|
|
3981
|
+
function useRoomSubscriptionSettings() {
|
|
3982
|
+
const updateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings();
|
|
3983
|
+
const client = useClient();
|
|
3984
|
+
const room = useRoom();
|
|
3985
|
+
const { store, getOrCreateSubscriptionSettingsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3986
|
+
const poller = getOrCreateSubscriptionSettingsPollerForRoomId(room.id);
|
|
3987
|
+
_react.useEffect.call(void 0,
|
|
3988
|
+
() => void store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
|
|
3989
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
3990
|
+
//
|
|
3991
|
+
// It is important to call waitUntil on *every* render.
|
|
3992
|
+
// This is harmless though, on most renders, except:
|
|
3993
|
+
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
3994
|
+
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
3995
|
+
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3996
|
+
// *next* render after that, a *new* fetch/promise will get created.
|
|
3997
|
+
);
|
|
3998
|
+
_react.useEffect.call(void 0, () => {
|
|
3999
|
+
poller.inc();
|
|
4000
|
+
poller.pollNowIfStale();
|
|
4001
|
+
return () => {
|
|
4002
|
+
poller.dec();
|
|
4003
|
+
};
|
|
4004
|
+
}, [poller]);
|
|
4005
|
+
const settings = useSignal(
|
|
4006
|
+
store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
|
|
4007
|
+
);
|
|
4008
|
+
return _react.useMemo.call(void 0, () => {
|
|
4009
|
+
return [settings, updateRoomSubscriptionSettings];
|
|
4010
|
+
}, [settings, updateRoomSubscriptionSettings]);
|
|
4011
|
+
}
|
|
3736
4012
|
function useRoomNotificationSettingsSuspense() {
|
|
3737
4013
|
ensureNotServerSide();
|
|
3738
4014
|
const client = useClient();
|
|
3739
4015
|
const store = getRoomExtrasForClient(client).store;
|
|
3740
4016
|
const room = useRoom();
|
|
3741
|
-
use(
|
|
4017
|
+
use(
|
|
4018
|
+
store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
|
|
4019
|
+
);
|
|
3742
4020
|
const [settings, updateRoomNotificationSettings] = useRoomNotificationSettings();
|
|
3743
4021
|
_core.assert.call(void 0, !settings.error, "Did not expect error");
|
|
3744
4022
|
_core.assert.call(void 0, !settings.isLoading, "Did not expect loading");
|
|
@@ -3746,6 +4024,21 @@ function useRoomNotificationSettingsSuspense() {
|
|
|
3746
4024
|
return [settings, updateRoomNotificationSettings];
|
|
3747
4025
|
}, [settings, updateRoomNotificationSettings]);
|
|
3748
4026
|
}
|
|
4027
|
+
function useRoomSubscriptionSettingsSuspense() {
|
|
4028
|
+
ensureNotServerSide();
|
|
4029
|
+
const client = useClient();
|
|
4030
|
+
const store = getRoomExtrasForClient(client).store;
|
|
4031
|
+
const room = useRoom();
|
|
4032
|
+
use(
|
|
4033
|
+
store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
|
|
4034
|
+
);
|
|
4035
|
+
const [settings, updateRoomSubscriptionSettings] = useRoomSubscriptionSettings();
|
|
4036
|
+
_core.assert.call(void 0, !settings.error, "Did not expect error");
|
|
4037
|
+
_core.assert.call(void 0, !settings.isLoading, "Did not expect loading");
|
|
4038
|
+
return _react.useMemo.call(void 0, () => {
|
|
4039
|
+
return [settings, updateRoomSubscriptionSettings];
|
|
4040
|
+
}, [settings, updateRoomSubscriptionSettings]);
|
|
4041
|
+
}
|
|
3749
4042
|
function useHistoryVersionData(versionId) {
|
|
3750
4043
|
const [state, setState] = _react.useState.call(void 0, {
|
|
3751
4044
|
isLoading: true
|
|
@@ -3814,15 +4107,24 @@ function useUpdateRoomNotificationSettings() {
|
|
|
3814
4107
|
const room = useRoom();
|
|
3815
4108
|
return _react.useCallback.call(void 0,
|
|
3816
4109
|
(settings) => {
|
|
3817
|
-
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
4110
|
+
const { store, onMutationFailure, pollThreadsForRoomId } = getRoomExtrasForClient(client);
|
|
4111
|
+
const userId = getCurrentUserId(client);
|
|
3818
4112
|
const optimisticId = store.optimisticUpdates.add({
|
|
3819
|
-
type: "update-
|
|
4113
|
+
type: "update-room-subscription-settings",
|
|
3820
4114
|
roomId: room.id,
|
|
4115
|
+
userId,
|
|
3821
4116
|
settings
|
|
3822
4117
|
});
|
|
3823
|
-
room.
|
|
3824
|
-
(
|
|
3825
|
-
store.
|
|
4118
|
+
room.updateSubscriptionSettings(settings).then(
|
|
4119
|
+
(updatedSettings) => {
|
|
4120
|
+
store.updateRoomSubscriptionSettings(
|
|
4121
|
+
room.id,
|
|
4122
|
+
optimisticId,
|
|
4123
|
+
updatedSettings
|
|
4124
|
+
);
|
|
4125
|
+
if (settings.threads) {
|
|
4126
|
+
pollThreadsForRoomId(room.id);
|
|
4127
|
+
}
|
|
3826
4128
|
},
|
|
3827
4129
|
(err) => onMutationFailure(
|
|
3828
4130
|
optimisticId,
|
|
@@ -3834,6 +4136,43 @@ function useUpdateRoomNotificationSettings() {
|
|
|
3834
4136
|
[client, room]
|
|
3835
4137
|
);
|
|
3836
4138
|
}
|
|
4139
|
+
function useUpdateRoomSubscriptionSettings() {
|
|
4140
|
+
const client = useClient();
|
|
4141
|
+
const room = useRoom();
|
|
4142
|
+
return _react.useCallback.call(void 0,
|
|
4143
|
+
(settings) => {
|
|
4144
|
+
const { store, onMutationFailure, pollThreadsForRoomId } = getRoomExtrasForClient(client);
|
|
4145
|
+
const userId = getCurrentUserId(client);
|
|
4146
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
4147
|
+
type: "update-room-subscription-settings",
|
|
4148
|
+
roomId: room.id,
|
|
4149
|
+
userId,
|
|
4150
|
+
settings
|
|
4151
|
+
});
|
|
4152
|
+
room.updateSubscriptionSettings(settings).then(
|
|
4153
|
+
(udpatedSettings) => {
|
|
4154
|
+
store.updateRoomSubscriptionSettings(
|
|
4155
|
+
room.id,
|
|
4156
|
+
optimisticId,
|
|
4157
|
+
udpatedSettings
|
|
4158
|
+
);
|
|
4159
|
+
if (settings.threads) {
|
|
4160
|
+
pollThreadsForRoomId(room.id);
|
|
4161
|
+
}
|
|
4162
|
+
},
|
|
4163
|
+
(err) => onMutationFailure(
|
|
4164
|
+
optimisticId,
|
|
4165
|
+
{
|
|
4166
|
+
type: "UPDATE_ROOM_SUBSCRIPTION_SETTINGS_ERROR",
|
|
4167
|
+
roomId: room.id
|
|
4168
|
+
},
|
|
4169
|
+
err
|
|
4170
|
+
)
|
|
4171
|
+
);
|
|
4172
|
+
},
|
|
4173
|
+
[client, room]
|
|
4174
|
+
);
|
|
4175
|
+
}
|
|
3837
4176
|
function useSuspendUntilPresenceReady() {
|
|
3838
4177
|
ensureNotServerSide();
|
|
3839
4178
|
const room = useRoom();
|
|
@@ -3894,7 +4233,7 @@ function useThreadsSuspense(options = {}) {
|
|
|
3894
4233
|
return result;
|
|
3895
4234
|
}
|
|
3896
4235
|
function selectorFor_useAttachmentUrl(state) {
|
|
3897
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
4236
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _34 => _34.isLoading])) {
|
|
3898
4237
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
3899
4238
|
}
|
|
3900
4239
|
if (state.error) {
|
|
@@ -3985,7 +4324,9 @@ var _useOthersMappedSuspense = useOthersMappedSuspense;
|
|
|
3985
4324
|
var _useThreads = useThreads;
|
|
3986
4325
|
var _useThreadsSuspense = useThreadsSuspense;
|
|
3987
4326
|
var _useRoomNotificationSettings = useRoomNotificationSettings;
|
|
4327
|
+
var _useRoomSubscriptionSettings = useRoomSubscriptionSettings;
|
|
3988
4328
|
var _useRoomNotificationSettingsSuspense = useRoomNotificationSettingsSuspense;
|
|
4329
|
+
var _useRoomSubscriptionSettingsSuspense = useRoomSubscriptionSettingsSuspense;
|
|
3989
4330
|
var _useHistoryVersions = useHistoryVersions;
|
|
3990
4331
|
var _useHistoryVersionsSuspense = useHistoryVersionsSuspense;
|
|
3991
4332
|
var _useOther = useOther;
|
|
@@ -4111,5 +4452,11 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
4111
4452
|
|
|
4112
4453
|
|
|
4113
4454
|
|
|
4114
|
-
|
|
4115
|
-
|
|
4455
|
+
|
|
4456
|
+
|
|
4457
|
+
|
|
4458
|
+
|
|
4459
|
+
|
|
4460
|
+
|
|
4461
|
+
exports.RoomContext = RoomContext; 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.useNotificationSettings = useNotificationSettings; exports.useNotificationSettingsSuspense = useNotificationSettingsSuspense; exports.useUpdateNotificationSettings = useUpdateNotificationSettings; 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.useErrorListener = useErrorListener; 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.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; 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.useSubscribeToThread = useSubscribeToThread; exports.useUnsubscribeFromThread = useUnsubscribeFromThread; exports.useThreadSubscription = useThreadSubscription; exports.useRoomThreadSubscription = useRoomThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useUpdateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings; 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._useRoomSubscriptionSettings = _useRoomSubscriptionSettings; exports._useRoomNotificationSettingsSuspense = _useRoomNotificationSettingsSuspense; exports._useRoomSubscriptionSettingsSuspense = _useRoomSubscriptionSettingsSuspense; 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;
|
|
4462
|
+
//# sourceMappingURL=chunk-VEO3XXA7.cjs.map
|