@messenger-box/platform-mobile 10.0.3-alpha.23 → 10.0.3-alpha.232

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.
Files changed (116) hide show
  1. package/lib/components/messages-container-ui/BuildModeView.js +428 -0
  2. package/lib/components/messages-container-ui/BuildModeView.js.map +1 -0
  3. package/lib/components/messages-container-ui/MessagesContainerUI.js +55 -0
  4. package/lib/components/messages-container-ui/MessagesContainerUI.js.map +1 -0
  5. package/lib/components/messages-container-ui/PlanModeView.js +336 -0
  6. package/lib/components/messages-container-ui/PlanModeView.js.map +1 -0
  7. package/lib/compute.js +2 -3
  8. package/lib/compute.js.map +1 -1
  9. package/lib/index.js +1 -1
  10. package/lib/index.js.map +1 -1
  11. package/lib/module.js.map +1 -1
  12. package/lib/queries/inboxQueries.js +62 -0
  13. package/lib/queries/inboxQueries.js.map +1 -0
  14. package/lib/routes.json +2 -3
  15. package/lib/screens/inbox/DialogMessages.js +8 -3
  16. package/lib/screens/inbox/DialogMessages.js.map +1 -1
  17. package/lib/screens/inbox/DialogThreadMessages.js +6 -11
  18. package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
  19. package/lib/screens/inbox/DialogThreads.js +9 -11
  20. package/lib/screens/inbox/DialogThreads.js.map +1 -1
  21. package/lib/screens/inbox/Inbox.js.map +1 -1
  22. package/lib/screens/inbox/components/CachedImage/consts.js +1 -1
  23. package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
  24. package/lib/screens/inbox/components/CachedImage/index.js +125 -96
  25. package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
  26. package/lib/screens/inbox/components/DialogItem.js +160 -0
  27. package/lib/screens/inbox/components/DialogItem.js.map +1 -0
  28. package/lib/screens/inbox/components/GiftedChatInboxComponent.js +315 -0
  29. package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
  30. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js +3 -1
  31. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js.map +1 -1
  32. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js +194 -0
  33. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js.map +1 -0
  34. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +149 -36
  35. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  36. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +4 -5
  37. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js.map +1 -1
  38. package/lib/screens/inbox/components/SubscriptionHandler.js +22 -0
  39. package/lib/screens/inbox/components/SubscriptionHandler.js.map +1 -0
  40. package/lib/screens/inbox/components/ThreadsViewItem.js +2 -4
  41. package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
  42. package/lib/screens/inbox/config/config.js +4 -2
  43. package/lib/screens/inbox/config/config.js.map +1 -1
  44. package/lib/screens/inbox/containers/ConversationView.js +1093 -1090
  45. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  46. package/lib/screens/inbox/containers/Dialogs.js +130 -577
  47. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  48. package/lib/screens/inbox/containers/ThreadConversationView.js +864 -1408
  49. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  50. package/lib/screens/inbox/containers/ThreadsView.js +9 -15
  51. package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
  52. package/lib/screens/inbox/hooks/useInboxMessages.js +31 -0
  53. package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
  54. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js +1 -1
  55. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js.map +1 -1
  56. package/lib/screens/inbox/workflow/dialog-threads-xstate.js.map +1 -1
  57. package/package.json +10 -8
  58. package/CHANGELOG.md +0 -172
  59. package/jest.config.js +0 -24
  60. package/lib/screens/inbox/components/DialogsListItem.js +0 -548
  61. package/lib/screens/inbox/components/DialogsListItem.js.map +0 -1
  62. package/lib/screens/inbox/components/ServiceDialogsListItem.js +0 -489
  63. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +0 -1
  64. package/lib/screens/inbox/components/workflow/dialogs-list-item-xstate.js +0 -175
  65. package/lib/screens/inbox/components/workflow/dialogs-list-item-xstate.js.map +0 -1
  66. package/lib/screens/inbox/components/workflow/service-dialogs-list-item-xstate.js +0 -191
  67. package/lib/screens/inbox/components/workflow/service-dialogs-list-item-xstate.js.map +0 -1
  68. package/lib/screens/inbox/containers/workflow/conversation-xstate.js +0 -380
  69. package/lib/screens/inbox/containers/workflow/conversation-xstate.js.map +0 -1
  70. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js +0 -211
  71. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js.map +0 -1
  72. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js +0 -438
  73. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js.map +0 -1
  74. package/rollup.config.mjs +0 -45
  75. package/src/components/index.ts +0 -0
  76. package/src/compute.ts +0 -63
  77. package/src/index.ts +0 -7
  78. package/src/module.ts +0 -10
  79. package/src/navigation/InboxNavigation.tsx +0 -102
  80. package/src/navigation/index.ts +0 -1
  81. package/src/screens/inbox/DialogMessages.tsx +0 -21
  82. package/src/screens/inbox/DialogThreadMessages.tsx +0 -97
  83. package/src/screens/inbox/DialogThreads.tsx +0 -125
  84. package/src/screens/inbox/Inbox.tsx +0 -17
  85. package/src/screens/inbox/components/CachedImage/consts.ts +0 -6
  86. package/src/screens/inbox/components/CachedImage/index.tsx +0 -223
  87. package/src/screens/inbox/components/DialogsHeader.tsx +0 -30
  88. package/src/screens/inbox/components/DialogsListItem.tsx +0 -819
  89. package/src/screens/inbox/components/ServiceDialogsListItem.tsx +0 -679
  90. package/src/screens/inbox/components/SlackMessageContainer/ImageViewerModal.tsx +0 -113
  91. package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +0 -313
  92. package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +0 -145
  93. package/src/screens/inbox/components/SlackMessageContainer/index.ts +0 -3
  94. package/src/screens/inbox/components/SmartLoader.tsx +0 -61
  95. package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +0 -301
  96. package/src/screens/inbox/components/ThreadsViewItem.tsx +0 -233
  97. package/src/screens/inbox/components/workflow/dialogs-list-item-xstate.ts +0 -145
  98. package/src/screens/inbox/components/workflow/service-dialogs-list-item-xstate.ts +0 -159
  99. package/src/screens/inbox/config/config.ts +0 -15
  100. package/src/screens/inbox/config/index.ts +0 -1
  101. package/src/screens/inbox/containers/ConversationView.tsx +0 -1784
  102. package/src/screens/inbox/containers/Dialogs.tsx +0 -829
  103. package/src/screens/inbox/containers/SupportServiceDialogs.tsx +0 -119
  104. package/src/screens/inbox/containers/ThreadConversationView.tsx +0 -2295
  105. package/src/screens/inbox/containers/ThreadsView.tsx +0 -224
  106. package/src/screens/inbox/containers/workflow/apollo/handleResult.ts +0 -20
  107. package/src/screens/inbox/containers/workflow/conversation-xstate.ts +0 -313
  108. package/src/screens/inbox/containers/workflow/dialogs-xstate.ts +0 -196
  109. package/src/screens/inbox/containers/workflow/thread-conversation-xstate.ts +0 -401
  110. package/src/screens/inbox/hooks/useSafeDialogThreadsMachine.ts +0 -136
  111. package/src/screens/inbox/index.ts +0 -37
  112. package/src/screens/inbox/machines/threadsMachine.ts +0 -147
  113. package/src/screens/inbox/workflow/dialog-threads-xstate.ts +0 -163
  114. package/src/screens/index.ts +0 -4
  115. package/tsconfig.json +0 -13
  116. package/webpack.config.js +0 -58
@@ -1,196 +0,0 @@
1
- import { assign, setup } from 'xstate';
2
- import { merge } from 'lodash-es';
3
-
4
- export const enum Actions {
5
- INITIAL_CONTEXT = 'INITIAL_CONTEXT',
6
- ERROR_HANDLED = 'ERROR_HANDLED',
7
- FETCH_CHANNELS = 'FETCH_CHANNELS',
8
- REFRESH_CHANNELS = 'REFRESH_CHANNELS',
9
- SELECT_CHANNEL = 'SELECT_CHANNEL',
10
- START_LOADING = 'START_LOADING',
11
- STOP_LOADING = 'STOP_LOADING',
12
- SET_SEARCH_QUERY = 'SET_SEARCH_QUERY',
13
- }
14
-
15
- export const enum BaseState {
16
- Idle = 'idle',
17
- Error = 'error',
18
- Loading = 'loading',
19
- Done = 'done',
20
- FetchChannels = 'fetchChannels',
21
- }
22
-
23
- export const enum MainState {
24
- RefreshChannels = 'refreshChannels',
25
- SelectChannel = 'selectChannel',
26
- }
27
-
28
- export const dialogsXstate = setup({
29
- types: {
30
- context: {} as {
31
- channels: any[];
32
- refreshing: boolean;
33
- loading: boolean;
34
- error: string | null;
35
- searchQuery: string;
36
- selectedChannelId: string | null;
37
- channelRole: string | null;
38
- channelFilters: Record<string, any>;
39
- supportServices: boolean;
40
- },
41
- },
42
- actions: {
43
- errorState: assign(({ context, event }) => {
44
- return {
45
- ...context,
46
- error: event.data?.message || 'An error occurred',
47
- loading: false,
48
- refreshing: false,
49
- };
50
- }),
51
- setInitialContext: assign(({ context, event }) => {
52
- return merge({
53
- ...context,
54
- channelRole: event.data?.channelRole || null,
55
- channelFilters: event.data?.channelFilters || {},
56
- supportServices: event.data?.supportServices || false,
57
- selectedChannelId: event.data?.selectedChannelId || null,
58
- loading: true,
59
- });
60
- }),
61
- setChannels: assign(({ context, event }) => {
62
- return {
63
- ...context,
64
- channels: event.data?.channels || [],
65
- loading: false,
66
- refreshing: false,
67
- };
68
- }),
69
- startRefreshing: assign(({ context }) => {
70
- return {
71
- ...context,
72
- refreshing: true,
73
- };
74
- }),
75
- stopRefreshing: assign(({ context }) => {
76
- return {
77
- ...context,
78
- refreshing: false,
79
- };
80
- }),
81
- startLoading: assign(({ context }) => {
82
- return {
83
- ...context,
84
- loading: true,
85
- };
86
- }),
87
- stopLoading: assign(({ context }) => {
88
- return {
89
- ...context,
90
- loading: false,
91
- };
92
- }),
93
- setSearchQuery: assign(({ context, event }) => {
94
- return {
95
- ...context,
96
- searchQuery: event.data?.searchQuery || '',
97
- };
98
- }),
99
- selectChannel: assign(({ context, event }) => {
100
- return {
101
- ...context,
102
- selectedChannelId: event.data?.channelId || null,
103
- };
104
- }),
105
- },
106
- guards: {
107
- hasChannels: ({ context }) => {
108
- return context.channels.length > 0;
109
- },
110
- },
111
- }).createMachine({
112
- id: 'dialogs-view',
113
- initial: BaseState.Idle,
114
- context: {
115
- channels: [],
116
- refreshing: false,
117
- loading: false,
118
- error: null,
119
- searchQuery: '',
120
- selectedChannelId: null,
121
- channelRole: null,
122
- channelFilters: {},
123
- supportServices: false,
124
- },
125
- states: {
126
- [BaseState.Idle]: {
127
- on: {
128
- [Actions.INITIAL_CONTEXT]: {
129
- target: BaseState.FetchChannels,
130
- actions: ['setInitialContext'],
131
- },
132
- [Actions.REFRESH_CHANNELS]: {
133
- target: MainState.RefreshChannels,
134
- actions: ['startRefreshing'],
135
- },
136
- [Actions.SELECT_CHANNEL]: {
137
- target: MainState.SelectChannel,
138
- actions: ['selectChannel'],
139
- },
140
- [Actions.START_LOADING]: {
141
- target: BaseState.Idle,
142
- actions: ['startLoading'],
143
- },
144
- [Actions.STOP_LOADING]: {
145
- target: BaseState.Idle,
146
- actions: ['stopLoading'],
147
- },
148
- [Actions.SET_SEARCH_QUERY]: {
149
- target: BaseState.Idle,
150
- actions: ['setSearchQuery'],
151
- },
152
- },
153
- },
154
- [BaseState.Error]: {
155
- entry: ['errorState'],
156
- on: {
157
- [Actions.ERROR_HANDLED]: {
158
- target: BaseState.Idle,
159
- },
160
- },
161
- },
162
- [BaseState.FetchChannels]: {
163
- invoke: {
164
- src: 'fetchChannels',
165
- input: ({ context, event }) => ({ context, event }),
166
- onDone: {
167
- target: BaseState.Idle,
168
- actions: ['setChannels'],
169
- },
170
- onError: {
171
- target: BaseState.Error,
172
- actions: ['errorState'],
173
- },
174
- },
175
- },
176
- [MainState.RefreshChannels]: {
177
- invoke: {
178
- src: 'refreshChannels',
179
- input: ({ context, event }) => ({ context, event }),
180
- onDone: {
181
- target: BaseState.Idle,
182
- actions: ['setChannels'],
183
- },
184
- onError: {
185
- target: BaseState.Error,
186
- actions: ['errorState'],
187
- },
188
- },
189
- },
190
- [MainState.SelectChannel]: {
191
- always: {
192
- target: BaseState.Idle,
193
- },
194
- },
195
- },
196
- } as any);
@@ -1,401 +0,0 @@
1
- import { assign, setup } from 'xstate';
2
- import { merge } from 'lodash-es';
3
-
4
- export const enum Actions {
5
- INITIAL_CONTEXT = 'INITIAL_CONTEXT',
6
- ERROR_HANDLED = 'ERROR_HANDLED',
7
- SEND_THREAD_MESSAGE = 'SEND_THREAD_MESSAGE',
8
- SEND_THREAD_MESSAGE_WITH_FILE = 'SEND_THREAD_MESSAGE_WITH_FILE',
9
- SET_THREAD_MESSAGES = 'SET_THREAD_MESSAGES',
10
- CLEAR_MESSAGES = 'CLEAR_MESSAGES',
11
- FETCH_MORE_MESSAGES = 'FETCH_MORE_MESSAGES',
12
- SUBSCRIBE_TO_THREAD_MESSAGES = 'SUBSCRIBE_TO_THREAD_MESSAGES',
13
- START_LOADING = 'START_LOADING',
14
- STOP_LOADING = 'STOP_LOADING',
15
- SET_IMAGE = 'SET_IMAGE',
16
- CLEAR_IMAGE = 'CLEAR_IMAGE',
17
- SET_MESSAGE_TEXT = 'SET_MESSAGE_TEXT',
18
- }
19
-
20
- export const enum BaseState {
21
- Idle = 'idle',
22
- Error = 'error',
23
- Loading = 'loading',
24
- Done = 'done',
25
- FetchThreadMessages = 'fetchThreadMessages',
26
- }
27
-
28
- export const enum MainState {
29
- SendThreadMessage = 'sendThreadMessage',
30
- SendThreadMessageWithFile = 'sendThreadMessageWithFile',
31
- FetchMoreMessages = 'fetchMoreMessages',
32
- }
33
-
34
- export const threadConversationXstate = setup({
35
- types: {
36
- context: {} as {
37
- channelId: string | null;
38
- postParentId: string | null;
39
- role: string | null;
40
- threadMessages: any[];
41
- totalCount: number;
42
- skip: number;
43
- loading: boolean;
44
- loadingOldMessages: boolean;
45
- error: string | null;
46
- selectedImage: string;
47
- files: any[];
48
- images: any[];
49
- messageText: string;
50
- imageLoading: boolean;
51
- postThread: any;
52
- threadPost: any[];
53
- isScrollToBottom: boolean;
54
- },
55
- },
56
- actions: {
57
- errorState: assign(({ context, event }) => {
58
- return {
59
- ...context,
60
- error: event.data?.message || 'An error occurred',
61
- loading: false,
62
- loadingOldMessages: false,
63
- imageLoading: false,
64
- };
65
- }),
66
- setInitialContext: assign(({ context, event }) => {
67
- return merge({
68
- ...context,
69
- channelId: event.data?.channelId || null,
70
- postParentId: event.data?.postParentId || null,
71
- role: event.data?.role || null,
72
- loading: false,
73
- });
74
- }),
75
- setThreadMessages: assign(({ context, event }) => {
76
- const messages = event.data?.messages || [];
77
- console.log(`setThreadMessages: Setting ${messages.length} messages`);
78
-
79
- // Create a set of unique IDs to remove duplicates
80
- const messageIds = new Set();
81
- const uniqueMessages = [];
82
-
83
- // Process messages to ensure uniqueness
84
- messages.forEach((msg) => {
85
- if (msg.id && !messageIds.has(msg.id)) {
86
- messageIds.add(msg.id);
87
- uniqueMessages.push(msg);
88
- }
89
- });
90
-
91
- console.log(`setThreadMessages: After deduplication, have ${uniqueMessages.length} unique messages`);
92
-
93
- return {
94
- ...context,
95
- threadMessages: uniqueMessages,
96
- totalCount: event.data?.totalCount || 0,
97
- loading: false,
98
- loadingOldMessages: false,
99
- threadPost: event.data?.threadPost || [],
100
- postThread: event.data?.postThread || null,
101
- };
102
- }),
103
- addThreadMessages: assign(({ context, event }) => {
104
- const newMessages = event.data?.messages || [];
105
- console.log('Adding thread messages and disabling loading state. New messages:', newMessages.length);
106
-
107
- if (newMessages.length === 0) {
108
- return {
109
- ...context,
110
- loadingOldMessages: false,
111
- loading: false,
112
- };
113
- }
114
-
115
- // Create a map of existing message IDs for quick lookup
116
- const existingMessageIds = new Set();
117
- context.threadMessages.forEach((msg) => existingMessageIds.add(msg.id));
118
-
119
- // Filter out any duplicate messages
120
- const uniqueNewMessages = newMessages.filter((msg) => {
121
- if (!msg.id || existingMessageIds.has(msg.id)) {
122
- console.log('Skipping duplicate message:', msg.id);
123
- return false; // Skip messages with no ID or duplicates
124
- }
125
- existingMessageIds.add(msg.id); // Add to set to catch duplicates in the new messages
126
- return true;
127
- });
128
-
129
- console.log(`After filtering, adding ${uniqueNewMessages.length} unique messages`);
130
-
131
- return {
132
- ...context,
133
- threadMessages: [...context.threadMessages, ...uniqueNewMessages],
134
- loadingOldMessages: false,
135
- loading: false,
136
- };
137
- }),
138
- addNewMessage: assign(({ context, event }) => {
139
- const message = event.data?.message;
140
- console.log('Adding new message to thread:', message?.id);
141
- if (!message) {
142
- console.warn('No message data provided to addNewMessage action');
143
- return context;
144
- }
145
-
146
- // Prevent duplicate messages by checking for the same ID
147
- const existingMessageIndex = context.threadMessages.findIndex((msg) => msg.id === message.id);
148
- if (existingMessageIndex !== -1) {
149
- console.log('Message already exists, not adding duplicate:', message.id);
150
- return {
151
- ...context,
152
- loading: false,
153
- };
154
- }
155
-
156
- // Use a set to ensure we only have unique message IDs
157
- const messageIds = new Set();
158
- const uniqueMessages = [...context.threadMessages];
159
-
160
- // Add all existing message IDs to the set
161
- uniqueMessages.forEach((msg) => messageIds.add(msg.id));
162
-
163
- // Only add the new message if its ID isn't already in the set
164
- if (!messageIds.has(message.id)) {
165
- uniqueMessages.unshift(message); // Add to beginning (newest first)
166
- }
167
-
168
- console.log('Successfully added new message to thread');
169
- return {
170
- ...context,
171
- threadMessages: uniqueMessages,
172
- totalCount: context.totalCount + 1,
173
- loading: false,
174
- };
175
- }),
176
- updateSkip: assign(({ context, event }) => {
177
- console.log('Setting loadingOldMessages to true');
178
- return {
179
- ...context,
180
- skip: context.threadMessages.length,
181
- loadingOldMessages: true,
182
- loading: event.data?.loading !== undefined ? event.data.loading : context.loading,
183
- };
184
- }),
185
- clearMessages: assign(({ context }) => {
186
- return {
187
- ...context,
188
- threadMessages: [],
189
- totalCount: 0,
190
- skip: 0,
191
- };
192
- }),
193
- setPostParentId: assign(({ context, event }) => {
194
- return {
195
- ...context,
196
- postParentId: event.data?.postParentId || null,
197
- };
198
- }),
199
- setPostThread: assign(({ context, event }) => {
200
- return {
201
- ...context,
202
- postThread: event.data?.postThread || null,
203
- };
204
- }),
205
- startLoading: assign(({ context, event }) => {
206
- return {
207
- ...context,
208
- loading: true,
209
- loadingOldMessages:
210
- event.data?.loadingOldMessages !== undefined
211
- ? event.data.loadingOldMessages
212
- : context.loadingOldMessages,
213
- };
214
- }),
215
- stopLoading: assign(({ context, event }) => {
216
- return {
217
- ...context,
218
- loading: false,
219
- loadingOldMessages:
220
- event.data?.loadingOldMessages !== undefined
221
- ? event.data.loadingOldMessages
222
- : context.loadingOldMessages,
223
- };
224
- }),
225
- startImageLoading: assign(({ context }) => {
226
- return {
227
- ...context,
228
- imageLoading: true,
229
- };
230
- }),
231
- stopImageLoading: assign(({ context }) => {
232
- return {
233
- ...context,
234
- imageLoading: false,
235
- };
236
- }),
237
- setSelectedImage: assign(({ context, event }) => {
238
- return {
239
- ...context,
240
- selectedImage: event.data?.image || '',
241
- files: event.data?.files || context.files,
242
- images: event.data?.images || context.images,
243
- imageLoading: false,
244
- };
245
- }),
246
- clearImageData: assign(({ context }) => {
247
- return {
248
- ...context,
249
- selectedImage: '',
250
- files: [],
251
- images: [],
252
- };
253
- }),
254
- setMessageText: assign(({ context, event }) => {
255
- return {
256
- ...context,
257
- messageText: event.data?.messageText || '',
258
- };
259
- }),
260
- setScrollToBottom: assign(({ context, event }) => {
261
- return {
262
- ...context,
263
- isScrollToBottom: event.data?.isScrollToBottom || false,
264
- };
265
- }),
266
- },
267
- guards: {
268
- hasMoreMessages: ({ context }) => {
269
- return context.totalCount > context.threadMessages.length;
270
- },
271
- },
272
- }).createMachine({
273
- id: 'thread-conversation-view',
274
- initial: BaseState.Idle,
275
- context: {
276
- channelId: null,
277
- postParentId: null,
278
- role: null,
279
- threadMessages: [],
280
- totalCount: 0,
281
- skip: 0,
282
- loading: false,
283
- loadingOldMessages: false,
284
- error: null,
285
- selectedImage: '',
286
- files: [],
287
- images: [],
288
- messageText: '',
289
- imageLoading: false,
290
- postThread: null,
291
- threadPost: [],
292
- isScrollToBottom: false,
293
- },
294
- states: {
295
- [BaseState.Idle]: {
296
- on: {
297
- [Actions.INITIAL_CONTEXT]: {
298
- target: BaseState.FetchThreadMessages,
299
- actions: ['setInitialContext'],
300
- },
301
- [Actions.SEND_THREAD_MESSAGE]: {
302
- target: MainState.SendThreadMessage,
303
- actions: ['startLoading'],
304
- },
305
- [Actions.SEND_THREAD_MESSAGE_WITH_FILE]: {
306
- target: MainState.SendThreadMessageWithFile,
307
- actions: ['startLoading'],
308
- },
309
- [Actions.FETCH_MORE_MESSAGES]: {
310
- target: MainState.FetchMoreMessages,
311
- actions: ['updateSkip'],
312
- guard: 'hasMoreMessages',
313
- },
314
- [Actions.CLEAR_MESSAGES]: {
315
- target: BaseState.Idle,
316
- actions: ['clearMessages'],
317
- },
318
- [Actions.START_LOADING]: {
319
- target: BaseState.Idle,
320
- actions: ['startLoading'],
321
- },
322
- [Actions.STOP_LOADING]: {
323
- target: BaseState.Idle,
324
- actions: ['stopLoading'],
325
- },
326
- [Actions.SET_IMAGE]: {
327
- target: BaseState.Idle,
328
- actions: ['setSelectedImage'],
329
- },
330
- [Actions.CLEAR_IMAGE]: {
331
- target: BaseState.Idle,
332
- actions: ['clearImageData'],
333
- },
334
- [Actions.SET_MESSAGE_TEXT]: {
335
- target: BaseState.Idle,
336
- actions: ['setMessageText'],
337
- },
338
- },
339
- },
340
- [BaseState.Error]: {
341
- entry: ['errorState'],
342
- on: {
343
- [Actions.ERROR_HANDLED]: {
344
- target: BaseState.Idle,
345
- },
346
- },
347
- },
348
- [BaseState.FetchThreadMessages]: {
349
- invoke: {
350
- src: 'fetchThreadMessages',
351
- input: ({ context, event }) => ({ context, event }),
352
- onDone: {
353
- target: BaseState.Idle,
354
- actions: ['setThreadMessages'],
355
- },
356
- onError: {
357
- target: BaseState.Error,
358
- },
359
- },
360
- },
361
- [MainState.SendThreadMessage]: {
362
- invoke: {
363
- src: 'sendThreadMessage',
364
- input: ({ context, event }) => ({ context, event }),
365
- onDone: {
366
- target: BaseState.Idle,
367
- actions: ['addNewMessage', 'stopLoading'],
368
- },
369
- onError: {
370
- target: BaseState.Error,
371
- },
372
- },
373
- },
374
- [MainState.SendThreadMessageWithFile]: {
375
- invoke: {
376
- src: 'sendThreadMessageWithFile',
377
- input: ({ context, event }) => ({ context, event }),
378
- onDone: {
379
- target: BaseState.Idle,
380
- actions: ['addNewMessage', 'clearImageData', 'stopLoading'],
381
- },
382
- onError: {
383
- target: BaseState.Error,
384
- },
385
- },
386
- },
387
- [MainState.FetchMoreMessages]: {
388
- invoke: {
389
- src: 'fetchMoreThreadMessages',
390
- input: ({ context, event }) => ({ context, event }),
391
- onDone: {
392
- target: BaseState.Idle,
393
- actions: ['addThreadMessages'],
394
- },
395
- onError: {
396
- target: BaseState.Error,
397
- },
398
- },
399
- },
400
- },
401
- } as any);