@dubsdotapp/expo 0.5.26 → 0.5.28
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.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/provider.tsx +18 -3
package/dist/index.js
CHANGED
|
@@ -8808,7 +8808,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8808
8808
|
const refreshMessages = (0, import_react49.useCallback)(async () => {
|
|
8809
8809
|
try {
|
|
8810
8810
|
const res = await client.getChatMessages({ limit: 30 });
|
|
8811
|
-
setMessages(res.messages);
|
|
8811
|
+
setMessages([...res.messages].reverse());
|
|
8812
8812
|
} catch (err) {
|
|
8813
8813
|
console.error("[Dubs:ChatProvider] Failed to load messages:", err);
|
|
8814
8814
|
}
|
|
@@ -8857,7 +8857,21 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8857
8857
|
const baseUrl = client.baseUrl;
|
|
8858
8858
|
const host = new URL(baseUrl).origin;
|
|
8859
8859
|
chatSocket.setListeners({
|
|
8860
|
-
|
|
8860
|
+
// Refetch the message list whenever the socket reaches 'connected'.
|
|
8861
|
+
// Covers both the initial connect AND every reconnect (app resumed
|
|
8862
|
+
// from background, transient network blip, server restart). Without
|
|
8863
|
+
// this, the provider's `messages` state is frozen at whatever it was
|
|
8864
|
+
// when the app last connected — Socket.IO's auto-reconnect resumes
|
|
8865
|
+
// delivery of *new* events but does not replay the gap.
|
|
8866
|
+
onConnectionChange: (next) => {
|
|
8867
|
+
setStatus(next);
|
|
8868
|
+
if (next === "connected") {
|
|
8869
|
+
refreshMessages().catch(() => {
|
|
8870
|
+
});
|
|
8871
|
+
refreshConversations().catch(() => {
|
|
8872
|
+
});
|
|
8873
|
+
}
|
|
8874
|
+
},
|
|
8861
8875
|
// Global chat
|
|
8862
8876
|
onNewMessage: (msg) => {
|
|
8863
8877
|
setMessages((prev) => {
|