@messenger-box/platform-mobile 10.0.3-alpha.40 → 10.0.3-alpha.46
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/compute.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/queries/inboxQueries.js +77 -0
- package/lib/queries/inboxQueries.js.map +1 -0
- package/lib/routes.json +2 -3
- package/lib/screens/inbox/DialogThreadMessages.js +3 -7
- package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
- package/lib/screens/inbox/DialogThreads.js +3 -7
- package/lib/screens/inbox/DialogThreads.js.map +1 -1
- package/lib/screens/inbox/components/DialogsListItem.js +47 -46
- package/lib/screens/inbox/components/DialogsListItem.js.map +1 -1
- package/lib/screens/inbox/components/GiftedChatInboxComponent.js +313 -0
- package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
- package/lib/screens/inbox/components/ServiceDialogsListItem.js +72 -57
- package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +115 -14
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
- package/lib/screens/inbox/components/SubscriptionHandler.js +24 -0
- package/lib/screens/inbox/components/SubscriptionHandler.js.map +1 -0
- package/lib/screens/inbox/containers/ConversationView.js +640 -493
- package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/Dialogs.js +100 -181
- package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadConversationView.js +659 -245
- package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadsView.js +3 -3
- package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
- package/lib/screens/inbox/hooks/useInboxMessages.js +31 -0
- package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
- package/package.json +4 -4
- package/src/index.ts +2 -0
- package/src/queries/inboxQueries.ts +298 -0
- package/src/queries/index.d.ts +2 -0
- package/src/queries/index.ts +1 -0
- package/src/screens/inbox/DialogThreadMessages.tsx +3 -11
- package/src/screens/inbox/DialogThreads.tsx +3 -7
- package/src/screens/inbox/components/Actionsheet.tsx +30 -0
- package/src/screens/inbox/components/DialogsListItem.tsx +89 -148
- package/src/screens/inbox/components/ExpandableInput.tsx +460 -0
- package/src/screens/inbox/components/ExpandableInputActionSheet.tsx +518 -0
- package/src/screens/inbox/components/GiftedChatInboxComponent.tsx +411 -0
- package/src/screens/inbox/components/ServiceDialogsListItem.tsx +202 -221
- package/src/screens/inbox/components/SlackInput.tsx +23 -0
- package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +216 -30
- package/src/screens/inbox/components/SubscriptionHandler.tsx +41 -0
- package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +6 -7
- package/src/screens/inbox/containers/ConversationView.tsx +1109 -669
- package/src/screens/inbox/containers/Dialogs.tsx +198 -342
- package/src/screens/inbox/containers/SupportServiceDialogs.tsx +2 -2
- package/src/screens/inbox/containers/ThreadConversationView.tsx +1141 -402
- package/src/screens/inbox/containers/ThreadsView.tsx +5 -5
- package/src/screens/inbox/hooks/useInboxMessages.ts +34 -0
- package/src/screens/inbox/machines/threadsMachine.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.0.3-alpha.46](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.45...v10.0.3-alpha.46) (2025-05-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @messenger-box/platform-mobile
|
|
9
|
+
|
|
10
|
+
## [10.0.3-alpha.43](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.42...v10.0.3-alpha.43) (2025-05-15)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @messenger-box/platform-mobile
|
|
13
|
+
|
|
6
14
|
## [10.0.3-alpha.40](https://github.com/cdmbase/messenger-box/compare/v10.0.3-alpha.39...v10.0.3-alpha.40) (2025-05-14)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @messenger-box/platform-mobile
|
package/lib/compute.js
CHANGED
|
@@ -42,8 +42,7 @@ const inboxPageStore = [{
|
|
|
42
42
|
componentPath: "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreads.js",
|
|
43
43
|
hasComponent: true,
|
|
44
44
|
queries: {
|
|
45
|
-
|
|
46
|
-
ThreadMessagesDocument: "{channelId: params.channelId,role: params.role,limit: params.limit,repliesLimit2: 5}"
|
|
45
|
+
ChannelDetailDocument: "{}"
|
|
47
46
|
}
|
|
48
47
|
}, {
|
|
49
48
|
key: "threadmessage",
|
|
@@ -68,7 +67,7 @@ const inboxPageStore = [{
|
|
|
68
67
|
componentPath: "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreadMessages.js",
|
|
69
68
|
hasComponent: true,
|
|
70
69
|
queries: {
|
|
71
|
-
|
|
70
|
+
ChannelDetailDocument: "{}"
|
|
72
71
|
}
|
|
73
72
|
}];
|
|
74
73
|
const selectedRoutes = ["message", "thread", "threadmessage"];
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import PlatformModule from './module';\n\nimport { Feature } from '@common-stack/client-react';\n\nexport default new Feature(PlatformModule);\n// export * from './navigation';\nexport * from './screens';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import PlatformModule from './module';\n\nimport { Feature } from '@common-stack/client-react';\n// import * as inboxQueries from './queries/inboxQueries';\n\nexport default new Feature(PlatformModule);\n// export * from './navigation';\nexport * from './screens';\n// export { inboxQueries };\n"],"names":[],"mappings":"yUAIA,YAAe,IAAI,QAAQ,cAAc,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {useViewChannelDetailQuery,useThreadMessagesQuery,OnThreadCreatedUpdatedDocument,useSendThreadMessageMutation,OnChatMessageAddedDocument,MessagesDocument,useOnThreadCreatedUpdatedSubscription,useCreatePostThreadMutation,useSendExpoNotificationOnPostMutation,useGetPostThreadLazyQuery,useAddDirectChannelMutation,useSendMessagesMutation,useMessagesQuery,useOnChatMessageAddedSubscription,useGetChannelsByUserWithServiceChannelsQuery}from'common/graphql';export{useMessagesQuery,useThreadMessagesQuery}from'common/graphql';import'react';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const useChannelsQuery = (options = {}) => {
|
|
21
|
+
return useGetChannelsByUserWithServiceChannelsQuery(__spreadProps(__spreadValues({}, options), {
|
|
22
|
+
fetchPolicy: "cache-and-network",
|
|
23
|
+
nextFetchPolicy: "network-only"
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
const useChannelDetailQuery = (channelId, options = {}) => {
|
|
27
|
+
return useViewChannelDetailQuery(__spreadValues({
|
|
28
|
+
variables: {
|
|
29
|
+
channelId
|
|
30
|
+
}
|
|
31
|
+
}, options));
|
|
32
|
+
};
|
|
33
|
+
const useThreadMessagesQueryWithOptions = (variables, options = {}) => {
|
|
34
|
+
return useThreadMessagesQuery(__spreadValues({
|
|
35
|
+
variables,
|
|
36
|
+
fetchPolicy: "cache-and-network",
|
|
37
|
+
refetchWritePolicy: "overwrite",
|
|
38
|
+
nextFetchPolicy: "network-only"
|
|
39
|
+
}, options));
|
|
40
|
+
};
|
|
41
|
+
const useChannelMessagesQuery = (variables = {}, options = {}) => {
|
|
42
|
+
return useMessagesQuery(__spreadValues({
|
|
43
|
+
variables,
|
|
44
|
+
fetchPolicy: "cache-and-network",
|
|
45
|
+
nextFetchPolicy: "cache-first",
|
|
46
|
+
refetchWritePolicy: "merge"
|
|
47
|
+
}, options));
|
|
48
|
+
};
|
|
49
|
+
const useSendChannelMessage = () => {
|
|
50
|
+
return useSendMessagesMutation();
|
|
51
|
+
};
|
|
52
|
+
const useAddDirectChannel = () => {
|
|
53
|
+
return useAddDirectChannelMutation();
|
|
54
|
+
};
|
|
55
|
+
const MESSAGES_DOCUMENT = MessagesDocument;
|
|
56
|
+
const useSendThreadMessage = () => {
|
|
57
|
+
return useSendThreadMessageMutation();
|
|
58
|
+
};
|
|
59
|
+
const useSendExpoNotification = () => {
|
|
60
|
+
return useSendExpoNotificationOnPostMutation();
|
|
61
|
+
};
|
|
62
|
+
const useCreatePostThread = (options = {}) => {
|
|
63
|
+
return useCreatePostThreadMutation(options);
|
|
64
|
+
};
|
|
65
|
+
const CHAT_MESSAGE_ADDED = OnChatMessageAddedDocument;
|
|
66
|
+
const THREAD_CREATED_UPDATED = OnThreadCreatedUpdatedDocument;
|
|
67
|
+
const useThreadCreatedUpdatedSubscription = (options = {}) => {
|
|
68
|
+
return useOnThreadCreatedUpdatedSubscription(__spreadValues({}, options));
|
|
69
|
+
};
|
|
70
|
+
const useChatMessageAddedSubscription = (options = {}) => {
|
|
71
|
+
return useOnChatMessageAddedSubscription(__spreadValues({}, options));
|
|
72
|
+
};
|
|
73
|
+
const useGetPostThreadLazy = (options = {}) => {
|
|
74
|
+
return useGetPostThreadLazyQuery(__spreadValues({
|
|
75
|
+
fetchPolicy: "cache-and-network"
|
|
76
|
+
}, options));
|
|
77
|
+
};export{CHAT_MESSAGE_ADDED,MESSAGES_DOCUMENT,THREAD_CREATED_UPDATED,useAddDirectChannel,useChannelDetailQuery,useChannelMessagesQuery,useChannelsQuery,useChatMessageAddedSubscription,useCreatePostThread,useGetPostThreadLazy,useSendChannelMessage,useSendExpoNotification,useSendThreadMessage,useThreadCreatedUpdatedSubscription,useThreadMessagesQueryWithOptions};//# sourceMappingURL=inboxQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inboxQueries.js","sources":["../../src/queries/inboxQueries.ts"],"sourcesContent":["// Imports from common/graphql\nimport {\n useGetChannelsByUserWithServiceChannelsQuery,\n OnChatMessageAddedDocument,\n OnThreadCreatedUpdatedDocument,\n useViewChannelDetailQuery,\n useThreadMessagesQuery,\n useSupportServiceChannelsQuery,\n useSendThreadMessageMutation,\n useMessagesQuery,\n useSendMessagesMutation,\n useAddDirectChannelMutation,\n MessagesDocument,\n useSendExpoNotificationOnPostMutation,\n useOnThreadCreatedUpdatedSubscription,\n useOnChatMessageAddedSubscription,\n useOnThreadChatMessageAddedSubscription,\n useCreatePostThreadMutation,\n useGetPostThreadLazyQuery,\n} from 'common/graphql';\nimport { useCallback } from 'react';\n\n// ====== CHANNEL QUERIES ======\n\n/**\n * Hook for fetching channels by user including service channels\n * @param options - Query options\n * @returns Query result with data, loading state, refetch and fetchMore functions\n */\nexport const useChannelsQuery = (options: any = {}) => {\n return useGetChannelsByUserWithServiceChannelsQuery({\n ...options,\n fetchPolicy: 'cache-and-network',\n nextFetchPolicy: 'network-only',\n });\n};\n\n/**\n * Hook for fetching service channels\n * @param options - Query options\n * @returns Query result with data, loading state and refetch function\n */\nexport const useServiceChannelsQuery = (options: any = {}) => {\n return useSupportServiceChannelsQuery({\n ...options,\n fetchPolicy: 'cache-and-network',\n });\n};\n\n/**\n * Hook for fetching channel details\n * @param channelId - ID of the channel to fetch\n * @param options - Additional query options\n * @returns Query result with channel details\n */\nexport const useChannelDetailQuery = (channelId: string, options: any = {}) => {\n return useViewChannelDetailQuery({\n variables: { channelId },\n ...options,\n });\n};\n\n// ====== THREAD QUERIES ======\n\n/**\n * Direct export of the thread messages query hook\n */\nexport { useThreadMessagesQuery };\n\n/**\n * Direct export of the messages query hook\n */\nexport { useMessagesQuery };\n\n/**\n * Hook for fetching thread messages with default options\n * @param variables - Query variables including channelId, role, and limit\n * @param options - Additional query options\n * @returns Query result with thread messages data\n */\nexport const useThreadMessagesQueryWithOptions = (variables: any, options: any = {}) => {\n return useThreadMessagesQuery({\n variables,\n fetchPolicy: 'cache-and-network',\n refetchWritePolicy: 'overwrite',\n nextFetchPolicy: 'network-only',\n ...options,\n });\n};\n\n// ====== MESSAGE QUERIES ======\n\n/**\n * Hook for fetching channel messages\n * @param variables - Query variables including channelId, parentId, and pagination params\n * @param options - Additional query options\n * @returns Query result for messages\n */\nexport const useChannelMessagesQuery = (variables: any = {}, options: any = {}) => {\n return useMessagesQuery({\n variables,\n fetchPolicy: 'cache-and-network',\n nextFetchPolicy: 'cache-first',\n refetchWritePolicy: 'merge',\n ...options,\n });\n};\n\n/**\n * Hook for sending messages in a channel\n * @returns Mutation function and result\n */\nexport const useSendChannelMessage = () => {\n return useSendMessagesMutation();\n};\n\n/**\n * Hook for adding a direct channel\n * @returns Mutation function and result\n */\nexport const useAddDirectChannel = () => {\n return useAddDirectChannelMutation();\n};\n\n/**\n * Messages document for queries\n */\nexport const MESSAGES_DOCUMENT = MessagesDocument;\n\n// ====== MUTATIONS ======\n\n/**\n * Hook for sending thread messages\n * @returns Mutation function and result\n */\nexport const useSendThreadMessage = () => {\n return useSendThreadMessageMutation();\n};\n\n/**\n * Hook for sending expo notifications\n * @returns Mutation function and result\n */\nexport const useSendExpoNotification = () => {\n return useSendExpoNotificationOnPostMutation();\n};\n\n/**\n * Hook for creating a post thread\n * @param options - Mutation options\n * @returns Mutation function and result\n */\nexport const useCreatePostThread = (options: any = {}) => {\n return useCreatePostThreadMutation(options);\n};\n\n// ====== SUBSCRIPTION DOCUMENTS ======\n\n/**\n * Document for chat message added subscription\n */\nexport const CHAT_MESSAGE_ADDED = OnChatMessageAddedDocument;\n\n/**\n * Document for thread created/updated subscription\n */\nexport const THREAD_CREATED_UPDATED = OnThreadCreatedUpdatedDocument;\n\n/**\n * Hook for subscribing to thread creation and updates\n * @returns Subscription result for thread creation/update events\n */\nexport const useThreadCreatedUpdatedSubscription = (options: any = {}) => {\n return useOnThreadCreatedUpdatedSubscription({\n ...options,\n });\n};\n\n/**\n * Hook for subscribing to chat message additions\n * @param options - Subscription options including variables like channelId\n * @returns Subscription result for new chat messages\n */\nexport const useChatMessageAddedSubscription = (options: any = {}) => {\n return useOnChatMessageAddedSubscription({\n ...options,\n });\n};\n\n/**\n * Hook for subscribing to thread chat message additions\n * @param options - Subscription options including variables like channelId and threadId\n * @returns Subscription result for new thread chat messages\n */\nexport const useThreadChatMessageAddedSubscription = (options: any = {}) => {\n return useOnThreadChatMessageAddedSubscription({\n ...options,\n });\n};\n\n// ====== LAZY QUERIES ======\n\n/**\n * Hook for lazily fetching a post thread\n * @param options - Lazy query options\n * @returns Lazy query function and result\n */\nexport const useGetPostThreadLazy = (options: any = {}) => {\n return useGetPostThreadLazyQuery({\n fetchPolicy: 'cache-and-network',\n ...options,\n });\n};\n\n// ====== CUSTOM QUERY HOOKS ======\n\n/**\n * Custom hook that combines channels and provides refresh functionality\n */\nexport const useInboxChannels = () => {\n const queryResult = useChannelsQuery();\n\n const refresh = useCallback(() => {\n return queryResult.refetch();\n }, [queryResult.refetch]);\n\n const loadMore = useCallback(\n (page: number) => {\n if (queryResult.loading || !queryResult.data) return;\n\n return queryResult.fetchMore({\n variables: { page },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n\n return {\n ...fetchMoreResult,\n channelsByUser: [...(prev.channelsByUser || []), ...(fetchMoreResult.channelsByUser || [])],\n supportServiceChannels: [\n ...(prev.supportServiceChannels || []),\n ...(fetchMoreResult.supportServiceChannels || []),\n ],\n };\n },\n });\n },\n [queryResult.fetchMore, queryResult.loading, queryResult.data],\n );\n\n return {\n ...queryResult,\n refresh,\n loadMore,\n };\n};\n\n/**\n * Custom hook for thread message operations\n */\nexport const useThreadOperations = (channelId: string, options: any = {}) => {\n const queryResult = useThreadMessagesQueryWithOptions({ channelId, ...options.variables }, options.queryOptions);\n\n const [sendMessage, sendMessageResult] = useSendThreadMessage();\n\n const refresh = useCallback(() => {\n return queryResult.refetch();\n }, [queryResult.refetch]);\n\n const fetchMoreMessages = useCallback(\n (variables: any) => {\n return queryResult.fetchMore({\n variables,\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult?.threadMessages?.data) return prev;\n\n return {\n ...prev,\n threadMessages: {\n ...prev.threadMessages,\n data: [...fetchMoreResult.threadMessages.data, ...(prev.threadMessages?.data || [])],\n },\n };\n },\n });\n },\n [queryResult.fetchMore],\n );\n\n return {\n data: queryResult.data,\n loading: queryResult.loading,\n error: queryResult.error,\n refresh,\n fetchMoreMessages,\n sendMessage,\n sendMessageResult,\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAWO,MAAM,gBAAmB,GAAA,CAAC,OAAe,GAAA,EAAO,KAAA;AACrD,EAAO,OAAA,4CAAA,CAA6C,iCAC/C,OAD+C,CAAA,EAAA;AAAA,IAElD,WAAa,EAAA,mBAAA;AAAA,IACb,eAAiB,EAAA;AAAA,GAClB,CAAA,CAAA;AACH;AAoBO,MAAM,qBA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CAAA,CAAsC,mBACxC,OACJ,CAAA,CAAA;AACH;AAOO,MAAM,+BAAkC,GAAA,CAAC,OAAe,GAAA,EAAO,KAAA;AACpE,EAAO,OAAA,iCAAA,CAAkC,mBACpC,OACJ,CAAA,CAAA;AACH;AAoBO,MAAM,oBAAuB,GAAA,CAAC,OAAe,GAAA,EAAO,KAAA;AACzD,EAAA,OAAO,yBAA0B,CAAA,cAAA,CAAA;AAAA,IAC/B,WAAa,EAAA;AAAA,GAAA,EACV,OACJ,CAAA,CAAA;AACH"}
|
package/lib/routes.json
CHANGED
|
@@ -46,8 +46,7 @@
|
|
|
46
46
|
"componentPath": "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreads.js",
|
|
47
47
|
"hasComponent": true,
|
|
48
48
|
"queries": {
|
|
49
|
-
"
|
|
50
|
-
"ThreadMessagesDocument": "{channelId: params.channelId,role: params.role,limit: params.limit,repliesLimit2: 5}"
|
|
49
|
+
"ChannelDetailDocument": "{}"
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
},
|
|
@@ -75,7 +74,7 @@
|
|
|
75
74
|
"componentPath": "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreadMessages.js",
|
|
76
75
|
"hasComponent": true,
|
|
77
76
|
"queries": {
|
|
78
|
-
"
|
|
77
|
+
"ChannelDetailDocument": "{}"
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-mobile';import {ThreadConversationView}from'./containers/ThreadConversationView.js';import {
|
|
1
|
+
import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-mobile';import {ThreadConversationView}from'./containers/ThreadConversationView.js';import {useChannelDetailQuery,useSendThreadMessage}from'../../queries/inboxQueries.js';import {useFocusEffect}from'@react-navigation/native';import colors from'tailwindcss/colors';function DialogThreadMessages({
|
|
2
2
|
channelId,
|
|
3
3
|
postParentId,
|
|
4
4
|
isPostParentIdThread,
|
|
@@ -8,12 +8,8 @@ import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-
|
|
|
8
8
|
data,
|
|
9
9
|
loading: channelLoading,
|
|
10
10
|
refetch
|
|
11
|
-
} =
|
|
12
|
-
|
|
13
|
-
id: channelId == null ? void 0 : channelId.toString()
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
const [sendThreadMessage] = useSendThreadMessageMutation();
|
|
11
|
+
} = useChannelDetailQuery(channelId == null ? void 0 : channelId.toString(), {});
|
|
12
|
+
const [sendThreadMessage] = useSendThreadMessage();
|
|
17
13
|
const [loading, setLoading] = React.useState(true);
|
|
18
14
|
const [channel, setChannel] = React.useState(null);
|
|
19
15
|
const [parentId, setParentId] = React.useState(postParentId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogThreadMessages.js","sources":["../../../src/screens/inbox/DialogThreadMessages.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport {
|
|
1
|
+
{"version":3,"file":"DialogThreadMessages.js","sources":["../../../src/screens/inbox/DialogThreadMessages.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport { useChannelDetailQuery, useSendThreadMessage } from '../../queries/inboxQueries';\nimport { useFocusEffect } from '@react-navigation/native';\n// import { useSelector } from 'react-redux';\nimport colors from 'tailwindcss/colors';\n\nexport function DialogThreadMessages({ channelId, postParentId, isPostParentIdThread, role }) {\n const { data, loading: channelLoading, refetch } = useChannelDetailQuery(channelId?.toString(), {});\n\n const [sendThreadMessage] = useSendThreadMessage();\n const [loading, setLoading] = React.useState<boolean>(true);\n const [channel, setChannel] = React.useState<any>(null);\n const [parentId, setParentId] = React.useState<any>(postParentId);\n\n const refetchChannelDetail = React.useCallback(\n (id: string) => {\n return refetch({ id: id?.toString() });\n },\n [channelId],\n );\n\n useFocusEffect(\n React.useCallback(() => {\n // Do something when the screen is focused\n if (channelId) refetch({ id: channelId?.toString() });\n return () => {};\n }, [channelId]),\n );\n\n React.useEffect(() => {\n setParentId(postParentId);\n }, [postParentId]);\n\n React.useEffect(() => {\n if (data?.viewChannelDetail) {\n setChannel(data?.viewChannelDetail);\n setLoading(false);\n }\n }, [data]);\n\n // React.useEffect(() => {\n // async function sendInitialMessage(channel: any) {\n // const content = `Welcome to ${channel?.title}`;\n // const createdBy = channel?.creator?.id;\n // await sendThreadMessage({\n // variables: {\n // channelId,\n // threadMessageInput: {\n // content,\n // role,\n // },\n // responderId: createdBy,\n // },\n // update: (cache, { data, errors }: any) => {\n // if (!data) {\n // return;\n // }\n // setParentId(data?.sendThreadMessage?.lastMessage?.id);\n // },\n // });\n // }\n // if ((!parentId || parentId == 0) && channel) {\n // sendInitialMessage(channel);\n // }\n\n // if (parentId) setLoading(false);\n // }, [parentId, channel]);\n\n return (\n <Box className=\"bg-white flex-1\">\n {/* {loading && !parentId ? ( */}\n {loading ? (\n <Spinner color={colors.blue[500]} />\n ) : (\n <ThreadConversationView\n channelId={channelId}\n postParentId={parentId}\n isPostParentIdThread={isPostParentIdThread}\n role={role}\n />\n )}\n </Box>\n );\n}\n\nexport default DialogThreadMessages;\n"],"names":[],"mappings":"wVAQO,SAAS,oBAAqB,CAAA;AAAA,EACnC,SAAA;AAAA,EACA,YAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAS,EAAA,cAAA;AAAA,IACT;AAAA,GACE,GAAA,qBAAA,CAAsB,SAAW,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,QAAA,EAAA,EAAY,EAAE,CAAA;AACnD,EAAM,M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,GAAM,CAAA,EAAA,CAAA,uCAAM,sBAAuB,EAAA,EAAA,SAAA,EAAsB,cAAc,QAAU,EAAA,oBAAA,EAA4C,MAAY,CACpL,CAAA;AACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import {Spinner,Box}from'@admin-layout/gluestack-ui-mobile';import {ThreadsView}from'./containers/ThreadsView.js';import {
|
|
1
|
+
import*as React from'react';import {Spinner,Box}from'@admin-layout/gluestack-ui-mobile';import {ThreadsView}from'./containers/ThreadsView.js';import {useChannelDetailQuery,useThreadMessagesQueryWithOptions}from'../../queries/inboxQueries.js';import {useFocusEffect}from'@react-navigation/native';import {config}from'./config/config.js';import colors from'tailwindcss/colors';import {useSafeDialogThreadsMachine}from'./hooks/useSafeDialogThreadsMachine.js';import {Actions,BaseState}from'./workflow/dialog-threads-xstate.js';const {
|
|
2
2
|
MESSAGES_PER_PAGE
|
|
3
3
|
} = config;
|
|
4
4
|
function DialogThreads({
|
|
@@ -20,18 +20,14 @@ function DialogThreads({
|
|
|
20
20
|
data: channelData,
|
|
21
21
|
loading: channelLoading,
|
|
22
22
|
refetch: channelRefetch
|
|
23
|
-
} =
|
|
24
|
-
variables: {
|
|
25
|
-
id: channelId == null ? void 0 : channelId.toString()
|
|
26
|
-
}
|
|
27
|
-
});
|
|
23
|
+
} = useChannelDetailQuery(channelId == null ? void 0 : channelId.toString(), {});
|
|
28
24
|
const {
|
|
29
25
|
data: threadsData,
|
|
30
26
|
loading: threadLoading,
|
|
31
27
|
error: threadsError,
|
|
32
28
|
refetch: threadsRefetch,
|
|
33
29
|
subscribeToMore: threadsSubscribeToMore
|
|
34
|
-
} =
|
|
30
|
+
} = useThreadMessagesQueryWithOptions({
|
|
35
31
|
variables: {
|
|
36
32
|
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
37
33
|
role: role == null ? void 0 : role.toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogThreads.js","sources":["../../../src/screens/inbox/DialogThreads.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport {
|
|
1
|
+
{"version":3,"file":"DialogThreads.js","sources":["../../../src/screens/inbox/DialogThreads.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport { useChannelDetailQuery, useThreadMessagesQueryWithOptions } from '../../queries/inboxQueries';\nimport { useFocusEffect } from '@react-navigation/native';\nimport { useSelector } from 'react-redux';\nimport { config } from './config';\nimport colors from 'tailwindcss/colors';\nimport { useSafeDialogThreadsMachine } from './hooks/useSafeDialogThreadsMachine';\nimport { Actions, BaseState } from './workflow/dialog-threads-xstate';\nconst { MESSAGES_PER_PAGE } = config;\n\nexport function DialogThreads({ channelId, postParentId, role }) {\n // Use the XState machine for state management\n const [state, send] = useSafeDialogThreadsMachine();\n const { context, value } = state;\n const { channelsDetail, loading, error } = context;\n\n // Fetch channel details\n const {\n data: channelData,\n loading: channelLoading,\n refetch: channelRefetch,\n } = useChannelDetailQuery(channelId?.toString(), {});\n\n // Fetch thread messages\n const {\n data: threadsData,\n loading: threadLoading,\n error: threadsError,\n refetch: threadsRefetch,\n subscribeToMore: threadsSubscribeToMore,\n } = useThreadMessagesQueryWithOptions({\n variables: {\n channelId: channelId?.toString(),\n role: role?.toString(),\n limit: MESSAGES_PER_PAGE,\n repliesLimit2: 5,\n },\n });\n\n // Initialize the machine with props\n React.useEffect(() => {\n send({\n type: Actions.INITIALIZE,\n data: { channelId, postParentId, role },\n });\n }, [channelId, postParentId, role]);\n\n // Update channel detail in state when data changes\n React.useEffect(() => {\n if (channelData?.viewChannelDetail) {\n send({\n type: Actions.SET_CHANNEL_DETAIL,\n data: { channelsDetail: channelData.viewChannelDetail },\n });\n }\n }, [channelData]);\n\n // Update thread data in state when data changes\n React.useEffect(() => {\n if (threadsData) {\n send({\n type: Actions.SET_THREADS,\n data: { threadData: threadsData?.threadMessages?.data || [] },\n });\n }\n }, [threadsData]);\n\n // Handle errors\n React.useEffect(() => {\n if (threadsError) {\n send({\n type: Actions.ERROR,\n data: { error: threadsError },\n });\n }\n }, [threadsError]);\n\n const refetchChannelDetail = React.useCallback(\n (id: string) => {\n return channelRefetch({ id: id?.toString() });\n },\n [channelId],\n );\n\n useFocusEffect(\n React.useCallback(() => {\n // Do something when the screen is focused\n if (channelId) refetchChannelDetail(channelId);\n return () => {};\n }, []),\n );\n\n return (\n <>\n {state.matches(BaseState.LoadingChannel) || channelLoading ? (\n <Spinner color={colors.blue[500]} />\n ) : (\n <>\n <Box className=\"flex-1 bg-gray-200 dark:border-gray-500 dark:bg-gray-500\">\n <ThreadsView\n data={threadsData}\n loading={threadLoading || state.matches(BaseState.LoadingThreads)}\n refetch={threadsRefetch}\n subscribeToMore={threadsSubscribeToMore}\n error={error || threadsError}\n channelId={channelId}\n role={role}\n channelsDetail={channelsDetail}\n refetchChannelDetail={refetchChannelDetail}\n />\n </Box>\n </>\n )}\n </>\n );\n}\n\nexport default DialogThreads;\n"],"names":[],"mappings":"4gBAWA,MAAM;AAAA,EACJ;AACF,CAAI,GAAA,MAAA;AACG,SAAS,aAAc,CAAA;AAAA,EAC5B,SAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAG,EAAA;AAED,EAAA,MAAM,CAAC,KAAA,EAAO,IAAI,CAAA,GAAI,2BAA4B,EAAA;AAClD,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,cAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACE,GAAA,OAAA;AAGJ,EAAM,MAAA;AAAA,IACJ,IAAM,EAAA,WAAA;AAAA,IACN,OAAS,EAAA,cA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,WAAa,EAAA,OAAA,EAAS,iBAAiB,KAAM,CAAA,OAAA,CAAQ,UAAU,cAAc,CAAA,EAAG,SAAS,cAAgB,EAAA,eAAA,EAAiB,wBAAwB,KAAO,EAAA,KAAA,IAAS,cAAc,SAAsB,EAAA,IAAA,EAAY,gBAAgC,oBAA4C,EAAA,CACrT,CACJ,CACR,CAAA;AACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default,{useRef,useState,useEffect,useCallback,useMemo}from'react';import {Pressable,HStack,Box,AvatarGroup,Avatar,AvatarFallbackText,AvatarBadge,Text,AvatarImage}from'@admin-layout/gluestack-ui-mobile';import {isToday,isYesterday,format}from'date-fns';import {useFocusEffect}from'@react-navigation/native';import {
|
|
1
|
+
import React__default,{useRef,useState,useEffect,useCallback,useMemo}from'react';import {Pressable,HStack,Box,AvatarGroup,Avatar,AvatarFallbackText,AvatarBadge,Text,AvatarImage}from'@admin-layout/gluestack-ui-mobile';import {isToday,isYesterday,format}from'date-fns';import {useFocusEffect}from'@react-navigation/native';import {useChatMessageAddedSubscription,CHAT_MESSAGE_ADDED}from'../../../queries/inboxQueries.js';import {startCase}from'lodash-es';import colors from'tailwindcss/colors';import {SubscriptionHandler}from'./SubscriptionHandler.js';import {useMessagesQuery}from'common/graphql';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -31,7 +31,8 @@ const LastMessageComponent = ({
|
|
|
31
31
|
subscribeToNewMessages,
|
|
32
32
|
title,
|
|
33
33
|
lastMessage,
|
|
34
|
-
channelId
|
|
34
|
+
channelId,
|
|
35
|
+
subscribeToMore
|
|
35
36
|
}) => {
|
|
36
37
|
var _a, _b;
|
|
37
38
|
React__default.useEffect(() => {
|
|
@@ -55,14 +56,25 @@ const LastMessageComponent = ({
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
const displayDate = (lastMessage == null ? void 0 : lastMessage.createdAt) ? createdAtText(lastMessage.createdAt) : (lastMessage == null ? void 0 : lastMessage.updatedAt) ? createdAtText(lastMessage.updatedAt) : "";
|
|
58
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
59
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
60
|
+
SubscriptionHandler,
|
|
61
|
+
{
|
|
62
|
+
subscribeToMore,
|
|
63
|
+
document: CHAT_MESSAGE_ADDED,
|
|
64
|
+
variables: {
|
|
65
|
+
channelId: channelId == null ? void 0 : channelId.toString()
|
|
66
|
+
},
|
|
67
|
+
updateQuery: void 0
|
|
68
|
+
}
|
|
69
|
+
), /* @__PURE__ */ React__default.createElement(HStack, { space: "sm", className: "flex-1 justify-between" }, /* @__PURE__ */ React__default.createElement(Box, { className: "flex-[0.8]" }, /* @__PURE__ */ React__default.createElement(Text, { color: colors.gray[600], className: "text-base text-wrap flex-wrap font-semibold" }, channelTitle), /* @__PURE__ */ React__default.createElement(Text, { color: colors.gray[600], numberOfLines: 1 }, displayMessage)), /* @__PURE__ */ React__default.createElement(Box, { className: "flex-[0.2]" }, /* @__PURE__ */ React__default.createElement(Text, { color: colors.gray[500] }, displayDate))));
|
|
59
70
|
};
|
|
60
71
|
const DialogsListItemComponent = function DialogsListItem2({
|
|
61
72
|
currentUser,
|
|
62
73
|
selectedChannelId,
|
|
63
74
|
channel,
|
|
64
75
|
onOpen,
|
|
65
|
-
forceRefresh
|
|
76
|
+
forceRefresh,
|
|
77
|
+
visible = true
|
|
66
78
|
}) {
|
|
67
79
|
var _a, _b, _c, _d;
|
|
68
80
|
const isMountedRef = useRef(true);
|
|
@@ -71,6 +83,7 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
71
83
|
const [title, setTitle] = useState("");
|
|
72
84
|
const [messages, setMessages] = useState([]);
|
|
73
85
|
const [lastMessage, setLastMessage] = useState(null);
|
|
86
|
+
const shouldQuery = !!(channel == null ? void 0 : channel.id) && visible;
|
|
74
87
|
const {
|
|
75
88
|
data: messagesQuery,
|
|
76
89
|
loading: messageLoading,
|
|
@@ -82,13 +95,15 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
82
95
|
parentId,
|
|
83
96
|
limit: 10
|
|
84
97
|
},
|
|
98
|
+
skip: !shouldQuery,
|
|
85
99
|
fetchPolicy: "cache-and-network",
|
|
86
100
|
refetchWritePolicy: "overwrite",
|
|
87
101
|
nextFetchPolicy: "network-only",
|
|
88
102
|
onCompleted: (data) => {
|
|
89
|
-
var _a2
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
var _a2;
|
|
104
|
+
if (!shouldQuery)
|
|
105
|
+
return;
|
|
106
|
+
if ((_a2 = data == null ? void 0 : data.messages) == null ? void 0 : _a2.data) {
|
|
92
107
|
setMessages(data.messages.data);
|
|
93
108
|
const sortedMessages = [...data.messages.data].sort((a, b) => new Date((b == null ? void 0 : b.updatedAt) || (b == null ? void 0 : b.createdAt)).getTime() - new Date((a == null ? void 0 : a.updatedAt) || (a == null ? void 0 : a.createdAt)).getTime());
|
|
94
109
|
if (sortedMessages.length > 0) {
|
|
@@ -97,17 +112,18 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
97
112
|
}
|
|
98
113
|
},
|
|
99
114
|
onError: (error) => {
|
|
115
|
+
if (!shouldQuery)
|
|
116
|
+
return;
|
|
100
117
|
console.error(`Error fetching messages for channel ${channel == null ? void 0 : channel.id}:`, error);
|
|
101
118
|
}
|
|
102
119
|
});
|
|
103
120
|
const {
|
|
104
|
-
data: newMessage
|
|
105
|
-
|
|
106
|
-
error: newMsgError
|
|
107
|
-
} = useOnChatMessageAddedSubscription({
|
|
121
|
+
data: newMessage
|
|
122
|
+
} = useChatMessageAddedSubscription({
|
|
108
123
|
variables: {
|
|
109
124
|
channelId: (_b = channel == null ? void 0 : channel.id) == null ? void 0 : _b.toString()
|
|
110
|
-
}
|
|
125
|
+
},
|
|
126
|
+
skip: !shouldQuery
|
|
111
127
|
});
|
|
112
128
|
useEffect(() => {
|
|
113
129
|
isMountedRef.current = true;
|
|
@@ -117,8 +133,7 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
117
133
|
}, []);
|
|
118
134
|
const refreshDialogState = useCallback(() => {
|
|
119
135
|
var _a2;
|
|
120
|
-
if (
|
|
121
|
-
console.log("Forcing dialog state refresh for channel:", channel == null ? void 0 : channel.id);
|
|
136
|
+
if (shouldQuery && isMountedRef.current) {
|
|
122
137
|
setLoading(true);
|
|
123
138
|
const options = {
|
|
124
139
|
channelId: (_a2 = channel == null ? void 0 : channel.id) == null ? void 0 : _a2.toString(),
|
|
@@ -126,18 +141,10 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
126
141
|
limit: 10
|
|
127
142
|
};
|
|
128
143
|
refetchMessages(options).then((result) => {
|
|
129
|
-
var _a3, _b2
|
|
144
|
+
var _a3, _b2;
|
|
130
145
|
if (((_b2 = (_a3 = result.data) == null ? void 0 : _a3.messages) == null ? void 0 : _b2.data) && isMountedRef.current) {
|
|
131
|
-
console.log(`Refreshed ${result.data.messages.data.length} messages for channel ${channel == null ? void 0 : channel.id}`);
|
|
132
146
|
const sortedMessages = [...result.data.messages.data].sort((a, b) => new Date((b == null ? void 0 : b.updatedAt) || (b == null ? void 0 : b.createdAt)).getTime() - new Date((a == null ? void 0 : a.updatedAt) || (a == null ? void 0 : a.createdAt)).getTime());
|
|
133
147
|
const latestMessage = sortedMessages.length > 0 ? sortedMessages[0] : null;
|
|
134
|
-
if (latestMessage) {
|
|
135
|
-
console.log("Latest message after refresh:", {
|
|
136
|
-
id: latestMessage.id,
|
|
137
|
-
message: ((_c2 = latestMessage.message) == null ? void 0 : _c2.substring(0, 20)) + "...",
|
|
138
|
-
date: latestMessage.createdAt || latestMessage.updatedAt
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
148
|
setMessages(result.data.messages.data);
|
|
142
149
|
setLastMessage(latestMessage);
|
|
143
150
|
}
|
|
@@ -147,7 +154,7 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
147
154
|
setLoading(false);
|
|
148
155
|
});
|
|
149
156
|
}
|
|
150
|
-
}, [channel == null ? void 0 : channel.id, refetchMessages,
|
|
157
|
+
}, [shouldQuery, channel == null ? void 0 : channel.id, refetchMessages, parentId]);
|
|
151
158
|
const firstRenderRef = useRef(true);
|
|
152
159
|
useFocusEffect(React__default.useCallback(() => {
|
|
153
160
|
if (!(channel == null ? void 0 : channel.id))
|
|
@@ -196,10 +203,11 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
196
203
|
};
|
|
197
204
|
}, [channel == null ? void 0 : channel.id, refetchMessages, messages, isMountedRef, parentId]));
|
|
198
205
|
useEffect(() => {
|
|
206
|
+
if (!shouldQuery)
|
|
207
|
+
return;
|
|
199
208
|
if ((channel == null ? void 0 : channel.id) && isMountedRef.current) {
|
|
200
209
|
const timer = setTimeout(() => {
|
|
201
210
|
if (isMountedRef.current) {
|
|
202
|
-
console.log("Initial data refresh for channel:", channel.id);
|
|
203
211
|
refreshDialogState();
|
|
204
212
|
}
|
|
205
213
|
}, 100);
|
|
@@ -207,10 +215,9 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
207
215
|
clearTimeout(timer);
|
|
208
216
|
};
|
|
209
217
|
}
|
|
210
|
-
}, [channel == null ? void 0 : channel.id, refreshDialogState
|
|
218
|
+
}, [shouldQuery, channel == null ? void 0 : channel.id, refreshDialogState]);
|
|
211
219
|
useEffect(() => {
|
|
212
|
-
if (forceRefresh && (channel == null ? void 0 : channel.id) && isMountedRef.current) {
|
|
213
|
-
console.log(`Force refreshing messages for channel ${channel == null ? void 0 : channel.id} due to forceRefresh prop`);
|
|
220
|
+
if (forceRefresh && shouldQuery && (channel == null ? void 0 : channel.id) && isMountedRef.current) {
|
|
214
221
|
const timer = setTimeout(() => {
|
|
215
222
|
var _a2;
|
|
216
223
|
if (isMountedRef.current && refetchMessages) {
|
|
@@ -221,7 +228,6 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
221
228
|
}).then((result) => {
|
|
222
229
|
var _a3, _b2;
|
|
223
230
|
if (((_b2 = (_a3 = result == null ? void 0 : result.data) == null ? void 0 : _a3.messages) == null ? void 0 : _b2.data) && isMountedRef.current) {
|
|
224
|
-
console.log(`Force refresh completed for channel ${channel == null ? void 0 : channel.id} with ${result.data.messages.data.length} messages`);
|
|
225
231
|
const sortedMessages = [...result.data.messages.data].sort((a, b) => new Date((b == null ? void 0 : b.updatedAt) || (b == null ? void 0 : b.createdAt)).getTime() - new Date((a == null ? void 0 : a.updatedAt) || (a == null ? void 0 : a.createdAt)).getTime());
|
|
226
232
|
const latestMessage = sortedMessages.length > 0 ? sortedMessages[0] : null;
|
|
227
233
|
setMessages(result.data.messages.data);
|
|
@@ -234,7 +240,7 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
234
240
|
}, 50);
|
|
235
241
|
return () => clearTimeout(timer);
|
|
236
242
|
}
|
|
237
|
-
}, [channel == null ? void 0 : channel.id, forceRefresh,
|
|
243
|
+
}, [shouldQuery, channel == null ? void 0 : channel.id, forceRefresh, refetchMessages, parentId]);
|
|
238
244
|
const channelMembers = useMemo(() => {
|
|
239
245
|
var _a2, _b2, _c2;
|
|
240
246
|
return (_c2 = (_b2 = (_a2 = channel == null ? void 0 : channel.members) == null ? void 0 : _a2.filter((ch) => {
|
|
@@ -251,7 +257,7 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
251
257
|
})) == null ? void 0 : _a2.filter((mu) => mu)) == null ? void 0 : _b2.join(", ")) != null ? _c2 : "";
|
|
252
258
|
setTitle(titleString);
|
|
253
259
|
}
|
|
254
|
-
}, [channelMembers
|
|
260
|
+
}, [channelMembers]);
|
|
255
261
|
const displayTitle = useMemo(() => {
|
|
256
262
|
const length = 30;
|
|
257
263
|
return title.length > length ? title.substring(0, length - 3) + "..." : title;
|
|
@@ -265,32 +271,27 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
265
271
|
});
|
|
266
272
|
}, [channel == null ? void 0 : channel.id, lastMessage, messages.length]);
|
|
267
273
|
useEffect(() => {
|
|
268
|
-
|
|
274
|
+
if (!shouldQuery)
|
|
275
|
+
return;
|
|
269
276
|
if ((newMessage == null ? void 0 : newMessage.chatMessageAdded) && (channel == null ? void 0 : channel.id)) {
|
|
270
277
|
const incomingMessage = newMessage.chatMessageAdded;
|
|
271
278
|
if (messages.some((msg) => msg.id === incomingMessage.id)) {
|
|
272
|
-
console.log("Message already in local state, skipping update:", incomingMessage.id);
|
|
273
279
|
return;
|
|
274
280
|
}
|
|
275
|
-
console.log("New message received from subscription:", {
|
|
276
|
-
channelId: channel.id,
|
|
277
|
-
messageId: incomingMessage.id,
|
|
278
|
-
message: ((_a2 = incomingMessage.message) == null ? void 0 : _a2.substring(0, 20)) + "...",
|
|
279
|
-
timestamp: incomingMessage.createdAt
|
|
280
|
-
});
|
|
281
281
|
setMessages((prevMessages) => [...prevMessages, incomingMessage]);
|
|
282
282
|
setLastMessage(incomingMessage);
|
|
283
283
|
}
|
|
284
|
-
}, [newMessage, channel == null ? void 0 : channel.id, messages]);
|
|
284
|
+
}, [shouldQuery, newMessage, channel == null ? void 0 : channel.id, messages]);
|
|
285
285
|
useEffect(() => {
|
|
286
|
+
if (!shouldQuery)
|
|
287
|
+
return;
|
|
286
288
|
if ((channel == null ? void 0 : channel.lastMessage) && channel.lastMessage.id) {
|
|
287
|
-
console.log("Channel has lastMessage property:", channel.lastMessage.id);
|
|
288
289
|
if (!messages.some((msg) => msg.id === channel.lastMessage.id)) {
|
|
289
290
|
setMessages((prevMessages) => [...prevMessages, channel.lastMessage]);
|
|
290
291
|
setLastMessage(channel.lastMessage);
|
|
291
292
|
}
|
|
292
293
|
}
|
|
293
|
-
}, [(_c = channel == null ? void 0 : channel.lastMessage) == null ? void 0 : _c.id, messages]);
|
|
294
|
+
}, [shouldQuery, (_c = channel == null ? void 0 : channel.lastMessage) == null ? void 0 : _c.id, messages]);
|
|
294
295
|
return /* @__PURE__ */ React__default.createElement(Pressable, { onPress: () => onOpen(channel == null ? void 0 : channel.id, displayTitle), className: "flex-1 border-gray-200 rounded-md dark:border-gray-600 dark:bg-gray-700", style: {
|
|
295
296
|
borderBottomWidth: 1,
|
|
296
297
|
borderColor: "#e5e7eb",
|
|
@@ -319,8 +320,8 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
319
320
|
} })));
|
|
320
321
|
})))), /* @__PURE__ */ React__default.createElement(Box, { className: "flex-1" }, /* @__PURE__ */ React__default.createElement(LastMessageComponent, { key: `last-msg-${(lastMessage == null ? void 0 : lastMessage.id) || "none"}-${messages.length}`, title: displayTitle, lastMessage, channelId: channel == null ? void 0 : channel.id, subscribeToNewMessages: () => {
|
|
321
322
|
var _a2;
|
|
322
|
-
return subscribeToMore({
|
|
323
|
-
document:
|
|
323
|
+
return shouldQuery ? subscribeToMore({
|
|
324
|
+
document: CHAT_MESSAGE_ADDED,
|
|
324
325
|
variables: {
|
|
325
326
|
channelId: (_a2 = channel.id) == null ? void 0 : _a2.toString()
|
|
326
327
|
},
|
|
@@ -348,7 +349,7 @@ const DialogsListItemComponent = function DialogsListItem2({
|
|
|
348
349
|
});
|
|
349
350
|
return merged;
|
|
350
351
|
}
|
|
351
|
-
});
|
|
352
|
-
} }))));
|
|
352
|
+
}) : void 0;
|
|
353
|
+
}, subscribeToMore }))));
|
|
353
354
|
};
|
|
354
355
|
const DialogsListItem = React__default.memo(DialogsListItemComponent);export{DialogsListItem,DialogsListItemComponent};//# sourceMappingURL=DialogsListItem.js.map
|