@liveblocks/react 2.17.0-rc1 → 2.17.0-usrnotsettings1
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 +1 -1
- package/dist/_private.d.ts +1 -1
- package/dist/_private.js +5 -5
- package/dist/_private.mjs +1 -1
- package/dist/{chunk-J5ZDLMBE.js → chunk-4F7C4HN7.js} +214 -41
- package/dist/chunk-4F7C4HN7.js.map +1 -0
- package/dist/{chunk-DR4OUZTF.js → chunk-DT3BO7N5.js} +2 -2
- package/dist/chunk-DT3BO7N5.js.map +1 -0
- package/dist/{chunk-XWYTEJGO.mjs → chunk-KAFU5ZQA.mjs} +2 -2
- package/dist/{chunk-4KNGHD4I.mjs → chunk-LOPNJCSB.mjs} +196 -23
- package/dist/chunk-LOPNJCSB.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{room-Ce3twcjb.d.mts → room-DlI0Yrzf.d.mts} +74 -3
- package/dist/{room-Ce3twcjb.d.ts → room-DlI0Yrzf.d.ts} +74 -3
- package/dist/suspense.d.mts +2 -2
- package/dist/suspense.d.ts +2 -2
- package/dist/suspense.js +9 -4
- package/dist/suspense.js.map +1 -1
- package/dist/suspense.mjs +8 -3
- package/dist/suspense.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-4KNGHD4I.mjs.map +0 -1
- package/dist/chunk-DR4OUZTF.js.map +0 -1
- package/dist/chunk-J5ZDLMBE.js.map +0 -1
- /package/dist/{chunk-XWYTEJGO.mjs.map → chunk-KAFU5ZQA.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.17.0-
|
|
3
|
+
var PKG_VERSION = "2.17.0-usrnotsettings1";
|
|
4
4
|
var PKG_FORMAT = "cjs";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ function ClientSideSuspense(props) {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense;
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-DT3BO7N5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-DT3BO7N5.js","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,wBAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-DT3BO7N5.js","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.17.0-
|
|
3
|
+
var PKG_VERSION = "2.17.0-usrnotsettings1";
|
|
4
4
|
var PKG_FORMAT = "esm";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ export {
|
|
|
20
20
|
PKG_FORMAT,
|
|
21
21
|
ClientSideSuspense
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-KAFU5ZQA.mjs.map
|
|
@@ -130,7 +130,9 @@ var config = {
|
|
|
130
130
|
HISTORY_VERSIONS_POLL_INTERVAL: 1 * MINUTES,
|
|
131
131
|
HISTORY_VERSIONS_MAX_STALE_TIME: 5 * SECONDS,
|
|
132
132
|
NOTIFICATION_SETTINGS_POLL_INTERVAL: 1 * MINUTES,
|
|
133
|
-
NOTIFICATION_SETTINGS_MAX_STALE_TIME: 5 * SECONDS
|
|
133
|
+
NOTIFICATION_SETTINGS_MAX_STALE_TIME: 5 * SECONDS,
|
|
134
|
+
USER_NOTIFICATION_SETTINGS_INTERVAL: 5 * MINUTES,
|
|
135
|
+
USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME: 1 * MINUTES
|
|
134
136
|
};
|
|
135
137
|
|
|
136
138
|
// src/lib/AsyncResult.ts
|
|
@@ -159,15 +161,6 @@ function count(it, predicate) {
|
|
|
159
161
|
return total;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
// src/lib/ssr.ts
|
|
163
|
-
function ensureNotServerSide() {
|
|
164
|
-
if (typeof window === "undefined") {
|
|
165
|
-
throw new Error(
|
|
166
|
-
"You cannot use the Suspense version of Liveblocks hooks server side. Make sure to only call them client side by using a ClientSideSuspense wrapper.\nFor tips, see https://liveblocks.io/docs/api-reference/liveblocks-react#ClientSideSuspense"
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
164
|
// src/lib/use-initial.ts
|
|
172
165
|
import { useCallback, useReducer } from "react";
|
|
173
166
|
|
|
@@ -233,6 +226,8 @@ import {
|
|
|
233
226
|
console as console2,
|
|
234
227
|
DefaultMap,
|
|
235
228
|
DerivedSignal,
|
|
229
|
+
entries,
|
|
230
|
+
keys,
|
|
236
231
|
kInternal,
|
|
237
232
|
MutableSignal as MutableSignal2,
|
|
238
233
|
nanoid,
|
|
@@ -723,6 +718,26 @@ function createStore_forPermissionHints() {
|
|
|
723
718
|
update
|
|
724
719
|
};
|
|
725
720
|
}
|
|
721
|
+
function createStore_forUserNotificationSettings(updates) {
|
|
722
|
+
const signal = new Signal({});
|
|
723
|
+
function update(settings) {
|
|
724
|
+
signal.set((prevSettings) => {
|
|
725
|
+
return {
|
|
726
|
+
...prevSettings,
|
|
727
|
+
...settings
|
|
728
|
+
};
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
return {
|
|
732
|
+
signal: DerivedSignal.from(
|
|
733
|
+
signal,
|
|
734
|
+
updates,
|
|
735
|
+
(base, updates2) => applyOptimisticUpdates_forUserNotificationSettings(base, updates2)
|
|
736
|
+
),
|
|
737
|
+
// Mutations
|
|
738
|
+
update
|
|
739
|
+
};
|
|
740
|
+
}
|
|
726
741
|
function createStore_forOptimistic(client) {
|
|
727
742
|
const signal = new Signal([]);
|
|
728
743
|
const syncSource = client[kInternal].createSyncSource();
|
|
@@ -762,9 +777,11 @@ var UmbrellaStore = class {
|
|
|
762
777
|
// \ | | | | & notifications by ID
|
|
763
778
|
// | \ | | Apply | |
|
|
764
779
|
// | `-> OptimisticUpdates --+--+--> Optimistic --+-+--> Notification Settings (Part 2)
|
|
765
|
-
// \ | Updates
|
|
766
|
-
// `------- etc etc ---------+
|
|
767
|
-
// ^
|
|
780
|
+
// \ | Updates | |
|
|
781
|
+
// `------- etc etc ---------+ | +--> History Versions (Part 3)
|
|
782
|
+
// ^ |
|
|
783
|
+
// | +-----> Channels Notification Settings (Part 4)
|
|
784
|
+
// |
|
|
768
785
|
// |
|
|
769
786
|
// | ^ ^
|
|
770
787
|
// Signal | |
|
|
@@ -785,6 +802,7 @@ var UmbrellaStore = class {
|
|
|
785
802
|
// prettier-ignore
|
|
786
803
|
historyVersions;
|
|
787
804
|
permissionHints;
|
|
805
|
+
userNotificationSettings;
|
|
788
806
|
optimisticUpdates;
|
|
789
807
|
//
|
|
790
808
|
// Output signals.
|
|
@@ -805,6 +823,8 @@ var UmbrellaStore = class {
|
|
|
805
823
|
#userThreadsLastRequestedAt = null;
|
|
806
824
|
// Room versions
|
|
807
825
|
#roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
826
|
+
// User Notification Settings
|
|
827
|
+
#userNotificationSettings;
|
|
808
828
|
constructor(client) {
|
|
809
829
|
this.#client = client[kInternal].as();
|
|
810
830
|
this.optimisticUpdates = createStore_forOptimistic(this.#client);
|
|
@@ -820,6 +840,16 @@ var UmbrellaStore = class {
|
|
|
820
840
|
return nextCursor;
|
|
821
841
|
}
|
|
822
842
|
);
|
|
843
|
+
const channelsNotificationSettingsFetcher = async () => {
|
|
844
|
+
const result = await this.#client.getNotificationSettings();
|
|
845
|
+
this.userNotificationSettings.update(result);
|
|
846
|
+
};
|
|
847
|
+
this.userNotificationSettings = createStore_forUserNotificationSettings(
|
|
848
|
+
this.optimisticUpdates.signal
|
|
849
|
+
);
|
|
850
|
+
this.#userNotificationSettings = new SinglePageResource(
|
|
851
|
+
channelsNotificationSettingsFetcher
|
|
852
|
+
);
|
|
823
853
|
this.threads = new ThreadDB();
|
|
824
854
|
this.notifications = createStore_forNotifications();
|
|
825
855
|
this.roomNotificationSettings = createStore_forRoomNotificationSettings(
|
|
@@ -997,6 +1027,19 @@ var UmbrellaStore = class {
|
|
|
997
1027
|
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
998
1028
|
}
|
|
999
1029
|
);
|
|
1030
|
+
const userNotificationSettings = {
|
|
1031
|
+
signal: DerivedSignal.from(() => {
|
|
1032
|
+
const result = this.#userNotificationSettings.get();
|
|
1033
|
+
if (result.isLoading || result.error) {
|
|
1034
|
+
return result;
|
|
1035
|
+
}
|
|
1036
|
+
return ASYNC_OK(
|
|
1037
|
+
"settings",
|
|
1038
|
+
nn(this.userNotificationSettings.signal.get())
|
|
1039
|
+
);
|
|
1040
|
+
}, shallow3),
|
|
1041
|
+
waitUntilLoaded: this.#userNotificationSettings.waitUntilLoaded
|
|
1042
|
+
};
|
|
1000
1043
|
this.outputs = {
|
|
1001
1044
|
threadifications,
|
|
1002
1045
|
threads,
|
|
@@ -1005,7 +1048,8 @@ var UmbrellaStore = class {
|
|
|
1005
1048
|
notifications,
|
|
1006
1049
|
loadingNotifications,
|
|
1007
1050
|
settingsByRoomId,
|
|
1008
|
-
versionsByRoomId
|
|
1051
|
+
versionsByRoomId,
|
|
1052
|
+
userNotificationSettings
|
|
1009
1053
|
};
|
|
1010
1054
|
autobind(this);
|
|
1011
1055
|
}
|
|
@@ -1250,6 +1294,25 @@ var UmbrellaStore = class {
|
|
|
1250
1294
|
const result = await room.getNotificationSettings({ signal });
|
|
1251
1295
|
this.roomNotificationSettings.update(roomId, result);
|
|
1252
1296
|
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Refresh User Notification Settings from poller
|
|
1299
|
+
*/
|
|
1300
|
+
async refreshUserNotificationSettings(signal) {
|
|
1301
|
+
const result = await this.#client.getNotificationSettings({
|
|
1302
|
+
signal
|
|
1303
|
+
});
|
|
1304
|
+
this.userNotificationSettings.update(result);
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Updates user notification settings with a new value, replacing the
|
|
1308
|
+
* corresponding optimistic update.
|
|
1309
|
+
*/
|
|
1310
|
+
updateUserNotificationSettings_confirmOptimisticUpdate(settings, optimisticUpdateId) {
|
|
1311
|
+
batch2(() => {
|
|
1312
|
+
this.optimisticUpdates.remove(optimisticUpdateId);
|
|
1313
|
+
this.userNotificationSettings.update(settings);
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1253
1316
|
};
|
|
1254
1317
|
function applyOptimisticUpdates_forThreadifications(baseThreadsDB, notificationsLUT, optimisticUpdates) {
|
|
1255
1318
|
const threadsDB = baseThreadsDB.clone();
|
|
@@ -1424,6 +1487,33 @@ function applyOptimisticUpdates_forSettings(settingsLUT, optimisticUpdates) {
|
|
|
1424
1487
|
}
|
|
1425
1488
|
return settingsByRoomId;
|
|
1426
1489
|
}
|
|
1490
|
+
function applyOptimisticUpdates_forUserNotificationSettings(baseSettings, optimisticUpdates) {
|
|
1491
|
+
const outcomingSettings = { ...baseSettings };
|
|
1492
|
+
for (const optimisticUpdate of optimisticUpdates) {
|
|
1493
|
+
switch (optimisticUpdate.type) {
|
|
1494
|
+
case "update-user-notification-settings": {
|
|
1495
|
+
const incomingSettings = optimisticUpdate.settings;
|
|
1496
|
+
for (const channelKey of keys(incomingSettings)) {
|
|
1497
|
+
const key = channelKey;
|
|
1498
|
+
const channelUpdates = incomingSettings[key];
|
|
1499
|
+
if (channelUpdates) {
|
|
1500
|
+
const realChannelUpdates = Object.fromEntries(
|
|
1501
|
+
entries(channelUpdates).filter(
|
|
1502
|
+
([_, value]) => value !== void 0
|
|
1503
|
+
)
|
|
1504
|
+
);
|
|
1505
|
+
outcomingSettings[key] = {
|
|
1506
|
+
...outcomingSettings[key],
|
|
1507
|
+
...realChannelUpdates
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return outcomingSettings;
|
|
1516
|
+
}
|
|
1427
1517
|
function compareInboxNotifications(inboxNotificationA, inboxNotificationB) {
|
|
1428
1518
|
if (inboxNotificationA.notifiedAt > inboxNotificationB.notifiedAt) {
|
|
1429
1519
|
return 1;
|
|
@@ -1717,10 +1807,25 @@ function makeLiveblocksExtrasForClient(client) {
|
|
|
1717
1807
|
config.USER_THREADS_POLL_INTERVAL,
|
|
1718
1808
|
{ maxStaleTimeMs: config.USER_THREADS_MAX_STALE_TIME }
|
|
1719
1809
|
);
|
|
1810
|
+
const userNotificationSettingsPoller = makePoller(
|
|
1811
|
+
async (signal) => {
|
|
1812
|
+
try {
|
|
1813
|
+
return await store.refreshUserNotificationSettings(signal);
|
|
1814
|
+
} catch (err) {
|
|
1815
|
+
console.warn(
|
|
1816
|
+
`Polling new user notification settings failed: ${String(err)}`
|
|
1817
|
+
);
|
|
1818
|
+
throw err;
|
|
1819
|
+
}
|
|
1820
|
+
},
|
|
1821
|
+
config.USER_NOTIFICATION_SETTINGS_INTERVAL,
|
|
1822
|
+
{ maxStaleTimeMs: config.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME }
|
|
1823
|
+
);
|
|
1720
1824
|
return {
|
|
1721
1825
|
store,
|
|
1722
1826
|
notificationsPoller,
|
|
1723
|
-
userThreadsPoller
|
|
1827
|
+
userThreadsPoller,
|
|
1828
|
+
userNotificationSettingsPoller
|
|
1724
1829
|
};
|
|
1725
1830
|
}
|
|
1726
1831
|
function makeLiveblocksContextBundle(client) {
|
|
@@ -1729,6 +1834,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1729
1834
|
const useMarkAllInboxNotificationsAsRead2 = () => useMarkAllInboxNotificationsAsRead_withClient(client);
|
|
1730
1835
|
const useDeleteInboxNotification2 = () => useDeleteInboxNotification_withClient(client);
|
|
1731
1836
|
const useDeleteAllInboxNotifications2 = () => useDeleteAllInboxNotifications_withClient(client);
|
|
1837
|
+
const useUpdateNotificationSettings2 = () => useUpdateNotificationSettings_withClient(client);
|
|
1732
1838
|
function LiveblocksProvider2(props) {
|
|
1733
1839
|
useEnsureNoLiveblocksProvider();
|
|
1734
1840
|
return /* @__PURE__ */ jsx(ClientContext.Provider, { value: client, children: props.children });
|
|
@@ -1742,6 +1848,8 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1742
1848
|
useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
|
|
1743
1849
|
useDeleteInboxNotification: useDeleteInboxNotification2,
|
|
1744
1850
|
useDeleteAllInboxNotifications: useDeleteAllInboxNotifications2,
|
|
1851
|
+
useNotificationSettings: () => useNotificationSettings_withClient(client),
|
|
1852
|
+
useUpdateNotificationSettings: useUpdateNotificationSettings2,
|
|
1745
1853
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
1746
1854
|
useUserThreads_experimental,
|
|
1747
1855
|
...shared.classic,
|
|
@@ -1754,6 +1862,8 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1754
1862
|
useDeleteInboxNotification: useDeleteInboxNotification2,
|
|
1755
1863
|
useDeleteAllInboxNotifications: useDeleteAllInboxNotifications2,
|
|
1756
1864
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
1865
|
+
useNotificationSettings: () => useNotificationSettingsSuspense_withClient(client),
|
|
1866
|
+
useUpdateNotificationSettings: useUpdateNotificationSettings2,
|
|
1757
1867
|
useUserThreads_experimental: useUserThreadsSuspense_experimental,
|
|
1758
1868
|
...shared.suspense
|
|
1759
1869
|
}
|
|
@@ -1787,7 +1897,6 @@ function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
|
1787
1897
|
);
|
|
1788
1898
|
}
|
|
1789
1899
|
function useInboxNotificationsSuspense_withClient(client) {
|
|
1790
|
-
ensureNotServerSide();
|
|
1791
1900
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
1792
1901
|
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
1793
1902
|
const result = useInboxNotifications_withClient(client, identity2, shallow4);
|
|
@@ -1803,7 +1912,6 @@ function useUnreadInboxNotificationsCount_withClient(client) {
|
|
|
1803
1912
|
);
|
|
1804
1913
|
}
|
|
1805
1914
|
function useUnreadInboxNotificationsCountSuspense_withClient(client) {
|
|
1806
|
-
ensureNotServerSide();
|
|
1807
1915
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
1808
1916
|
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
1809
1917
|
const result = useUnreadInboxNotificationsCount_withClient(client);
|
|
@@ -1938,6 +2046,57 @@ function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
|
1938
2046
|
)
|
|
1939
2047
|
);
|
|
1940
2048
|
}
|
|
2049
|
+
function useUpdateNotificationSettings_withClient(client) {
|
|
2050
|
+
return useCallback2(
|
|
2051
|
+
(settings) => {
|
|
2052
|
+
const { store } = getLiveblocksExtrasForClient(client);
|
|
2053
|
+
const optimisticUpdateId = store.optimisticUpdates.add({
|
|
2054
|
+
type: "update-user-notification-settings",
|
|
2055
|
+
settings
|
|
2056
|
+
});
|
|
2057
|
+
client.updateNotificationSettings(settings).then(
|
|
2058
|
+
(settings2) => {
|
|
2059
|
+
store.updateUserNotificationSettings_confirmOptimisticUpdate(
|
|
2060
|
+
settings2,
|
|
2061
|
+
optimisticUpdateId
|
|
2062
|
+
);
|
|
2063
|
+
},
|
|
2064
|
+
() => {
|
|
2065
|
+
store.optimisticUpdates.remove(optimisticUpdateId);
|
|
2066
|
+
}
|
|
2067
|
+
);
|
|
2068
|
+
},
|
|
2069
|
+
[client]
|
|
2070
|
+
);
|
|
2071
|
+
}
|
|
2072
|
+
function useNotificationSettings_withClient(client) {
|
|
2073
|
+
const updateNotificationSettings = useUpdateNotificationSettings_withClient(client);
|
|
2074
|
+
const { store, userNotificationSettingsPoller: poller } = getLiveblocksExtrasForClient(client);
|
|
2075
|
+
useEffect3(() => {
|
|
2076
|
+
void store.outputs.userNotificationSettings.waitUntilLoaded();
|
|
2077
|
+
});
|
|
2078
|
+
useEffect3(() => {
|
|
2079
|
+
poller.inc();
|
|
2080
|
+
poller.pollNowIfStale();
|
|
2081
|
+
return () => {
|
|
2082
|
+
poller.dec();
|
|
2083
|
+
};
|
|
2084
|
+
}, [poller]);
|
|
2085
|
+
const settings = useSignal(store.outputs.userNotificationSettings.signal);
|
|
2086
|
+
return useMemo2(() => {
|
|
2087
|
+
return [settings, updateNotificationSettings];
|
|
2088
|
+
}, [settings, updateNotificationSettings]);
|
|
2089
|
+
}
|
|
2090
|
+
function useNotificationSettingsSuspense_withClient(client) {
|
|
2091
|
+
const store = getLiveblocksExtrasForClient(client).store;
|
|
2092
|
+
use(store.outputs.userNotificationSettings.waitUntilLoaded());
|
|
2093
|
+
const [settings, updateNotificationSettings] = useNotificationSettings_withClient(client);
|
|
2094
|
+
assert(!settings.error, "Did not expect error");
|
|
2095
|
+
assert(!settings.isLoading, "Did not expect loading");
|
|
2096
|
+
return useMemo2(() => {
|
|
2097
|
+
return [settings, updateNotificationSettings];
|
|
2098
|
+
}, [settings, updateNotificationSettings]);
|
|
2099
|
+
}
|
|
1941
2100
|
function useUser_withClient(client, userId) {
|
|
1942
2101
|
const usersStore = client[kInternal2].usersStore;
|
|
1943
2102
|
const getUserState = useCallback2(
|
|
@@ -2111,7 +2270,6 @@ function LiveblocksProvider(props) {
|
|
|
2111
2270
|
lostConnectionTimeout: useInitial(o.lostConnectionTimeout),
|
|
2112
2271
|
backgroundKeepAliveTimeout: useInitial(o.backgroundKeepAliveTimeout),
|
|
2113
2272
|
polyfills: useInitial(o.polyfills),
|
|
2114
|
-
largeMessageStrategy: useInitial(o.largeMessageStrategy),
|
|
2115
2273
|
unstable_fallbackToHTTP: useInitial(o.unstable_fallbackToHTTP),
|
|
2116
2274
|
unstable_streamData: useInitial(o.unstable_streamData),
|
|
2117
2275
|
preventUnsavedChanges: useInitial(o.preventUnsavedChanges),
|
|
@@ -2163,7 +2321,6 @@ function useUserThreads_experimental(options = {}) {
|
|
|
2163
2321
|
);
|
|
2164
2322
|
}
|
|
2165
2323
|
function useUserThreadsSuspense_experimental(options = {}) {
|
|
2166
|
-
ensureNotServerSide();
|
|
2167
2324
|
const client = useClient();
|
|
2168
2325
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
2169
2326
|
const queryKey = makeUserThreadsQueryKey(options.query);
|
|
@@ -2203,6 +2360,15 @@ function useUnreadInboxNotificationsCount() {
|
|
|
2203
2360
|
function useUnreadInboxNotificationsCountSuspense() {
|
|
2204
2361
|
return useUnreadInboxNotificationsCountSuspense_withClient(useClient());
|
|
2205
2362
|
}
|
|
2363
|
+
function useNotificationSettings() {
|
|
2364
|
+
return useNotificationSettings_withClient(useClient());
|
|
2365
|
+
}
|
|
2366
|
+
function useNotificationSettingsSuspense() {
|
|
2367
|
+
return useNotificationSettingsSuspense_withClient(useClient());
|
|
2368
|
+
}
|
|
2369
|
+
function useUpdateNotificationSettings() {
|
|
2370
|
+
return useUpdateNotificationSettings_withClient(useClient());
|
|
2371
|
+
}
|
|
2206
2372
|
function useUser(userId) {
|
|
2207
2373
|
const client = useClient();
|
|
2208
2374
|
return useUser_withClient(client, userId);
|
|
@@ -3558,7 +3724,6 @@ function useRoomNotificationSettings() {
|
|
|
3558
3724
|
}, [settings, updateRoomNotificationSettings]);
|
|
3559
3725
|
}
|
|
3560
3726
|
function useRoomNotificationSettingsSuspense() {
|
|
3561
|
-
ensureNotServerSide();
|
|
3562
3727
|
const client = useClient();
|
|
3563
3728
|
const store = getRoomExtrasForClient(client).store;
|
|
3564
3729
|
const room = useRoom();
|
|
@@ -3623,7 +3788,6 @@ function useHistoryVersions() {
|
|
|
3623
3788
|
return useSignal(store.outputs.versionsByRoomId.getOrCreate(room.id).signal);
|
|
3624
3789
|
}
|
|
3625
3790
|
function useHistoryVersionsSuspense() {
|
|
3626
|
-
ensureNotServerSide();
|
|
3627
3791
|
const client = useClient();
|
|
3628
3792
|
const room = useRoom();
|
|
3629
3793
|
const store = getRoomExtrasForClient(client).store;
|
|
@@ -3658,6 +3822,13 @@ function useUpdateRoomNotificationSettings() {
|
|
|
3658
3822
|
[client, room]
|
|
3659
3823
|
);
|
|
3660
3824
|
}
|
|
3825
|
+
function ensureNotServerSide() {
|
|
3826
|
+
if (typeof window === "undefined") {
|
|
3827
|
+
throw new Error(
|
|
3828
|
+
"You cannot use the Suspense version of this hook on the server side. Make sure to only call them on the client side.\nFor tips, see https://liveblocks.io/docs/api-reference/liveblocks-react#suspense-avoid-ssr"
|
|
3829
|
+
);
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3661
3832
|
function useSuspendUntilPresenceReady() {
|
|
3662
3833
|
ensureNotServerSide();
|
|
3663
3834
|
const room = useRoom();
|
|
@@ -3706,7 +3877,6 @@ function useStorageStatusSuspense(options) {
|
|
|
3706
3877
|
return useStorageStatus(options);
|
|
3707
3878
|
}
|
|
3708
3879
|
function useThreadsSuspense(options = {}) {
|
|
3709
|
-
ensureNotServerSide();
|
|
3710
3880
|
const client = useClient();
|
|
3711
3881
|
const room = useRoom();
|
|
3712
3882
|
const { store } = getRoomExtrasForClient(client);
|
|
@@ -3850,6 +4020,9 @@ export {
|
|
|
3850
4020
|
useDeleteInboxNotification,
|
|
3851
4021
|
useUnreadInboxNotificationsCount,
|
|
3852
4022
|
useUnreadInboxNotificationsCountSuspense,
|
|
4023
|
+
useNotificationSettings,
|
|
4024
|
+
useNotificationSettingsSuspense,
|
|
4025
|
+
useUpdateNotificationSettings,
|
|
3853
4026
|
useRoomInfo,
|
|
3854
4027
|
useRoomInfoSuspense,
|
|
3855
4028
|
_useInboxNotificationThread,
|
|
@@ -3934,4 +4107,4 @@ export {
|
|
|
3934
4107
|
_useStorageRoot,
|
|
3935
4108
|
_useUpdateMyPresence
|
|
3936
4109
|
};
|
|
3937
|
-
//# sourceMappingURL=chunk-
|
|
4110
|
+
//# sourceMappingURL=chunk-LOPNJCSB.mjs.map
|