@liveblocks/react 2.12.1-emails1 → 2.12.1-test2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_private.d.mts +2 -2
- package/dist/_private.d.ts +2 -2
- package/dist/_private.js +34 -8
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +33 -7
- package/dist/_private.mjs.map +1 -1
- package/dist/{chunk-IACZPXTY.js → chunk-HVOJBD7X.js} +156 -79
- package/dist/chunk-HVOJBD7X.js.map +1 -0
- package/dist/{chunk-2FEIER5D.mjs → chunk-IGSZZWUJ.mjs} +2 -2
- package/dist/{chunk-OGGMNN4C.js → chunk-MFSDNSIH.js} +2 -2
- package/dist/{chunk-CX62YECU.mjs → chunk-SEMVNYPJ.mjs} +155 -78
- package/dist/chunk-SEMVNYPJ.mjs.map +1 -0
- package/dist/index.d.mts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +2 -2
- package/dist/{liveblocks-1ujmr05d.d.mts → room-t_BUxm1-.d.mts} +761 -9
- package/dist/{liveblocks-1ujmr05d.d.ts → room-t_BUxm1-.d.ts} +761 -9
- package/dist/suspense.d.mts +2 -2
- package/dist/suspense.d.ts +2 -2
- package/dist/suspense.js +4 -4
- package/dist/suspense.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-CX62YECU.mjs.map +0 -1
- package/dist/chunk-IACZPXTY.js.map +0 -1
- package/dist/suspense-560_K0iP.d.ts +0 -730
- package/dist/suspense-TeBnnKGw.d.mts +0 -730
- /package/dist/{chunk-2FEIER5D.mjs.map → chunk-IGSZZWUJ.mjs.map} +0 -0
- /package/dist/{chunk-OGGMNN4C.js.map → chunk-MFSDNSIH.js.map} +0 -0
|
@@ -528,6 +528,7 @@ var UmbrellaStore = class {
|
|
|
528
528
|
this._rawThreadsDB = new ThreadDB();
|
|
529
529
|
this._store = _core.createStore.call(void 0, {
|
|
530
530
|
optimisticUpdates: [],
|
|
531
|
+
permissionsByRoom: {},
|
|
531
532
|
notificationsById: {},
|
|
532
533
|
settingsByRoomId: {},
|
|
533
534
|
versionsByRoomId: {}
|
|
@@ -656,6 +657,9 @@ var UmbrellaStore = class {
|
|
|
656
657
|
subscribe(callback) {
|
|
657
658
|
return this._store.subscribe(callback);
|
|
658
659
|
}
|
|
660
|
+
_getPermissions(roomId) {
|
|
661
|
+
return this._store.get().permissionsByRoom[roomId];
|
|
662
|
+
}
|
|
659
663
|
// Direct low-level cache mutations ------------------------------------------------- {{{
|
|
660
664
|
mutateThreadsDB(mutate) {
|
|
661
665
|
const db = this._rawThreadsDB;
|
|
@@ -954,17 +958,32 @@ var UmbrellaStore = class {
|
|
|
954
958
|
waitUntilNotificationsLoaded() {
|
|
955
959
|
return this._notifications.waitUntilLoaded();
|
|
956
960
|
}
|
|
961
|
+
updateRoomPermissions(permissions) {
|
|
962
|
+
const permissionsByRoom = { ...this._store.get().permissionsByRoom };
|
|
963
|
+
Object.entries(permissions).forEach(([roomId, newPermissions]) => {
|
|
964
|
+
const existingPermissions = _nullishCoalesce(permissionsByRoom[roomId], () => ( /* @__PURE__ */ new Set()));
|
|
965
|
+
newPermissions.forEach(
|
|
966
|
+
(permission) => existingPermissions.add(permission)
|
|
967
|
+
);
|
|
968
|
+
permissionsByRoom[roomId] = existingPermissions;
|
|
969
|
+
});
|
|
970
|
+
this._store.set((state) => ({
|
|
971
|
+
...state,
|
|
972
|
+
permissionsByRoom
|
|
973
|
+
}));
|
|
974
|
+
}
|
|
957
975
|
waitUntilRoomThreadsLoaded(roomId, query) {
|
|
958
976
|
const threadsFetcher = async (cursor) => {
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
977
|
+
const result = await this._client[_core.kInternal].httpClient.getThreads({
|
|
978
|
+
roomId,
|
|
979
|
+
cursor,
|
|
980
|
+
query
|
|
981
|
+
});
|
|
964
982
|
this.updateThreadsAndNotifications(
|
|
965
983
|
result.threads,
|
|
966
984
|
result.inboxNotifications
|
|
967
985
|
);
|
|
986
|
+
this.updateRoomPermissions(result.permissionHints);
|
|
968
987
|
const lastRequestedAt = this._roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
969
988
|
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
970
989
|
this._roomThreadsLastRequestedAtByRoom.set(roomId, result.requestedAt);
|
|
@@ -991,11 +1010,8 @@ var UmbrellaStore = class {
|
|
|
991
1010
|
if (lastRequestedAt === void 0) {
|
|
992
1011
|
return;
|
|
993
1012
|
}
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
`Room with id ${roomId} is not available on client`
|
|
997
|
-
);
|
|
998
|
-
const updates = await room.getThreadsSince({
|
|
1013
|
+
const updates = await this._client[_core.kInternal].httpClient.getThreadsSince({
|
|
1014
|
+
roomId,
|
|
999
1015
|
since: lastRequestedAt,
|
|
1000
1016
|
signal
|
|
1001
1017
|
});
|
|
@@ -1005,6 +1021,7 @@ var UmbrellaStore = class {
|
|
|
1005
1021
|
updates.threads.deleted,
|
|
1006
1022
|
updates.inboxNotifications.deleted
|
|
1007
1023
|
);
|
|
1024
|
+
this.updateRoomPermissions(updates.permissionHints);
|
|
1008
1025
|
if (lastRequestedAt < updates.requestedAt) {
|
|
1009
1026
|
this._roomThreadsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1010
1027
|
}
|
|
@@ -1012,7 +1029,7 @@ var UmbrellaStore = class {
|
|
|
1012
1029
|
waitUntilUserThreadsLoaded(query) {
|
|
1013
1030
|
const queryKey = makeUserThreadsQueryKey(query);
|
|
1014
1031
|
const threadsFetcher = async (cursor) => {
|
|
1015
|
-
const result = await this._client[_core.kInternal].getUserThreads_experimental({
|
|
1032
|
+
const result = await this._client[_core.kInternal].httpClient.getUserThreads_experimental({
|
|
1016
1033
|
cursor,
|
|
1017
1034
|
query
|
|
1018
1035
|
});
|
|
@@ -1020,6 +1037,7 @@ var UmbrellaStore = class {
|
|
|
1020
1037
|
result.threads,
|
|
1021
1038
|
result.inboxNotifications
|
|
1022
1039
|
);
|
|
1040
|
+
this.updateRoomPermissions(result.permissionHints);
|
|
1023
1041
|
if (this._userThreadsLastRequestedAt === null) {
|
|
1024
1042
|
this._userThreadsLastRequestedAt = result.requestedAt;
|
|
1025
1043
|
}
|
|
@@ -1044,7 +1062,7 @@ var UmbrellaStore = class {
|
|
|
1044
1062
|
if (lastRequestedAt === null) {
|
|
1045
1063
|
return;
|
|
1046
1064
|
}
|
|
1047
|
-
const result = await this._client[_core.kInternal].getUserThreadsSince_experimental({
|
|
1065
|
+
const result = await this._client[_core.kInternal].httpClient.getUserThreadsSince_experimental({
|
|
1048
1066
|
since: lastRequestedAt,
|
|
1049
1067
|
signal
|
|
1050
1068
|
});
|
|
@@ -1057,6 +1075,7 @@ var UmbrellaStore = class {
|
|
|
1057
1075
|
result.threads.deleted,
|
|
1058
1076
|
result.inboxNotifications.deleted
|
|
1059
1077
|
);
|
|
1078
|
+
this.updateRoomPermissions(result.permissionHints);
|
|
1060
1079
|
}
|
|
1061
1080
|
waitUntilRoomVersionsLoaded(roomId) {
|
|
1062
1081
|
const queryKey = makeVersionsQueryKey(roomId);
|
|
@@ -2367,13 +2386,12 @@ function makeMutationContext(room) {
|
|
|
2367
2386
|
setMyPresence: room.updatePresence
|
|
2368
2387
|
};
|
|
2369
2388
|
}
|
|
2370
|
-
function getCurrentUserId(
|
|
2371
|
-
const
|
|
2372
|
-
if (
|
|
2389
|
+
function getCurrentUserId(client) {
|
|
2390
|
+
const userId = client[_core.kInternal].currentUserIdStore.get();
|
|
2391
|
+
if (userId === void 0) {
|
|
2373
2392
|
return "anonymous";
|
|
2374
|
-
} else {
|
|
2375
|
-
return self.id;
|
|
2376
2393
|
}
|
|
2394
|
+
return userId;
|
|
2377
2395
|
}
|
|
2378
2396
|
function handleApiError(err) {
|
|
2379
2397
|
const message = `Request failed with status ${err.status}: ${err.message}`;
|
|
@@ -3020,8 +3038,10 @@ function useCommentsErrorListener(callback) {
|
|
|
3020
3038
|
}, [savedCallback, commentsErrorEventSource]);
|
|
3021
3039
|
}
|
|
3022
3040
|
function useCreateThread() {
|
|
3041
|
+
return useCreateRoomThread(useRoom().id);
|
|
3042
|
+
}
|
|
3043
|
+
function useCreateRoomThread(roomId) {
|
|
3023
3044
|
const client = useClient();
|
|
3024
|
-
const room = useRoom();
|
|
3025
3045
|
return React4.useCallback(
|
|
3026
3046
|
(options) => {
|
|
3027
3047
|
const body = options.body;
|
|
@@ -3033,10 +3053,10 @@ function useCreateThread() {
|
|
|
3033
3053
|
const newComment = {
|
|
3034
3054
|
id: commentId,
|
|
3035
3055
|
threadId,
|
|
3036
|
-
roomId
|
|
3056
|
+
roomId,
|
|
3037
3057
|
createdAt,
|
|
3038
3058
|
type: "comment",
|
|
3039
|
-
userId: getCurrentUserId(
|
|
3059
|
+
userId: getCurrentUserId(client),
|
|
3040
3060
|
body,
|
|
3041
3061
|
reactions: [],
|
|
3042
3062
|
attachments: _nullishCoalesce(attachments, () => ( []))
|
|
@@ -3046,7 +3066,7 @@ function useCreateThread() {
|
|
|
3046
3066
|
type: "thread",
|
|
3047
3067
|
createdAt,
|
|
3048
3068
|
updatedAt: createdAt,
|
|
3049
|
-
roomId
|
|
3069
|
+
roomId,
|
|
3050
3070
|
metadata,
|
|
3051
3071
|
comments: [newComment],
|
|
3052
3072
|
resolved: false
|
|
@@ -3055,10 +3075,17 @@ function useCreateThread() {
|
|
|
3055
3075
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
3056
3076
|
type: "create-thread",
|
|
3057
3077
|
thread: newThread,
|
|
3058
|
-
roomId
|
|
3078
|
+
roomId
|
|
3059
3079
|
});
|
|
3060
3080
|
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _15 => _15.map, 'call', _16 => _16((attachment) => attachment.id)]);
|
|
3061
|
-
|
|
3081
|
+
client[_core.kInternal].httpClient.createThread({
|
|
3082
|
+
roomId,
|
|
3083
|
+
threadId,
|
|
3084
|
+
commentId,
|
|
3085
|
+
body,
|
|
3086
|
+
metadata,
|
|
3087
|
+
attachmentIds
|
|
3088
|
+
}).then(
|
|
3062
3089
|
(thread) => {
|
|
3063
3090
|
store.createThread(optimisticUpdateId, thread);
|
|
3064
3091
|
},
|
|
@@ -3066,7 +3093,7 @@ function useCreateThread() {
|
|
|
3066
3093
|
err,
|
|
3067
3094
|
optimisticUpdateId,
|
|
3068
3095
|
(err2) => new CreateThreadError(err2, {
|
|
3069
|
-
roomId
|
|
3096
|
+
roomId,
|
|
3070
3097
|
threadId,
|
|
3071
3098
|
commentId,
|
|
3072
3099
|
body,
|
|
@@ -3076,43 +3103,47 @@ function useCreateThread() {
|
|
|
3076
3103
|
);
|
|
3077
3104
|
return newThread;
|
|
3078
3105
|
},
|
|
3079
|
-
[client,
|
|
3106
|
+
[client, roomId]
|
|
3080
3107
|
);
|
|
3081
3108
|
}
|
|
3082
3109
|
function useDeleteThread() {
|
|
3110
|
+
return useDeleteRoomThread(useRoom().id);
|
|
3111
|
+
}
|
|
3112
|
+
function useDeleteRoomThread(roomId) {
|
|
3083
3113
|
const client = useClient();
|
|
3084
|
-
const room = useRoom();
|
|
3085
3114
|
return React4.useCallback(
|
|
3086
3115
|
(threadId) => {
|
|
3087
3116
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3088
|
-
const userId = getCurrentUserId(
|
|
3117
|
+
const userId = getCurrentUserId(client);
|
|
3089
3118
|
const existing = store.getFullState().threadsDB.get(threadId);
|
|
3090
3119
|
if (_optionalChain([existing, 'optionalAccess', _17 => _17.comments, 'optionalAccess', _18 => _18[0], 'optionalAccess', _19 => _19.userId]) !== userId) {
|
|
3091
3120
|
throw new Error("Only the thread creator can delete the thread");
|
|
3092
3121
|
}
|
|
3093
3122
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
3094
3123
|
type: "delete-thread",
|
|
3095
|
-
roomId
|
|
3124
|
+
roomId,
|
|
3096
3125
|
threadId,
|
|
3097
3126
|
deletedAt: /* @__PURE__ */ new Date()
|
|
3098
3127
|
});
|
|
3099
|
-
|
|
3128
|
+
client[_core.kInternal].httpClient.deleteThread({ roomId, threadId }).then(
|
|
3100
3129
|
() => {
|
|
3101
3130
|
store.deleteThread(threadId, optimisticUpdateId);
|
|
3102
3131
|
},
|
|
3103
3132
|
(err) => onMutationFailure(
|
|
3104
3133
|
err,
|
|
3105
3134
|
optimisticUpdateId,
|
|
3106
|
-
(err2) => new DeleteThreadError(err2, { roomId
|
|
3135
|
+
(err2) => new DeleteThreadError(err2, { roomId, threadId })
|
|
3107
3136
|
)
|
|
3108
3137
|
);
|
|
3109
3138
|
},
|
|
3110
|
-
[client,
|
|
3139
|
+
[client, roomId]
|
|
3111
3140
|
);
|
|
3112
3141
|
}
|
|
3113
3142
|
function useEditThreadMetadata() {
|
|
3143
|
+
return useEditRoomThreadMetadata(useRoom().id);
|
|
3144
|
+
}
|
|
3145
|
+
function useEditRoomThreadMetadata(roomId) {
|
|
3114
3146
|
const client = useClient();
|
|
3115
|
-
const room = useRoom();
|
|
3116
3147
|
return React4.useCallback(
|
|
3117
3148
|
(options) => {
|
|
3118
3149
|
if (!options.metadata) {
|
|
@@ -3128,7 +3159,7 @@ function useEditThreadMetadata() {
|
|
|
3128
3159
|
threadId,
|
|
3129
3160
|
updatedAt
|
|
3130
3161
|
});
|
|
3131
|
-
|
|
3162
|
+
client[_core.kInternal].httpClient.editThreadMetadata({ roomId, threadId, metadata }).then(
|
|
3132
3163
|
(metadata2) => (
|
|
3133
3164
|
// Replace the optimistic update by the real thing
|
|
3134
3165
|
store.patchThread(
|
|
@@ -3142,19 +3173,21 @@ function useEditThreadMetadata() {
|
|
|
3142
3173
|
err,
|
|
3143
3174
|
optimisticUpdateId,
|
|
3144
3175
|
(error) => new EditThreadMetadataError(error, {
|
|
3145
|
-
roomId
|
|
3176
|
+
roomId,
|
|
3146
3177
|
threadId,
|
|
3147
3178
|
metadata
|
|
3148
3179
|
})
|
|
3149
3180
|
)
|
|
3150
3181
|
);
|
|
3151
3182
|
},
|
|
3152
|
-
[client,
|
|
3183
|
+
[client, roomId]
|
|
3153
3184
|
);
|
|
3154
3185
|
}
|
|
3155
3186
|
function useCreateComment() {
|
|
3187
|
+
return useCreateRoomComment(useRoom().id);
|
|
3188
|
+
}
|
|
3189
|
+
function useCreateRoomComment(roomId) {
|
|
3156
3190
|
const client = useClient();
|
|
3157
|
-
const room = useRoom();
|
|
3158
3191
|
return React4.useCallback(
|
|
3159
3192
|
({ threadId, body, attachments }) => {
|
|
3160
3193
|
const commentId = _core.createCommentId.call(void 0, );
|
|
@@ -3162,10 +3195,10 @@ function useCreateComment() {
|
|
|
3162
3195
|
const comment = {
|
|
3163
3196
|
id: commentId,
|
|
3164
3197
|
threadId,
|
|
3165
|
-
roomId
|
|
3198
|
+
roomId,
|
|
3166
3199
|
type: "comment",
|
|
3167
3200
|
createdAt,
|
|
3168
|
-
userId: getCurrentUserId(
|
|
3201
|
+
userId: getCurrentUserId(client),
|
|
3169
3202
|
body,
|
|
3170
3203
|
reactions: [],
|
|
3171
3204
|
attachments: _nullishCoalesce(attachments, () => ( []))
|
|
@@ -3176,7 +3209,7 @@ function useCreateComment() {
|
|
|
3176
3209
|
comment
|
|
3177
3210
|
});
|
|
3178
3211
|
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _20 => _20.map, 'call', _21 => _21((attachment) => attachment.id)]);
|
|
3179
|
-
|
|
3212
|
+
client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3180
3213
|
(newComment) => {
|
|
3181
3214
|
store.createComment(newComment, optimisticUpdateId);
|
|
3182
3215
|
},
|
|
@@ -3184,7 +3217,7 @@ function useCreateComment() {
|
|
|
3184
3217
|
err,
|
|
3185
3218
|
optimisticUpdateId,
|
|
3186
3219
|
(err2) => new CreateCommentError(err2, {
|
|
3187
|
-
roomId
|
|
3220
|
+
roomId,
|
|
3188
3221
|
threadId,
|
|
3189
3222
|
commentId,
|
|
3190
3223
|
body
|
|
@@ -3193,12 +3226,14 @@ function useCreateComment() {
|
|
|
3193
3226
|
);
|
|
3194
3227
|
return comment;
|
|
3195
3228
|
},
|
|
3196
|
-
[client,
|
|
3229
|
+
[client, roomId]
|
|
3197
3230
|
);
|
|
3198
3231
|
}
|
|
3199
3232
|
function useEditComment() {
|
|
3233
|
+
return useEditRoomComment(useRoom().id);
|
|
3234
|
+
}
|
|
3235
|
+
function useEditRoomComment(roomId) {
|
|
3200
3236
|
const client = useClient();
|
|
3201
|
-
const room = useRoom();
|
|
3202
3237
|
return React4.useCallback(
|
|
3203
3238
|
({ threadId, commentId, body, attachments }) => {
|
|
3204
3239
|
const editedAt = /* @__PURE__ */ new Date();
|
|
@@ -3229,7 +3264,7 @@ function useEditComment() {
|
|
|
3229
3264
|
}
|
|
3230
3265
|
});
|
|
3231
3266
|
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _22 => _22.map, 'call', _23 => _23((attachment) => attachment.id)]);
|
|
3232
|
-
|
|
3267
|
+
client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3233
3268
|
(editedComment) => {
|
|
3234
3269
|
store.editComment(threadId, optimisticUpdateId, editedComment);
|
|
3235
3270
|
},
|
|
@@ -3237,7 +3272,7 @@ function useEditComment() {
|
|
|
3237
3272
|
err,
|
|
3238
3273
|
optimisticUpdateId,
|
|
3239
3274
|
(error) => new EditCommentError(error, {
|
|
3240
|
-
roomId
|
|
3275
|
+
roomId,
|
|
3241
3276
|
threadId,
|
|
3242
3277
|
commentId,
|
|
3243
3278
|
body
|
|
@@ -3245,12 +3280,14 @@ function useEditComment() {
|
|
|
3245
3280
|
)
|
|
3246
3281
|
);
|
|
3247
3282
|
},
|
|
3248
|
-
[client,
|
|
3283
|
+
[client, roomId]
|
|
3249
3284
|
);
|
|
3250
3285
|
}
|
|
3251
3286
|
function useDeleteComment() {
|
|
3287
|
+
return useDeleteRoomComment(useRoom().id);
|
|
3288
|
+
}
|
|
3289
|
+
function useDeleteRoomComment(roomId) {
|
|
3252
3290
|
const client = useClient();
|
|
3253
|
-
const room = useRoom();
|
|
3254
3291
|
return React4.useCallback(
|
|
3255
3292
|
({ threadId, commentId }) => {
|
|
3256
3293
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
@@ -3260,9 +3297,9 @@ function useDeleteComment() {
|
|
|
3260
3297
|
threadId,
|
|
3261
3298
|
commentId,
|
|
3262
3299
|
deletedAt,
|
|
3263
|
-
roomId
|
|
3300
|
+
roomId
|
|
3264
3301
|
});
|
|
3265
|
-
|
|
3302
|
+
client[_core.kInternal].httpClient.deleteComment({ roomId, threadId, commentId }).then(
|
|
3266
3303
|
() => {
|
|
3267
3304
|
store.deleteComment(
|
|
3268
3305
|
threadId,
|
|
@@ -3275,23 +3312,25 @@ function useDeleteComment() {
|
|
|
3275
3312
|
err,
|
|
3276
3313
|
optimisticUpdateId,
|
|
3277
3314
|
(error) => new DeleteCommentError(error, {
|
|
3278
|
-
roomId
|
|
3315
|
+
roomId,
|
|
3279
3316
|
threadId,
|
|
3280
3317
|
commentId
|
|
3281
3318
|
})
|
|
3282
3319
|
)
|
|
3283
3320
|
);
|
|
3284
3321
|
},
|
|
3285
|
-
[client,
|
|
3322
|
+
[client, roomId]
|
|
3286
3323
|
);
|
|
3287
3324
|
}
|
|
3288
3325
|
function useAddReaction() {
|
|
3326
|
+
return useAddRoomCommentReaction(useRoom().id);
|
|
3327
|
+
}
|
|
3328
|
+
function useAddRoomCommentReaction(roomId) {
|
|
3289
3329
|
const client = useClient();
|
|
3290
|
-
const room = useRoom();
|
|
3291
3330
|
return React4.useCallback(
|
|
3292
3331
|
({ threadId, commentId, emoji }) => {
|
|
3293
3332
|
const createdAt = /* @__PURE__ */ new Date();
|
|
3294
|
-
const userId = getCurrentUserId(
|
|
3333
|
+
const userId = getCurrentUserId(client);
|
|
3295
3334
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3296
3335
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
3297
3336
|
type: "add-reaction",
|
|
@@ -3303,7 +3342,7 @@ function useAddReaction() {
|
|
|
3303
3342
|
createdAt
|
|
3304
3343
|
}
|
|
3305
3344
|
});
|
|
3306
|
-
|
|
3345
|
+
client[_core.kInternal].httpClient.addReaction({ roomId, threadId, commentId, emoji }).then(
|
|
3307
3346
|
(addedReaction) => {
|
|
3308
3347
|
store.addReaction(
|
|
3309
3348
|
threadId,
|
|
@@ -3317,7 +3356,7 @@ function useAddReaction() {
|
|
|
3317
3356
|
err,
|
|
3318
3357
|
optimisticUpdateId,
|
|
3319
3358
|
(error) => new AddReactionError(error, {
|
|
3320
|
-
roomId
|
|
3359
|
+
roomId,
|
|
3321
3360
|
threadId,
|
|
3322
3361
|
commentId,
|
|
3323
3362
|
emoji
|
|
@@ -3325,15 +3364,17 @@ function useAddReaction() {
|
|
|
3325
3364
|
)
|
|
3326
3365
|
);
|
|
3327
3366
|
},
|
|
3328
|
-
[client,
|
|
3367
|
+
[client, roomId]
|
|
3329
3368
|
);
|
|
3330
3369
|
}
|
|
3331
3370
|
function useRemoveReaction() {
|
|
3371
|
+
return useRemoveRoomCommentReaction(useRoom().id);
|
|
3372
|
+
}
|
|
3373
|
+
function useRemoveRoomCommentReaction(roomId) {
|
|
3332
3374
|
const client = useClient();
|
|
3333
|
-
const room = useRoom();
|
|
3334
3375
|
return React4.useCallback(
|
|
3335
3376
|
({ threadId, commentId, emoji }) => {
|
|
3336
|
-
const userId = getCurrentUserId(
|
|
3377
|
+
const userId = getCurrentUserId(client);
|
|
3337
3378
|
const removedAt = /* @__PURE__ */ new Date();
|
|
3338
3379
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3339
3380
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
@@ -3344,7 +3385,7 @@ function useRemoveReaction() {
|
|
|
3344
3385
|
userId,
|
|
3345
3386
|
removedAt
|
|
3346
3387
|
});
|
|
3347
|
-
|
|
3388
|
+
client[_core.kInternal].httpClient.removeReaction({ roomId, threadId, commentId, emoji }).then(
|
|
3348
3389
|
() => {
|
|
3349
3390
|
store.removeReaction(
|
|
3350
3391
|
threadId,
|
|
@@ -3359,7 +3400,7 @@ function useRemoveReaction() {
|
|
|
3359
3400
|
err,
|
|
3360
3401
|
optimisticUpdateId,
|
|
3361
3402
|
(error) => new RemoveReactionError(error, {
|
|
3362
|
-
roomId
|
|
3403
|
+
roomId,
|
|
3363
3404
|
threadId,
|
|
3364
3405
|
commentId,
|
|
3365
3406
|
emoji
|
|
@@ -3367,12 +3408,14 @@ function useRemoveReaction() {
|
|
|
3367
3408
|
)
|
|
3368
3409
|
);
|
|
3369
3410
|
},
|
|
3370
|
-
[client,
|
|
3411
|
+
[client, roomId]
|
|
3371
3412
|
);
|
|
3372
3413
|
}
|
|
3373
3414
|
function useMarkThreadAsRead() {
|
|
3415
|
+
return useMarkRoomThreadAsRead(useRoom().id);
|
|
3416
|
+
}
|
|
3417
|
+
function useMarkRoomThreadAsRead(roomId) {
|
|
3374
3418
|
const client = useClient();
|
|
3375
|
-
const room = useRoom();
|
|
3376
3419
|
return React4.useCallback(
|
|
3377
3420
|
(threadId) => {
|
|
3378
3421
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3388,7 +3431,10 @@ function useMarkThreadAsRead() {
|
|
|
3388
3431
|
inboxNotificationId: inboxNotification.id,
|
|
3389
3432
|
readAt: now
|
|
3390
3433
|
});
|
|
3391
|
-
|
|
3434
|
+
client[_core.kInternal].httpClient.markRoomInboxNotificationAsRead({
|
|
3435
|
+
roomId,
|
|
3436
|
+
inboxNotificationId: inboxNotification.id
|
|
3437
|
+
}).then(
|
|
3392
3438
|
() => {
|
|
3393
3439
|
store.updateInboxNotification(
|
|
3394
3440
|
inboxNotification.id,
|
|
@@ -3408,12 +3454,14 @@ function useMarkThreadAsRead() {
|
|
|
3408
3454
|
}
|
|
3409
3455
|
);
|
|
3410
3456
|
},
|
|
3411
|
-
[client,
|
|
3457
|
+
[client, roomId]
|
|
3412
3458
|
);
|
|
3413
3459
|
}
|
|
3414
3460
|
function useMarkThreadAsResolved() {
|
|
3461
|
+
return useMarkRoomThreadAsResolved(useRoom().id);
|
|
3462
|
+
}
|
|
3463
|
+
function useMarkRoomThreadAsResolved(roomId) {
|
|
3415
3464
|
const client = useClient();
|
|
3416
|
-
const room = useRoom();
|
|
3417
3465
|
return React4.useCallback(
|
|
3418
3466
|
(threadId) => {
|
|
3419
3467
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
@@ -3423,7 +3471,7 @@ function useMarkThreadAsResolved() {
|
|
|
3423
3471
|
threadId,
|
|
3424
3472
|
updatedAt
|
|
3425
3473
|
});
|
|
3426
|
-
|
|
3474
|
+
client[_core.kInternal].httpClient.markThreadAsResolved({ roomId, threadId }).then(
|
|
3427
3475
|
() => {
|
|
3428
3476
|
store.patchThread(
|
|
3429
3477
|
threadId,
|
|
@@ -3436,18 +3484,20 @@ function useMarkThreadAsResolved() {
|
|
|
3436
3484
|
err,
|
|
3437
3485
|
optimisticUpdateId,
|
|
3438
3486
|
(error) => new MarkThreadAsResolvedError(error, {
|
|
3439
|
-
roomId
|
|
3487
|
+
roomId,
|
|
3440
3488
|
threadId
|
|
3441
3489
|
})
|
|
3442
3490
|
)
|
|
3443
3491
|
);
|
|
3444
3492
|
},
|
|
3445
|
-
[client,
|
|
3493
|
+
[client, roomId]
|
|
3446
3494
|
);
|
|
3447
3495
|
}
|
|
3448
3496
|
function useMarkThreadAsUnresolved() {
|
|
3497
|
+
return useMarkRoomThreadAsUnresolved(useRoom().id);
|
|
3498
|
+
}
|
|
3499
|
+
function useMarkRoomThreadAsUnresolved(roomId) {
|
|
3449
3500
|
const client = useClient();
|
|
3450
|
-
const room = useRoom();
|
|
3451
3501
|
return React4.useCallback(
|
|
3452
3502
|
(threadId) => {
|
|
3453
3503
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
@@ -3457,7 +3507,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
3457
3507
|
threadId,
|
|
3458
3508
|
updatedAt
|
|
3459
3509
|
});
|
|
3460
|
-
|
|
3510
|
+
client[_core.kInternal].httpClient.markThreadAsUnresolved({ roomId, threadId }).then(
|
|
3461
3511
|
() => {
|
|
3462
3512
|
store.patchThread(
|
|
3463
3513
|
threadId,
|
|
@@ -3470,13 +3520,13 @@ function useMarkThreadAsUnresolved() {
|
|
|
3470
3520
|
err,
|
|
3471
3521
|
optimisticUpdateId,
|
|
3472
3522
|
(error) => new MarkThreadAsUnresolvedError(error, {
|
|
3473
|
-
roomId
|
|
3523
|
+
roomId,
|
|
3474
3524
|
threadId
|
|
3475
3525
|
})
|
|
3476
3526
|
)
|
|
3477
3527
|
);
|
|
3478
3528
|
},
|
|
3479
|
-
[client,
|
|
3529
|
+
[client, roomId]
|
|
3480
3530
|
);
|
|
3481
3531
|
}
|
|
3482
3532
|
function useThreadSubscription(threadId) {
|
|
@@ -3745,16 +3795,20 @@ function selectorFor_useAttachmentUrl(state) {
|
|
|
3745
3795
|
}
|
|
3746
3796
|
function useAttachmentUrl(attachmentId) {
|
|
3747
3797
|
const room = useRoom();
|
|
3748
|
-
|
|
3798
|
+
return useRoomAttachmentUrl(attachmentId, room.id);
|
|
3799
|
+
}
|
|
3800
|
+
function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
3801
|
+
const client = useClient();
|
|
3802
|
+
const store = client[_core.kInternal].httpClient.getOrCreateAttachmentUrlsStore(roomId);
|
|
3749
3803
|
const getAttachmentUrlState = React4.useCallback(
|
|
3750
|
-
() =>
|
|
3751
|
-
[
|
|
3804
|
+
() => store.getState(attachmentId),
|
|
3805
|
+
[store, attachmentId]
|
|
3752
3806
|
);
|
|
3753
3807
|
React4.useEffect(() => {
|
|
3754
|
-
void
|
|
3755
|
-
}, [
|
|
3808
|
+
void store.get(attachmentId);
|
|
3809
|
+
}, [store, attachmentId]);
|
|
3756
3810
|
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
3757
|
-
|
|
3811
|
+
store.subscribe,
|
|
3758
3812
|
getAttachmentUrlState,
|
|
3759
3813
|
getAttachmentUrlState,
|
|
3760
3814
|
selectorFor_useAttachmentUrl,
|
|
@@ -3789,6 +3843,15 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
3789
3843
|
error: void 0
|
|
3790
3844
|
};
|
|
3791
3845
|
}
|
|
3846
|
+
function useRoomPermissions(roomId) {
|
|
3847
|
+
const client = useClient();
|
|
3848
|
+
const store = getRoomExtrasForClient(client).store;
|
|
3849
|
+
return _nullishCoalesce(useSyncExternalStore2(
|
|
3850
|
+
store.subscribe,
|
|
3851
|
+
React4.useCallback(() => store._getPermissions(roomId), [store, roomId]),
|
|
3852
|
+
React4.useCallback(() => store._getPermissions(roomId), [store, roomId])
|
|
3853
|
+
), () => ( /* @__PURE__ */ new Set()));
|
|
3854
|
+
}
|
|
3792
3855
|
function createRoomContext(client) {
|
|
3793
3856
|
return getOrCreateRoomContextBundle(client);
|
|
3794
3857
|
}
|
|
@@ -3912,5 +3975,19 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
3912
3975
|
|
|
3913
3976
|
|
|
3914
3977
|
|
|
3915
|
-
|
|
3916
|
-
|
|
3978
|
+
|
|
3979
|
+
|
|
3980
|
+
|
|
3981
|
+
|
|
3982
|
+
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
|
|
3986
|
+
|
|
3987
|
+
|
|
3988
|
+
|
|
3989
|
+
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
exports.RoomContext = RoomContext; exports.useRoomOrNull = useRoomOrNull; exports.ClientContext = ClientContext; 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.useSyncStatus = useSyncStatus; 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.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useRoomNotificationSettings = _useRoomNotificationSettings; exports._useRoomNotificationSettingsSuspense = _useRoomNotificationSettingsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
|
|
3993
|
+
//# sourceMappingURL=chunk-HVOJBD7X.js.map
|