@natoe/colab 0.1.34 → 0.1.36
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/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -659,6 +659,15 @@ interface CollabContextValue {
|
|
|
659
659
|
config: CollabConfig;
|
|
660
660
|
apiBaseUrl: string;
|
|
661
661
|
totalUnread: number;
|
|
662
|
+
/**
|
|
663
|
+
* Increments on EVERY `unread_update` push from the user-notifications
|
|
664
|
+
* channel, whether or not the totals changed. `totalUnread` alone cannot
|
|
665
|
+
* signal "something happened": your own sent message never counts toward
|
|
666
|
+
* your unread total, so after you send, the counts arrive unchanged and a
|
|
667
|
+
* value-keyed effect never fires. Consumers that resync on activity (the
|
|
668
|
+
* inbox's last-message previews) should depend on this instead.
|
|
669
|
+
*/
|
|
670
|
+
unreadUpdateSeq: number;
|
|
662
671
|
/**
|
|
663
672
|
* Per-conversation unread counts, keyed by conversation ID. Updated
|
|
664
673
|
* live via the user_notifications channel's unread_update push, so
|
package/dist/index.d.ts
CHANGED
|
@@ -659,6 +659,15 @@ interface CollabContextValue {
|
|
|
659
659
|
config: CollabConfig;
|
|
660
660
|
apiBaseUrl: string;
|
|
661
661
|
totalUnread: number;
|
|
662
|
+
/**
|
|
663
|
+
* Increments on EVERY `unread_update` push from the user-notifications
|
|
664
|
+
* channel, whether or not the totals changed. `totalUnread` alone cannot
|
|
665
|
+
* signal "something happened": your own sent message never counts toward
|
|
666
|
+
* your unread total, so after you send, the counts arrive unchanged and a
|
|
667
|
+
* value-keyed effect never fires. Consumers that resync on activity (the
|
|
668
|
+
* inbox's last-message previews) should depend on this instead.
|
|
669
|
+
*/
|
|
670
|
+
unreadUpdateSeq: number;
|
|
662
671
|
/**
|
|
663
672
|
* Per-conversation unread counts, keyed by conversation ID. Updated
|
|
664
673
|
* live via the user_notifications channel's unread_update push, so
|
package/dist/index.js
CHANGED
|
@@ -607,6 +607,7 @@ function CollabProvider({ config, apiBaseUrl, children }) {
|
|
|
607
607
|
});
|
|
608
608
|
const [unreadCounts, setUnreadCounts] = React4.useState({});
|
|
609
609
|
const [unreadCountsByOrder, setUnreadCountsByOrder] = React4.useState({});
|
|
610
|
+
const [unreadUpdateSeq, setUnreadUpdateSeq] = React4.useState(0);
|
|
610
611
|
const pendingKeys = React4.useRef(/* @__PURE__ */ new Set());
|
|
611
612
|
const pendingResolvers = React4.useRef(/* @__PURE__ */ new Map());
|
|
612
613
|
const previewCache = React4.useRef(/* @__PURE__ */ new Map());
|
|
@@ -625,6 +626,7 @@ function CollabProvider({ config, apiBaseUrl, children }) {
|
|
|
625
626
|
setUnreadCounts(counts.conversation);
|
|
626
627
|
setUnreadCountsByOrder(counts.order);
|
|
627
628
|
previewCache.current.clear();
|
|
629
|
+
setUnreadUpdateSeq((n) => n + 1);
|
|
628
630
|
});
|
|
629
631
|
if (!s.isConnected()) {
|
|
630
632
|
s.connect(config);
|
|
@@ -858,6 +860,7 @@ function CollabProvider({ config, apiBaseUrl, children }) {
|
|
|
858
860
|
config,
|
|
859
861
|
apiBaseUrl,
|
|
860
862
|
totalUnread,
|
|
863
|
+
unreadUpdateSeq,
|
|
861
864
|
unreadCounts,
|
|
862
865
|
unreadCountsByOrder,
|
|
863
866
|
requestPreview,
|
|
@@ -5876,7 +5879,7 @@ var styles14 = {
|
|
|
5876
5879
|
}};
|
|
5877
5880
|
function useConversationList(options) {
|
|
5878
5881
|
const enabled = options?.enabled ?? true;
|
|
5879
|
-
const { fetchConversationList, config,
|
|
5882
|
+
const { fetchConversationList, config, unreadUpdateSeq } = useCollab();
|
|
5880
5883
|
const [conversations, setConversations] = React4.useState([]);
|
|
5881
5884
|
const [isLoading, setIsLoading] = React4.useState(enabled);
|
|
5882
5885
|
const [error, setError] = React4.useState(null);
|
|
@@ -5914,15 +5917,16 @@ function useConversationList(options) {
|
|
|
5914
5917
|
if (!enabled) return;
|
|
5915
5918
|
refresh();
|
|
5916
5919
|
}, [enabled, refresh]);
|
|
5917
|
-
const
|
|
5920
|
+
const hasHandledInitialSeqRef = React4.useRef(false);
|
|
5918
5921
|
React4.useEffect(() => {
|
|
5919
5922
|
if (!enabled) return;
|
|
5920
|
-
if (!
|
|
5921
|
-
|
|
5923
|
+
if (!hasHandledInitialSeqRef.current) {
|
|
5924
|
+
hasHandledInitialSeqRef.current = true;
|
|
5922
5925
|
return;
|
|
5923
5926
|
}
|
|
5924
|
-
silentRefresh
|
|
5925
|
-
|
|
5927
|
+
const t = setTimeout(silentRefresh, 250);
|
|
5928
|
+
return () => clearTimeout(t);
|
|
5929
|
+
}, [unreadUpdateSeq, enabled]);
|
|
5926
5930
|
const filter = React4.useCallback(
|
|
5927
5931
|
(query) => {
|
|
5928
5932
|
const q = query.trim().toLowerCase();
|