@messenger-box/platform-mobile 10.0.3-alpha.22 → 10.0.3-alpha.23
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 +4 -0
- package/lib/screens/inbox/DialogThreads.js +52 -12
- package/lib/screens/inbox/DialogThreads.js.map +1 -1
- package/lib/screens/inbox/components/ThreadsViewItem.js +66 -44
- package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
- package/lib/screens/inbox/containers/ConversationView.js +36 -34
- package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/Dialogs.js +82 -37
- package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadConversationView.js +282 -219
- package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadsView.js +83 -50
- package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
- package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js +108 -0
- package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js.map +1 -0
- package/lib/screens/inbox/workflow/dialog-threads-xstate.js +151 -0
- package/lib/screens/inbox/workflow/dialog-threads-xstate.js.map +1 -0
- package/package.json +2 -2
- package/src/screens/inbox/DialogThreads.tsx +49 -53
- package/src/screens/inbox/components/SmartLoader.tsx +61 -0
- package/src/screens/inbox/components/ThreadsViewItem.tsx +177 -265
- package/src/screens/inbox/containers/ConversationView.tsx +32 -30
- package/src/screens/inbox/containers/Dialogs.tsx +57 -22
- package/src/screens/inbox/containers/ThreadConversationView.tsx +467 -484
- package/src/screens/inbox/containers/ThreadsView.tsx +102 -183
- package/src/screens/inbox/hooks/useSafeDialogThreadsMachine.ts +136 -0
- package/src/screens/inbox/index.ts +37 -0
- package/src/screens/inbox/machines/threadsMachine.ts +147 -0
- package/src/screens/inbox/workflow/dialog-threads-xstate.ts +163 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default,{useState,useRef,useCallback,useEffect,useMemo}from'react';import {Button,Box,
|
|
1
|
+
import React__default,{useState,useRef,useCallback,useEffect,useMemo}from'react';import {Button,Box,Image,Text,ButtonText,Spinner,HStack,VStack,Avatar,AvatarFallbackText,AvatarImage,Center}from'@admin-layout/gluestack-ui-mobile';import {Platform,View,TouchableHighlight,SafeAreaView,Alert,Linking}from'react-native';import {useRoute,useNavigation,useFocusEffect}from'@react-navigation/native';import {useSelector}from'react-redux';import {orderBy,startCase,uniqBy}from'lodash-es';import*as ImagePicker from'expo-image-picker';import {MaterialIcons,MaterialCommunityIcons,Ionicons}from'@expo/vector-icons';import {Send,Actions as Actions$1,InputToolbar,MessageText,GiftedChat}from'react-native-gifted-chat';import {PreDefinedRole}from'common';import {useCreatePostThreadMutation,useSendExpoNotificationOnPostMutation,useGetPostThreadLazyQuery,OnThreadChatMessageAddedDocument}from'common/graphql';import {useUploadFilesNative}from'@messenger-box/platform-client';import {objectId}from'@messenger-box/core';import {format,isToday,isYesterday}from'date-fns';import {userSelector}from'@adminide-stack/user-auth0-client';import {config}from'../config/config.js';import Message from'../components/SlackMessageContainer/SlackMessage.js';import ImageViewerModal from'../components/SlackMessageContainer/ImageViewerModal.js';import CachedImage from'../components/CachedImage/index.js';import colors from'tailwindcss/colors';import {Actions,BaseState,MainState}from'./workflow/thread-conversation-xstate.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -298,7 +298,7 @@ const ThreadConversationViewComponent = ({
|
|
|
298
298
|
isPostParentIdThread,
|
|
299
299
|
role
|
|
300
300
|
}) => {
|
|
301
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
301
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
302
302
|
const {
|
|
303
303
|
params
|
|
304
304
|
} = useRoute();
|
|
@@ -468,7 +468,14 @@ const ThreadConversationViewComponent = ({
|
|
|
468
468
|
}, [state.value]);
|
|
469
469
|
const fetchThreadMessages = useCallback(() => {
|
|
470
470
|
if (channelId && parentId) {
|
|
471
|
-
|
|
471
|
+
if (__DEV__)
|
|
472
|
+
console.log("Initial fetch of thread messages using larger limit (50)");
|
|
473
|
+
safeSend({
|
|
474
|
+
type: Actions.START_LOADING,
|
|
475
|
+
data: {
|
|
476
|
+
loading: true
|
|
477
|
+
}
|
|
478
|
+
});
|
|
472
479
|
getThreadMessages({
|
|
473
480
|
variables: {
|
|
474
481
|
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
@@ -487,7 +494,8 @@ const ThreadConversationViewComponent = ({
|
|
|
487
494
|
const threadReplies = (_b2 = threads == null ? void 0 : threads.replies) != null ? _b2 : [];
|
|
488
495
|
const messageTotalCount = (_c2 = threads == null ? void 0 : threads.replyCount) != null ? _c2 : 0;
|
|
489
496
|
const messages = [...threadReplies];
|
|
490
|
-
|
|
497
|
+
if (__DEV__)
|
|
498
|
+
console.log(`Initial fetch complete. Got ${messages.length} messages of ${messageTotalCount} total`);
|
|
491
499
|
safeSend({
|
|
492
500
|
type: Actions.SET_THREAD_MESSAGES,
|
|
493
501
|
data: {
|
|
@@ -507,7 +515,7 @@ const ThreadConversationViewComponent = ({
|
|
|
507
515
|
});
|
|
508
516
|
});
|
|
509
517
|
}
|
|
510
|
-
}, [channelId, parentId, role]);
|
|
518
|
+
}, [channelId, parentId, role, getThreadMessages, safeSend]);
|
|
511
519
|
React__default.useEffect(() => {
|
|
512
520
|
var _a2, _b2, _c2;
|
|
513
521
|
if (data == null ? void 0 : data.getPostThread) {
|
|
@@ -587,109 +595,16 @@ const ThreadConversationViewComponent = ({
|
|
|
587
595
|
threadMessageListRef.current.scrollToBottom();
|
|
588
596
|
}
|
|
589
597
|
}, [threadMessageListRef]);
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
});
|
|
601
|
-
console.log("Using proven approach: Skip=0, Limit=50");
|
|
602
|
-
const queryVariables = {
|
|
603
|
-
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
604
|
-
role: role == null ? void 0 : role.toString(),
|
|
605
|
-
postParentId: !parentId || parentId == 0 ? null : parentId == null ? void 0 : parentId.toString(),
|
|
606
|
-
selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
|
|
607
|
-
limit: 50,
|
|
608
|
-
skip: 0
|
|
609
|
-
};
|
|
610
|
-
console.log("Query variables:", JSON.stringify(queryVariables));
|
|
611
|
-
fetchMoreMessages({
|
|
612
|
-
variables: queryVariables
|
|
613
|
-
}).then((res) => {
|
|
614
|
-
var _a2, _b2, _c2, _d2;
|
|
615
|
-
console.log("API response received:", JSON.stringify(res == null ? void 0 : res.data, null, 2));
|
|
616
|
-
if ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.getPostThread) {
|
|
617
|
-
const threads = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.getPostThread;
|
|
618
|
-
const threadReplies = (_c2 = threads == null ? void 0 : threads.replies) != null ? _c2 : [];
|
|
619
|
-
const actualTotalCount = (_d2 = threads == null ? void 0 : threads.replyCount) != null ? _d2 : 0;
|
|
620
|
-
console.log("API response details:");
|
|
621
|
-
console.log("- replyCount:", threads == null ? void 0 : threads.replyCount);
|
|
622
|
-
console.log("- replies array length:", threadReplies.length);
|
|
623
|
-
console.log("- replies structure:", threadReplies.length > 0 ? `First item has fields: ${Object.keys(threadReplies[0]).join(", ")}` : "No items");
|
|
624
|
-
if (threadReplies.length > 0) {
|
|
625
|
-
console.log("- Sample message:", JSON.stringify(threadReplies[0], null, 2));
|
|
626
|
-
}
|
|
627
|
-
console.log("Successfully loaded more messages:", threadReplies.length, "of total:", actualTotalCount);
|
|
628
|
-
console.log("Thread reply IDs:", threadReplies.map((msg) => msg.id).join(", "));
|
|
629
|
-
const existingIds = new Set(threadMessages.map((msg) => msg.id));
|
|
630
|
-
const newUniqueMessages = threadReplies.filter((msg) => !existingIds.has(msg.id));
|
|
631
|
-
console.log(`Found ${newUniqueMessages.length} unique new messages out of ${threadReplies.length} received`);
|
|
632
|
-
if (actualTotalCount !== totalCount) {
|
|
633
|
-
console.log(`Updating totalCount from ${totalCount} to ${actualTotalCount} based on API response`);
|
|
634
|
-
}
|
|
635
|
-
if (newUniqueMessages.length === 0) {
|
|
636
|
-
console.log("No new unique messages found, adjusting total count");
|
|
637
|
-
registerLoadAttemptResult(false);
|
|
638
|
-
safeSend({
|
|
639
|
-
type: Actions.SET_THREAD_MESSAGES,
|
|
640
|
-
data: {
|
|
641
|
-
messages: threadMessages,
|
|
642
|
-
totalCount: threadMessages.length,
|
|
643
|
-
threadPost: safeContextProperty("threadPost", []),
|
|
644
|
-
postThread: safeContextProperty("postThread", null)
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
registerLoadAttemptResult(true);
|
|
650
|
-
console.log(`Adding ${newUniqueMessages.length} new messages to thread`);
|
|
651
|
-
safeSend({
|
|
652
|
-
type: "FETCH_MORE_MESSAGES_SUCCESS",
|
|
653
|
-
data: {
|
|
654
|
-
messages: newUniqueMessages,
|
|
655
|
-
totalCount: actualTotalCount,
|
|
656
|
-
loadingOldMessages: false
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
} else {
|
|
660
|
-
console.log("No thread data returned when loading more messages");
|
|
661
|
-
registerLoadAttemptResult(false);
|
|
662
|
-
safeSend({
|
|
663
|
-
type: Actions.STOP_LOADING,
|
|
664
|
-
data: {
|
|
665
|
-
loadingOldMessages: false
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
}).catch((error) => {
|
|
670
|
-
console.error("Error fetching more messages:", error);
|
|
671
|
-
registerLoadAttemptResult(false);
|
|
672
|
-
safeSend({
|
|
673
|
-
type: "ERROR",
|
|
674
|
-
data: {
|
|
675
|
-
message: error.message,
|
|
676
|
-
loadingOldMessages: false
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
});
|
|
680
|
-
} else {
|
|
681
|
-
console.log("No more messages to load or already loading");
|
|
682
|
-
if (safeContextProperty("loadingOldMessages", false)) {
|
|
683
|
-
safeSend({
|
|
684
|
-
type: Actions.STOP_LOADING,
|
|
685
|
-
data: {
|
|
686
|
-
loadingOldMessages: false
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
}, [parentId, channelId, state.context, registerLoadAttemptResult]);
|
|
692
|
-
const handleScrollToTop = ({
|
|
598
|
+
const isCloseToTop = useCallback(({
|
|
599
|
+
layoutMeasurement,
|
|
600
|
+
contentOffset,
|
|
601
|
+
contentSize
|
|
602
|
+
}) => {
|
|
603
|
+
const visibleHeight = layoutMeasurement.height;
|
|
604
|
+
const topThreshold = Math.min(80, visibleHeight * 0.15);
|
|
605
|
+
return contentOffset.y <= topThreshold;
|
|
606
|
+
}, []);
|
|
607
|
+
const handleScrollToTop = useCallback(({
|
|
693
608
|
nativeEvent
|
|
694
609
|
}) => {
|
|
695
610
|
if (isCloseToTop(nativeEvent)) {
|
|
@@ -697,30 +612,20 @@ const ThreadConversationViewComponent = ({
|
|
|
697
612
|
const totalCount = safeContextProperty("totalCount", 0);
|
|
698
613
|
const currentCount = safeContextProperty("threadMessages", []).length;
|
|
699
614
|
const hasMoreMessages = totalCount > currentCount;
|
|
700
|
-
|
|
615
|
+
if (__DEV__)
|
|
616
|
+
console.log(`Scroll near top - Loading state: ${isLoading}, Messages: ${currentCount}/${totalCount}, Has more: ${hasMoreMessages}`);
|
|
701
617
|
if (!isLoading && hasMoreMessages) {
|
|
702
|
-
|
|
618
|
+
if (__DEV__)
|
|
619
|
+
console.log("Near top of list - loading older messages");
|
|
703
620
|
safeSend({
|
|
704
621
|
type: Actions.FETCH_MORE_MESSAGES
|
|
705
622
|
});
|
|
706
623
|
}
|
|
707
624
|
}
|
|
708
|
-
};
|
|
625
|
+
}, [isCloseToTop, safeContextProperty, safeSend]);
|
|
709
626
|
const handleEndReached = () => {
|
|
710
627
|
console.log("Reached end of message list");
|
|
711
628
|
};
|
|
712
|
-
const isCloseToTop = ({
|
|
713
|
-
layoutMeasurement,
|
|
714
|
-
contentOffset,
|
|
715
|
-
contentSize
|
|
716
|
-
}) => {
|
|
717
|
-
const visibleHeight = layoutMeasurement.height;
|
|
718
|
-
const topThreshold = Math.min(80, visibleHeight * 0.15);
|
|
719
|
-
const distanceFromTop = contentOffset.y;
|
|
720
|
-
const totalContentHeight = contentSize.height;
|
|
721
|
-
console.log(`Scroll position: ${distanceFromTop.toFixed(0)}px from top, threshold: ${topThreshold.toFixed(0)}px, content height: ${totalContentHeight.toFixed(0)}px`);
|
|
722
|
-
return contentOffset.y <= topThreshold;
|
|
723
|
-
};
|
|
724
629
|
const onSelectImages = async () => {
|
|
725
630
|
var _a2;
|
|
726
631
|
try {
|
|
@@ -990,79 +895,62 @@ const ThreadConversationViewComponent = ({
|
|
|
990
895
|
};
|
|
991
896
|
const messageList = useMemo(() => {
|
|
992
897
|
const threadMessages = safeContextProperty("threadMessages", []);
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
if (threadMessages == null ? void 0 : threadMessages.length)
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
} else {
|
|
1012
|
-
console.warn(`Invalid date value for message ${msg.id}: ${msg.createdAt}`);
|
|
1013
|
-
messageDate = new Date();
|
|
1014
|
-
}
|
|
1015
|
-
} catch (error) {
|
|
1016
|
-
console.error(`Error creating date for message ${msg.id}:`, error);
|
|
898
|
+
if (__DEV__)
|
|
899
|
+
console.log(`Creating message list from ${threadMessages.length} thread messages`);
|
|
900
|
+
if (!(threadMessages == null ? void 0 : threadMessages.length))
|
|
901
|
+
return [];
|
|
902
|
+
const messageIds = /* @__PURE__ */ new Set();
|
|
903
|
+
const res = threadMessages.filter((msg) => {
|
|
904
|
+
if (!msg.id || messageIds.has(msg.id))
|
|
905
|
+
return false;
|
|
906
|
+
messageIds.add(msg.id);
|
|
907
|
+
return true;
|
|
908
|
+
}).map((msg) => {
|
|
909
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
|
|
910
|
+
const uniqueId = msg.id || `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
911
|
+
let messageDate;
|
|
912
|
+
try {
|
|
913
|
+
if (msg.createdAt && !isNaN(new Date(msg.createdAt).getTime())) {
|
|
914
|
+
messageDate = new Date(msg.createdAt);
|
|
915
|
+
} else {
|
|
1017
916
|
messageDate = new Date();
|
|
1018
917
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
918
|
+
} catch (error) {
|
|
919
|
+
messageDate = new Date();
|
|
920
|
+
}
|
|
921
|
+
let imageUrl = null;
|
|
922
|
+
if (((_a2 = msg.files) == null ? void 0 : _a2.data) && msg.files.data.length > 0) {
|
|
923
|
+
const fileData = msg.files.data[0];
|
|
924
|
+
if (fileData && fileData.url) {
|
|
925
|
+
imageUrl = fileData.url;
|
|
1026
926
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
const sortedMessages = orderBy(res, [(msg) => {
|
|
927
|
+
}
|
|
928
|
+
let messageText = msg.message || "";
|
|
929
|
+
return {
|
|
930
|
+
_id: uniqueId,
|
|
931
|
+
text: messageText,
|
|
932
|
+
createdAt: messageDate,
|
|
933
|
+
user: {
|
|
934
|
+
_id: (_d2 = (_b2 = msg == null ? void 0 : msg.author) == null ? void 0 : _b2.id) != null ? _d2 : (_c2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _c2.id,
|
|
935
|
+
name: (_j2 = (_h2 = (_e2 = msg == null ? void 0 : msg.author) == null ? void 0 : _e2.givenName) != null ? _h2 : ((_f2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _f2.given_name) + " " + ((_g2 = msg == null ? void 0 : msg.author) == null ? void 0 : _g2.familyName)) != null ? _j2 : (_i2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _i2.family_name,
|
|
936
|
+
avatar: (_m2 = (_k2 = msg == null ? void 0 : msg.author) == null ? void 0 : _k2.picture) != null ? _m2 : (_l2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _l2.picture
|
|
937
|
+
},
|
|
938
|
+
type: (msg == null ? void 0 : msg.type) || "",
|
|
939
|
+
image: imageUrl,
|
|
940
|
+
sent: (msg == null ? void 0 : msg.isDelivered) || true,
|
|
941
|
+
received: (msg == null ? void 0 : msg.isRead) || false,
|
|
942
|
+
propsConfiguration: msg == null ? void 0 : msg.propsConfiguration
|
|
943
|
+
};
|
|
944
|
+
});
|
|
945
|
+
return orderBy(res, [(msg) => {
|
|
1047
946
|
try {
|
|
1048
947
|
return msg.createdAt instanceof Date ? msg.createdAt.getTime() : new Date().getTime();
|
|
1049
948
|
} catch (error) {
|
|
1050
|
-
console.error("Error sorting message by date:", error);
|
|
1051
949
|
return 0;
|
|
1052
950
|
}
|
|
1053
951
|
}], ["desc"]);
|
|
1054
|
-
if (sortedMessages.length > 0) {
|
|
1055
|
-
try {
|
|
1056
|
-
const firstMsg = sortedMessages[0];
|
|
1057
|
-
const lastMsg = sortedMessages[sortedMessages.length - 1];
|
|
1058
|
-
console.log("Message date range:", lastMsg.createdAt instanceof Date ? lastMsg.createdAt.toISOString() : "invalid date", "to", firstMsg.createdAt instanceof Date ? firstMsg.createdAt.toISOString() : "invalid date");
|
|
1059
|
-
} catch (error) {
|
|
1060
|
-
console.error("Error logging message date range:", error);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
return sortedMessages;
|
|
1064
952
|
}, [safeContextProperty("threadMessages"), auth]);
|
|
1065
|
-
const renderSend = (props) => {
|
|
953
|
+
const renderSend = useCallback((props) => {
|
|
1066
954
|
const hasImage = safeContextProperty("selectedImage", "") !== "";
|
|
1067
955
|
const isDisabled = !hasImage && (!props.text || props.text.trim().length === 0);
|
|
1068
956
|
return /* @__PURE__ */ React__default.createElement(Send, __spreadProps(__spreadValues({}, props), { containerStyle: {
|
|
@@ -1076,8 +964,8 @@ const ThreadConversationViewComponent = ({
|
|
|
1076
964
|
alignItems: "center",
|
|
1077
965
|
justifyContent: "center"
|
|
1078
966
|
} }, /* @__PURE__ */ React__default.createElement(MaterialCommunityIcons, { name: "send-circle", size: 30, color: isDisabled ? colors.gray[400] : colors.blue[500] })));
|
|
1079
|
-
};
|
|
1080
|
-
const renderActions = (props) => {
|
|
967
|
+
}, [safeContextProperty]);
|
|
968
|
+
const renderActions = useCallback((props) => {
|
|
1081
969
|
return /* @__PURE__ */ React__default.createElement(
|
|
1082
970
|
Actions$1,
|
|
1083
971
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -1102,8 +990,8 @@ const ThreadConversationViewComponent = ({
|
|
|
1102
990
|
}
|
|
1103
991
|
})
|
|
1104
992
|
);
|
|
1105
|
-
};
|
|
1106
|
-
const renderAccessory = (props) => {
|
|
993
|
+
}, [onSelectImages]);
|
|
994
|
+
const renderAccessory = useCallback((props) => {
|
|
1107
995
|
var _a2, _b2;
|
|
1108
996
|
const selectedImage2 = safeContextProperty("selectedImage", "");
|
|
1109
997
|
if (!selectedImage2) {
|
|
@@ -1149,11 +1037,80 @@ const ThreadConversationViewComponent = ({
|
|
|
1149
1037
|
color: "white",
|
|
1150
1038
|
fontWeight: "bold"
|
|
1151
1039
|
} }, "X"))));
|
|
1152
|
-
};
|
|
1040
|
+
}, [(_a = state == null ? void 0 : state.context) == null ? void 0 : _a.selectedImage, safeSend]);
|
|
1041
|
+
const renderInputToolbar = useCallback((props) => {
|
|
1042
|
+
return /* @__PURE__ */ React__default.createElement(InputToolbar, __spreadProps(__spreadValues({}, props), { containerStyle: {
|
|
1043
|
+
backgroundColor: "white",
|
|
1044
|
+
borderTopWidth: 1,
|
|
1045
|
+
borderTopColor: colors.gray[200],
|
|
1046
|
+
paddingHorizontal: 4,
|
|
1047
|
+
paddingVertical: 4
|
|
1048
|
+
}, primaryStyle: {
|
|
1049
|
+
alignItems: "center"
|
|
1050
|
+
} }));
|
|
1051
|
+
}, []);
|
|
1153
1052
|
const setImageViewerObject = (obj, v) => {
|
|
1154
1053
|
setImageObject(obj);
|
|
1155
1054
|
setImageViewer(v);
|
|
1156
1055
|
};
|
|
1056
|
+
const renderMessageText = useCallback((props) => {
|
|
1057
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v, _w, _x, _y;
|
|
1058
|
+
const {
|
|
1059
|
+
currentMessage
|
|
1060
|
+
} = props;
|
|
1061
|
+
if (currentMessage.type === "ALERT") {
|
|
1062
|
+
const attachment = (_b2 = (_a2 = currentMessage == null ? void 0 : currentMessage.propsConfiguration) == null ? void 0 : _a2.contents) == null ? void 0 : _b2.attachment;
|
|
1063
|
+
let action = "";
|
|
1064
|
+
let actionId = "";
|
|
1065
|
+
let params2 = {};
|
|
1066
|
+
if ((_c2 = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _c2.extraParams) {
|
|
1067
|
+
const extraParams = (_d2 = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _d2.extraParams;
|
|
1068
|
+
const route = (_e2 = extraParams == null ? void 0 : extraParams.route) != null ? _e2 : null;
|
|
1069
|
+
let path = null;
|
|
1070
|
+
let param = null;
|
|
1071
|
+
if (role && role == PreDefinedRole.Guest) {
|
|
1072
|
+
path = ((_f2 = route == null ? void 0 : route.guest) == null ? void 0 : _f2.name) ? (_h2 = (_g2 = route == null ? void 0 : route.guest) == null ? void 0 : _g2.name) != null ? _h2 : null : null;
|
|
1073
|
+
param = ((_i2 = route == null ? void 0 : route.guest) == null ? void 0 : _i2.params) ? (_k2 = (_j2 = route == null ? void 0 : route.guest) == null ? void 0 : _j2.params) != null ? _k2 : null : null;
|
|
1074
|
+
} else if (role && role == PreDefinedRole.Owner) {
|
|
1075
|
+
path = ((_l2 = route == null ? void 0 : route.host) == null ? void 0 : _l2.name) ? (_n2 = (_m2 = route == null ? void 0 : route.host) == null ? void 0 : _m2.name) != null ? _n2 : null : null;
|
|
1076
|
+
param = ((_o2 = route == null ? void 0 : route.host) == null ? void 0 : _o2.params) ? (_q2 = (_p2 = route == null ? void 0 : route.host) == null ? void 0 : _p2.params) != null ? _q2 : null : null;
|
|
1077
|
+
} else {
|
|
1078
|
+
path = ((_r2 = route == null ? void 0 : route.host) == null ? void 0 : _r2.name) ? (_t2 = (_s2 = route == null ? void 0 : route.host) == null ? void 0 : _s2.name) != null ? _t2 : null : null;
|
|
1079
|
+
param = ((_u2 = route == null ? void 0 : route.host) == null ? void 0 : _u2.params) ? (_w = (_v = route == null ? void 0 : route.host) == null ? void 0 : _v.params) != null ? _w : null : null;
|
|
1080
|
+
}
|
|
1081
|
+
action = path;
|
|
1082
|
+
params2 = __spreadValues({}, param);
|
|
1083
|
+
} else if ((_x = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _x.link) {
|
|
1084
|
+
action = CALL_TO_ACTION_PATH;
|
|
1085
|
+
actionId = (_y = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _y.link.split("/").pop();
|
|
1086
|
+
params2 = {
|
|
1087
|
+
reservationId: actionId
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (attachment == null ? void 0 : attachment.callToAction) && action ? /* @__PURE__ */ React__default.createElement(Box, { className: `bg-[${CALL_TO_ACTION_BOX_BGCOLOR}] rounded-[15] pb-2` }, /* @__PURE__ */ React__default.createElement(Button, { variant: "outline", size: "sm", className: `border-[${CALL_TO_ACTION_BUTTON_BORDERCOLOR}]`, onPress: () => action && params2 && navigation.navigate(action, params2) }, /* @__PURE__ */ React__default.createElement(ButtonText, { className: `color-[${CALL_TO_ACTION_TEXT_COLOR}]` }, attachment.callToAction.title)), /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
|
|
1091
|
+
left: {
|
|
1092
|
+
marginLeft: 5,
|
|
1093
|
+
color: CALL_TO_ACTION_TEXT_COLOR,
|
|
1094
|
+
paddingHorizontal: 2
|
|
1095
|
+
}
|
|
1096
|
+
} }))) : /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
|
|
1097
|
+
left: {
|
|
1098
|
+
marginLeft: 5
|
|
1099
|
+
}
|
|
1100
|
+
} })));
|
|
1101
|
+
} else if (currentMessage.text === "\u{1F4CE} File attachment") {
|
|
1102
|
+
return null;
|
|
1103
|
+
} else {
|
|
1104
|
+
return /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
|
|
1105
|
+
left: {
|
|
1106
|
+
marginLeft: 5
|
|
1107
|
+
}
|
|
1108
|
+
} }));
|
|
1109
|
+
}
|
|
1110
|
+
}, [role, navigation]);
|
|
1111
|
+
const renderMessage = useCallback((props) => {
|
|
1112
|
+
return /* @__PURE__ */ React__default.createElement(Message, __spreadProps(__spreadValues({}, props), { isShowImageViewer, setImageViewer: setImageViewerObject }));
|
|
1113
|
+
}, [isShowImageViewer, setImageViewerObject]);
|
|
1157
1114
|
const modalContent = React__default.useMemo(() => {
|
|
1158
1115
|
if (!imageObject)
|
|
1159
1116
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
|
|
@@ -1169,24 +1126,10 @@ const ThreadConversationViewComponent = ({
|
|
|
1169
1126
|
expiresIn: 86400
|
|
1170
1127
|
}, alt: "image" });
|
|
1171
1128
|
}, [imageObject]);
|
|
1172
|
-
const renderMessage = (props) => {
|
|
1173
|
-
return /* @__PURE__ */ React__default.createElement(Message, __spreadProps(__spreadValues({}, props), { isShowImageViewer, setImageViewer: setImageViewerObject }));
|
|
1174
|
-
};
|
|
1175
1129
|
const currentMessageText = useMemo(() => {
|
|
1176
1130
|
const text = safeContextProperty("messageText", "") || " ";
|
|
1177
1131
|
return text;
|
|
1178
1132
|
}, [safeContextProperty("messageText")]);
|
|
1179
|
-
const renderInputToolbar = (props) => {
|
|
1180
|
-
return /* @__PURE__ */ React__default.createElement(InputToolbar, __spreadProps(__spreadValues({}, props), { containerStyle: {
|
|
1181
|
-
backgroundColor: "white",
|
|
1182
|
-
borderTopWidth: 1,
|
|
1183
|
-
borderTopColor: colors.gray[200],
|
|
1184
|
-
paddingHorizontal: 4,
|
|
1185
|
-
paddingVertical: 4
|
|
1186
|
-
}, primaryStyle: {
|
|
1187
|
-
alignItems: "center"
|
|
1188
|
-
} }));
|
|
1189
|
-
};
|
|
1190
1133
|
const forceLoadMessages = useCallback((skipValue) => {
|
|
1191
1134
|
console.log(`Force loading messages with explicit skip=${skipValue}, limit=50`);
|
|
1192
1135
|
if (channelId && parentId) {
|
|
@@ -1237,6 +1180,126 @@ const ThreadConversationViewComponent = ({
|
|
|
1237
1180
|
});
|
|
1238
1181
|
}
|
|
1239
1182
|
}, [channelId, parentId, getThreadMessages, safeSend]);
|
|
1183
|
+
const onFetchOld = useCallback(() => {
|
|
1184
|
+
const totalCount = safeContextProperty("totalCount", 0);
|
|
1185
|
+
const threadMessages = safeContextProperty("threadMessages", []);
|
|
1186
|
+
const isLoading = safeContextProperty("loadingOldMessages", false);
|
|
1187
|
+
if (totalCount <= threadMessages.length || isLoading) {
|
|
1188
|
+
if (isLoading) {
|
|
1189
|
+
safeSend({
|
|
1190
|
+
type: Actions.STOP_LOADING,
|
|
1191
|
+
data: {
|
|
1192
|
+
loadingOldMessages: false
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
if (__DEV__)
|
|
1197
|
+
console.log("No more messages to load or already loading");
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
if (__DEV__)
|
|
1201
|
+
console.log("Loading more messages - current count:", threadMessages.length, "of", totalCount);
|
|
1202
|
+
safeSend({
|
|
1203
|
+
type: Actions.FETCH_MORE_MESSAGES,
|
|
1204
|
+
data: {
|
|
1205
|
+
loadingOldMessages: true
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
if (__DEV__)
|
|
1209
|
+
console.log("Using proven approach: Skip=0, Limit=50");
|
|
1210
|
+
const queryVariables = {
|
|
1211
|
+
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
1212
|
+
role: role == null ? void 0 : role.toString(),
|
|
1213
|
+
postParentId: !parentId || parentId == 0 ? null : parentId == null ? void 0 : parentId.toString(),
|
|
1214
|
+
selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
|
|
1215
|
+
limit: 50,
|
|
1216
|
+
skip: 0
|
|
1217
|
+
};
|
|
1218
|
+
if (__DEV__)
|
|
1219
|
+
console.log("Query variables:", JSON.stringify(queryVariables));
|
|
1220
|
+
fetchMoreMessages({
|
|
1221
|
+
variables: queryVariables
|
|
1222
|
+
}).then((res) => {
|
|
1223
|
+
var _a2, _b2, _c2, _d2;
|
|
1224
|
+
if (__DEV__)
|
|
1225
|
+
console.log("API response received with status:", res ? "success" : "empty");
|
|
1226
|
+
if ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.getPostThread) {
|
|
1227
|
+
const threads = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.getPostThread;
|
|
1228
|
+
const threadReplies = (_c2 = threads == null ? void 0 : threads.replies) != null ? _c2 : [];
|
|
1229
|
+
const actualTotalCount = (_d2 = threads == null ? void 0 : threads.replyCount) != null ? _d2 : 0;
|
|
1230
|
+
if (__DEV__) {
|
|
1231
|
+
console.log("API response details:");
|
|
1232
|
+
console.log("- replyCount:", threads == null ? void 0 : threads.replyCount);
|
|
1233
|
+
console.log("- replies array length:", threadReplies.length);
|
|
1234
|
+
}
|
|
1235
|
+
if (threadReplies.length > 0) {
|
|
1236
|
+
const existingIds = new Set(threadMessages.map((msg) => msg.id));
|
|
1237
|
+
const newUniqueMessages = threadReplies.filter((msg) => !existingIds.has(msg.id));
|
|
1238
|
+
if (__DEV__)
|
|
1239
|
+
console.log(`Found ${newUniqueMessages.length} unique new messages out of ${threadReplies.length} received`);
|
|
1240
|
+
if (newUniqueMessages.length === 0) {
|
|
1241
|
+
if (__DEV__)
|
|
1242
|
+
console.log("No new unique messages found, adjusting total count");
|
|
1243
|
+
registerLoadAttemptResult(false);
|
|
1244
|
+
safeSend({
|
|
1245
|
+
type: Actions.SET_THREAD_MESSAGES,
|
|
1246
|
+
data: {
|
|
1247
|
+
messages: threadMessages,
|
|
1248
|
+
totalCount: threadMessages.length,
|
|
1249
|
+
threadPost: safeContextProperty("threadPost", []),
|
|
1250
|
+
postThread: safeContextProperty("postThread", null)
|
|
1251
|
+
}
|
|
1252
|
+
});
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
registerLoadAttemptResult(true);
|
|
1256
|
+
if (__DEV__)
|
|
1257
|
+
console.log(`Adding ${newUniqueMessages.length} new messages to thread`);
|
|
1258
|
+
safeSend({
|
|
1259
|
+
type: "FETCH_MORE_MESSAGES_SUCCESS",
|
|
1260
|
+
data: {
|
|
1261
|
+
messages: newUniqueMessages,
|
|
1262
|
+
totalCount: actualTotalCount,
|
|
1263
|
+
loadingOldMessages: false
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
} else {
|
|
1267
|
+
if (__DEV__)
|
|
1268
|
+
console.log("No thread replies returned when loading more messages");
|
|
1269
|
+
registerLoadAttemptResult(false);
|
|
1270
|
+
safeSend({
|
|
1271
|
+
type: Actions.SET_THREAD_MESSAGES,
|
|
1272
|
+
data: {
|
|
1273
|
+
messages: threadMessages,
|
|
1274
|
+
totalCount: threadMessages.length,
|
|
1275
|
+
threadPost: safeContextProperty("threadPost", []),
|
|
1276
|
+
postThread: safeContextProperty("postThread", null)
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
} else {
|
|
1281
|
+
if (__DEV__)
|
|
1282
|
+
console.log("No thread data returned when loading more messages");
|
|
1283
|
+
registerLoadAttemptResult(false);
|
|
1284
|
+
safeSend({
|
|
1285
|
+
type: Actions.STOP_LOADING,
|
|
1286
|
+
data: {
|
|
1287
|
+
loadingOldMessages: false
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}).catch((error) => {
|
|
1292
|
+
console.error("Error fetching more messages:", error);
|
|
1293
|
+
registerLoadAttemptResult(false);
|
|
1294
|
+
safeSend({
|
|
1295
|
+
type: "ERROR",
|
|
1296
|
+
data: {
|
|
1297
|
+
message: error.message,
|
|
1298
|
+
loadingOldMessages: false
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
});
|
|
1302
|
+
}, [parentId, channelId, role, safeContextProperty, safeSend, fetchMoreMessages, registerLoadAttemptResult]);
|
|
1240
1303
|
return /* @__PURE__ */ React__default.createElement(SafeAreaView, { style: {
|
|
1241
1304
|
flex: 1
|
|
1242
1305
|
} }, safeContextProperty("loadingOldMessages", false) === true && /* @__PURE__ */ React__default.createElement(Box, { className: "absolute top-10 left-0 right-0 z-10 items-center" }, /* @__PURE__ */ React__default.createElement(Box, { className: "bg-blue-500/20 rounded-full px-4 py-2 flex-row items-center" }, /* @__PURE__ */ React__default.createElement(Spinner, { color: colors.blue[500], size: "small" }), /* @__PURE__ */ React__default.createElement(Text, { className: "text-sm font-medium color-blue-600 ml-2" }, "Loading messages..."))), !safeContextProperty("loadingOldMessages", false) && safeContextProperty("totalCount", 0) > safeContextProperty("threadMessages", []).length && /* @__PURE__ */ React__default.createElement(Box, { className: "absolute top-10 left-0 right-0 z-10 items-center" }, /* @__PURE__ */ React__default.createElement(HStack, { space: 2, className: "px-2" }, /* @__PURE__ */ React__default.createElement(TouchableHighlight, { onPress: () => {
|
|
@@ -1417,13 +1480,13 @@ const ThreadConversationViewComponent = ({
|
|
|
1417
1480
|
text: "Cancel",
|
|
1418
1481
|
style: "cancel"
|
|
1419
1482
|
}]);
|
|
1420
|
-
}, underlayColor: "#e6e6e6" }, /* @__PURE__ */ React__default.createElement(Box, { className: "bg-gray-200 rounded-full px-4 py-2 flex-row items-center" }, /* @__PURE__ */ React__default.createElement(MaterialIcons, { name: "arrow-upward", size: 16, color: colors.blue[500] }), /* @__PURE__ */ React__default.createElement(Text, { className: "text-sm font-medium color-blue-600 ml-2" }, "Load More (", safeContextProperty("totalCount", 0) - safeContextProperty("threadMessages", []).length, ")"))), /* @__PURE__ */ React__default.createElement(TouchableHighlight, { onPress: forceRefreshMessages, underlayColor: "#e6e6e6" }, /* @__PURE__ */ React__default.createElement(Box, { className: "bg-gray-200 rounded-full px-4 py-2 flex-row items-center" }, /* @__PURE__ */ React__default.createElement(MaterialIcons, { name: "refresh", size: 16, color: colors.blue[500] }), /* @__PURE__ */ React__default.createElement(Text, { className: "text-sm font-medium color-blue-600 ml-2" }, "Refresh All"))))), isPostParentIdThread && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, ((
|
|
1483
|
+
}, underlayColor: "#e6e6e6" }, /* @__PURE__ */ React__default.createElement(Box, { className: "bg-gray-200 rounded-full px-4 py-2 flex-row items-center" }, /* @__PURE__ */ React__default.createElement(MaterialIcons, { name: "arrow-upward", size: 16, color: colors.blue[500] }), /* @__PURE__ */ React__default.createElement(Text, { className: "text-sm font-medium color-blue-600 ml-2" }, "Load More (", safeContextProperty("totalCount", 0) - safeContextProperty("threadMessages", []).length, ")"))), /* @__PURE__ */ React__default.createElement(TouchableHighlight, { onPress: forceRefreshMessages, underlayColor: "#e6e6e6" }, /* @__PURE__ */ React__default.createElement(Box, { className: "bg-gray-200 rounded-full px-4 py-2 flex-row items-center" }, /* @__PURE__ */ React__default.createElement(MaterialIcons, { name: "refresh", size: 16, color: colors.blue[500] }), /* @__PURE__ */ React__default.createElement(Text, { className: "text-sm font-medium color-blue-600 ml-2" }, "Refresh All"))))), isPostParentIdThread && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, ((_b = safeContextProperty("threadPost", [])) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(VStack, { className: "px-2 pt-2 pb-0", space: "sm" }, /* @__PURE__ */ React__default.createElement(HStack, { space: "sm", className: "items-center" }, /* @__PURE__ */ React__default.createElement(Avatar, { className: "bg-transparent", size: "md" }, /* @__PURE__ */ React__default.createElement(AvatarFallbackText, null, startCase((_e = (_d = (_c = safeContextProperty("threadPost")[0]) == null ? void 0 : _c.author) == null ? void 0 : _d.username) == null ? void 0 : _e.charAt(0))), /* @__PURE__ */ React__default.createElement(AvatarImage, { alt: "image", style: {
|
|
1421
1484
|
borderRadius: 6,
|
|
1422
1485
|
borderWidth: 2,
|
|
1423
1486
|
borderColor: "#fff"
|
|
1424
1487
|
}, source: {
|
|
1425
|
-
uri: (
|
|
1426
|
-
} })), /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(Text, { className: "font-bold color-black" }, (
|
|
1488
|
+
uri: (_g = (_f = safeContextProperty("threadPost")[0]) == null ? void 0 : _f.author) == null ? void 0 : _g.picture
|
|
1489
|
+
} })), /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(Text, { className: "font-bold color-black" }, (_j = (_i = (_h = safeContextProperty("threadPost")[0]) == null ? void 0 : _h.author) == null ? void 0 : _i.givenName) != null ? _j : "", " ", (_m = (_l = (_k = safeContextProperty("threadPost")[0]) == null ? void 0 : _k.author) == null ? void 0 : _l.familyName) != null ? _m : ""), /* @__PURE__ */ React__default.createElement(Text, { className: "pl-0 color-gray-500" }, createdAtText((_n = safeContextProperty("threadPost")[0]) == null ? void 0 : _n.createdAt), " at", " ", (() => {
|
|
1427
1490
|
var _a2;
|
|
1428
1491
|
try {
|
|
1429
1492
|
const createdAt = (_a2 = safeContextProperty("threadPost")[0]) == null ? void 0 : _a2.createdAt;
|
|
@@ -1436,7 +1499,7 @@ const ThreadConversationViewComponent = ({
|
|
|
1436
1499
|
console.error("Error formatting thread post time:", error);
|
|
1437
1500
|
return "unknown time";
|
|
1438
1501
|
}
|
|
1439
|
-
})()))), /* @__PURE__ */ React__default.createElement(HStack, { space: "sm", className: "px-2 items-center" }, /* @__PURE__ */ React__default.createElement(Text, null, (
|
|
1502
|
+
})()))), /* @__PURE__ */ React__default.createElement(HStack, { space: "sm", className: "px-2 items-center" }, /* @__PURE__ */ React__default.createElement(Text, null, (_p = (_o = safeContextProperty("threadPost")[0]) == null ? void 0 : _o.message) != null ? _p : ""))), /* @__PURE__ */ React__default.createElement(Box, { className: "py-4" }, /* @__PURE__ */ React__default.createElement(Box, { className: "px-4 py-2 border-t border-b border-gray-200" }, /* @__PURE__ */ React__default.createElement(Text, { className: "font-bold color-gray-600" }, (_r = (_q = safeContextProperty("threadPost")[0]) == null ? void 0 : _q.replies) == null ? void 0 : _r.totalCount, " ", ((_t = (_s = safeContextProperty("threadPost")[0]) == null ? void 0 : _s.replies) == null ? void 0 : _t.totalCount) > 0 ? "replies" : "reply"))))), /* @__PURE__ */ React__default.createElement(GiftedChat, { ref: threadMessageListRef, wrapInSafeArea: false, renderLoading: () => /* @__PURE__ */ React__default.createElement(Spinner, { color: colors.blue[500] }), messages: messageList, listViewProps: {
|
|
1440
1503
|
onScroll: handleScrollToTop,
|
|
1441
1504
|
onEndReached: handleEndReached,
|
|
1442
1505
|
onEndReachedThreshold: 0.2,
|
|
@@ -1458,7 +1521,8 @@ const ThreadConversationViewComponent = ({
|
|
|
1458
1521
|
}
|
|
1459
1522
|
const currentInputText = currentMessageText;
|
|
1460
1523
|
const messageToSend = (currentInputText == null ? void 0 : currentInputText.trim()) || ((_b2 = (_a2 = messages[0]) == null ? void 0 : _a2.text) == null ? void 0 : _b2.trim()) || " ";
|
|
1461
|
-
|
|
1524
|
+
if (__DEV__)
|
|
1525
|
+
console.log("GiftedChat onSend triggered with text from state:", messageToSend);
|
|
1462
1526
|
safeSend({
|
|
1463
1527
|
type: Actions.SET_MESSAGE_TEXT,
|
|
1464
1528
|
data: {
|
|
@@ -1466,7 +1530,8 @@ const ThreadConversationViewComponent = ({
|
|
|
1466
1530
|
}
|
|
1467
1531
|
});
|
|
1468
1532
|
if (safeContextProperty("images", []).length > 0) {
|
|
1469
|
-
|
|
1533
|
+
if (__DEV__)
|
|
1534
|
+
console.log("Sending message with file:", messageToSend, "Images:", safeContextProperty("images", []).length);
|
|
1470
1535
|
safeSend({
|
|
1471
1536
|
type: Actions.SEND_THREAD_MESSAGE_WITH_FILE,
|
|
1472
1537
|
data: {
|
|
@@ -1474,7 +1539,8 @@ const ThreadConversationViewComponent = ({
|
|
|
1474
1539
|
}
|
|
1475
1540
|
});
|
|
1476
1541
|
} else {
|
|
1477
|
-
|
|
1542
|
+
if (__DEV__)
|
|
1543
|
+
console.log("Sending text message:", messageToSend);
|
|
1478
1544
|
safeSend({
|
|
1479
1545
|
type: Actions.SEND_THREAD_MESSAGE,
|
|
1480
1546
|
data: {
|
|
@@ -1483,9 +1549,6 @@ const ThreadConversationViewComponent = ({
|
|
|
1483
1549
|
});
|
|
1484
1550
|
}
|
|
1485
1551
|
}, text: currentMessageText, onInputTextChanged: (text) => {
|
|
1486
|
-
if (text.length % 5 === 0 || text.length < 5) {
|
|
1487
|
-
console.log("Input text changed:", text);
|
|
1488
|
-
}
|
|
1489
1552
|
safeSend({
|
|
1490
1553
|
type: Actions.SET_MESSAGE_TEXT,
|
|
1491
1554
|
data: {
|
|
@@ -1494,7 +1557,7 @@ const ThreadConversationViewComponent = ({
|
|
|
1494
1557
|
});
|
|
1495
1558
|
}, renderFooter: () => safeContextProperty("loading", false) && !safeContextProperty("loadingOldMessages", false) ? /* @__PURE__ */ React__default.createElement(Box, { className: "w-full py-2 items-center" }, /* @__PURE__ */ React__default.createElement(Spinner, { color: colors.blue[500] })) : safeContextProperty("imageLoading", false) ? /* @__PURE__ */ React__default.createElement(Box, { className: "w-full py-2 items-center" }, /* @__PURE__ */ React__default.createElement(Spinner, { color: colors.blue[500] })) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), scrollToBottom: true, loadEarlier: false, isLoadingEarlier: false, user: {
|
|
1496
1559
|
_id: (auth == null ? void 0 : auth.id) || ""
|
|
1497
|
-
}, isTyping:
|
|
1560
|
+
}, isTyping: safeContextProperty("loading", false), alwaysShowSend: safeContextProperty("loading", false) ? false : true, infiniteScroll: true, renderSend, renderInputToolbar, minInputToolbarHeight: 50, renderActions, renderAccessory: !!((_u = state == null ? void 0 : state.context) == null ? void 0 : _u.selectedImage) ? renderAccessory : void 0, renderMessage, renderMessageText, maxInputLength: 1e3, placeholder: "Type a message...", showUserAvatar: true, showAvatarForEveryMessage: false, inverted: true, parsePatterns: (linkStyle) => [{
|
|
1498
1561
|
type: "url",
|
|
1499
1562
|
style: __spreadProps(__spreadValues({}, linkStyle), {
|
|
1500
1563
|
color: colors.blue[500]
|
|
@@ -1544,7 +1607,7 @@ const ThreadConversationViewComponent = ({
|
|
|
1544
1607
|
return prev;
|
|
1545
1608
|
const newMessage = (_a2 = subscriptionData == null ? void 0 : subscriptionData.data) == null ? void 0 : _a2.threadChatMessageAdded;
|
|
1546
1609
|
const prevReplyCount = (_b2 = prev == null ? void 0 : prev.getPostThread) == null ? void 0 : _b2.replyCount;
|
|
1547
|
-
const newReplyCount = prevReplyCount || 0 + 1;
|
|
1610
|
+
const newReplyCount = (prevReplyCount || 0) + 1;
|
|
1548
1611
|
const replies = ((_c2 = prev == null ? void 0 : prev.getPostThread) == null ? void 0 : _c2.replies) || [];
|
|
1549
1612
|
safeSend({
|
|
1550
1613
|
type: Actions.SET_THREAD_MESSAGES,
|
|
@@ -1566,11 +1629,11 @@ const ThreadConversationViewComponent = ({
|
|
|
1566
1629
|
})
|
|
1567
1630
|
});
|
|
1568
1631
|
}
|
|
1569
|
-
}) })), messagesContainerStyle: (messageList == null ? void 0 : messageList.length) == 0
|
|
1632
|
+
}) })), messagesContainerStyle: (messageList == null ? void 0 : messageList.length) == 0 ? {
|
|
1570
1633
|
transform: [{
|
|
1571
1634
|
scaleY: -1
|
|
1572
1635
|
}]
|
|
1573
|
-
}, renderChatEmpty: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !threadLoading && messageList && (messageList == null ? void 0 : messageList.length) == 0 && /* @__PURE__ */ React__default.createElement(Box, { className: "p-5" }, /* @__PURE__ */ React__default.createElement(Center, { className: "mt-6" }, /* @__PURE__ */ React__default.createElement(Ionicons, { name: "chatbubbles", size: 30 }), /* @__PURE__ */ React__default.createElement(Text, null, "You don't have any message yet!")))), lightboxProps: {
|
|
1636
|
+
} : void 0, renderChatEmpty: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !threadLoading && messageList && (messageList == null ? void 0 : messageList.length) == 0 && /* @__PURE__ */ React__default.createElement(Box, { className: "p-5" }, /* @__PURE__ */ React__default.createElement(Center, { className: "mt-6" }, /* @__PURE__ */ React__default.createElement(Ionicons, { name: "chatbubbles", size: 30 }), /* @__PURE__ */ React__default.createElement(Text, null, "You don't have any message yet!")))), lightboxProps: {
|
|
1574
1637
|
underlayColor: "transparent",
|
|
1575
1638
|
springConfig: {
|
|
1576
1639
|
tension: 9e4,
|