@liveblocks/react 3.8.0-next1 → 3.8.0-next3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/_private.cjs CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
 
27
27
 
28
- var _chunk45BFK66Kcjs = require('./chunk-45BFK66K.cjs');
28
+ var _chunkOYVPE6CVcjs = require('./chunk-OYVPE6CV.cjs');
29
29
 
30
30
  // src/lib/use-layout-effect.ts
31
31
  var _react = require('react');
@@ -50,7 +50,7 @@ function selectorFor_useGroup(state) {
50
50
  };
51
51
  }
52
52
  function useGroup(groupId) {
53
- const client = _chunk45BFK66Kcjs.useClient.call(void 0, );
53
+ const client = _chunkOYVPE6CVcjs.useClient.call(void 0, );
54
54
  const store = client[_core.kInternal].httpClient.groupsStore;
55
55
  const getGroupState = _react.useCallback.call(void 0,
56
56
  () => store.getItemState(groupId),
@@ -59,7 +59,7 @@ function useGroup(groupId) {
59
59
  _react.useEffect.call(void 0, () => {
60
60
  void store.enqueue(groupId);
61
61
  }, [store, groupId]);
62
- return _chunk45BFK66Kcjs.useSyncExternalStoreWithSelector.call(void 0,
62
+ return _chunkOYVPE6CVcjs.useSyncExternalStoreWithSelector.call(void 0,
63
63
  store.subscribe,
64
64
  getGroupState,
65
65
  getGroupState,
@@ -80,8 +80,8 @@ function normalizeMentionSuggestions(suggestions) {
80
80
  function useMentionSuggestions(roomId, search) {
81
81
  const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
82
82
  const lastInvokedAt = _react.useRef.call(void 0, );
83
- const resolveMentionSuggestions = _chunk45BFK66Kcjs.useResolveMentionSuggestions.call(void 0, );
84
- const mentionSuggestionsCache = _chunk45BFK66Kcjs.useMentionSuggestionsCache.call(void 0, );
83
+ const resolveMentionSuggestions = _chunkOYVPE6CVcjs.useResolveMentionSuggestions.call(void 0, );
84
+ const mentionSuggestionsCache = _chunkOYVPE6CVcjs.useMentionSuggestionsCache.call(void 0, );
85
85
  _react.useEffect.call(void 0, () => {
86
86
  if (search === void 0 || !resolveMentionSuggestions) {
87
87
  return;
@@ -136,7 +136,7 @@ function useMentionSuggestions(roomId, search) {
136
136
 
137
137
 
138
138
  function useSyncSource() {
139
- const client = _chunk45BFK66Kcjs.useClient.call(void 0, );
139
+ const client = _chunkOYVPE6CVcjs.useClient.call(void 0, );
140
140
  const createSyncSource = client[_core.kInternal].createSyncSource;
141
141
  const [syncSource, setSyncSource] = _react.useState.call(void 0, );
142
142
  _react.useEffect.call(void 0, () => {
@@ -176,5 +176,5 @@ function useSyncSource() {
176
176
 
177
177
 
178
178
 
179
- exports.getUmbrellaStoreForClient = _chunk45BFK66Kcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunk45BFK66Kcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunk45BFK66Kcjs.useClientOrNull; exports.useCreateRoomComment = _chunk45BFK66Kcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunk45BFK66Kcjs.useCreateRoomThread; exports.useCreateTextMention = _chunk45BFK66Kcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunk45BFK66Kcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunk45BFK66Kcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunk45BFK66Kcjs.useDeleteTextMention; exports.useEditRoomComment = _chunk45BFK66Kcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunk45BFK66Kcjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useLatest = _chunk45BFK66Kcjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunk45BFK66Kcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunk45BFK66Kcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunk45BFK66Kcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunk45BFK66Kcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunk45BFK66Kcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunk45BFK66Kcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunk45BFK66Kcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunk45BFK66Kcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunk45BFK66Kcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunk45BFK66Kcjs.useRoomThreadSubscription; exports.useSignal = _chunk45BFK66Kcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunk45BFK66Kcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunk45BFK66Kcjs.useYjsProvider;
179
+ exports.getUmbrellaStoreForClient = _chunkOYVPE6CVcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkOYVPE6CVcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkOYVPE6CVcjs.useClientOrNull; exports.useCreateRoomComment = _chunkOYVPE6CVcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkOYVPE6CVcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkOYVPE6CVcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkOYVPE6CVcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkOYVPE6CVcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkOYVPE6CVcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkOYVPE6CVcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkOYVPE6CVcjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useLatest = _chunkOYVPE6CVcjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkOYVPE6CVcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkOYVPE6CVcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkOYVPE6CVcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkOYVPE6CVcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkOYVPE6CVcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkOYVPE6CVcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkOYVPE6CVcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkOYVPE6CVcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkOYVPE6CVcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkOYVPE6CVcjs.useRoomThreadSubscription; exports.useSignal = _chunkOYVPE6CVcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkOYVPE6CVcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkOYVPE6CVcjs.useYjsProvider;
180
180
  //# sourceMappingURL=_private.cjs.map
@@ -1,5 +1,5 @@
1
- import { G as GroupAsyncResult } from './room-DSJuooXd.cjs';
2
- export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-DSJuooXd.cjs';
1
+ import { G as GroupAsyncResult } from './room-C97RX2dB.cjs';
2
+ export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-C97RX2dB.cjs';
3
3
  import { MutableRefObject, useEffect } from 'react';
4
4
  import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
5
5
  import '@liveblocks/client';
@@ -1,5 +1,5 @@
1
- import { G as GroupAsyncResult } from './room-DSJuooXd.js';
2
- export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-DSJuooXd.js';
1
+ import { G as GroupAsyncResult } from './room-C97RX2dB.js';
2
+ export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-C97RX2dB.js';
3
3
  import { MutableRefObject, useEffect } from 'react';
4
4
  import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
5
5
  import '@liveblocks/client';
package/dist/_private.js CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  useSignal,
26
26
  useSyncExternalStoreWithSelector,
27
27
  useYjsProvider
28
- } from "./chunk-GXPZZIB2.js";
28
+ } from "./chunk-DL5PAL6E.js";
29
29
 
30
30
  // src/lib/use-layout-effect.ts
31
31
  import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "3.8.0-next1";
3
+ var PKG_VERSION = "3.8.0-next3";
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-TMNECRRU.js.map
23
+ //# sourceMappingURL=chunk-2A5VCDEZ.js.map
@@ -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 = "3.8.0-next1";
3
+ var PKG_VERSION = "3.8.0-next3";
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-X3KI55GF.cjs.map
23
+ //# sourceMappingURL=chunk-4ZS65AZV.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-X3KI55GF.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,aAAA;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-X3KI55GF.cjs","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
+ {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-4ZS65AZV.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,aAAA;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-4ZS65AZV.cjs","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"]}
@@ -172,6 +172,7 @@ import {
172
172
  assert,
173
173
  console as console2,
174
174
  createClient,
175
+ DefaultMap as DefaultMap2,
175
176
  HttpError,
176
177
  kInternal as kInternal3,
177
178
  makePoller,
@@ -216,21 +217,6 @@ function ASYNC_OK(fieldOrData, data) {
216
217
  }
217
218
  }
218
219
 
219
- // src/lib/itertools.ts
220
- function find(it, predicate) {
221
- for (const item of it) {
222
- if (predicate(item)) return item;
223
- }
224
- return void 0;
225
- }
226
- function count(it, predicate) {
227
- let total = 0;
228
- for (const item of it) {
229
- if (predicate(item)) total++;
230
- }
231
- return total;
232
- }
233
-
234
220
  // src/lib/ssr.ts
235
221
  function ensureNotServerSide() {
236
222
  if (typeof window === "undefined") {
@@ -324,6 +310,14 @@ function autobind(self) {
324
310
  } while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
325
311
  }
326
312
 
313
+ // src/lib/itertools.ts
314
+ function find(it, predicate) {
315
+ for (const item of it) {
316
+ if (predicate(item)) return item;
317
+ }
318
+ return void 0;
319
+ }
320
+
327
321
  // src/lib/querying.ts
328
322
  import { isStartsWithOperator } from "@liveblocks/core";
329
323
  function makeThreadsFilter(query) {
@@ -722,6 +716,21 @@ function createStore_forNotifications() {
722
716
  upsert
723
717
  };
724
718
  }
719
+ function createStore_forUnreadNotificationsCount() {
720
+ const baseSignal = new MutableSignal3(
721
+ /* @__PURE__ */ new Map()
722
+ );
723
+ function update(queryKey, count) {
724
+ baseSignal.mutate((lut) => {
725
+ lut.set(queryKey, count);
726
+ });
727
+ }
728
+ return {
729
+ signal: DerivedSignal.from(baseSignal, (c) => Object.fromEntries(c)),
730
+ // Mutations
731
+ update
732
+ };
733
+ }
725
734
  function createStore_forSubscriptions(updates, threads) {
726
735
  const baseSignal = new MutableSignal3(/* @__PURE__ */ new Map());
727
736
  function applyDelta(newSubscriptions, deletedSubscriptions) {
@@ -911,6 +920,7 @@ var UmbrellaStore = class {
911
920
  roomSubscriptionSettings;
912
921
  // prettier-ignore
913
922
  historyVersions;
923
+ unreadNotificationsCount;
914
924
  permissionHints;
915
925
  notificationSettings;
916
926
  optimisticUpdates;
@@ -958,6 +968,7 @@ var UmbrellaStore = class {
958
968
  this.optimisticUpdates.signal
959
969
  );
960
970
  this.historyVersions = createStore_forHistoryVersions();
971
+ this.unreadNotificationsCount = createStore_forUnreadNotificationsCount();
961
972
  const threadifications = DerivedSignal.from(
962
973
  this.threads.signal,
963
974
  this.notifications.signal,
@@ -1114,6 +1125,35 @@ var UmbrellaStore = class {
1114
1125
  };
1115
1126
  }
1116
1127
  );
1128
+ const unreadNotificationsCount = new DefaultMap(
1129
+ (queryKey) => {
1130
+ const query = JSON.parse(queryKey);
1131
+ const resource = new SinglePageResource(async () => {
1132
+ const result = await this.#client.getUnreadInboxNotificationsCount({
1133
+ query
1134
+ });
1135
+ this.unreadNotificationsCount.update(queryKey, result);
1136
+ });
1137
+ const signal = DerivedSignal.from(
1138
+ () => {
1139
+ const result = resource.get();
1140
+ if (result.isLoading || result.error) {
1141
+ return result;
1142
+ } else {
1143
+ return ASYNC_OK(
1144
+ "count",
1145
+ nn(this.unreadNotificationsCount.signal.get()[queryKey])
1146
+ );
1147
+ }
1148
+ },
1149
+ shallow
1150
+ );
1151
+ return {
1152
+ signal,
1153
+ waitUntilLoaded: resource.waitUntilLoaded
1154
+ };
1155
+ }
1156
+ );
1117
1157
  const roomSubscriptionSettingsByRoomId = new DefaultMap(
1118
1158
  (roomId) => {
1119
1159
  const resource = new SinglePageResource(async () => {
@@ -1262,6 +1302,7 @@ var UmbrellaStore = class {
1262
1302
  loadingUserThreads,
1263
1303
  notifications,
1264
1304
  loadingNotifications,
1305
+ unreadNotificationsCount,
1265
1306
  roomSubscriptionSettingsByRoomId,
1266
1307
  versionsByRoomId,
1267
1308
  notificationSettings,
@@ -1469,6 +1510,14 @@ var UmbrellaStore = class {
1469
1510
  result.subscriptions.deleted
1470
1511
  );
1471
1512
  }
1513
+ async fetchUnreadNotificationsCount(queryKey, signal) {
1514
+ const query = JSON.parse(queryKey);
1515
+ const result = await this.#client.getUnreadInboxNotificationsCount({
1516
+ query,
1517
+ signal
1518
+ });
1519
+ this.unreadNotificationsCount.update(queryKey, result);
1520
+ }
1472
1521
  async fetchRoomThreadsDeltaUpdate(roomId, signal) {
1473
1522
  const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
1474
1523
  if (lastRequestedAt === void 0) {
@@ -1983,16 +2032,10 @@ var _umbrellaStores = /* @__PURE__ */ new WeakMap();
1983
2032
  var _extras = /* @__PURE__ */ new WeakMap();
1984
2033
  var _bundles = /* @__PURE__ */ new WeakMap();
1985
2034
  function selectorFor_useUnreadInboxNotificationsCount(result) {
1986
- if (!result.inboxNotifications) {
2035
+ if (!("count" in result) || result.count === void 0) {
1987
2036
  return result;
1988
2037
  }
1989
- return ASYNC_OK(
1990
- "count",
1991
- count(
1992
- result.inboxNotifications,
1993
- (n) => n.readAt === null || n.readAt < n.notifiedAt
1994
- )
1995
- );
2038
+ return ASYNC_OK("count", result.count);
1996
2039
  }
1997
2040
  function selectorFor_useUser(state, userId) {
1998
2041
  if (state === void 0 || state?.isLoading) {
@@ -2091,6 +2134,22 @@ function makeLiveblocksExtrasForClient(client) {
2091
2134
  config.NOTIFICATIONS_POLL_INTERVAL,
2092
2135
  { maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
2093
2136
  );
2137
+ const unreadNotificationsCountPollersByQueryKey = new DefaultMap2(
2138
+ (queryKey) => makePoller(
2139
+ async (signal) => {
2140
+ try {
2141
+ return await store.fetchUnreadNotificationsCount(queryKey, signal);
2142
+ } catch (err) {
2143
+ console2.warn(
2144
+ `Polling unread inbox notifications countfailed: ${String(err)}`
2145
+ );
2146
+ throw err;
2147
+ }
2148
+ },
2149
+ config.NOTIFICATIONS_POLL_INTERVAL,
2150
+ { maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
2151
+ )
2152
+ );
2094
2153
  const userThreadsPoller = makePoller(
2095
2154
  async (signal) => {
2096
2155
  try {
@@ -2121,7 +2180,8 @@ function makeLiveblocksExtrasForClient(client) {
2121
2180
  store,
2122
2181
  notificationsPoller,
2123
2182
  userThreadsPoller,
2124
- notificationSettingsPoller
2183
+ notificationSettingsPoller,
2184
+ unreadNotificationsCountPollersByQueryKey
2125
2185
  };
2126
2186
  }
2127
2187
  function makeLiveblocksContextBundle(client) {
@@ -2225,11 +2285,31 @@ function useInboxNotificationsSuspense_withClient(client, options) {
2225
2285
  return result;
2226
2286
  }
2227
2287
  function useUnreadInboxNotificationsCount_withClient(client, options) {
2228
- return useInboxNotifications_withClient(
2229
- client,
2288
+ const { store, unreadNotificationsCountPollersByQueryKey: pollers } = getLiveblocksExtrasForClient(client);
2289
+ const queryKey = makeInboxNotificationsQueryKey(options?.query);
2290
+ const poller = pollers.getOrCreate(queryKey);
2291
+ useEffect4(
2292
+ () => void store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
2293
+ // NOTE: Deliberately *not* using a dependency array here!
2294
+ //
2295
+ // It is important to call waitUntil on *every* render.
2296
+ // This is harmless though, on most renders, except:
2297
+ // 1. The very first render, in which case we'll want to trigger the initial page fetch.
2298
+ // 2. All other subsequent renders now "just" return the same promise (a quick operation).
2299
+ // 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
2300
+ // *next* render after that, a *new* fetch/promise will get created.
2301
+ );
2302
+ useEffect4(() => {
2303
+ poller.inc();
2304
+ poller.pollNowIfStale();
2305
+ return () => {
2306
+ poller.dec();
2307
+ };
2308
+ }, [poller]);
2309
+ return useSignal(
2310
+ store.outputs.unreadNotificationsCount.getOrCreate(queryKey).signal,
2230
2311
  selectorFor_useUnreadInboxNotificationsCount,
2231
- shallow3,
2232
- options
2312
+ shallow3
2233
2313
  );
2234
2314
  }
2235
2315
  function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
@@ -2237,7 +2317,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2237
2317
  const store = getLiveblocksExtrasForClient(client).store;
2238
2318
  const queryKey = makeInboxNotificationsQueryKey(options?.query);
2239
2319
  use(
2240
- store.outputs.loadingNotifications.getOrCreate(queryKey).waitUntilLoaded()
2320
+ store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
2241
2321
  );
2242
2322
  const result = useUnreadInboxNotificationsCount_withClient(client, options);
2243
2323
  assert(!result.isLoading, "Did not expect loading");
@@ -2247,7 +2327,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2247
2327
  function useMarkInboxNotificationAsRead_withClient(client) {
2248
2328
  return useCallback2(
2249
2329
  (inboxNotificationId) => {
2250
- const { store } = getLiveblocksExtrasForClient(client);
2330
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2251
2331
  const readAt = /* @__PURE__ */ new Date();
2252
2332
  const optimisticId = store.optimisticUpdates.add({
2253
2333
  type: "mark-inbox-notification-as-read",
@@ -2261,6 +2341,10 @@ function useMarkInboxNotificationAsRead_withClient(client) {
2261
2341
  readAt,
2262
2342
  optimisticId
2263
2343
  );
2344
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2345
+ poller.markAsStale();
2346
+ poller.pollNowIfStale();
2347
+ }
2264
2348
  },
2265
2349
  (err) => {
2266
2350
  store.optimisticUpdates.remove(optimisticId);
@@ -2279,7 +2363,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
2279
2363
  }
2280
2364
  function useMarkAllInboxNotificationsAsRead_withClient(client) {
2281
2365
  return useCallback2(() => {
2282
- const { store } = getLiveblocksExtrasForClient(client);
2366
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2283
2367
  const readAt = /* @__PURE__ */ new Date();
2284
2368
  const optimisticId = store.optimisticUpdates.add({
2285
2369
  type: "mark-all-inbox-notifications-as-read",
@@ -2288,6 +2372,10 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
2288
2372
  client.markAllInboxNotificationsAsRead().then(
2289
2373
  () => {
2290
2374
  store.markAllInboxNotificationsRead(optimisticId, readAt);
2375
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2376
+ poller.markAsStale();
2377
+ poller.pollNowIfStale();
2378
+ }
2291
2379
  },
2292
2380
  (err) => {
2293
2381
  store.optimisticUpdates.remove(optimisticId);
@@ -2303,7 +2391,7 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
2303
2391
  function useDeleteInboxNotification_withClient(client) {
2304
2392
  return useCallback2(
2305
2393
  (inboxNotificationId) => {
2306
- const { store } = getLiveblocksExtrasForClient(client);
2394
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2307
2395
  const deletedAt = /* @__PURE__ */ new Date();
2308
2396
  const optimisticId = store.optimisticUpdates.add({
2309
2397
  type: "delete-inbox-notification",
@@ -2313,6 +2401,10 @@ function useDeleteInboxNotification_withClient(client) {
2313
2401
  client.deleteInboxNotification(inboxNotificationId).then(
2314
2402
  () => {
2315
2403
  store.deleteInboxNotification(inboxNotificationId, optimisticId);
2404
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2405
+ poller.markAsStale();
2406
+ poller.pollNowIfStale();
2407
+ }
2316
2408
  },
2317
2409
  (err) => {
2318
2410
  store.optimisticUpdates.remove(optimisticId);
@@ -2328,7 +2420,7 @@ function useDeleteInboxNotification_withClient(client) {
2328
2420
  }
2329
2421
  function useDeleteAllInboxNotifications_withClient(client) {
2330
2422
  return useCallback2(() => {
2331
- const { store } = getLiveblocksExtrasForClient(client);
2423
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2332
2424
  const deletedAt = /* @__PURE__ */ new Date();
2333
2425
  const optimisticId = store.optimisticUpdates.add({
2334
2426
  type: "delete-all-inbox-notifications",
@@ -2337,6 +2429,10 @@ function useDeleteAllInboxNotifications_withClient(client) {
2337
2429
  client.deleteAllInboxNotifications().then(
2338
2430
  () => {
2339
2431
  store.deleteAllInboxNotifications(optimisticId);
2432
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2433
+ poller.markAsStale();
2434
+ poller.pollNowIfStale();
2435
+ }
2340
2436
  },
2341
2437
  (err) => {
2342
2438
  store.optimisticUpdates.remove(optimisticId);
@@ -3103,7 +3199,7 @@ import {
3103
3199
  console as console3,
3104
3200
  createCommentId,
3105
3201
  createThreadId,
3106
- DefaultMap as DefaultMap2,
3202
+ DefaultMap as DefaultMap3,
3107
3203
  errorIf,
3108
3204
  getSubscriptionKey as getSubscriptionKey2,
3109
3205
  HttpError as HttpError2,
@@ -3237,7 +3333,7 @@ function makeRoomExtrasForClient(client) {
3237
3333
  throw innerError;
3238
3334
  }
3239
3335
  }
3240
- const threadsPollersByRoomId = new DefaultMap2(
3336
+ const threadsPollersByRoomId = new DefaultMap3(
3241
3337
  (roomId) => makePoller2(
3242
3338
  async (signal) => {
3243
3339
  try {
@@ -3251,7 +3347,7 @@ function makeRoomExtrasForClient(client) {
3251
3347
  { maxStaleTimeMs: config.ROOM_THREADS_MAX_STALE_TIME }
3252
3348
  )
3253
3349
  );
3254
- const versionsPollersByRoomId = new DefaultMap2(
3350
+ const versionsPollersByRoomId = new DefaultMap3(
3255
3351
  (roomId) => makePoller2(
3256
3352
  async (signal) => {
3257
3353
  try {
@@ -3265,7 +3361,7 @@ function makeRoomExtrasForClient(client) {
3265
3361
  { maxStaleTimeMs: config.HISTORY_VERSIONS_MAX_STALE_TIME }
3266
3362
  )
3267
3363
  );
3268
- const roomSubscriptionSettingsPollersByRoomId = new DefaultMap2(
3364
+ const roomSubscriptionSettingsPollersByRoomId = new DefaultMap3(
3269
3365
  (roomId) => makePoller2(
3270
3366
  async (signal) => {
3271
3367
  try {
@@ -4838,4 +4934,4 @@ export {
4838
4934
  _useStorageRoot,
4839
4935
  _useUpdateMyPresence
4840
4936
  };
4841
- //# sourceMappingURL=chunk-GXPZZIB2.js.map
4937
+ //# sourceMappingURL=chunk-DL5PAL6E.js.map