@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.mjs CHANGED
@@ -8835,7 +8835,7 @@ function ChatProvider({ children, autoConnect = true }) {
8835
8835
  const refreshMessages = useCallback35(async () => {
8836
8836
  try {
8837
8837
  const res = await client.getChatMessages({ limit: 30 });
8838
- setMessages(res.messages);
8838
+ setMessages([...res.messages].reverse());
8839
8839
  } catch (err) {
8840
8840
  console.error("[Dubs:ChatProvider] Failed to load messages:", err);
8841
8841
  }
@@ -8884,7 +8884,21 @@ function ChatProvider({ children, autoConnect = true }) {
8884
8884
  const baseUrl = client.baseUrl;
8885
8885
  const host = new URL(baseUrl).origin;
8886
8886
  chatSocket.setListeners({
8887
- onConnectionChange: setStatus,
8887
+ // Refetch the message list whenever the socket reaches 'connected'.
8888
+ // Covers both the initial connect AND every reconnect (app resumed
8889
+ // from background, transient network blip, server restart). Without
8890
+ // this, the provider's `messages` state is frozen at whatever it was
8891
+ // when the app last connected — Socket.IO's auto-reconnect resumes
8892
+ // delivery of *new* events but does not replay the gap.
8893
+ onConnectionChange: (next) => {
8894
+ setStatus(next);
8895
+ if (next === "connected") {
8896
+ refreshMessages().catch(() => {
8897
+ });
8898
+ refreshConversations().catch(() => {
8899
+ });
8900
+ }
8901
+ },
8888
8902
  // Global chat
8889
8903
  onNewMessage: (msg) => {
8890
8904
  setMessages((prev) => {