@liveblocks/react 2.3.0 → 2.4.0-test1
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-N2EE2UOX.mjs → chunk-2ITOEAYK.mjs} +77 -86
- package/dist/chunk-2ITOEAYK.mjs.map +1 -0
- package/dist/{chunk-K5EDPAZP.js → chunk-L4QUDD4I.js} +81 -90
- package/dist/chunk-L4QUDD4I.js.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.mjs +1 -1
- package/dist/{suspense-cGHXI2Em.d.mts → suspense-HhfQZzDE.d.mts} +1 -1
- package/dist/{suspense-cGHXI2Em.d.ts → suspense-HhfQZzDE.d.ts} +1 -1
- 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 -4
- package/dist/chunk-K5EDPAZP.js.map +0 -1
- package/dist/chunk-N2EE2UOX.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.
|
|
3
|
+
var PKG_VERSION = "2.4.0-test1";
|
|
4
4
|
var PKG_FORMAT = "esm";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
kInternal,
|
|
21
21
|
makePoller,
|
|
22
22
|
memoizeOnSuccess,
|
|
23
|
+
nanoid,
|
|
23
24
|
raise,
|
|
24
25
|
shallow
|
|
25
26
|
} from "@liveblocks/core";
|
|
26
|
-
import { nanoid } from "nanoid";
|
|
27
27
|
import React2, {
|
|
28
28
|
createContext,
|
|
29
29
|
useCallback as useCallback2,
|
|
@@ -244,20 +244,32 @@ function getExtrasForClient(client) {
|
|
|
244
244
|
function makeExtrasForClient(client) {
|
|
245
245
|
const internals = client[kInternal];
|
|
246
246
|
const store = internals.cacheStore;
|
|
247
|
-
const notifications = internals.notifications;
|
|
248
247
|
let lastRequestedAt;
|
|
249
248
|
async function fetchInboxNotifications() {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
249
|
+
if (lastRequestedAt === void 0) {
|
|
250
|
+
const result = await client.getInboxNotifications();
|
|
251
|
+
store.updateThreadsAndNotifications(
|
|
252
|
+
result.threads,
|
|
253
|
+
result.inboxNotifications,
|
|
254
|
+
[],
|
|
255
|
+
[],
|
|
256
|
+
INBOX_NOTIFICATIONS_QUERY
|
|
257
|
+
);
|
|
258
|
+
lastRequestedAt = result.requestedAt;
|
|
259
|
+
} else {
|
|
260
|
+
const result = await client.getInboxNotificationsSince({
|
|
261
|
+
since: lastRequestedAt
|
|
262
|
+
});
|
|
263
|
+
store.updateThreadsAndNotifications(
|
|
264
|
+
result.threads.modified,
|
|
265
|
+
result.inboxNotifications.modified,
|
|
266
|
+
result.threads.deleted,
|
|
267
|
+
result.inboxNotifications.deleted,
|
|
268
|
+
INBOX_NOTIFICATIONS_QUERY
|
|
269
|
+
);
|
|
270
|
+
if (lastRequestedAt < result.requestedAt) {
|
|
271
|
+
lastRequestedAt = result.requestedAt;
|
|
272
|
+
}
|
|
261
273
|
}
|
|
262
274
|
}
|
|
263
275
|
let pollerSubscribers = 0;
|
|
@@ -311,7 +323,6 @@ function makeExtrasForClient(client) {
|
|
|
311
323
|
}
|
|
312
324
|
return {
|
|
313
325
|
store,
|
|
314
|
-
notifications,
|
|
315
326
|
useEnableInboxNotificationsPolling,
|
|
316
327
|
waitUntilInboxNotificationsLoaded,
|
|
317
328
|
loadInboxNotifications
|
|
@@ -399,7 +410,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client) {
|
|
|
399
410
|
function useMarkInboxNotificationAsRead_withClient(client) {
|
|
400
411
|
return useCallback2(
|
|
401
412
|
(inboxNotificationId) => {
|
|
402
|
-
const { store
|
|
413
|
+
const { store } = getExtrasForClient(client);
|
|
403
414
|
const optimisticUpdateId = nanoid();
|
|
404
415
|
const readAt = /* @__PURE__ */ new Date();
|
|
405
416
|
store.pushOptimisticUpdate({
|
|
@@ -408,7 +419,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
408
419
|
inboxNotificationId,
|
|
409
420
|
readAt
|
|
410
421
|
});
|
|
411
|
-
|
|
422
|
+
client.markInboxNotificationAsRead(inboxNotificationId).then(
|
|
412
423
|
() => {
|
|
413
424
|
store.set((state) => {
|
|
414
425
|
const existingNotification = state.inboxNotifications[inboxNotificationId];
|
|
@@ -450,7 +461,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
450
461
|
}
|
|
451
462
|
function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
452
463
|
return useCallback2(() => {
|
|
453
|
-
const { store
|
|
464
|
+
const { store } = getExtrasForClient(client);
|
|
454
465
|
const optimisticUpdateId = nanoid();
|
|
455
466
|
const readAt = /* @__PURE__ */ new Date();
|
|
456
467
|
store.pushOptimisticUpdate({
|
|
@@ -458,7 +469,7 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
|
458
469
|
id: optimisticUpdateId,
|
|
459
470
|
readAt
|
|
460
471
|
});
|
|
461
|
-
|
|
472
|
+
client.markAllInboxNotificationsAsRead().then(
|
|
462
473
|
() => {
|
|
463
474
|
store.set((state) => ({
|
|
464
475
|
...state,
|
|
@@ -489,7 +500,7 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
|
489
500
|
function useDeleteInboxNotification_withClient(client) {
|
|
490
501
|
return useCallback2(
|
|
491
502
|
(inboxNotificationId) => {
|
|
492
|
-
const { store
|
|
503
|
+
const { store } = getExtrasForClient(client);
|
|
493
504
|
const optimisticUpdateId = nanoid();
|
|
494
505
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
495
506
|
store.pushOptimisticUpdate({
|
|
@@ -498,7 +509,7 @@ function useDeleteInboxNotification_withClient(client) {
|
|
|
498
509
|
inboxNotificationId,
|
|
499
510
|
deletedAt
|
|
500
511
|
});
|
|
501
|
-
|
|
512
|
+
client.deleteInboxNotification(inboxNotificationId).then(
|
|
502
513
|
() => {
|
|
503
514
|
store.set((state) => {
|
|
504
515
|
const existingNotification = state.inboxNotifications[inboxNotificationId];
|
|
@@ -535,7 +546,7 @@ function useDeleteInboxNotification_withClient(client) {
|
|
|
535
546
|
}
|
|
536
547
|
function useDeleteAllInboxNotifications_withClient(client) {
|
|
537
548
|
return useCallback2(() => {
|
|
538
|
-
const { store
|
|
549
|
+
const { store } = getExtrasForClient(client);
|
|
539
550
|
const optimisticUpdateId = nanoid();
|
|
540
551
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
541
552
|
store.pushOptimisticUpdate({
|
|
@@ -543,7 +554,7 @@ function useDeleteAllInboxNotifications_withClient(client) {
|
|
|
543
554
|
id: optimisticUpdateId,
|
|
544
555
|
deletedAt
|
|
545
556
|
});
|
|
546
|
-
|
|
557
|
+
client.deleteAllInboxNotifications().then(
|
|
547
558
|
() => {
|
|
548
559
|
store.set((state) => ({
|
|
549
560
|
...state,
|
|
@@ -952,36 +963,24 @@ import {
|
|
|
952
963
|
addReaction,
|
|
953
964
|
CommentsApiError,
|
|
954
965
|
console as console2,
|
|
966
|
+
createCommentId,
|
|
967
|
+
createThreadId,
|
|
955
968
|
deleteComment,
|
|
956
969
|
deprecateIf,
|
|
957
970
|
errorIf,
|
|
958
971
|
kInternal as kInternal2,
|
|
959
972
|
makeEventSource,
|
|
960
973
|
makePoller as makePoller2,
|
|
974
|
+
nanoid as nanoid2,
|
|
961
975
|
NotificationsApiError,
|
|
962
976
|
removeReaction,
|
|
963
977
|
ServerMsgCode,
|
|
964
978
|
stringify,
|
|
965
979
|
upsertComment
|
|
966
980
|
} from "@liveblocks/core";
|
|
967
|
-
import { nanoid as nanoid3 } from "nanoid";
|
|
968
981
|
import * as React4 from "react";
|
|
969
982
|
import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
|
|
970
983
|
|
|
971
|
-
// src/comments/lib/createIds.ts
|
|
972
|
-
import { nanoid as nanoid2 } from "nanoid";
|
|
973
|
-
var THREAD_ID_PREFIX = "th";
|
|
974
|
-
var COMMENT_ID_PREFIX = "cm";
|
|
975
|
-
function createOptimisticId(prefix) {
|
|
976
|
-
return `${prefix}_${nanoid2()}`;
|
|
977
|
-
}
|
|
978
|
-
function createThreadId() {
|
|
979
|
-
return createOptimisticId(THREAD_ID_PREFIX);
|
|
980
|
-
}
|
|
981
|
-
function createCommentId() {
|
|
982
|
-
return createOptimisticId(COMMENT_ID_PREFIX);
|
|
983
|
-
}
|
|
984
|
-
|
|
985
984
|
// src/comments/lib/select-notification-settings.ts
|
|
986
985
|
import {
|
|
987
986
|
applyOptimisticUpdates as applyOptimisticUpdates3,
|
|
@@ -1166,18 +1165,17 @@ function makeExtrasForClient2(client) {
|
|
|
1166
1165
|
if (isFetchingThreadsUpdates === true) return;
|
|
1167
1166
|
try {
|
|
1168
1167
|
requestStatusByRoom.set(room.id, true);
|
|
1169
|
-
const
|
|
1170
|
-
const updates = await commentsAPI.getThreads({ since });
|
|
1168
|
+
const updates = await room.getThreadsSince({ since });
|
|
1171
1169
|
setTimeout(() => {
|
|
1172
1170
|
requestStatusByRoom.set(room.id, false);
|
|
1173
1171
|
}, DEFAULT_DEDUPING_INTERVAL);
|
|
1174
1172
|
store.updateThreadsAndNotifications(
|
|
1175
|
-
updates.threads,
|
|
1176
|
-
updates.inboxNotifications,
|
|
1177
|
-
updates.
|
|
1178
|
-
updates.
|
|
1173
|
+
updates.threads.modified,
|
|
1174
|
+
updates.inboxNotifications.modified,
|
|
1175
|
+
updates.threads.deleted,
|
|
1176
|
+
updates.inboxNotifications.deleted
|
|
1179
1177
|
);
|
|
1180
|
-
lastRequestedAtByRoom.set(room.id, updates.
|
|
1178
|
+
lastRequestedAtByRoom.set(room.id, updates.requestedAt);
|
|
1181
1179
|
} catch (err) {
|
|
1182
1180
|
requestStatusByRoom.set(room.id, false);
|
|
1183
1181
|
return;
|
|
@@ -1186,8 +1184,7 @@ function makeExtrasForClient2(client) {
|
|
|
1186
1184
|
async function getThreadsAndInboxNotifications(room, queryKey, options, { retryCount } = { retryCount: 0 }) {
|
|
1187
1185
|
const existingRequest = requestsByQuery.get(queryKey);
|
|
1188
1186
|
if (existingRequest !== void 0) return existingRequest;
|
|
1189
|
-
const
|
|
1190
|
-
const request = commentsAPI.getThreads(options);
|
|
1187
|
+
const request = room.getThreads(options);
|
|
1191
1188
|
requestsByQuery.set(queryKey, request);
|
|
1192
1189
|
store.setQueryState(queryKey, {
|
|
1193
1190
|
isLoading: true
|
|
@@ -1196,14 +1193,15 @@ function makeExtrasForClient2(client) {
|
|
|
1196
1193
|
const result = await request;
|
|
1197
1194
|
store.updateThreadsAndNotifications(
|
|
1198
1195
|
result.threads,
|
|
1196
|
+
// TODO: Figure out how to remove this casting
|
|
1199
1197
|
result.inboxNotifications,
|
|
1200
|
-
|
|
1201
|
-
|
|
1198
|
+
[],
|
|
1199
|
+
[],
|
|
1202
1200
|
queryKey
|
|
1203
1201
|
);
|
|
1204
1202
|
const lastRequestedAt = lastRequestedAtByRoom.get(room.id);
|
|
1205
|
-
if (lastRequestedAt === void 0 || lastRequestedAt > result.
|
|
1206
|
-
lastRequestedAtByRoom.set(room.id, result.
|
|
1203
|
+
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
1204
|
+
lastRequestedAtByRoom.set(room.id, result.requestedAt);
|
|
1207
1205
|
}
|
|
1208
1206
|
poller.start(POLLING_INTERVAL2);
|
|
1209
1207
|
} catch (err) {
|
|
@@ -1224,7 +1222,7 @@ function makeExtrasForClient2(client) {
|
|
|
1224
1222
|
const existingRequest = requestsByQuery.get(queryKey);
|
|
1225
1223
|
if (existingRequest !== void 0) return existingRequest;
|
|
1226
1224
|
try {
|
|
1227
|
-
const request = room
|
|
1225
|
+
const request = room.getNotificationSettings();
|
|
1228
1226
|
requestsByQuery.set(queryKey, request);
|
|
1229
1227
|
store.setQueryState(queryKey, {
|
|
1230
1228
|
isLoading: true
|
|
@@ -1444,10 +1442,8 @@ function RoomProviderInner(props) {
|
|
|
1444
1442
|
store.deleteThread(message.threadId);
|
|
1445
1443
|
return;
|
|
1446
1444
|
}
|
|
1447
|
-
const info = await room
|
|
1448
|
-
|
|
1449
|
-
});
|
|
1450
|
-
if (!info) {
|
|
1445
|
+
const info = await room.getThread(message.threadId);
|
|
1446
|
+
if (!info.thread) {
|
|
1451
1447
|
store.deleteThread(message.threadId);
|
|
1452
1448
|
return;
|
|
1453
1449
|
}
|
|
@@ -1848,7 +1844,7 @@ function useCreateThread() {
|
|
|
1848
1844
|
comments: [newComment],
|
|
1849
1845
|
resolved: false
|
|
1850
1846
|
};
|
|
1851
|
-
const optimisticUpdateId =
|
|
1847
|
+
const optimisticUpdateId = nanoid2();
|
|
1852
1848
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1853
1849
|
store.pushOptimisticUpdate({
|
|
1854
1850
|
type: "create-thread",
|
|
@@ -1856,8 +1852,7 @@ function useCreateThread() {
|
|
|
1856
1852
|
id: optimisticUpdateId,
|
|
1857
1853
|
roomId: room.id
|
|
1858
1854
|
});
|
|
1859
|
-
|
|
1860
|
-
commentsAPI.createThread({ threadId, commentId, body, metadata }).then(
|
|
1855
|
+
room.createThread({ threadId, commentId, body, metadata }).then(
|
|
1861
1856
|
(thread) => {
|
|
1862
1857
|
store.set((state) => ({
|
|
1863
1858
|
...state,
|
|
@@ -1892,7 +1887,7 @@ function useDeleteThread() {
|
|
|
1892
1887
|
const room = useRoom();
|
|
1893
1888
|
return React4.useCallback(
|
|
1894
1889
|
(threadId) => {
|
|
1895
|
-
const optimisticUpdateId =
|
|
1890
|
+
const optimisticUpdateId = nanoid2();
|
|
1896
1891
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1897
1892
|
const thread = store.get().threads[threadId];
|
|
1898
1893
|
const userId = getCurrentUserId(room);
|
|
@@ -1906,8 +1901,7 @@ function useDeleteThread() {
|
|
|
1906
1901
|
threadId,
|
|
1907
1902
|
deletedAt: /* @__PURE__ */ new Date()
|
|
1908
1903
|
});
|
|
1909
|
-
|
|
1910
|
-
commentsAPI.deleteThread({ threadId }).then(
|
|
1904
|
+
room.deleteThread(threadId).then(
|
|
1911
1905
|
() => {
|
|
1912
1906
|
store.set((state) => {
|
|
1913
1907
|
const existingThread = state.threads[threadId];
|
|
@@ -1951,7 +1945,7 @@ function useEditThreadMetadata() {
|
|
|
1951
1945
|
const threadId = options.threadId;
|
|
1952
1946
|
const metadata = options.metadata;
|
|
1953
1947
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
1954
|
-
const optimisticUpdateId =
|
|
1948
|
+
const optimisticUpdateId = nanoid2();
|
|
1955
1949
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1956
1950
|
store.pushOptimisticUpdate({
|
|
1957
1951
|
type: "edit-thread-metadata",
|
|
@@ -1960,8 +1954,7 @@ function useEditThreadMetadata() {
|
|
|
1960
1954
|
threadId,
|
|
1961
1955
|
updatedAt
|
|
1962
1956
|
});
|
|
1963
|
-
|
|
1964
|
-
commentsAPI.editThreadMetadata({ metadata, threadId }).then(
|
|
1957
|
+
room.editThreadMetadata({ metadata, threadId }).then(
|
|
1965
1958
|
(metadata2) => {
|
|
1966
1959
|
store.set((state) => {
|
|
1967
1960
|
const existingThread = state.threads[threadId];
|
|
@@ -2030,14 +2023,14 @@ function useCreateComment() {
|
|
|
2030
2023
|
body,
|
|
2031
2024
|
reactions: []
|
|
2032
2025
|
};
|
|
2033
|
-
const optimisticUpdateId =
|
|
2026
|
+
const optimisticUpdateId = nanoid2();
|
|
2034
2027
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2035
2028
|
store.pushOptimisticUpdate({
|
|
2036
2029
|
type: "create-comment",
|
|
2037
2030
|
comment,
|
|
2038
2031
|
id: optimisticUpdateId
|
|
2039
2032
|
});
|
|
2040
|
-
room
|
|
2033
|
+
room.createComment({ threadId, commentId, body }).then(
|
|
2041
2034
|
(newComment) => {
|
|
2042
2035
|
store.set((state) => {
|
|
2043
2036
|
const existingThread = state.threads[threadId];
|
|
@@ -2097,7 +2090,7 @@ function useEditComment() {
|
|
|
2097
2090
|
return React4.useCallback(
|
|
2098
2091
|
({ threadId, commentId, body }) => {
|
|
2099
2092
|
const editedAt = /* @__PURE__ */ new Date();
|
|
2100
|
-
const optimisticUpdateId =
|
|
2093
|
+
const optimisticUpdateId = nanoid2();
|
|
2101
2094
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2102
2095
|
const thread = store.get().threads[threadId];
|
|
2103
2096
|
if (thread === void 0) {
|
|
@@ -2124,7 +2117,7 @@ function useEditComment() {
|
|
|
2124
2117
|
},
|
|
2125
2118
|
id: optimisticUpdateId
|
|
2126
2119
|
});
|
|
2127
|
-
room
|
|
2120
|
+
room.editComment({ threadId, commentId, body }).then(
|
|
2128
2121
|
(editedComment) => {
|
|
2129
2122
|
store.set((state) => {
|
|
2130
2123
|
const existingThread = state.threads[threadId];
|
|
@@ -2169,7 +2162,7 @@ function useDeleteComment() {
|
|
|
2169
2162
|
return React4.useCallback(
|
|
2170
2163
|
({ threadId, commentId }) => {
|
|
2171
2164
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
2172
|
-
const optimisticUpdateId =
|
|
2165
|
+
const optimisticUpdateId = nanoid2();
|
|
2173
2166
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2174
2167
|
store.pushOptimisticUpdate({
|
|
2175
2168
|
type: "delete-comment",
|
|
@@ -2179,7 +2172,7 @@ function useDeleteComment() {
|
|
|
2179
2172
|
id: optimisticUpdateId,
|
|
2180
2173
|
roomId: room.id
|
|
2181
2174
|
});
|
|
2182
|
-
room
|
|
2175
|
+
room.deleteComment({ threadId, commentId }).then(
|
|
2183
2176
|
() => {
|
|
2184
2177
|
store.set((state) => {
|
|
2185
2178
|
const existingThread = state.threads[threadId];
|
|
@@ -2223,7 +2216,7 @@ function useAddReaction() {
|
|
|
2223
2216
|
({ threadId, commentId, emoji }) => {
|
|
2224
2217
|
const createdAt = /* @__PURE__ */ new Date();
|
|
2225
2218
|
const userId = getCurrentUserId(room);
|
|
2226
|
-
const optimisticUpdateId =
|
|
2219
|
+
const optimisticUpdateId = nanoid2();
|
|
2227
2220
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2228
2221
|
store.pushOptimisticUpdate({
|
|
2229
2222
|
type: "add-reaction",
|
|
@@ -2236,7 +2229,7 @@ function useAddReaction() {
|
|
|
2236
2229
|
},
|
|
2237
2230
|
id: optimisticUpdateId
|
|
2238
2231
|
});
|
|
2239
|
-
room
|
|
2232
|
+
room.addReaction({ threadId, commentId, emoji }).then(
|
|
2240
2233
|
(addedReaction) => {
|
|
2241
2234
|
store.set((state) => {
|
|
2242
2235
|
const existingThread = state.threads[threadId];
|
|
@@ -2285,7 +2278,7 @@ function useRemoveReaction() {
|
|
|
2285
2278
|
({ threadId, commentId, emoji }) => {
|
|
2286
2279
|
const userId = getCurrentUserId(room);
|
|
2287
2280
|
const removedAt = /* @__PURE__ */ new Date();
|
|
2288
|
-
const optimisticUpdateId =
|
|
2281
|
+
const optimisticUpdateId = nanoid2();
|
|
2289
2282
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2290
2283
|
store.pushOptimisticUpdate({
|
|
2291
2284
|
type: "remove-reaction",
|
|
@@ -2296,7 +2289,7 @@ function useRemoveReaction() {
|
|
|
2296
2289
|
removedAt,
|
|
2297
2290
|
id: optimisticUpdateId
|
|
2298
2291
|
});
|
|
2299
|
-
room
|
|
2292
|
+
room.removeReaction({ threadId, commentId, emoji }).then(
|
|
2300
2293
|
() => {
|
|
2301
2294
|
store.set((state) => {
|
|
2302
2295
|
const existingThread = state.threads[threadId];
|
|
@@ -2352,7 +2345,7 @@ function useMarkThreadAsRead() {
|
|
|
2352
2345
|
(inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
|
|
2353
2346
|
);
|
|
2354
2347
|
if (!inboxNotification) return;
|
|
2355
|
-
const optimisticUpdateId =
|
|
2348
|
+
const optimisticUpdateId = nanoid2();
|
|
2356
2349
|
const now = /* @__PURE__ */ new Date();
|
|
2357
2350
|
store.pushOptimisticUpdate({
|
|
2358
2351
|
type: "mark-inbox-notification-as-read",
|
|
@@ -2360,7 +2353,7 @@ function useMarkThreadAsRead() {
|
|
|
2360
2353
|
inboxNotificationId: inboxNotification.id,
|
|
2361
2354
|
readAt: now
|
|
2362
2355
|
});
|
|
2363
|
-
room
|
|
2356
|
+
room.markInboxNotificationAsRead(inboxNotification.id).then(
|
|
2364
2357
|
() => {
|
|
2365
2358
|
store.set((state) => ({
|
|
2366
2359
|
...state,
|
|
@@ -2396,7 +2389,7 @@ function useMarkThreadAsResolved() {
|
|
|
2396
2389
|
const room = useRoom();
|
|
2397
2390
|
return React4.useCallback(
|
|
2398
2391
|
(threadId) => {
|
|
2399
|
-
const optimisticUpdateId =
|
|
2392
|
+
const optimisticUpdateId = nanoid2();
|
|
2400
2393
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
2401
2394
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2402
2395
|
store.pushOptimisticUpdate({
|
|
@@ -2405,8 +2398,7 @@ function useMarkThreadAsResolved() {
|
|
|
2405
2398
|
threadId,
|
|
2406
2399
|
updatedAt
|
|
2407
2400
|
});
|
|
2408
|
-
|
|
2409
|
-
commentsAPI.markThreadAsResolved({ threadId }).then(
|
|
2401
|
+
room.markThreadAsResolved(threadId).then(
|
|
2410
2402
|
() => {
|
|
2411
2403
|
store.set((state) => {
|
|
2412
2404
|
const existingThread = state.threads[threadId];
|
|
@@ -2462,7 +2454,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
2462
2454
|
const room = useRoom();
|
|
2463
2455
|
return React4.useCallback(
|
|
2464
2456
|
(threadId) => {
|
|
2465
|
-
const optimisticUpdateId =
|
|
2457
|
+
const optimisticUpdateId = nanoid2();
|
|
2466
2458
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
2467
2459
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2468
2460
|
store.pushOptimisticUpdate({
|
|
@@ -2471,8 +2463,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
2471
2463
|
threadId,
|
|
2472
2464
|
updatedAt
|
|
2473
2465
|
});
|
|
2474
|
-
|
|
2475
|
-
commentsAPI.markThreadAsUnresolved({ threadId }).then(
|
|
2466
|
+
room.markThreadAsUnresolved(threadId).then(
|
|
2476
2467
|
() => {
|
|
2477
2468
|
store.set((state) => {
|
|
2478
2469
|
const existingThread = state.threads[threadId];
|
|
@@ -2592,7 +2583,7 @@ function useUpdateRoomNotificationSettings() {
|
|
|
2592
2583
|
const room = useRoom();
|
|
2593
2584
|
return React4.useCallback(
|
|
2594
2585
|
(settings) => {
|
|
2595
|
-
const optimisticUpdateId =
|
|
2586
|
+
const optimisticUpdateId = nanoid2();
|
|
2596
2587
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2597
2588
|
store.pushOptimisticUpdate({
|
|
2598
2589
|
id: optimisticUpdateId,
|
|
@@ -2600,7 +2591,7 @@ function useUpdateRoomNotificationSettings() {
|
|
|
2600
2591
|
roomId: room.id,
|
|
2601
2592
|
settings
|
|
2602
2593
|
});
|
|
2603
|
-
room
|
|
2594
|
+
room.updateNotificationSettings(settings).then(
|
|
2604
2595
|
(settings2) => {
|
|
2605
2596
|
store.set((state) => ({
|
|
2606
2597
|
...state,
|
|
@@ -2870,4 +2861,4 @@ export {
|
|
|
2870
2861
|
_useStorageRoot,
|
|
2871
2862
|
_useUpdateMyPresence
|
|
2872
2863
|
};
|
|
2873
|
-
//# sourceMappingURL=chunk-
|
|
2864
|
+
//# sourceMappingURL=chunk-2ITOEAYK.mjs.map
|