@messenger-box/platform-mobile 10.0.3-alpha.5 → 10.0.3-alpha.54
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 +96 -0
- package/lib/compute.js +2 -3
- package/lib/compute.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/queries/inboxQueries.js +65 -0
- package/lib/queries/inboxQueries.js.map +1 -0
- package/lib/routes.json +2 -3
- package/lib/screens/inbox/DialogMessages.js +1 -1
- package/lib/screens/inbox/DialogMessages.js.map +1 -1
- package/lib/screens/inbox/DialogThreadMessages.js +4 -8
- package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
- package/lib/screens/inbox/DialogThreads.js +57 -12
- package/lib/screens/inbox/DialogThreads.js.map +1 -1
- package/lib/screens/inbox/Inbox.js +1 -1
- package/lib/screens/inbox/Inbox.js.map +1 -1
- package/lib/screens/inbox/components/CachedImage/consts.js +1 -1
- package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
- package/lib/screens/inbox/components/CachedImage/index.js +168 -46
- package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
- package/lib/screens/inbox/components/DialogItem.js +169 -0
- package/lib/screens/inbox/components/DialogItem.js.map +1 -0
- package/lib/screens/inbox/components/GiftedChatInboxComponent.js +313 -0
- package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +147 -31
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +6 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.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/components/ThreadsViewItem.js +66 -55
- package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
- package/lib/screens/inbox/config/config.js +2 -2
- package/lib/screens/inbox/config/config.js.map +1 -1
- package/lib/screens/inbox/containers/ConversationView.js +1111 -434
- package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/Dialogs.js +193 -80
- package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadConversationView.js +725 -216
- 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/useInboxMessages.js +31 -0
- package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
- 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 +4 -4
- package/src/compute.ts +5 -6
- package/src/index.ts +2 -0
- package/src/navigation/InboxNavigation.tsx +3 -3
- package/src/queries/inboxQueries.ts +299 -0
- package/src/queries/index.d.ts +2 -0
- package/src/queries/index.ts +1 -0
- package/src/screens/inbox/DialogMessages.tsx +1 -1
- package/src/screens/inbox/DialogThreadMessages.tsx +7 -14
- package/src/screens/inbox/DialogThreads.tsx +55 -61
- package/src/screens/inbox/Inbox.tsx +1 -1
- package/src/screens/inbox/components/Actionsheet.tsx +30 -0
- package/src/screens/inbox/components/CachedImage/consts.ts +4 -3
- package/src/screens/inbox/components/CachedImage/index.tsx +232 -61
- package/src/screens/inbox/components/DialogItem.tsx +306 -0
- package/src/screens/inbox/components/DialogsHeader.tsx +6 -13
- package/src/screens/inbox/components/DialogsListItem.tsx +262 -198
- 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 +337 -194
- package/src/screens/inbox/components/SlackInput.tsx +23 -0
- package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +233 -23
- package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +1 -1
- package/src/screens/inbox/components/SmartLoader.tsx +61 -0
- package/src/screens/inbox/components/SubscriptionHandler.tsx +41 -0
- package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +53 -55
- package/src/screens/inbox/components/ThreadsViewItem.tsx +178 -285
- package/src/screens/inbox/components/workflow/dialogs-list-item-xstate.ts +145 -0
- package/src/screens/inbox/components/workflow/service-dialogs-list-item-xstate.ts +159 -0
- package/src/screens/inbox/config/config.ts +2 -2
- package/src/screens/inbox/containers/ConversationView.tsx +1843 -702
- package/src/screens/inbox/containers/ConversationView.tsx.bk +1467 -0
- package/src/screens/inbox/containers/Dialogs.tsx +402 -204
- package/src/screens/inbox/containers/SupportServiceDialogs.tsx +4 -4
- package/src/screens/inbox/containers/ThreadConversationView.tsx +1350 -319
- package/src/screens/inbox/containers/ThreadsView.tsx +105 -193
- package/src/screens/inbox/containers/workflow/apollo/handleResult.ts +20 -0
- package/src/screens/inbox/containers/workflow/conversation-xstate.ts +313 -0
- package/src/screens/inbox/containers/workflow/dialogs-xstate.ts +196 -0
- package/src/screens/inbox/containers/workflow/thread-conversation-xstate.ts +401 -0
- package/src/screens/inbox/hooks/useInboxMessages.ts +34 -0
- 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
- package/tsconfig.json +11 -54
- package/lib/screens/inbox/components/DialogsListItem.js +0 -171
- package/lib/screens/inbox/components/DialogsListItem.js.map +0 -1
- package/lib/screens/inbox/components/ServiceDialogsListItem.js +0 -171
- package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +0 -1
package/src/compute.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
2
|
import { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';
|
|
3
|
-
import {
|
|
4
|
-
import { IPageStore } from '@adminide-stack/core/lib/interfaces/page-store.js';
|
|
3
|
+
import type { IRouteModule } from '@common-stack/core';
|
|
5
4
|
|
|
6
|
-
export const inboxPageStore:
|
|
5
|
+
export const inboxPageStore: IRouteModule[] = [
|
|
7
6
|
{
|
|
8
7
|
key: 'message',
|
|
9
8
|
path: '/message',
|
|
@@ -57,8 +56,8 @@ export const inboxPageStore: IPageStore[] = [
|
|
|
57
56
|
},
|
|
58
57
|
];
|
|
59
58
|
|
|
60
|
-
const selectedRoutes = ['message', 'thread','threadmessage'];
|
|
59
|
+
const selectedRoutes = ['message', 'thread', 'threadmessage'];
|
|
61
60
|
|
|
62
|
-
const filteredRoutes
|
|
61
|
+
const filteredRoutes = getFilteredRoutes(inboxPageStore, selectedRoutes);
|
|
63
62
|
|
|
64
|
-
export { filteredRoutes };
|
|
63
|
+
export { filteredRoutes };
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import PlatformModule from './module';
|
|
2
2
|
|
|
3
3
|
import { Feature } from '@common-stack/client-react';
|
|
4
|
+
// import * as inboxQueries from './queries/inboxQueries';
|
|
4
5
|
|
|
5
6
|
export default new Feature(PlatformModule);
|
|
6
7
|
// export * from './navigation';
|
|
7
8
|
export * from './screens';
|
|
9
|
+
// export { inboxQueries };
|
|
@@ -28,7 +28,7 @@ const inboxConfig = {
|
|
|
28
28
|
gestureEnabled: false,
|
|
29
29
|
swipeEnabled: false,
|
|
30
30
|
headerLeft: (props: any) => (
|
|
31
|
-
<Button
|
|
31
|
+
<Button className="bg-transparent" onPress={() => navigation.goBack()}>
|
|
32
32
|
<MaterialIcons size={20} name="arrow-back-ios" color={'black'} />
|
|
33
33
|
</Button>
|
|
34
34
|
),
|
|
@@ -57,7 +57,7 @@ const inboxConfig = {
|
|
|
57
57
|
gestureEnabled: false,
|
|
58
58
|
swipeEnabled: false,
|
|
59
59
|
headerLeft: (props: any) => (
|
|
60
|
-
<Button
|
|
60
|
+
<Button className="bg-transparent" onPress={() => navigation.goBack()}>
|
|
61
61
|
<MaterialIcons size={20} name="arrow-back-ios" color={'black'} />
|
|
62
62
|
</Button>
|
|
63
63
|
),
|
|
@@ -87,7 +87,7 @@ const inboxConfig = {
|
|
|
87
87
|
gestureEnabled: false,
|
|
88
88
|
swipeEnabled: false,
|
|
89
89
|
headerLeft: (props: any) => (
|
|
90
|
-
<Button
|
|
90
|
+
<Button className="bg-transparent" onPress={() => navigation.goBack()}>
|
|
91
91
|
<MaterialIcons size={20} name="arrow-back-ios" color={'black'} />
|
|
92
92
|
</Button>
|
|
93
93
|
),
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// Imports from common/graphql
|
|
2
|
+
import {
|
|
3
|
+
useGetChannelsByUserWithServiceChannelsQuery,
|
|
4
|
+
useGetChannelsByUserQuery,
|
|
5
|
+
OnChatMessageAddedDocument,
|
|
6
|
+
OnThreadCreatedUpdatedDocument,
|
|
7
|
+
useViewChannelDetailQuery,
|
|
8
|
+
useThreadMessagesQuery,
|
|
9
|
+
useSupportServiceChannelsQuery,
|
|
10
|
+
useSendThreadMessageMutation,
|
|
11
|
+
useMessagesQuery,
|
|
12
|
+
useSendMessagesMutation,
|
|
13
|
+
useAddDirectChannelMutation,
|
|
14
|
+
MessagesDocument,
|
|
15
|
+
useSendExpoNotificationOnPostMutation,
|
|
16
|
+
useOnThreadCreatedUpdatedSubscription,
|
|
17
|
+
useOnChatMessageAddedSubscription,
|
|
18
|
+
useOnThreadChatMessageAddedSubscription,
|
|
19
|
+
useCreatePostThreadMutation,
|
|
20
|
+
useGetPostThreadLazyQuery,
|
|
21
|
+
} from 'common/graphql';
|
|
22
|
+
import { useCallback } from 'react';
|
|
23
|
+
|
|
24
|
+
// ====== CHANNEL QUERIES ======
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook for fetching channels by user including service channels
|
|
28
|
+
* @param options - Query options
|
|
29
|
+
* @returns Query result with data, loading state, refetch and fetchMore functions
|
|
30
|
+
*/
|
|
31
|
+
export const useChannelsQuery = (options: any = {}) => {
|
|
32
|
+
return useGetChannelsByUserQuery({
|
|
33
|
+
...options,
|
|
34
|
+
fetchPolicy: 'cache-and-network',
|
|
35
|
+
//nextFetchPolicy: 'network-only',
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Hook for fetching service channels
|
|
41
|
+
* @param options - Query options
|
|
42
|
+
* @returns Query result with data, loading state and refetch function
|
|
43
|
+
*/
|
|
44
|
+
export const useServiceChannelsQuery = (options: any = {}) => {
|
|
45
|
+
return useSupportServiceChannelsQuery({
|
|
46
|
+
...options,
|
|
47
|
+
fetchPolicy: 'cache-and-network',
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Hook for fetching channel details
|
|
53
|
+
* @param channelId - ID of the channel to fetch
|
|
54
|
+
* @param options - Additional query options
|
|
55
|
+
* @returns Query result with channel details
|
|
56
|
+
*/
|
|
57
|
+
export const useChannelDetailQuery = (channelId: string, options: any = {}) => {
|
|
58
|
+
return useViewChannelDetailQuery({
|
|
59
|
+
variables: { channelId },
|
|
60
|
+
...options,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// ====== THREAD QUERIES ======
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Direct export of the thread messages query hook
|
|
68
|
+
*/
|
|
69
|
+
export { useThreadMessagesQuery };
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Direct export of the messages query hook
|
|
73
|
+
*/
|
|
74
|
+
export { useMessagesQuery };
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Hook for fetching thread messages with default options
|
|
78
|
+
* @param variables - Query variables including channelId, role, and limit
|
|
79
|
+
* @param options - Additional query options
|
|
80
|
+
* @returns Query result with thread messages data
|
|
81
|
+
*/
|
|
82
|
+
export const useThreadMessagesQueryWithOptions = (variables: any, options: any = {}) => {
|
|
83
|
+
return useThreadMessagesQuery({
|
|
84
|
+
variables,
|
|
85
|
+
fetchPolicy: 'cache-and-network',
|
|
86
|
+
refetchWritePolicy: 'overwrite',
|
|
87
|
+
nextFetchPolicy: 'network-only',
|
|
88
|
+
...options,
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// ====== MESSAGE QUERIES ======
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Hook for fetching channel messages
|
|
96
|
+
* @param variables - Query variables including channelId, parentId, and pagination params
|
|
97
|
+
* @param options - Additional query options
|
|
98
|
+
* @returns Query result for messages
|
|
99
|
+
*/
|
|
100
|
+
export const useChannelMessagesQuery = (variables: any = {}, options: any = {}) => {
|
|
101
|
+
return useMessagesQuery({
|
|
102
|
+
variables,
|
|
103
|
+
fetchPolicy: 'cache-and-network',
|
|
104
|
+
nextFetchPolicy: 'cache-first',
|
|
105
|
+
refetchWritePolicy: 'merge',
|
|
106
|
+
...options,
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Hook for sending messages in a channel
|
|
112
|
+
* @returns Mutation function and result
|
|
113
|
+
*/
|
|
114
|
+
export const useSendChannelMessage = () => {
|
|
115
|
+
return useSendMessagesMutation();
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Hook for adding a direct channel
|
|
120
|
+
* @returns Mutation function and result
|
|
121
|
+
*/
|
|
122
|
+
export const useAddDirectChannel = () => {
|
|
123
|
+
return useAddDirectChannelMutation();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Messages document for queries
|
|
128
|
+
*/
|
|
129
|
+
export const MESSAGES_DOCUMENT = MessagesDocument;
|
|
130
|
+
|
|
131
|
+
// ====== MUTATIONS ======
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Hook for sending thread messages
|
|
135
|
+
* @returns Mutation function and result
|
|
136
|
+
*/
|
|
137
|
+
export const useSendThreadMessage = () => {
|
|
138
|
+
return useSendThreadMessageMutation();
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Hook for sending expo notifications
|
|
143
|
+
* @returns Mutation function and result
|
|
144
|
+
*/
|
|
145
|
+
export const useSendExpoNotification = () => {
|
|
146
|
+
return useSendExpoNotificationOnPostMutation();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook for creating a post thread
|
|
151
|
+
* @param options - Mutation options
|
|
152
|
+
* @returns Mutation function and result
|
|
153
|
+
*/
|
|
154
|
+
export const useCreatePostThread = (options: any = {}) => {
|
|
155
|
+
return useCreatePostThreadMutation(options);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// ====== SUBSCRIPTION DOCUMENTS ======
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Document for chat message added subscription
|
|
162
|
+
*/
|
|
163
|
+
export const CHAT_MESSAGE_ADDED = OnChatMessageAddedDocument;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Document for thread created/updated subscription
|
|
167
|
+
*/
|
|
168
|
+
export const THREAD_CREATED_UPDATED = OnThreadCreatedUpdatedDocument;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Hook for subscribing to thread creation and updates
|
|
172
|
+
* @returns Subscription result for thread creation/update events
|
|
173
|
+
*/
|
|
174
|
+
export const useThreadCreatedUpdatedSubscription = (options: any = {}) => {
|
|
175
|
+
return useOnThreadCreatedUpdatedSubscription({
|
|
176
|
+
...options,
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Hook for subscribing to chat message additions
|
|
182
|
+
* @param options - Subscription options including variables like channelId
|
|
183
|
+
* @returns Subscription result for new chat messages
|
|
184
|
+
*/
|
|
185
|
+
export const useChatMessageAddedSubscription = (options: any = {}) => {
|
|
186
|
+
return useOnChatMessageAddedSubscription({
|
|
187
|
+
...options,
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Hook for subscribing to thread chat message additions
|
|
193
|
+
* @param options - Subscription options including variables like channelId and threadId
|
|
194
|
+
* @returns Subscription result for new thread chat messages
|
|
195
|
+
*/
|
|
196
|
+
export const useThreadChatMessageAddedSubscription = (options: any = {}) => {
|
|
197
|
+
return useOnThreadChatMessageAddedSubscription({
|
|
198
|
+
...options,
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// ====== LAZY QUERIES ======
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Hook for lazily fetching a post thread
|
|
206
|
+
* @param options - Lazy query options
|
|
207
|
+
* @returns Lazy query function and result
|
|
208
|
+
*/
|
|
209
|
+
export const useGetPostThreadLazy = (options: any = {}) => {
|
|
210
|
+
return useGetPostThreadLazyQuery({
|
|
211
|
+
fetchPolicy: 'cache-and-network',
|
|
212
|
+
...options,
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// ====== CUSTOM QUERY HOOKS ======
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Custom hook that combines channels and provides refresh functionality
|
|
220
|
+
*/
|
|
221
|
+
export const useInboxChannels = () => {
|
|
222
|
+
const queryResult = useChannelsQuery();
|
|
223
|
+
|
|
224
|
+
const refresh = useCallback(() => {
|
|
225
|
+
return queryResult.refetch();
|
|
226
|
+
}, [queryResult.refetch]);
|
|
227
|
+
|
|
228
|
+
const loadMore = useCallback(
|
|
229
|
+
(page: number) => {
|
|
230
|
+
if (queryResult.loading || !queryResult.data) return;
|
|
231
|
+
|
|
232
|
+
return queryResult.fetchMore({
|
|
233
|
+
variables: { page },
|
|
234
|
+
updateQuery: (prev, { fetchMoreResult }) => {
|
|
235
|
+
if (!fetchMoreResult) return prev;
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
...fetchMoreResult,
|
|
239
|
+
channelsByUser: [...(prev.channelsByUser || []), ...(fetchMoreResult.channelsByUser || [])],
|
|
240
|
+
// supportServiceChannels: [
|
|
241
|
+
// ...(prev.supportServiceChannels || []),
|
|
242
|
+
// ...(fetchMoreResult.supportServiceChannels || []),
|
|
243
|
+
// ],
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
[queryResult.fetchMore, queryResult.loading, queryResult.data],
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
...queryResult,
|
|
253
|
+
refresh,
|
|
254
|
+
loadMore,
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Custom hook for thread message operations
|
|
260
|
+
*/
|
|
261
|
+
export const useThreadOperations = (channelId: string, options: any = {}) => {
|
|
262
|
+
const queryResult = useThreadMessagesQueryWithOptions({ channelId, ...options.variables }, options.queryOptions);
|
|
263
|
+
|
|
264
|
+
const [sendMessage, sendMessageResult] = useSendThreadMessage();
|
|
265
|
+
|
|
266
|
+
const refresh = useCallback(() => {
|
|
267
|
+
return queryResult.refetch();
|
|
268
|
+
}, [queryResult.refetch]);
|
|
269
|
+
|
|
270
|
+
const fetchMoreMessages = useCallback(
|
|
271
|
+
(variables: any) => {
|
|
272
|
+
return queryResult.fetchMore({
|
|
273
|
+
variables,
|
|
274
|
+
updateQuery: (prev, { fetchMoreResult }) => {
|
|
275
|
+
if (!fetchMoreResult?.threadMessages?.data) return prev;
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
...prev,
|
|
279
|
+
threadMessages: {
|
|
280
|
+
...prev.threadMessages,
|
|
281
|
+
data: [...fetchMoreResult.threadMessages.data, ...(prev.threadMessages?.data || [])],
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
[queryResult.fetchMore],
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
data: queryResult.data,
|
|
292
|
+
loading: queryResult.loading,
|
|
293
|
+
error: queryResult.error,
|
|
294
|
+
refresh,
|
|
295
|
+
fetchMoreMessages,
|
|
296
|
+
sendMessage,
|
|
297
|
+
sendMessageResult,
|
|
298
|
+
};
|
|
299
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './inboxQueries';
|
|
@@ -7,7 +7,7 @@ export function DialogMessages({ channelId, role, isShowThreadMessage = true, ..
|
|
|
7
7
|
const currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
8
8
|
return (
|
|
9
9
|
// <Box bg={'white'} flex={1} pt={5}>
|
|
10
|
-
<Box bg
|
|
10
|
+
<Box className="bg-white flex-1">
|
|
11
11
|
<ConversationView
|
|
12
12
|
{...rest}
|
|
13
13
|
channelId={currentRoute?.params?.channelId ?? channelId}
|
|
@@ -2,22 +2,15 @@ import * as React from 'react';
|
|
|
2
2
|
import { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';
|
|
3
3
|
import { ThreadConversationView } from './containers/ThreadConversationView';
|
|
4
4
|
import { ThreadsView } from './containers/ThreadsView';
|
|
5
|
-
import {
|
|
5
|
+
import { useChannelDetailQuery, useSendThreadMessage } from '../../queries/inboxQueries';
|
|
6
6
|
import { useFocusEffect } from '@react-navigation/native';
|
|
7
|
-
import { useSelector } from 'react-redux';
|
|
7
|
+
// import { useSelector } from 'react-redux';
|
|
8
|
+
import colors from 'tailwindcss/colors';
|
|
8
9
|
|
|
9
10
|
export function DialogThreadMessages({ channelId, postParentId, isPostParentIdThread, role }) {
|
|
10
|
-
const {
|
|
11
|
-
data,
|
|
12
|
-
loading: channelLoading,
|
|
13
|
-
refetch,
|
|
14
|
-
} = useViewChannelDetailQuery({
|
|
15
|
-
variables: {
|
|
16
|
-
id: channelId?.toString(),
|
|
17
|
-
},
|
|
18
|
-
});
|
|
11
|
+
const { data, loading: channelLoading, refetch } = useChannelDetailQuery(channelId?.toString(), {});
|
|
19
12
|
|
|
20
|
-
const [sendThreadMessage] =
|
|
13
|
+
const [sendThreadMessage] = useSendThreadMessage();
|
|
21
14
|
const [loading, setLoading] = React.useState<boolean>(true);
|
|
22
15
|
const [channel, setChannel] = React.useState<any>(null);
|
|
23
16
|
const [parentId, setParentId] = React.useState<any>(postParentId);
|
|
@@ -77,10 +70,10 @@ export function DialogThreadMessages({ channelId, postParentId, isPostParentIdTh
|
|
|
77
70
|
// }, [parentId, channel]);
|
|
78
71
|
|
|
79
72
|
return (
|
|
80
|
-
<Box bg
|
|
73
|
+
<Box className="bg-white flex-1">
|
|
81
74
|
{/* {loading && !parentId ? ( */}
|
|
82
75
|
{loading ? (
|
|
83
|
-
<Spinner color={
|
|
76
|
+
<Spinner color={colors.blue[500]} />
|
|
84
77
|
) : (
|
|
85
78
|
<ThreadConversationView
|
|
86
79
|
channelId={channelId}
|
|
@@ -2,44 +2,83 @@ import * as React from 'react';
|
|
|
2
2
|
import { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';
|
|
3
3
|
import { ThreadConversationView } from './containers/ThreadConversationView';
|
|
4
4
|
import { ThreadsView } from './containers/ThreadsView';
|
|
5
|
-
import {
|
|
5
|
+
import { useChannelDetailQuery, useThreadMessagesQueryWithOptions } from '../../queries/inboxQueries';
|
|
6
6
|
import { useFocusEffect } from '@react-navigation/native';
|
|
7
7
|
import { useSelector } from 'react-redux';
|
|
8
8
|
import { config } from './config';
|
|
9
|
+
import colors from 'tailwindcss/colors';
|
|
10
|
+
import { useSafeDialogThreadsMachine } from './hooks/useSafeDialogThreadsMachine';
|
|
11
|
+
import { Actions, BaseState } from './workflow/dialog-threads-xstate';
|
|
9
12
|
const { MESSAGES_PER_PAGE } = config;
|
|
10
13
|
|
|
11
14
|
export function DialogThreads({ channelId, postParentId, role }) {
|
|
15
|
+
// Use the XState machine for state management
|
|
16
|
+
const [state, send] = useSafeDialogThreadsMachine();
|
|
17
|
+
const { context, value } = state;
|
|
18
|
+
const { channelsDetail, loading, error } = context;
|
|
19
|
+
|
|
20
|
+
// Fetch channel details
|
|
12
21
|
const {
|
|
13
22
|
data: channelData,
|
|
14
23
|
loading: channelLoading,
|
|
15
24
|
refetch: channelRefetch,
|
|
16
|
-
} =
|
|
17
|
-
variables: {
|
|
18
|
-
id: channelId?.toString(),
|
|
19
|
-
},
|
|
20
|
-
});
|
|
25
|
+
} = useChannelDetailQuery(channelId?.toString(), {});
|
|
21
26
|
|
|
27
|
+
// Fetch thread messages
|
|
22
28
|
const {
|
|
23
29
|
data: threadsData,
|
|
24
30
|
loading: threadLoading,
|
|
25
31
|
error: threadsError,
|
|
26
32
|
refetch: threadsRefetch,
|
|
27
33
|
subscribeToMore: threadsSubscribeToMore,
|
|
28
|
-
} =
|
|
34
|
+
} = useThreadMessagesQueryWithOptions({
|
|
29
35
|
variables: {
|
|
30
36
|
channelId: channelId?.toString(),
|
|
31
37
|
role: role?.toString(),
|
|
32
38
|
limit: MESSAGES_PER_PAGE,
|
|
33
39
|
repliesLimit2: 5,
|
|
34
40
|
},
|
|
35
|
-
// fetchPolicy: 'cache-and-network',
|
|
36
41
|
});
|
|
42
|
+
console.log('threadsData', threadsData?.threadMessages?.totalCount);
|
|
43
|
+
console.log('channelid', channelId);
|
|
44
|
+
// Initialize the machine with props
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
send({
|
|
47
|
+
type: Actions.INITIALIZE,
|
|
48
|
+
data: { channelId, postParentId, role },
|
|
49
|
+
});
|
|
50
|
+
}, [channelId, postParentId, role]);
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
// Update channel detail in state when data changes
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
if (channelData?.viewChannelDetail) {
|
|
55
|
+
send({
|
|
56
|
+
type: Actions.SET_CHANNEL_DETAIL,
|
|
57
|
+
data: { channelsDetail: channelData.viewChannelDetail },
|
|
58
|
+
});
|
|
59
|
+
}
|
|
41
60
|
}, [channelData]);
|
|
42
61
|
|
|
62
|
+
// Update thread data in state when data changes
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
if (threadsData) {
|
|
65
|
+
send({
|
|
66
|
+
type: Actions.SET_THREADS,
|
|
67
|
+
data: { threadData: threadsData?.threadMessages?.data || [] },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [threadsData]);
|
|
71
|
+
|
|
72
|
+
// Handle errors
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
if (threadsError) {
|
|
75
|
+
send({
|
|
76
|
+
type: Actions.ERROR,
|
|
77
|
+
data: { error: threadsError },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}, [threadsError]);
|
|
81
|
+
|
|
43
82
|
const refetchChannelDetail = React.useCallback(
|
|
44
83
|
(id: string) => {
|
|
45
84
|
return channelRefetch({ id: id?.toString() });
|
|
@@ -56,24 +95,18 @@ export function DialogThreads({ channelId, postParentId, role }) {
|
|
|
56
95
|
);
|
|
57
96
|
|
|
58
97
|
return (
|
|
59
|
-
// <Box bg={'white'} flex={1} pt={5}>
|
|
60
98
|
<>
|
|
61
|
-
{channelLoading ? (
|
|
62
|
-
<Spinner color={
|
|
99
|
+
{state.matches(BaseState.LoadingChannel) || channelLoading ? (
|
|
100
|
+
<Spinner color={colors.blue[500]} />
|
|
63
101
|
) : (
|
|
64
102
|
<>
|
|
65
|
-
<Box
|
|
66
|
-
flex={1}
|
|
67
|
-
$dark-borderColor="$coolGray600"
|
|
68
|
-
$dark-backgroundColor="$trueGray700"
|
|
69
|
-
$light-backgroundColor="$trueGray50"
|
|
70
|
-
>
|
|
103
|
+
<Box className="flex-1 bg-gray-200 dark:border-gray-500 dark:bg-gray-500">
|
|
71
104
|
<ThreadsView
|
|
72
105
|
data={threadsData}
|
|
73
|
-
loading={threadLoading}
|
|
106
|
+
loading={threadLoading || state.matches(BaseState.LoadingThreads)}
|
|
74
107
|
refetch={threadsRefetch}
|
|
75
108
|
subscribeToMore={threadsSubscribeToMore}
|
|
76
|
-
error={threadsError}
|
|
109
|
+
error={error || threadsError}
|
|
77
110
|
channelId={channelId}
|
|
78
111
|
role={role}
|
|
79
112
|
channelsDetail={channelsDetail}
|
|
@@ -84,45 +117,6 @@ export function DialogThreads({ channelId, postParentId, role }) {
|
|
|
84
117
|
)}
|
|
85
118
|
</>
|
|
86
119
|
);
|
|
87
|
-
|
|
88
|
-
// return (
|
|
89
|
-
// // <Box bg={'white'} flex={1} pt={5}>
|
|
90
|
-
// <>
|
|
91
|
-
// {channelLoading ? (
|
|
92
|
-
// <Spinner />
|
|
93
|
-
// ) : (
|
|
94
|
-
// <>
|
|
95
|
-
// {postParentId || postParentId == 0 ? (
|
|
96
|
-
// <Box bg={'white'} flex={1}>
|
|
97
|
-
// <ThreadConversationView
|
|
98
|
-
// channelId={channelId}
|
|
99
|
-
// postParentId={postParentId}
|
|
100
|
-
// channelsDetail={channelsDetail}
|
|
101
|
-
// refetchChannelDetail={refetchChannelDetail}
|
|
102
|
-
// />
|
|
103
|
-
// </Box>
|
|
104
|
-
// ) : (
|
|
105
|
-
// <Box
|
|
106
|
-
// flex={1}
|
|
107
|
-
// _dark={{
|
|
108
|
-
// borderColor: 'coolGray.600',
|
|
109
|
-
// backgroundColor: 'gray.700',
|
|
110
|
-
// }}
|
|
111
|
-
// _light={{
|
|
112
|
-
// backgroundColor: 'gray.50',
|
|
113
|
-
// }}
|
|
114
|
-
// >
|
|
115
|
-
// <ThreadsView
|
|
116
|
-
// channelId={channelId}
|
|
117
|
-
// channelsDetail={channelsDetail}
|
|
118
|
-
// refetchChannelDetail={refetchChannelDetail}
|
|
119
|
-
// />
|
|
120
|
-
// </Box>
|
|
121
|
-
// )}
|
|
122
|
-
// </>
|
|
123
|
-
// )}
|
|
124
|
-
// </>
|
|
125
|
-
// );
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
export default DialogThreads;
|
|
@@ -7,7 +7,7 @@ import { Dialogs } from './containers/Dialogs';
|
|
|
7
7
|
export const Inbox = (props: any) => {
|
|
8
8
|
const { channelFilters, channelRole, supportServices } = props;
|
|
9
9
|
return (
|
|
10
|
-
<Box
|
|
10
|
+
<Box className="flex-1 bg-white">
|
|
11
11
|
{/* {supportServices && (
|
|
12
12
|
<SupportServiceDialogs channelFilters={channelFilters} channelRole={channelRole} {...props} />
|
|
13
13
|
)} */}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, TouchableOpacity, View, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export const Actionsheet = ({ isOpen, onCancel, children }) => {
|
|
5
|
+
if (!isOpen) return null;
|
|
6
|
+
return (
|
|
7
|
+
<Modal visible={isOpen} transparent animationType="slide" onRequestClose={onCancel}>
|
|
8
|
+
<TouchableOpacity style={styles.overlay} activeOpacity={1} onPress={onCancel}>
|
|
9
|
+
<View style={styles.sheet} onStartShouldSetResponder={() => true}>
|
|
10
|
+
{children}
|
|
11
|
+
</View>
|
|
12
|
+
</TouchableOpacity>
|
|
13
|
+
</Modal>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
overlay: {
|
|
19
|
+
flex: 1,
|
|
20
|
+
backgroundColor: 'rgba(0,0,0,0.3)',
|
|
21
|
+
justifyContent: 'flex-end',
|
|
22
|
+
},
|
|
23
|
+
sheet: {
|
|
24
|
+
backgroundColor: '#fff',
|
|
25
|
+
borderTopLeftRadius: 16,
|
|
26
|
+
borderTopRightRadius: 16,
|
|
27
|
+
padding: 16,
|
|
28
|
+
minHeight: 100,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as FileSystem from
|
|
1
|
+
import * as FileSystem from 'expo-file-system';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// Make sure cache directory path ends with a slash
|
|
4
|
+
export const IMAGE_CACHE_FOLDER = `${FileSystem.cacheDirectory}/image-cache/`;
|
|
4
5
|
// export const IMAGE_CACHE_FOLDER = `${FileSystem.documentDirectory}images/`
|
|
5
|
-
export default IMAGE_CACHE_FOLDER
|
|
6
|
+
export default IMAGE_CACHE_FOLDER;
|