@messenger-box/platform-mobile 10.0.3-alpha.33 → 10.0.3-alpha.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/CHANGELOG.md +8 -0
- package/lib/screens/inbox/components/DialogsListItem.js +26 -6
- package/lib/screens/inbox/components/DialogsListItem.js.map +1 -1
- package/lib/screens/inbox/components/ServiceDialogsListItem.js +171 -42
- package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +1 -1
- package/lib/screens/inbox/containers/ConversationView.js +116 -51
- package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/Dialogs.js +168 -56
- package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
- package/package.json +4 -4
- package/src/screens/inbox/components/DialogsListItem.tsx +31 -0
- package/src/screens/inbox/components/ServiceDialogsListItem.tsx +300 -113
- package/src/screens/inbox/containers/ConversationView.tsx +146 -63
- package/src/screens/inbox/containers/Dialogs.tsx +228 -57
|
@@ -267,12 +267,33 @@ const ConversationViewComponent = (_a) => {
|
|
|
267
267
|
}
|
|
268
268
|
}, [state]);
|
|
269
269
|
const safeSend = useCallback((event) => {
|
|
270
|
+
var _a3;
|
|
270
271
|
try {
|
|
272
|
+
console.log("\u{1F6E0}\uFE0F Safe send event:", event.type);
|
|
271
273
|
send(event);
|
|
274
|
+
if (event.type === Actions.SET_CHANNEL_MESSAGES) {
|
|
275
|
+
setTimeout(() => {
|
|
276
|
+
var _a4, _b3;
|
|
277
|
+
if (state.context.channelMessages.length === 0 && ((_b3 = (_a4 = event.data) == null ? void 0 : _a4.messages) == null ? void 0 : _b3.length) > 0) {
|
|
278
|
+
console.warn("\u{1F6E0}\uFE0F SET_CHANNEL_MESSAGES did not update state - messages still empty");
|
|
279
|
+
}
|
|
280
|
+
}, 100);
|
|
281
|
+
}
|
|
272
282
|
} catch (error) {
|
|
273
|
-
console.error("Error
|
|
283
|
+
console.error("\u{1F6E0}\uFE0F Error in safeSend:", error, "Event type:", event.type);
|
|
284
|
+
if (event.type === Actions.SET_CHANNEL_MESSAGES && ((_a3 = event.data) == null ? void 0 : _a3.messages)) {
|
|
285
|
+
console.log("\u{1F6E0}\uFE0F Attempting fallback for SET_CHANNEL_MESSAGES");
|
|
286
|
+
try {
|
|
287
|
+
send({
|
|
288
|
+
type: "DIRECT_STATE_UPDATE",
|
|
289
|
+
data: event.data
|
|
290
|
+
});
|
|
291
|
+
} catch (fallbackError) {
|
|
292
|
+
console.error("\u{1F6E0}\uFE0F Even fallback failed:", fallbackError);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
274
295
|
}
|
|
275
|
-
}, [send]);
|
|
296
|
+
}, [send, state.context.channelMessages.length]);
|
|
276
297
|
useEffect(() => {
|
|
277
298
|
if (ChannelId) {
|
|
278
299
|
console.log("Setting initial channel ID on mount:", ChannelId);
|
|
@@ -354,10 +375,26 @@ const ConversationViewComponent = (_a) => {
|
|
|
354
375
|
console.log("Raw message data from query:", JSON.stringify(queryData.messages.data).substring(0, 100) + "...");
|
|
355
376
|
console.log("Message count from query:", queryData.messages.data.length);
|
|
356
377
|
console.log("Total count from query:", queryData.messages.totalCount);
|
|
378
|
+
if (queryData.messages.data.length > 0) {
|
|
379
|
+
console.log("\u{1F504} IMMEDIATE STATE UPDATE with messages:", queryData.messages.data.length);
|
|
380
|
+
safeSend({
|
|
381
|
+
type: Actions.SET_CHANNEL_MESSAGES,
|
|
382
|
+
data: {
|
|
383
|
+
messages: queryData.messages.data,
|
|
384
|
+
totalCount: queryData.messages.totalCount
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
357
388
|
}
|
|
358
389
|
},
|
|
359
390
|
onError: (error) => {
|
|
360
391
|
console.error("MESSAGE QUERY ERROR:", error);
|
|
392
|
+
safeSend({
|
|
393
|
+
type: "ERROR",
|
|
394
|
+
data: {
|
|
395
|
+
message: String(error)
|
|
396
|
+
}
|
|
397
|
+
});
|
|
361
398
|
}
|
|
362
399
|
});
|
|
363
400
|
const fetchMessagesDirectly = useCallback(async () => {
|
|
@@ -744,15 +781,32 @@ const ConversationViewComponent = (_a) => {
|
|
|
744
781
|
} = data.messages;
|
|
745
782
|
if (messages && messages.length > 0) {
|
|
746
783
|
console.log("\u{1F4E9} QUERY DATA - Setting channel messages, count:", messages.length);
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
784
|
+
setTimeout(() => {
|
|
785
|
+
safeSend({
|
|
786
|
+
type: Actions.SET_CHANNEL_MESSAGES,
|
|
787
|
+
data: {
|
|
788
|
+
messages: uniqBy([...messages, ...state.context.channelMessages], ({
|
|
789
|
+
id
|
|
790
|
+
}) => id),
|
|
791
|
+
totalCount: messageTotalCount
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
setTimeout(() => {
|
|
795
|
+
var _a4;
|
|
796
|
+
const currentMessagesCount = ((_a4 = state.context.channelMessages) == null ? void 0 : _a4.length) || 0;
|
|
797
|
+
console.log("\u{1F4E9} STATE UPDATE VERIFICATION - Current message count:", currentMessagesCount);
|
|
798
|
+
if (currentMessagesCount === 0) {
|
|
799
|
+
console.warn("\u26A0\uFE0F STATE NOT UPDATED after message data received - triggering fallback");
|
|
800
|
+
safeSend({
|
|
801
|
+
type: Actions.SET_CHANNEL_MESSAGES,
|
|
802
|
+
data: {
|
|
803
|
+
messages,
|
|
804
|
+
totalCount: messageTotalCount
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}, 500);
|
|
809
|
+
}, 0);
|
|
756
810
|
if (messages[0]) {
|
|
757
811
|
const sample = messages[0];
|
|
758
812
|
console.log("\u{1F4E9} SAMPLE MESSAGE:", JSON.stringify({
|
|
@@ -765,15 +819,9 @@ const ConversationViewComponent = (_a) => {
|
|
|
765
819
|
createdAt: sample.createdAt
|
|
766
820
|
}));
|
|
767
821
|
}
|
|
768
|
-
setTimeout(() => {
|
|
769
|
-
var _a4;
|
|
770
|
-
if (((_a4 = state.context.channelMessages) == null ? void 0 : _a4.length) === 0) {
|
|
771
|
-
console.warn("\u26A0\uFE0F STATE NOT UPDATED after message data received - may need fallback");
|
|
772
|
-
}
|
|
773
|
-
}, 500);
|
|
774
822
|
}
|
|
775
823
|
}
|
|
776
|
-
}, [data]);
|
|
824
|
+
}, [data, safeSend]);
|
|
777
825
|
const onFetchOld = useCallback(() => {
|
|
778
826
|
var _a3, _b3, _c2, _d2;
|
|
779
827
|
if (fetchOldDebounceRef.current)
|
|
@@ -1281,41 +1329,50 @@ const ConversationViewComponent = (_a) => {
|
|
|
1281
1329
|
updateQuery: (prev, {
|
|
1282
1330
|
subscriptionData
|
|
1283
1331
|
}) => {
|
|
1284
|
-
var _a5, _b5, _c2;
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1332
|
+
var _a5, _b5, _c2, _d2;
|
|
1333
|
+
try {
|
|
1334
|
+
console.log("\u{1F514} Subscription data received for channel:", (_a5 = state == null ? void 0 : state.context) == null ? void 0 : _a5.channelId);
|
|
1335
|
+
if (!((_b5 = subscriptionData == null ? void 0 : subscriptionData.data) == null ? void 0 : _b5.chatMessageAdded)) {
|
|
1336
|
+
console.log("\u{1F514} No valid message in subscription data");
|
|
1337
|
+
return prev;
|
|
1338
|
+
}
|
|
1339
|
+
const newMessage = subscriptionData.data.chatMessageAdded;
|
|
1340
|
+
console.log("\u{1F514} New message received:", newMessage.id);
|
|
1341
|
+
const currentMessages = ((_c2 = prev == null ? void 0 : prev.messages) == null ? void 0 : _c2.data) || [];
|
|
1342
|
+
if (currentMessages.some((msg) => msg.id === newMessage.id)) {
|
|
1343
|
+
console.log("\u{1F514} Message already in cache, skipping update");
|
|
1344
|
+
return prev;
|
|
1345
|
+
}
|
|
1346
|
+
setTimeout(() => {
|
|
1347
|
+
try {
|
|
1348
|
+
console.log("\u{1F514} Directly updating state machine with new message");
|
|
1349
|
+
safeSend({
|
|
1350
|
+
type: Actions.SET_CHANNEL_MESSAGES,
|
|
1351
|
+
data: {
|
|
1352
|
+
messages: [...state.context.channelMessages, newMessage],
|
|
1353
|
+
totalCount: (state.context.totalCount || 0) + 1
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
} catch (error) {
|
|
1357
|
+
console.error("\u{1F514} Error updating state with subscription data:", error);
|
|
1305
1358
|
}
|
|
1359
|
+
}, 0);
|
|
1360
|
+
const updatedData = __spreadProps(__spreadValues({}, prev), {
|
|
1361
|
+
messages: __spreadProps(__spreadValues({}, prev.messages), {
|
|
1362
|
+
data: [...currentMessages, newMessage],
|
|
1363
|
+
totalCount: (((_d2 = prev == null ? void 0 : prev.messages) == null ? void 0 : _d2.totalCount) || 0) + 1
|
|
1364
|
+
})
|
|
1306
1365
|
});
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
});
|
|
1366
|
+
console.log("\u{1F514} Returning updated query data with new messages");
|
|
1367
|
+
return updatedData;
|
|
1368
|
+
} catch (error) {
|
|
1369
|
+
console.error("\u{1F514} Error in subscription updateQuery:", error);
|
|
1370
|
+
return prev;
|
|
1371
|
+
}
|
|
1314
1372
|
}
|
|
1315
1373
|
});
|
|
1316
1374
|
} }));
|
|
1317
1375
|
}, [isShowImageViewer, modalContent, (_l = state == null ? void 0 : state.context) == null ? void 0 : _l.channelId, (_m = state == null ? void 0 : state.context) == null ? void 0 : _m.channelMessages, subscribeToMore, safeSend]);
|
|
1318
|
-
const lastProcessedMessageRef = useRef(null);
|
|
1319
1376
|
const listViewProps = useMemo(() => ({
|
|
1320
1377
|
onEndReached,
|
|
1321
1378
|
onEndReachedThreshold: 0.5,
|
|
@@ -1436,11 +1493,19 @@ const SubscriptionHandler = ({
|
|
|
1436
1493
|
}) => {
|
|
1437
1494
|
const channelIdRef = useRef(channelId);
|
|
1438
1495
|
useEffect(() => {
|
|
1439
|
-
if (channelId
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
return subscribeToNewMessages();
|
|
1496
|
+
if (!channelId) {
|
|
1497
|
+
console.log("\u26A0\uFE0F No channel ID for subscription");
|
|
1498
|
+
return;
|
|
1443
1499
|
}
|
|
1500
|
+
console.log("\u{1F504} Setting up NEW subscription for channel:", channelId);
|
|
1501
|
+
const unsubscribe = subscribeToNewMessages();
|
|
1502
|
+
channelIdRef.current = channelId;
|
|
1503
|
+
return () => {
|
|
1504
|
+
if (unsubscribe && typeof unsubscribe === "function") {
|
|
1505
|
+
console.log("\u{1F504} Cleaning up subscription for channel:", channelIdRef.current);
|
|
1506
|
+
unsubscribe();
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1444
1509
|
}, [channelId, subscribeToNewMessages]);
|
|
1445
1510
|
return null;
|
|
1446
1511
|
};
|