@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
|
@@ -0,0 +1,145 @@
|
|
|
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_MESSAGES = 'FETCH_MESSAGES',
|
|
8
|
+
UPDATE_MESSAGES = 'UPDATE_MESSAGES',
|
|
9
|
+
SUBSCRIBE_TO_MESSAGES = 'SUBSCRIBE_TO_MESSAGES',
|
|
10
|
+
SET_TITLE = 'SET_TITLE',
|
|
11
|
+
START_LOADING = 'START_LOADING',
|
|
12
|
+
STOP_LOADING = 'STOP_LOADING',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const enum BaseState {
|
|
16
|
+
Idle = 'idle',
|
|
17
|
+
Error = 'error',
|
|
18
|
+
FetchingMessages = 'fetchingMessages',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const dialogsListItemXstate = setup({
|
|
22
|
+
types: {
|
|
23
|
+
context: {} as {
|
|
24
|
+
channelId: string | null;
|
|
25
|
+
currentUser: any;
|
|
26
|
+
messages: any[];
|
|
27
|
+
loading: boolean;
|
|
28
|
+
error: string | null;
|
|
29
|
+
title: string;
|
|
30
|
+
channelMembers: any[];
|
|
31
|
+
lastMessage: any;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
errorState: assign(({ context, event }) => {
|
|
36
|
+
return {
|
|
37
|
+
...context,
|
|
38
|
+
error: event.data?.message || 'An error occurred',
|
|
39
|
+
loading: false,
|
|
40
|
+
};
|
|
41
|
+
}),
|
|
42
|
+
setInitialContext: assign(({ context, event }) => {
|
|
43
|
+
return merge({
|
|
44
|
+
...context,
|
|
45
|
+
channelId: event.data?.channelId || null,
|
|
46
|
+
currentUser: event.data?.currentUser || null,
|
|
47
|
+
loading: true,
|
|
48
|
+
});
|
|
49
|
+
}),
|
|
50
|
+
setMessages: assign(({ context, event }) => {
|
|
51
|
+
return {
|
|
52
|
+
...context,
|
|
53
|
+
messages: event.data?.messages || [],
|
|
54
|
+
loading: false,
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
updateMessages: assign(({ context, event }) => {
|
|
58
|
+
const newMessage = event.data?.message;
|
|
59
|
+
if (!newMessage) return context;
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
...context,
|
|
63
|
+
messages: [...context.messages, newMessage],
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
setTitle: assign(({ context, event }) => {
|
|
67
|
+
return {
|
|
68
|
+
...context,
|
|
69
|
+
title: event.data?.title || '',
|
|
70
|
+
};
|
|
71
|
+
}),
|
|
72
|
+
startLoading: assign(({ context }) => {
|
|
73
|
+
return {
|
|
74
|
+
...context,
|
|
75
|
+
loading: true,
|
|
76
|
+
};
|
|
77
|
+
}),
|
|
78
|
+
stopLoading: assign(({ context }) => {
|
|
79
|
+
return {
|
|
80
|
+
...context,
|
|
81
|
+
loading: false,
|
|
82
|
+
};
|
|
83
|
+
}),
|
|
84
|
+
},
|
|
85
|
+
}).createMachine({
|
|
86
|
+
id: 'dialogs-list-item',
|
|
87
|
+
initial: BaseState.Idle,
|
|
88
|
+
context: {
|
|
89
|
+
channelId: null,
|
|
90
|
+
currentUser: null,
|
|
91
|
+
messages: [],
|
|
92
|
+
loading: false,
|
|
93
|
+
error: null,
|
|
94
|
+
title: '',
|
|
95
|
+
channelMembers: [],
|
|
96
|
+
lastMessage: null,
|
|
97
|
+
},
|
|
98
|
+
states: {
|
|
99
|
+
[BaseState.Idle]: {
|
|
100
|
+
on: {
|
|
101
|
+
[Actions.INITIAL_CONTEXT]: {
|
|
102
|
+
target: BaseState.FetchingMessages,
|
|
103
|
+
actions: ['setInitialContext'],
|
|
104
|
+
},
|
|
105
|
+
[Actions.UPDATE_MESSAGES]: {
|
|
106
|
+
target: BaseState.Idle,
|
|
107
|
+
actions: ['updateMessages'],
|
|
108
|
+
},
|
|
109
|
+
[Actions.SET_TITLE]: {
|
|
110
|
+
target: BaseState.Idle,
|
|
111
|
+
actions: ['setTitle'],
|
|
112
|
+
},
|
|
113
|
+
[Actions.START_LOADING]: {
|
|
114
|
+
target: BaseState.Idle,
|
|
115
|
+
actions: ['startLoading'],
|
|
116
|
+
},
|
|
117
|
+
[Actions.STOP_LOADING]: {
|
|
118
|
+
target: BaseState.Idle,
|
|
119
|
+
actions: ['stopLoading'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
[BaseState.Error]: {
|
|
124
|
+
entry: ['errorState'],
|
|
125
|
+
on: {
|
|
126
|
+
[Actions.ERROR_HANDLED]: {
|
|
127
|
+
target: BaseState.Idle,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
[BaseState.FetchingMessages]: {
|
|
132
|
+
invoke: {
|
|
133
|
+
src: 'fetchMessages',
|
|
134
|
+
input: ({ context, event }) => ({ context, event }),
|
|
135
|
+
onDone: {
|
|
136
|
+
target: BaseState.Idle,
|
|
137
|
+
actions: ['setMessages'],
|
|
138
|
+
},
|
|
139
|
+
onError: {
|
|
140
|
+
target: BaseState.Error,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
} as any);
|
|
@@ -0,0 +1,159 @@
|
|
|
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_THREAD_MESSAGES = 'FETCH_THREAD_MESSAGES',
|
|
8
|
+
UPDATE_THREAD_MESSAGES = 'UPDATE_THREAD_MESSAGES',
|
|
9
|
+
SUBSCRIBE_TO_THREAD_MESSAGES = 'SUBSCRIBE_TO_THREAD_MESSAGES',
|
|
10
|
+
SET_TITLE = 'SET_TITLE',
|
|
11
|
+
START_LOADING = 'START_LOADING',
|
|
12
|
+
STOP_LOADING = 'STOP_LOADING',
|
|
13
|
+
SET_SERVICE_POST_PARENT_ID = 'SET_SERVICE_POST_PARENT_ID',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const enum BaseState {
|
|
17
|
+
Idle = 'idle',
|
|
18
|
+
Error = 'error',
|
|
19
|
+
FetchingThreadMessages = 'fetchingThreadMessages',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const serviceDialogsListItemXstate = setup({
|
|
23
|
+
types: {
|
|
24
|
+
context: {} as {
|
|
25
|
+
channelId: string | null;
|
|
26
|
+
currentUser: any;
|
|
27
|
+
threadMessages: any[];
|
|
28
|
+
loading: boolean;
|
|
29
|
+
error: string | null;
|
|
30
|
+
title: string;
|
|
31
|
+
role: string;
|
|
32
|
+
servicePostParentId: string | null;
|
|
33
|
+
lastMessage: any;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
actions: {
|
|
37
|
+
errorState: assign(({ context, event }) => {
|
|
38
|
+
return {
|
|
39
|
+
...context,
|
|
40
|
+
error: event.data?.message || 'An error occurred',
|
|
41
|
+
loading: false,
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
setInitialContext: assign(({ context, event }) => {
|
|
45
|
+
return merge({
|
|
46
|
+
...context,
|
|
47
|
+
channelId: event.data?.channelId || null,
|
|
48
|
+
currentUser: event.data?.currentUser || null,
|
|
49
|
+
role: event.data?.role || null,
|
|
50
|
+
loading: true,
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
setThreadMessages: assign(({ context, event }) => {
|
|
54
|
+
return {
|
|
55
|
+
...context,
|
|
56
|
+
threadMessages: event.data?.threadMessages || [],
|
|
57
|
+
loading: false,
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
updateThreadMessages: assign(({ context, event }) => {
|
|
61
|
+
const newThreadMessage = event.data?.message;
|
|
62
|
+
if (!newThreadMessage) return context;
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...context,
|
|
66
|
+
threadMessages: [...context.threadMessages, newThreadMessage],
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
setTitle: assign(({ context, event }) => {
|
|
70
|
+
return {
|
|
71
|
+
...context,
|
|
72
|
+
title: event.data?.title || '',
|
|
73
|
+
};
|
|
74
|
+
}),
|
|
75
|
+
setServicePostParentId: assign(({ context, event }) => {
|
|
76
|
+
return {
|
|
77
|
+
...context,
|
|
78
|
+
servicePostParentId: event.data?.servicePostParentId || null,
|
|
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
|
+
},
|
|
94
|
+
}).createMachine({
|
|
95
|
+
id: 'service-dialogs-list-item',
|
|
96
|
+
initial: BaseState.Idle,
|
|
97
|
+
context: {
|
|
98
|
+
channelId: null,
|
|
99
|
+
currentUser: null,
|
|
100
|
+
threadMessages: [],
|
|
101
|
+
loading: false,
|
|
102
|
+
error: null,
|
|
103
|
+
title: '',
|
|
104
|
+
role: '',
|
|
105
|
+
servicePostParentId: null,
|
|
106
|
+
lastMessage: null,
|
|
107
|
+
},
|
|
108
|
+
states: {
|
|
109
|
+
[BaseState.Idle]: {
|
|
110
|
+
on: {
|
|
111
|
+
[Actions.INITIAL_CONTEXT]: {
|
|
112
|
+
target: BaseState.FetchingThreadMessages,
|
|
113
|
+
actions: ['setInitialContext'],
|
|
114
|
+
},
|
|
115
|
+
[Actions.UPDATE_THREAD_MESSAGES]: {
|
|
116
|
+
target: BaseState.Idle,
|
|
117
|
+
actions: ['updateThreadMessages'],
|
|
118
|
+
},
|
|
119
|
+
[Actions.SET_TITLE]: {
|
|
120
|
+
target: BaseState.Idle,
|
|
121
|
+
actions: ['setTitle'],
|
|
122
|
+
},
|
|
123
|
+
[Actions.SET_SERVICE_POST_PARENT_ID]: {
|
|
124
|
+
target: BaseState.Idle,
|
|
125
|
+
actions: ['setServicePostParentId'],
|
|
126
|
+
},
|
|
127
|
+
[Actions.START_LOADING]: {
|
|
128
|
+
target: BaseState.Idle,
|
|
129
|
+
actions: ['startLoading'],
|
|
130
|
+
},
|
|
131
|
+
[Actions.STOP_LOADING]: {
|
|
132
|
+
target: BaseState.Idle,
|
|
133
|
+
actions: ['stopLoading'],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
[BaseState.Error]: {
|
|
138
|
+
entry: ['errorState'],
|
|
139
|
+
on: {
|
|
140
|
+
[Actions.ERROR_HANDLED]: {
|
|
141
|
+
target: BaseState.Idle,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
[BaseState.FetchingThreadMessages]: {
|
|
146
|
+
invoke: {
|
|
147
|
+
src: 'fetchThreadMessages',
|
|
148
|
+
input: ({ context, event }) => ({ context, event }),
|
|
149
|
+
onDone: {
|
|
150
|
+
target: BaseState.Idle,
|
|
151
|
+
actions: ['setThreadMessages'],
|
|
152
|
+
},
|
|
153
|
+
onError: {
|
|
154
|
+
target: BaseState.Error,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
} as any);
|
|
@@ -10,6 +10,6 @@ export const config = cleanEnv(process['APP_ENV'] || process.env, {
|
|
|
10
10
|
THREADS_PATH: str({ default: 'MainStack.Thread' }),
|
|
11
11
|
CALL_TO_ACTION_PATH: str({ default: 'MainStack.GuestReservationRequestDetail' }),
|
|
12
12
|
CALL_TO_ACTION_BOX_BGCOLOR: str({ default: '#0084ff' }),
|
|
13
|
-
CALL_TO_ACTION_BUTTON_BORDERCOLOR: str({ default: '#
|
|
14
|
-
CALL_TO_ACTION_TEXT_COLOR: str({ default: '#
|
|
13
|
+
CALL_TO_ACTION_BUTTON_BORDERCOLOR: str({ default: '#000' }),
|
|
14
|
+
CALL_TO_ACTION_TEXT_COLOR: str({ default: '#000' }),
|
|
15
15
|
});
|