@liveblocks/react 2.2.3-alpha2 → 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-AKAI4UTH.mjs → chunk-2ITOEAYK.mjs} +328 -221
- package/dist/chunk-2ITOEAYK.mjs.map +1 -0
- package/dist/{chunk-OZDSOIGV.js → chunk-L4QUDD4I.js} +335 -228
- 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 +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{suspense-Wplc32v5.d.mts → suspense-HhfQZzDE.d.mts} +56 -51
- package/dist/{suspense-Wplc32v5.d.ts → suspense-HhfQZzDE.d.ts} +56 -51
- package/dist/suspense.d.mts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +7 -3
- package/dist/suspense.js.map +1 -1
- package/dist/suspense.mjs +5 -1
- package/dist/suspense.mjs.map +1 -1
- package/package.json +3 -4
- package/dist/chunk-AKAI4UTH.mjs.map +0 -1
- package/dist/chunk-OZDSOIGV.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.
|
|
3
|
+
var PKG_VERSION = "2.4.0-test1";
|
|
4
4
|
var PKG_FORMAT = "cjs";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,8 +20,10 @@ function ClientSideSuspense(props) {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
23
26
|
var _core = require('@liveblocks/core');
|
|
24
|
-
var _nanoid = require('nanoid');
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
|
|
@@ -43,6 +45,7 @@ function selectedInboxNotifications(state) {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
// src/lib/retry-error.ts
|
|
48
|
+
|
|
46
49
|
var MAX_ERROR_RETRY_COUNT = 5;
|
|
47
50
|
var ERROR_RETRY_INTERVAL = 5e3;
|
|
48
51
|
function retryError(action, retryCount) {
|
|
@@ -52,6 +55,23 @@ function retryError(action, retryCount) {
|
|
|
52
55
|
void action();
|
|
53
56
|
}, timeout);
|
|
54
57
|
}
|
|
58
|
+
async function autoRetry(promiseFn, maxTries, backoff) {
|
|
59
|
+
const fallbackBackoff = backoff.length > 0 ? backoff[backoff.length - 1] : 0;
|
|
60
|
+
let attempt = 0;
|
|
61
|
+
while (true) {
|
|
62
|
+
attempt++;
|
|
63
|
+
const promise = promiseFn();
|
|
64
|
+
try {
|
|
65
|
+
return await promise;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
if (attempt >= maxTries) {
|
|
68
|
+
throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
|
|
72
|
+
await _core.wait.call(void 0, delay);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
55
75
|
|
|
56
76
|
// src/lib/use-initial.ts
|
|
57
77
|
|
|
@@ -83,6 +103,33 @@ function useInitialUnlessFunction(latestValue) {
|
|
|
83
103
|
}
|
|
84
104
|
}
|
|
85
105
|
|
|
106
|
+
// src/lib/use-polyfill.ts
|
|
107
|
+
var use = (
|
|
108
|
+
// React.use ||
|
|
109
|
+
(promise) => {
|
|
110
|
+
if (promise.status === "pending") {
|
|
111
|
+
throw promise;
|
|
112
|
+
} else if (promise.status === "fulfilled") {
|
|
113
|
+
return promise.value;
|
|
114
|
+
} else if (promise.status === "rejected") {
|
|
115
|
+
throw promise.reason;
|
|
116
|
+
} else {
|
|
117
|
+
promise.status = "pending";
|
|
118
|
+
promise.then(
|
|
119
|
+
(v) => {
|
|
120
|
+
promise.status = "fulfilled";
|
|
121
|
+
promise.value = v;
|
|
122
|
+
},
|
|
123
|
+
(e) => {
|
|
124
|
+
promise.status = "rejected";
|
|
125
|
+
promise.reason = e;
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
throw promise;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
|
|
86
133
|
// src/liveblocks.tsx
|
|
87
134
|
var ClientContext = _react.createContext.call(void 0, null);
|
|
88
135
|
function missingUserError(userId) {
|
|
@@ -115,12 +162,6 @@ function selectorFor_useInboxNotifications(state) {
|
|
|
115
162
|
isLoading: false
|
|
116
163
|
};
|
|
117
164
|
}
|
|
118
|
-
function selectorFor_useInboxNotificationsSuspense(state) {
|
|
119
|
-
return {
|
|
120
|
-
inboxNotifications: selectedInboxNotifications(state),
|
|
121
|
-
isLoading: false
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
165
|
function selectUnreadInboxNotificationsCount(state) {
|
|
125
166
|
let count = 0;
|
|
126
167
|
for (const notification of selectedInboxNotifications(state)) {
|
|
@@ -148,10 +189,40 @@ function selectorFor_useUnreadInboxNotificationsCount(state) {
|
|
|
148
189
|
count: selectUnreadInboxNotificationsCount(state)
|
|
149
190
|
};
|
|
150
191
|
}
|
|
151
|
-
function
|
|
192
|
+
function selectorFor_useUser(state, userId) {
|
|
193
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _2 => _2.isLoading])) {
|
|
194
|
+
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
195
|
+
}
|
|
196
|
+
if (state.error) {
|
|
197
|
+
return state;
|
|
198
|
+
}
|
|
199
|
+
if (!state.data) {
|
|
200
|
+
return {
|
|
201
|
+
isLoading: false,
|
|
202
|
+
error: missingUserError(userId)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
152
205
|
return {
|
|
153
206
|
isLoading: false,
|
|
154
|
-
|
|
207
|
+
user: state.data
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function selectorFor_useRoomInfo(state, roomId) {
|
|
211
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _3 => _3.isLoading])) {
|
|
212
|
+
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
213
|
+
}
|
|
214
|
+
if (state.error) {
|
|
215
|
+
return state;
|
|
216
|
+
}
|
|
217
|
+
if (!state.data) {
|
|
218
|
+
return {
|
|
219
|
+
isLoading: false,
|
|
220
|
+
error: missingRoomInfoError(roomId)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
isLoading: false,
|
|
225
|
+
info: state.data
|
|
155
226
|
};
|
|
156
227
|
}
|
|
157
228
|
function getOrCreateContextBundle(client) {
|
|
@@ -173,94 +244,96 @@ function getExtrasForClient(client) {
|
|
|
173
244
|
function makeExtrasForClient(client) {
|
|
174
245
|
const internals = client[_core.kInternal];
|
|
175
246
|
const store = internals.cacheStore;
|
|
176
|
-
const notifications = internals.notifications;
|
|
177
|
-
let fetchInboxNotifications$ = null;
|
|
178
247
|
let lastRequestedAt;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
248
|
+
async function fetchInboxNotifications() {
|
|
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;
|
|
192
272
|
}
|
|
193
|
-
)
|
|
194
|
-
);
|
|
195
|
-
async function fetchInboxNotifications({ retryCount } = { retryCount: 0 }) {
|
|
196
|
-
if (fetchInboxNotifications$ !== null) {
|
|
197
|
-
return fetchInboxNotifications$;
|
|
198
273
|
}
|
|
274
|
+
}
|
|
275
|
+
let pollerSubscribers = 0;
|
|
276
|
+
const poller = _core.makePoller.call(void 0, async () => {
|
|
277
|
+
try {
|
|
278
|
+
await waitUntilInboxNotificationsLoaded();
|
|
279
|
+
await fetchInboxNotifications();
|
|
280
|
+
} catch (err) {
|
|
281
|
+
console.warn(`Polling new inbox notifications failed: ${String(err)}`);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const waitUntilInboxNotificationsLoaded = _core.memoizeOnSuccess.call(void 0, async () => {
|
|
199
285
|
store.setQueryState(INBOX_NOTIFICATIONS_QUERY, {
|
|
200
286
|
isLoading: true
|
|
201
287
|
});
|
|
202
288
|
try {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
result.inboxNotifications,
|
|
208
|
-
result.deletedThreads,
|
|
209
|
-
result.deletedInboxNotifications,
|
|
210
|
-
INBOX_NOTIFICATIONS_QUERY
|
|
289
|
+
await autoRetry(
|
|
290
|
+
() => fetchInboxNotifications(),
|
|
291
|
+
5,
|
|
292
|
+
[5e3, 5e3, 1e4, 15e3]
|
|
211
293
|
);
|
|
212
|
-
|
|
213
|
-
lastRequestedAt = result.meta.requestedAt;
|
|
214
|
-
}
|
|
215
|
-
poller.start(POLLING_INTERVAL);
|
|
216
|
-
} catch (er) {
|
|
217
|
-
fetchInboxNotifications$ = null;
|
|
218
|
-
retryError(() => {
|
|
219
|
-
void fetchInboxNotifications({
|
|
220
|
-
retryCount: retryCount + 1
|
|
221
|
-
});
|
|
222
|
-
}, retryCount);
|
|
294
|
+
} catch (err) {
|
|
223
295
|
store.setQueryState(INBOX_NOTIFICATIONS_QUERY, {
|
|
224
296
|
isLoading: false,
|
|
225
|
-
error:
|
|
297
|
+
error: err
|
|
226
298
|
});
|
|
299
|
+
throw err;
|
|
227
300
|
}
|
|
228
|
-
|
|
301
|
+
});
|
|
302
|
+
function loadInboxNotifications() {
|
|
303
|
+
void waitUntilInboxNotificationsLoaded().catch(() => {
|
|
304
|
+
});
|
|
229
305
|
}
|
|
230
|
-
|
|
231
|
-
function useSubscribeToInboxNotificationsEffect(options) {
|
|
232
|
-
const autoFetch = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.autoFetch]), () => ( true)));
|
|
306
|
+
function useEnableInboxNotificationsPolling() {
|
|
233
307
|
_react.useEffect.call(void 0, () => {
|
|
234
|
-
|
|
235
|
-
void fetchInboxNotifications();
|
|
236
|
-
}
|
|
237
|
-
inboxNotificationsSubscribers++;
|
|
308
|
+
pollerSubscribers++;
|
|
238
309
|
poller.start(POLLING_INTERVAL);
|
|
239
310
|
return () => {
|
|
240
|
-
if (
|
|
311
|
+
if (pollerSubscribers <= 0) {
|
|
241
312
|
console.warn(
|
|
242
313
|
`Internal unexpected behavior. Cannot decrease subscriber count for query "${INBOX_NOTIFICATIONS_QUERY}"`
|
|
243
314
|
);
|
|
244
315
|
return;
|
|
245
316
|
}
|
|
246
|
-
|
|
247
|
-
if (
|
|
317
|
+
pollerSubscribers--;
|
|
318
|
+
if (pollerSubscribers <= 0) {
|
|
248
319
|
poller.stop();
|
|
249
320
|
}
|
|
250
321
|
};
|
|
251
|
-
}, [
|
|
322
|
+
}, []);
|
|
252
323
|
}
|
|
253
324
|
return {
|
|
254
325
|
store,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
326
|
+
useEnableInboxNotificationsPolling,
|
|
327
|
+
waitUntilInboxNotificationsLoaded,
|
|
328
|
+
loadInboxNotifications
|
|
258
329
|
};
|
|
259
330
|
}
|
|
260
331
|
function makeLiveblocksContextBundle(client) {
|
|
261
332
|
const useInboxNotificationThread2 = (inboxNotificationId) => useInboxNotificationThread_withClient(client, inboxNotificationId);
|
|
262
333
|
const useMarkInboxNotificationAsRead2 = () => useMarkInboxNotificationAsRead_withClient(client);
|
|
263
334
|
const useMarkAllInboxNotificationsAsRead2 = () => useMarkAllInboxNotificationsAsRead_withClient(client);
|
|
335
|
+
const useDeleteInboxNotification2 = () => useDeleteInboxNotification_withClient(client);
|
|
336
|
+
const useDeleteAllInboxNotifications2 = () => useDeleteAllInboxNotifications_withClient(client);
|
|
264
337
|
function LiveblocksProvider2(props) {
|
|
265
338
|
useEnsureNoLiveblocksProvider();
|
|
266
339
|
return /* @__PURE__ */ React.default.createElement(ClientContext.Provider, { value: client }, props.children);
|
|
@@ -272,6 +345,8 @@ function makeLiveblocksContextBundle(client) {
|
|
|
272
345
|
useUnreadInboxNotificationsCount: () => useUnreadInboxNotificationsCount_withClient(client),
|
|
273
346
|
useMarkInboxNotificationAsRead: useMarkInboxNotificationAsRead2,
|
|
274
347
|
useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
|
|
348
|
+
useDeleteInboxNotification: useDeleteInboxNotification2,
|
|
349
|
+
useDeleteAllInboxNotifications: useDeleteAllInboxNotifications2,
|
|
275
350
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
276
351
|
...shared.classic,
|
|
277
352
|
suspense: {
|
|
@@ -280,6 +355,8 @@ function makeLiveblocksContextBundle(client) {
|
|
|
280
355
|
useUnreadInboxNotificationsCount: () => useUnreadInboxNotificationsCountSuspense_withClient(client),
|
|
281
356
|
useMarkInboxNotificationAsRead: useMarkInboxNotificationAsRead2,
|
|
282
357
|
useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
|
|
358
|
+
useDeleteInboxNotification: useDeleteInboxNotification2,
|
|
359
|
+
useDeleteAllInboxNotifications: useDeleteAllInboxNotifications2,
|
|
283
360
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
284
361
|
...shared.suspense
|
|
285
362
|
}
|
|
@@ -287,8 +364,11 @@ function makeLiveblocksContextBundle(client) {
|
|
|
287
364
|
return bundle;
|
|
288
365
|
}
|
|
289
366
|
function useInboxNotifications_withClient(client) {
|
|
290
|
-
const { store,
|
|
291
|
-
|
|
367
|
+
const { loadInboxNotifications, store, useEnableInboxNotificationsPolling } = getExtrasForClient(client);
|
|
368
|
+
_react.useEffect.call(void 0, () => {
|
|
369
|
+
loadInboxNotifications();
|
|
370
|
+
}, [loadInboxNotifications]);
|
|
371
|
+
useEnableInboxNotificationsPolling();
|
|
292
372
|
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
293
373
|
store.subscribe,
|
|
294
374
|
store.get,
|
|
@@ -298,30 +378,19 @@ function useInboxNotifications_withClient(client) {
|
|
|
298
378
|
);
|
|
299
379
|
}
|
|
300
380
|
function useInboxNotificationsSuspense_withClient(client) {
|
|
301
|
-
const {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (query === void 0 || query.isLoading) {
|
|
308
|
-
throw fetchInboxNotifications();
|
|
309
|
-
}
|
|
310
|
-
if (query.error !== void 0) {
|
|
311
|
-
throw query.error;
|
|
312
|
-
}
|
|
313
|
-
useSubscribeToInboxNotificationsEffect({ autoFetch: false });
|
|
314
|
-
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
315
|
-
store.subscribe,
|
|
316
|
-
store.get,
|
|
317
|
-
store.get,
|
|
318
|
-
selectorFor_useInboxNotificationsSuspense,
|
|
319
|
-
_core.shallow
|
|
320
|
-
);
|
|
381
|
+
const { waitUntilInboxNotificationsLoaded } = getExtrasForClient(client);
|
|
382
|
+
use(waitUntilInboxNotificationsLoaded());
|
|
383
|
+
const result = useInboxNotifications_withClient(client);
|
|
384
|
+
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
385
|
+
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
386
|
+
return result;
|
|
321
387
|
}
|
|
322
388
|
function useUnreadInboxNotificationsCount_withClient(client) {
|
|
323
|
-
const { store,
|
|
324
|
-
|
|
389
|
+
const { store, loadInboxNotifications, useEnableInboxNotificationsPolling } = getExtrasForClient(client);
|
|
390
|
+
_react.useEffect.call(void 0, () => {
|
|
391
|
+
loadInboxNotifications();
|
|
392
|
+
}, [loadInboxNotifications]);
|
|
393
|
+
useEnableInboxNotificationsPolling();
|
|
325
394
|
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
326
395
|
store.subscribe,
|
|
327
396
|
store.get,
|
|
@@ -331,29 +400,18 @@ function useUnreadInboxNotificationsCount_withClient(client) {
|
|
|
331
400
|
);
|
|
332
401
|
}
|
|
333
402
|
function useUnreadInboxNotificationsCountSuspense_withClient(client) {
|
|
334
|
-
const {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (query === void 0 || query.isLoading) {
|
|
341
|
-
throw fetchInboxNotifications();
|
|
342
|
-
}
|
|
343
|
-
useSubscribeToInboxNotificationsEffect({ autoFetch: false });
|
|
344
|
-
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
345
|
-
store.subscribe,
|
|
346
|
-
store.get,
|
|
347
|
-
store.get,
|
|
348
|
-
selectorFor_useUnreadInboxNotificationsCountSuspense,
|
|
349
|
-
_core.shallow
|
|
350
|
-
);
|
|
403
|
+
const { waitUntilInboxNotificationsLoaded } = getExtrasForClient(client);
|
|
404
|
+
use(waitUntilInboxNotificationsLoaded());
|
|
405
|
+
const result = useUnreadInboxNotificationsCount_withClient(client);
|
|
406
|
+
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
407
|
+
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
408
|
+
return result;
|
|
351
409
|
}
|
|
352
410
|
function useMarkInboxNotificationAsRead_withClient(client) {
|
|
353
411
|
return _react.useCallback.call(void 0,
|
|
354
412
|
(inboxNotificationId) => {
|
|
355
|
-
const { store
|
|
356
|
-
const optimisticUpdateId =
|
|
413
|
+
const { store } = getExtrasForClient(client);
|
|
414
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
357
415
|
const readAt = /* @__PURE__ */ new Date();
|
|
358
416
|
store.pushOptimisticUpdate({
|
|
359
417
|
type: "mark-inbox-notification-as-read",
|
|
@@ -361,7 +419,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
361
419
|
inboxNotificationId,
|
|
362
420
|
readAt
|
|
363
421
|
});
|
|
364
|
-
|
|
422
|
+
client.markInboxNotificationAsRead(inboxNotificationId).then(
|
|
365
423
|
() => {
|
|
366
424
|
store.set((state) => {
|
|
367
425
|
const existingNotification = state.inboxNotifications[inboxNotificationId];
|
|
@@ -403,15 +461,15 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
403
461
|
}
|
|
404
462
|
function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
405
463
|
return _react.useCallback.call(void 0, () => {
|
|
406
|
-
const { store
|
|
407
|
-
const optimisticUpdateId =
|
|
464
|
+
const { store } = getExtrasForClient(client);
|
|
465
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
408
466
|
const readAt = /* @__PURE__ */ new Date();
|
|
409
467
|
store.pushOptimisticUpdate({
|
|
410
|
-
type: "mark-inbox-notifications-as-read",
|
|
468
|
+
type: "mark-all-inbox-notifications-as-read",
|
|
411
469
|
id: optimisticUpdateId,
|
|
412
470
|
readAt
|
|
413
471
|
});
|
|
414
|
-
|
|
472
|
+
client.markAllInboxNotificationsAsRead().then(
|
|
415
473
|
() => {
|
|
416
474
|
store.set((state) => ({
|
|
417
475
|
...state,
|
|
@@ -439,6 +497,84 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
|
439
497
|
);
|
|
440
498
|
}, [client]);
|
|
441
499
|
}
|
|
500
|
+
function useDeleteInboxNotification_withClient(client) {
|
|
501
|
+
return _react.useCallback.call(void 0,
|
|
502
|
+
(inboxNotificationId) => {
|
|
503
|
+
const { store } = getExtrasForClient(client);
|
|
504
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
505
|
+
const deletedAt = /* @__PURE__ */ new Date();
|
|
506
|
+
store.pushOptimisticUpdate({
|
|
507
|
+
type: "delete-inbox-notification",
|
|
508
|
+
id: optimisticUpdateId,
|
|
509
|
+
inboxNotificationId,
|
|
510
|
+
deletedAt
|
|
511
|
+
});
|
|
512
|
+
client.deleteInboxNotification(inboxNotificationId).then(
|
|
513
|
+
() => {
|
|
514
|
+
store.set((state) => {
|
|
515
|
+
const existingNotification = state.inboxNotifications[inboxNotificationId];
|
|
516
|
+
if (existingNotification === void 0) {
|
|
517
|
+
return {
|
|
518
|
+
...state,
|
|
519
|
+
optimisticUpdates: state.optimisticUpdates.filter(
|
|
520
|
+
(update) => update.id !== optimisticUpdateId
|
|
521
|
+
)
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
const { [inboxNotificationId]: _, ...inboxNotifications } = state.inboxNotifications;
|
|
525
|
+
return {
|
|
526
|
+
...state,
|
|
527
|
+
inboxNotifications,
|
|
528
|
+
optimisticUpdates: state.optimisticUpdates.filter(
|
|
529
|
+
(update) => update.id !== optimisticUpdateId
|
|
530
|
+
)
|
|
531
|
+
};
|
|
532
|
+
});
|
|
533
|
+
},
|
|
534
|
+
() => {
|
|
535
|
+
store.set((state) => ({
|
|
536
|
+
...state,
|
|
537
|
+
optimisticUpdates: state.optimisticUpdates.filter(
|
|
538
|
+
(update) => update.id !== optimisticUpdateId
|
|
539
|
+
)
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
542
|
+
);
|
|
543
|
+
},
|
|
544
|
+
[client]
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
function useDeleteAllInboxNotifications_withClient(client) {
|
|
548
|
+
return _react.useCallback.call(void 0, () => {
|
|
549
|
+
const { store } = getExtrasForClient(client);
|
|
550
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
551
|
+
const deletedAt = /* @__PURE__ */ new Date();
|
|
552
|
+
store.pushOptimisticUpdate({
|
|
553
|
+
type: "delete-all-inbox-notifications",
|
|
554
|
+
id: optimisticUpdateId,
|
|
555
|
+
deletedAt
|
|
556
|
+
});
|
|
557
|
+
client.deleteAllInboxNotifications().then(
|
|
558
|
+
() => {
|
|
559
|
+
store.set((state) => ({
|
|
560
|
+
...state,
|
|
561
|
+
inboxNotifications: {},
|
|
562
|
+
optimisticUpdates: state.optimisticUpdates.filter(
|
|
563
|
+
(update) => update.id !== optimisticUpdateId
|
|
564
|
+
)
|
|
565
|
+
}));
|
|
566
|
+
},
|
|
567
|
+
() => {
|
|
568
|
+
store.set((state) => ({
|
|
569
|
+
...state,
|
|
570
|
+
optimisticUpdates: state.optimisticUpdates.filter(
|
|
571
|
+
(update) => update.id !== optimisticUpdateId
|
|
572
|
+
)
|
|
573
|
+
}));
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
}, [client]);
|
|
577
|
+
}
|
|
442
578
|
function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
443
579
|
const { store } = getExtrasForClient(client);
|
|
444
580
|
const selector = _react.useCallback.call(void 0,
|
|
@@ -472,17 +608,17 @@ function useUser_withClient(client, userId) {
|
|
|
472
608
|
_react.useEffect.call(void 0, () => {
|
|
473
609
|
void usersStore.get(userId);
|
|
474
610
|
}, [usersStore, userId]);
|
|
475
|
-
const
|
|
611
|
+
const selector = _react.useCallback.call(void 0,
|
|
612
|
+
(state) => selectorFor_useUser(state, userId),
|
|
613
|
+
[userId]
|
|
614
|
+
);
|
|
615
|
+
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
476
616
|
usersStore.subscribe,
|
|
477
617
|
getUserState,
|
|
478
|
-
getUserState
|
|
618
|
+
getUserState,
|
|
619
|
+
selector,
|
|
620
|
+
_core.shallow
|
|
479
621
|
);
|
|
480
|
-
return state ? {
|
|
481
|
-
isLoading: state.isLoading,
|
|
482
|
-
user: state.data,
|
|
483
|
-
// Return an error if `undefined` was returned by `resolveUsers` for this user ID
|
|
484
|
-
error: !state.isLoading && !state.data && !state.error ? missingUserError(userId) : state.error
|
|
485
|
-
} : { isLoading: true };
|
|
486
622
|
}
|
|
487
623
|
function useUserSuspense_withClient(client, userId) {
|
|
488
624
|
const usersStore = client[_core.kInternal].usersStore;
|
|
@@ -505,10 +641,13 @@ function useUserSuspense_withClient(client, userId) {
|
|
|
505
641
|
getUserState,
|
|
506
642
|
getUserState
|
|
507
643
|
);
|
|
644
|
+
_core.assert.call(void 0, state !== void 0, "Unexpected missing state");
|
|
645
|
+
_core.assert.call(void 0, !state.isLoading, "Unexpected loading state");
|
|
646
|
+
_core.assert.call(void 0, !state.error, "Unexpected error state");
|
|
508
647
|
return {
|
|
509
648
|
isLoading: false,
|
|
510
|
-
user:
|
|
511
|
-
error:
|
|
649
|
+
user: state.data,
|
|
650
|
+
error: void 0
|
|
512
651
|
};
|
|
513
652
|
}
|
|
514
653
|
function useRoomInfo_withClient(client, roomId) {
|
|
@@ -517,20 +656,20 @@ function useRoomInfo_withClient(client, roomId) {
|
|
|
517
656
|
() => roomsInfoStore.getState(roomId),
|
|
518
657
|
[roomsInfoStore, roomId]
|
|
519
658
|
);
|
|
659
|
+
const selector = _react.useCallback.call(void 0,
|
|
660
|
+
(state) => selectorFor_useRoomInfo(state, roomId),
|
|
661
|
+
[roomId]
|
|
662
|
+
);
|
|
520
663
|
_react.useEffect.call(void 0, () => {
|
|
521
664
|
void roomsInfoStore.get(roomId);
|
|
522
665
|
}, [roomsInfoStore, roomId]);
|
|
523
|
-
|
|
666
|
+
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
524
667
|
roomsInfoStore.subscribe,
|
|
525
668
|
getRoomInfoState,
|
|
526
|
-
getRoomInfoState
|
|
669
|
+
getRoomInfoState,
|
|
670
|
+
selector,
|
|
671
|
+
_core.shallow
|
|
527
672
|
);
|
|
528
|
-
return state ? {
|
|
529
|
-
isLoading: state.isLoading,
|
|
530
|
-
info: state.data,
|
|
531
|
-
// Return an error if `undefined` was returned by `resolveRoomsInfo` for this room ID
|
|
532
|
-
error: !state.isLoading && !state.data && !state.error ? missingRoomInfoError(roomId) : state.error
|
|
533
|
-
} : { isLoading: true };
|
|
534
673
|
}
|
|
535
674
|
function useRoomInfoSuspense_withClient(client, roomId) {
|
|
536
675
|
const roomsInfoStore = client[_core.kInternal].roomsInfoStore;
|
|
@@ -553,10 +692,14 @@ function useRoomInfoSuspense_withClient(client, roomId) {
|
|
|
553
692
|
getRoomInfoState,
|
|
554
693
|
getRoomInfoState
|
|
555
694
|
);
|
|
695
|
+
_core.assert.call(void 0, state !== void 0, "Unexpected missing state");
|
|
696
|
+
_core.assert.call(void 0, !state.isLoading, "Unexpected loading state");
|
|
697
|
+
_core.assert.call(void 0, !state.error, "Unexpected error state");
|
|
698
|
+
_core.assert.call(void 0, state.data !== void 0, "Unexpected missing room info data");
|
|
556
699
|
return {
|
|
557
700
|
isLoading: false,
|
|
558
|
-
info:
|
|
559
|
-
error:
|
|
701
|
+
info: state.data,
|
|
702
|
+
error: void 0
|
|
560
703
|
};
|
|
561
704
|
}
|
|
562
705
|
function createSharedContext(client) {
|
|
@@ -576,7 +719,7 @@ function createSharedContext(client) {
|
|
|
576
719
|
}
|
|
577
720
|
function useEnsureNoLiveblocksProvider(options) {
|
|
578
721
|
const existing = useClientOrNull();
|
|
579
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
722
|
+
if (!_optionalChain([options, 'optionalAccess', _4 => _4.allowNesting]) && existing !== null) {
|
|
580
723
|
throw new Error(
|
|
581
724
|
"You cannot nest multiple LiveblocksProvider instances in the same React tree."
|
|
582
725
|
);
|
|
@@ -641,6 +784,12 @@ function useMarkAllInboxNotificationsAsRead() {
|
|
|
641
784
|
function useMarkInboxNotificationAsRead() {
|
|
642
785
|
return useMarkInboxNotificationAsRead_withClient(useClient());
|
|
643
786
|
}
|
|
787
|
+
function useDeleteAllInboxNotifications() {
|
|
788
|
+
return useDeleteAllInboxNotifications_withClient(useClient());
|
|
789
|
+
}
|
|
790
|
+
function useDeleteInboxNotification() {
|
|
791
|
+
return useDeleteInboxNotification_withClient(useClient());
|
|
792
|
+
}
|
|
644
793
|
function useUnreadInboxNotificationsCount() {
|
|
645
794
|
return useUnreadInboxNotificationsCount_withClient(useClient());
|
|
646
795
|
}
|
|
@@ -777,6 +926,9 @@ function selectedThreads(roomId, state, options) {
|
|
|
777
926
|
}
|
|
778
927
|
const query = options.query;
|
|
779
928
|
if (!query) return true;
|
|
929
|
+
if (query.resolved !== void 0 && thread.resolved !== query.resolved) {
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
780
932
|
for (const key in query.metadata) {
|
|
781
933
|
const metadataValue = thread.metadata[key];
|
|
782
934
|
const filterValue = query.metadata[key];
|
|
@@ -827,19 +979,7 @@ var _client = require('@liveblocks/client');
|
|
|
827
979
|
|
|
828
980
|
|
|
829
981
|
|
|
830
|
-
// src/comments/lib/createIds.ts
|
|
831
982
|
|
|
832
|
-
var THREAD_ID_PREFIX = "th";
|
|
833
|
-
var COMMENT_ID_PREFIX = "cm";
|
|
834
|
-
function createOptimisticId(prefix) {
|
|
835
|
-
return `${prefix}_${_nanoid.nanoid.call(void 0, )}`;
|
|
836
|
-
}
|
|
837
|
-
function createThreadId() {
|
|
838
|
-
return createOptimisticId(THREAD_ID_PREFIX);
|
|
839
|
-
}
|
|
840
|
-
function createCommentId() {
|
|
841
|
-
return createOptimisticId(COMMENT_ID_PREFIX);
|
|
842
|
-
}
|
|
843
983
|
|
|
844
984
|
// src/comments/lib/select-notification-settings.ts
|
|
845
985
|
|
|
@@ -851,33 +991,6 @@ function selectNotificationSettings(roomId, state) {
|
|
|
851
991
|
return _core.nn.call(void 0, notificationSettings[roomId]);
|
|
852
992
|
}
|
|
853
993
|
|
|
854
|
-
// src/lib/use-polyfill.ts
|
|
855
|
-
var use = (
|
|
856
|
-
// React.use ||
|
|
857
|
-
(promise) => {
|
|
858
|
-
if (promise.status === "pending") {
|
|
859
|
-
throw promise;
|
|
860
|
-
} else if (promise.status === "fulfilled") {
|
|
861
|
-
return promise.value;
|
|
862
|
-
} else if (promise.status === "rejected") {
|
|
863
|
-
throw promise.reason;
|
|
864
|
-
} else {
|
|
865
|
-
promise.status = "pending";
|
|
866
|
-
promise.then(
|
|
867
|
-
(v) => {
|
|
868
|
-
promise.status = "fulfilled";
|
|
869
|
-
promise.value = v;
|
|
870
|
-
},
|
|
871
|
-
(e) => {
|
|
872
|
-
promise.status = "rejected";
|
|
873
|
-
promise.reason = e;
|
|
874
|
-
}
|
|
875
|
-
);
|
|
876
|
-
throw promise;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
);
|
|
880
|
-
|
|
881
994
|
// src/use-scroll-to-comment-on-load-effect.ts
|
|
882
995
|
|
|
883
996
|
function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
|
|
@@ -980,7 +1093,7 @@ function getCurrentUserId(room) {
|
|
|
980
1093
|
}
|
|
981
1094
|
function handleApiError(err) {
|
|
982
1095
|
const message = `Request failed with status ${err.status}: ${err.message}`;
|
|
983
|
-
if (_optionalChain([err, 'access',
|
|
1096
|
+
if (_optionalChain([err, 'access', _5 => _5.details, 'optionalAccess', _6 => _6.error]) === "FORBIDDEN") {
|
|
984
1097
|
const detailedMessage = [message, err.details.suggestion, err.details.docs].filter(Boolean).join("\n");
|
|
985
1098
|
_core.console.error(detailedMessage);
|
|
986
1099
|
}
|
|
@@ -1052,18 +1165,17 @@ function makeExtrasForClient2(client) {
|
|
|
1052
1165
|
if (isFetchingThreadsUpdates === true) return;
|
|
1053
1166
|
try {
|
|
1054
1167
|
requestStatusByRoom.set(room.id, true);
|
|
1055
|
-
const
|
|
1056
|
-
const updates = await commentsAPI.getThreads({ since });
|
|
1168
|
+
const updates = await room.getThreadsSince({ since });
|
|
1057
1169
|
setTimeout(() => {
|
|
1058
1170
|
requestStatusByRoom.set(room.id, false);
|
|
1059
1171
|
}, DEFAULT_DEDUPING_INTERVAL);
|
|
1060
1172
|
store.updateThreadsAndNotifications(
|
|
1061
|
-
updates.threads,
|
|
1062
|
-
updates.inboxNotifications,
|
|
1063
|
-
updates.
|
|
1064
|
-
updates.
|
|
1173
|
+
updates.threads.modified,
|
|
1174
|
+
updates.inboxNotifications.modified,
|
|
1175
|
+
updates.threads.deleted,
|
|
1176
|
+
updates.inboxNotifications.deleted
|
|
1065
1177
|
);
|
|
1066
|
-
lastRequestedAtByRoom.set(room.id, updates.
|
|
1178
|
+
lastRequestedAtByRoom.set(room.id, updates.requestedAt);
|
|
1067
1179
|
} catch (err) {
|
|
1068
1180
|
requestStatusByRoom.set(room.id, false);
|
|
1069
1181
|
return;
|
|
@@ -1072,8 +1184,7 @@ function makeExtrasForClient2(client) {
|
|
|
1072
1184
|
async function getThreadsAndInboxNotifications(room, queryKey, options, { retryCount } = { retryCount: 0 }) {
|
|
1073
1185
|
const existingRequest = requestsByQuery.get(queryKey);
|
|
1074
1186
|
if (existingRequest !== void 0) return existingRequest;
|
|
1075
|
-
const
|
|
1076
|
-
const request = commentsAPI.getThreads(options);
|
|
1187
|
+
const request = room.getThreads(options);
|
|
1077
1188
|
requestsByQuery.set(queryKey, request);
|
|
1078
1189
|
store.setQueryState(queryKey, {
|
|
1079
1190
|
isLoading: true
|
|
@@ -1082,14 +1193,15 @@ function makeExtrasForClient2(client) {
|
|
|
1082
1193
|
const result = await request;
|
|
1083
1194
|
store.updateThreadsAndNotifications(
|
|
1084
1195
|
result.threads,
|
|
1196
|
+
// TODO: Figure out how to remove this casting
|
|
1085
1197
|
result.inboxNotifications,
|
|
1086
|
-
|
|
1087
|
-
|
|
1198
|
+
[],
|
|
1199
|
+
[],
|
|
1088
1200
|
queryKey
|
|
1089
1201
|
);
|
|
1090
1202
|
const lastRequestedAt = lastRequestedAtByRoom.get(room.id);
|
|
1091
|
-
if (lastRequestedAt === void 0 || lastRequestedAt > result.
|
|
1092
|
-
lastRequestedAtByRoom.set(room.id, result.
|
|
1203
|
+
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
1204
|
+
lastRequestedAtByRoom.set(room.id, result.requestedAt);
|
|
1093
1205
|
}
|
|
1094
1206
|
poller.start(POLLING_INTERVAL2);
|
|
1095
1207
|
} catch (err) {
|
|
@@ -1110,7 +1222,7 @@ function makeExtrasForClient2(client) {
|
|
|
1110
1222
|
const existingRequest = requestsByQuery.get(queryKey);
|
|
1111
1223
|
if (existingRequest !== void 0) return existingRequest;
|
|
1112
1224
|
try {
|
|
1113
|
-
const request = room
|
|
1225
|
+
const request = room.getNotificationSettings();
|
|
1114
1226
|
requestsByQuery.set(queryKey, request);
|
|
1115
1227
|
store.setQueryState(queryKey, {
|
|
1116
1228
|
isLoading: true
|
|
@@ -1330,10 +1442,8 @@ function RoomProviderInner(props) {
|
|
|
1330
1442
|
store.deleteThread(message.threadId);
|
|
1331
1443
|
return;
|
|
1332
1444
|
}
|
|
1333
|
-
const info = await room
|
|
1334
|
-
|
|
1335
|
-
});
|
|
1336
|
-
if (!info) {
|
|
1445
|
+
const info = await room.getThread(message.threadId);
|
|
1446
|
+
if (!info.thread) {
|
|
1337
1447
|
store.deleteThread(message.threadId);
|
|
1338
1448
|
return;
|
|
1339
1449
|
}
|
|
@@ -1402,7 +1512,7 @@ function useStatus() {
|
|
|
1402
1512
|
return useSyncExternalStore2(subscribe, getSnapshot, getServerSnapshot);
|
|
1403
1513
|
}
|
|
1404
1514
|
function useStorageStatus(options) {
|
|
1405
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1515
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.smooth]), () => ( false)));
|
|
1406
1516
|
if (smooth) {
|
|
1407
1517
|
return useStorageStatusSmooth();
|
|
1408
1518
|
} else {
|
|
@@ -1711,8 +1821,8 @@ function useCreateThread() {
|
|
|
1711
1821
|
(options) => {
|
|
1712
1822
|
const body = options.body;
|
|
1713
1823
|
const metadata = _nullishCoalesce(options.metadata, () => ( {}));
|
|
1714
|
-
const threadId = createThreadId();
|
|
1715
|
-
const commentId = createCommentId();
|
|
1824
|
+
const threadId = _core.createThreadId.call(void 0, );
|
|
1825
|
+
const commentId = _core.createCommentId.call(void 0, );
|
|
1716
1826
|
const createdAt = /* @__PURE__ */ new Date();
|
|
1717
1827
|
const newComment = {
|
|
1718
1828
|
id: commentId,
|
|
@@ -1734,7 +1844,7 @@ function useCreateThread() {
|
|
|
1734
1844
|
comments: [newComment],
|
|
1735
1845
|
resolved: false
|
|
1736
1846
|
};
|
|
1737
|
-
const optimisticUpdateId =
|
|
1847
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
1738
1848
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1739
1849
|
store.pushOptimisticUpdate({
|
|
1740
1850
|
type: "create-thread",
|
|
@@ -1742,8 +1852,7 @@ function useCreateThread() {
|
|
|
1742
1852
|
id: optimisticUpdateId,
|
|
1743
1853
|
roomId: room.id
|
|
1744
1854
|
});
|
|
1745
|
-
|
|
1746
|
-
commentsAPI.createThread({ threadId, commentId, body, metadata }).then(
|
|
1855
|
+
room.createThread({ threadId, commentId, body, metadata }).then(
|
|
1747
1856
|
(thread) => {
|
|
1748
1857
|
store.set((state) => ({
|
|
1749
1858
|
...state,
|
|
@@ -1778,11 +1887,11 @@ function useDeleteThread() {
|
|
|
1778
1887
|
const room = useRoom();
|
|
1779
1888
|
return React4.useCallback(
|
|
1780
1889
|
(threadId) => {
|
|
1781
|
-
const optimisticUpdateId =
|
|
1890
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
1782
1891
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1783
1892
|
const thread = store.get().threads[threadId];
|
|
1784
1893
|
const userId = getCurrentUserId(room);
|
|
1785
|
-
if (_optionalChain([thread, 'optionalAccess',
|
|
1894
|
+
if (_optionalChain([thread, 'optionalAccess', _8 => _8.comments, 'optionalAccess', _9 => _9[0], 'optionalAccess', _10 => _10.userId]) !== userId) {
|
|
1786
1895
|
throw new Error("Only the thread creator can delete the thread");
|
|
1787
1896
|
}
|
|
1788
1897
|
store.pushOptimisticUpdate({
|
|
@@ -1792,8 +1901,7 @@ function useDeleteThread() {
|
|
|
1792
1901
|
threadId,
|
|
1793
1902
|
deletedAt: /* @__PURE__ */ new Date()
|
|
1794
1903
|
});
|
|
1795
|
-
|
|
1796
|
-
commentsAPI.deleteThread({ threadId }).then(
|
|
1904
|
+
room.deleteThread(threadId).then(
|
|
1797
1905
|
() => {
|
|
1798
1906
|
store.set((state) => {
|
|
1799
1907
|
const existingThread = state.threads[threadId];
|
|
@@ -1837,7 +1945,7 @@ function useEditThreadMetadata() {
|
|
|
1837
1945
|
const threadId = options.threadId;
|
|
1838
1946
|
const metadata = options.metadata;
|
|
1839
1947
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
1840
|
-
const optimisticUpdateId =
|
|
1948
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
1841
1949
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1842
1950
|
store.pushOptimisticUpdate({
|
|
1843
1951
|
type: "edit-thread-metadata",
|
|
@@ -1846,8 +1954,7 @@ function useEditThreadMetadata() {
|
|
|
1846
1954
|
threadId,
|
|
1847
1955
|
updatedAt
|
|
1848
1956
|
});
|
|
1849
|
-
|
|
1850
|
-
commentsAPI.editThreadMetadata({ metadata, threadId }).then(
|
|
1957
|
+
room.editThreadMetadata({ metadata, threadId }).then(
|
|
1851
1958
|
(metadata2) => {
|
|
1852
1959
|
store.set((state) => {
|
|
1853
1960
|
const existingThread = state.threads[threadId];
|
|
@@ -1904,7 +2011,7 @@ function useCreateComment() {
|
|
|
1904
2011
|
const room = useRoom();
|
|
1905
2012
|
return React4.useCallback(
|
|
1906
2013
|
({ threadId, body }) => {
|
|
1907
|
-
const commentId = createCommentId();
|
|
2014
|
+
const commentId = _core.createCommentId.call(void 0, );
|
|
1908
2015
|
const createdAt = /* @__PURE__ */ new Date();
|
|
1909
2016
|
const comment = {
|
|
1910
2017
|
id: commentId,
|
|
@@ -1916,14 +2023,14 @@ function useCreateComment() {
|
|
|
1916
2023
|
body,
|
|
1917
2024
|
reactions: []
|
|
1918
2025
|
};
|
|
1919
|
-
const optimisticUpdateId =
|
|
2026
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
1920
2027
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1921
2028
|
store.pushOptimisticUpdate({
|
|
1922
2029
|
type: "create-comment",
|
|
1923
2030
|
comment,
|
|
1924
2031
|
id: optimisticUpdateId
|
|
1925
2032
|
});
|
|
1926
|
-
room
|
|
2033
|
+
room.createComment({ threadId, commentId, body }).then(
|
|
1927
2034
|
(newComment) => {
|
|
1928
2035
|
store.set((state) => {
|
|
1929
2036
|
const existingThread = state.threads[threadId];
|
|
@@ -1983,7 +2090,7 @@ function useEditComment() {
|
|
|
1983
2090
|
return React4.useCallback(
|
|
1984
2091
|
({ threadId, commentId, body }) => {
|
|
1985
2092
|
const editedAt = /* @__PURE__ */ new Date();
|
|
1986
|
-
const optimisticUpdateId =
|
|
2093
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
1987
2094
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
1988
2095
|
const thread = store.get().threads[threadId];
|
|
1989
2096
|
if (thread === void 0) {
|
|
@@ -2010,7 +2117,7 @@ function useEditComment() {
|
|
|
2010
2117
|
},
|
|
2011
2118
|
id: optimisticUpdateId
|
|
2012
2119
|
});
|
|
2013
|
-
room
|
|
2120
|
+
room.editComment({ threadId, commentId, body }).then(
|
|
2014
2121
|
(editedComment) => {
|
|
2015
2122
|
store.set((state) => {
|
|
2016
2123
|
const existingThread = state.threads[threadId];
|
|
@@ -2055,7 +2162,7 @@ function useDeleteComment() {
|
|
|
2055
2162
|
return React4.useCallback(
|
|
2056
2163
|
({ threadId, commentId }) => {
|
|
2057
2164
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
2058
|
-
const optimisticUpdateId =
|
|
2165
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2059
2166
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2060
2167
|
store.pushOptimisticUpdate({
|
|
2061
2168
|
type: "delete-comment",
|
|
@@ -2065,7 +2172,7 @@ function useDeleteComment() {
|
|
|
2065
2172
|
id: optimisticUpdateId,
|
|
2066
2173
|
roomId: room.id
|
|
2067
2174
|
});
|
|
2068
|
-
room
|
|
2175
|
+
room.deleteComment({ threadId, commentId }).then(
|
|
2069
2176
|
() => {
|
|
2070
2177
|
store.set((state) => {
|
|
2071
2178
|
const existingThread = state.threads[threadId];
|
|
@@ -2109,7 +2216,7 @@ function useAddReaction() {
|
|
|
2109
2216
|
({ threadId, commentId, emoji }) => {
|
|
2110
2217
|
const createdAt = /* @__PURE__ */ new Date();
|
|
2111
2218
|
const userId = getCurrentUserId(room);
|
|
2112
|
-
const optimisticUpdateId =
|
|
2219
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2113
2220
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2114
2221
|
store.pushOptimisticUpdate({
|
|
2115
2222
|
type: "add-reaction",
|
|
@@ -2122,7 +2229,7 @@ function useAddReaction() {
|
|
|
2122
2229
|
},
|
|
2123
2230
|
id: optimisticUpdateId
|
|
2124
2231
|
});
|
|
2125
|
-
room
|
|
2232
|
+
room.addReaction({ threadId, commentId, emoji }).then(
|
|
2126
2233
|
(addedReaction) => {
|
|
2127
2234
|
store.set((state) => {
|
|
2128
2235
|
const existingThread = state.threads[threadId];
|
|
@@ -2171,7 +2278,7 @@ function useRemoveReaction() {
|
|
|
2171
2278
|
({ threadId, commentId, emoji }) => {
|
|
2172
2279
|
const userId = getCurrentUserId(room);
|
|
2173
2280
|
const removedAt = /* @__PURE__ */ new Date();
|
|
2174
|
-
const optimisticUpdateId =
|
|
2281
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2175
2282
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2176
2283
|
store.pushOptimisticUpdate({
|
|
2177
2284
|
type: "remove-reaction",
|
|
@@ -2182,7 +2289,7 @@ function useRemoveReaction() {
|
|
|
2182
2289
|
removedAt,
|
|
2183
2290
|
id: optimisticUpdateId
|
|
2184
2291
|
});
|
|
2185
|
-
room
|
|
2292
|
+
room.removeReaction({ threadId, commentId, emoji }).then(
|
|
2186
2293
|
() => {
|
|
2187
2294
|
store.set((state) => {
|
|
2188
2295
|
const existingThread = state.threads[threadId];
|
|
@@ -2238,7 +2345,7 @@ function useMarkThreadAsRead() {
|
|
|
2238
2345
|
(inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
|
|
2239
2346
|
);
|
|
2240
2347
|
if (!inboxNotification) return;
|
|
2241
|
-
const optimisticUpdateId =
|
|
2348
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2242
2349
|
const now = /* @__PURE__ */ new Date();
|
|
2243
2350
|
store.pushOptimisticUpdate({
|
|
2244
2351
|
type: "mark-inbox-notification-as-read",
|
|
@@ -2246,7 +2353,7 @@ function useMarkThreadAsRead() {
|
|
|
2246
2353
|
inboxNotificationId: inboxNotification.id,
|
|
2247
2354
|
readAt: now
|
|
2248
2355
|
});
|
|
2249
|
-
room
|
|
2356
|
+
room.markInboxNotificationAsRead(inboxNotification.id).then(
|
|
2250
2357
|
() => {
|
|
2251
2358
|
store.set((state) => ({
|
|
2252
2359
|
...state,
|
|
@@ -2282,7 +2389,7 @@ function useMarkThreadAsResolved() {
|
|
|
2282
2389
|
const room = useRoom();
|
|
2283
2390
|
return React4.useCallback(
|
|
2284
2391
|
(threadId) => {
|
|
2285
|
-
const optimisticUpdateId =
|
|
2392
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2286
2393
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
2287
2394
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2288
2395
|
store.pushOptimisticUpdate({
|
|
@@ -2291,8 +2398,7 @@ function useMarkThreadAsResolved() {
|
|
|
2291
2398
|
threadId,
|
|
2292
2399
|
updatedAt
|
|
2293
2400
|
});
|
|
2294
|
-
|
|
2295
|
-
commentsAPI.markThreadAsResolved({ threadId }).then(
|
|
2401
|
+
room.markThreadAsResolved(threadId).then(
|
|
2296
2402
|
() => {
|
|
2297
2403
|
store.set((state) => {
|
|
2298
2404
|
const existingThread = state.threads[threadId];
|
|
@@ -2348,7 +2454,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
2348
2454
|
const room = useRoom();
|
|
2349
2455
|
return React4.useCallback(
|
|
2350
2456
|
(threadId) => {
|
|
2351
|
-
const optimisticUpdateId =
|
|
2457
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2352
2458
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
2353
2459
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2354
2460
|
store.pushOptimisticUpdate({
|
|
@@ -2357,8 +2463,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
2357
2463
|
threadId,
|
|
2358
2464
|
updatedAt
|
|
2359
2465
|
});
|
|
2360
|
-
|
|
2361
|
-
commentsAPI.markThreadAsUnresolved({ threadId }).then(
|
|
2466
|
+
room.markThreadAsUnresolved(threadId).then(
|
|
2362
2467
|
() => {
|
|
2363
2468
|
store.set((state) => {
|
|
2364
2469
|
const existingThread = state.threads[threadId];
|
|
@@ -2478,7 +2583,7 @@ function useUpdateRoomNotificationSettings() {
|
|
|
2478
2583
|
const room = useRoom();
|
|
2479
2584
|
return React4.useCallback(
|
|
2480
2585
|
(settings) => {
|
|
2481
|
-
const optimisticUpdateId =
|
|
2586
|
+
const optimisticUpdateId = _core.nanoid.call(void 0, );
|
|
2482
2587
|
const { store, onMutationFailure } = getExtrasForClient2(client);
|
|
2483
2588
|
store.pushOptimisticUpdate({
|
|
2484
2589
|
id: optimisticUpdateId,
|
|
@@ -2486,7 +2591,7 @@ function useUpdateRoomNotificationSettings() {
|
|
|
2486
2591
|
roomId: room.id,
|
|
2487
2592
|
settings
|
|
2488
2593
|
});
|
|
2489
|
-
room
|
|
2594
|
+
room.updateNotificationSettings(settings).then(
|
|
2490
2595
|
(settings2) => {
|
|
2491
2596
|
store.set((state) => ({
|
|
2492
2597
|
...state,
|
|
@@ -2753,5 +2858,7 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
2753
2858
|
|
|
2754
2859
|
|
|
2755
2860
|
|
|
2756
|
-
|
|
2757
|
-
|
|
2861
|
+
|
|
2862
|
+
|
|
2863
|
+
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense; exports.ClientContext = ClientContext; 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.CreateThreadError = CreateThreadError; exports.selectedThreads = selectedThreads; exports.RoomContext = RoomContext; exports.useStatus = useStatus; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useErrorListener = useErrorListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCommentsErrorListener = useCommentsErrorListener; exports.useCreateComment = useCreateComment; exports.useEditComment = useEditComment; exports.useDeleteComment = useDeleteComment; exports.useRemoveReaction = useRemoveReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useRoomNotificationSettings = useRoomNotificationSettings; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; 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._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;
|
|
2864
|
+
//# sourceMappingURL=chunk-L4QUDD4I.js.map
|