@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.5.26",
3
+ "version": "0.5.28",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -87,8 +87,11 @@ export function ChatProvider({ children, autoConnect = true }: ChatProviderProps
87
87
  const refreshMessages = useCallback(async () => {
88
88
  try {
89
89
  const res = await client.getChatMessages({ limit: 30 });
90
- // API returns newest-first keep that order for inverted FlatList
91
- setMessages(res.messages);
90
+ // The dev API returns messages oldest-first (chatService applies a
91
+ // .reverse() for legacy chat-order callers). Inverted chat FlatLists
92
+ // — and onNewMessage's prepend below — assume newest-first. Flip
93
+ // here so the internal store is consistent everywhere.
94
+ setMessages([...res.messages].reverse());
92
95
  } catch (err) {
93
96
  console.error('[Dubs:ChatProvider] Failed to load messages:', err);
94
97
  }
@@ -155,7 +158,19 @@ export function ChatProvider({ children, autoConnect = true }: ChatProviderProps
155
158
  const host = new URL(baseUrl).origin;
156
159
 
157
160
  chatSocket.setListeners({
158
- onConnectionChange: setStatus,
161
+ // Refetch the message list whenever the socket reaches 'connected'.
162
+ // Covers both the initial connect AND every reconnect (app resumed
163
+ // from background, transient network blip, server restart). Without
164
+ // this, the provider's `messages` state is frozen at whatever it was
165
+ // when the app last connected — Socket.IO's auto-reconnect resumes
166
+ // delivery of *new* events but does not replay the gap.
167
+ onConnectionChange: (next) => {
168
+ setStatus(next);
169
+ if (next === 'connected') {
170
+ refreshMessages().catch(() => {});
171
+ refreshConversations().catch(() => {});
172
+ }
173
+ },
159
174
  // Global chat
160
175
  onNewMessage: (msg) => {
161
176
  setMessages((prev) => {