@messenger-box/platform-mobile 10.0.2-alpha.5 → 10.0.3-alpha.5

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 (69) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/compute.js +14 -14
  3. package/lib/compute.js.map +1 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/module.js +1 -2
  6. package/lib/module.js.map +1 -1
  7. package/lib/screens/inbox/DialogMessages.js +44 -20
  8. package/lib/screens/inbox/DialogMessages.js.map +1 -1
  9. package/lib/screens/inbox/DialogThreadMessages.js +13 -48
  10. package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
  11. package/lib/screens/inbox/DialogThreads.js +13 -70
  12. package/lib/screens/inbox/DialogThreads.js.map +1 -1
  13. package/lib/screens/inbox/Inbox.js +18 -9
  14. package/lib/screens/inbox/Inbox.js.map +1 -1
  15. package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
  16. package/lib/screens/inbox/components/CachedImage/index.js +41 -27
  17. package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
  18. package/lib/screens/inbox/components/DialogsListItem.js +96 -146
  19. package/lib/screens/inbox/components/DialogsListItem.js.map +1 -1
  20. package/lib/screens/inbox/components/ServiceDialogsListItem.js +95 -148
  21. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +1 -1
  22. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js +37 -51
  23. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js.map +1 -1
  24. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +113 -97
  25. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  26. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +50 -42
  27. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js.map +1 -1
  28. package/lib/screens/inbox/components/ThreadsViewItem.js +41 -149
  29. package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
  30. package/lib/screens/inbox/config/config.js +8 -10
  31. package/lib/screens/inbox/config/config.js.map +1 -1
  32. package/lib/screens/inbox/containers/ConversationView.js +357 -501
  33. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  34. package/lib/screens/inbox/containers/Dialogs.js +49 -140
  35. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  36. package/lib/screens/inbox/containers/ThreadConversationView.js +297 -400
  37. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  38. package/lib/screens/inbox/containers/ThreadsView.js +83 -190
  39. package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
  40. package/package.json +4 -4
  41. package/rollup.config.mjs +5 -1
  42. package/lib/compute.d.ts +0 -5
  43. package/lib/index.d.ts +0 -4
  44. package/lib/module.d.ts +0 -3
  45. package/lib/navigation/InboxNavigation.d.ts +0 -2
  46. package/lib/navigation/index.d.ts +0 -1
  47. package/lib/screens/inbox/DialogMessages.d.ts +0 -8
  48. package/lib/screens/inbox/DialogThreadMessages.d.ts +0 -8
  49. package/lib/screens/inbox/DialogThreads.d.ts +0 -7
  50. package/lib/screens/inbox/Inbox.d.ts +0 -2
  51. package/lib/screens/inbox/components/CachedImage/consts.d.ts +0 -2
  52. package/lib/screens/inbox/components/CachedImage/index.d.ts +0 -8
  53. package/lib/screens/inbox/components/DialogsHeader.d.ts +0 -8
  54. package/lib/screens/inbox/components/DialogsListItem.d.ts +0 -19
  55. package/lib/screens/inbox/components/ServiceDialogsListItem.d.ts +0 -21
  56. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.d.ts +0 -3
  57. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.d.ts +0 -34
  58. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.d.ts +0 -25
  59. package/lib/screens/inbox/components/SlackMessageContainer/index.d.ts +0 -3
  60. package/lib/screens/inbox/components/SupportServiceDialogsListItem.d.ts +0 -21
  61. package/lib/screens/inbox/components/ThreadsViewItem.d.ts +0 -20
  62. package/lib/screens/inbox/config/config.d.ts +0 -11
  63. package/lib/screens/inbox/config/index.d.ts +0 -1
  64. package/lib/screens/inbox/containers/ConversationView.d.ts +0 -11
  65. package/lib/screens/inbox/containers/Dialogs.d.ts +0 -7
  66. package/lib/screens/inbox/containers/SupportServiceDialogs.d.ts +0 -6
  67. package/lib/screens/inbox/containers/ThreadConversationView.d.ts +0 -11
  68. package/lib/screens/inbox/containers/ThreadsView.d.ts +0 -13
  69. package/lib/screens/index.d.ts +0 -4
@@ -1,16 +1,38 @@
1
- import {__awaiter}from'tslib';import React__default,{useState,useRef,useEffect,useCallback,useMemo}from'react';import {Button,Spinner,VStack,HStack,Avatar,AvatarFallbackText,AvatarImage,Box,Text,Center,ButtonText,Image}from'@admin-layout/gluestack-ui-mobile';import {Platform}from'react-native';import {useRoute,useNavigation,useFocusEffect}from'@react-navigation/native';import {useSelector}from'react-redux';import {uniqBy,orderBy,startCase}from'lodash-es';import*as ImagePicker from'expo-image-picker';import {encode}from'base-64';import {MaterialIcons,Ionicons,MaterialCommunityIcons}from'@expo/vector-icons';import {GiftedChat,Send,MessageText,Actions}from'react-native-gifted-chat';import {PreDefinedRole}from'common';import {useCreatePostThreadMutation,useSendExpoNotificationOnPostMutation,useGetPostThreadLazyQuery,OnThreadChatMessageAddedDocument}from'common/lib/generated/generated.js';import {useUploadFilesNative}from'@messenger-box/platform-client';import {objectId}from'@messenger-box/core';import {format,isToday,isYesterday}from'date-fns';import {userSelector}from'@adminide-stack/user-auth0-client';import {config}from'../config/config.js';import Message from'../components/SlackMessageContainer/SlackMessage.js';import ImageViewerModal from'../components/SlackMessageContainer/ImageViewerModal.js';import CachedImage from'../components/CachedImage/index.js';const {
1
+ import React__default,{useState,useRef,useEffect,useCallback,useMemo}from'react';import {Button,Spinner,VStack,HStack,Avatar,AvatarFallbackText,AvatarImage,Box,Text,Center,Image,ButtonText}from'@admin-layout/gluestack-ui-mobile';import {Platform}from'react-native';import {useRoute,useNavigation,useFocusEffect}from'@react-navigation/native';import {useSelector}from'react-redux';import {uniqBy,orderBy,startCase}from'lodash-es';import*as ImagePicker from'expo-image-picker';import {encode}from'base-64';import {MaterialIcons,Ionicons,MaterialCommunityIcons}from'@expo/vector-icons';import {GiftedChat,Actions,MessageText,Send}from'react-native-gifted-chat';import {PreDefinedRole}from'common';import {useCreatePostThreadMutation,useSendExpoNotificationOnPostMutation,useGetPostThreadLazyQuery,OnThreadChatMessageAddedDocument}from'common/lib/generated/generated.js';import {useUploadFilesNative}from'@messenger-box/platform-client';import {objectId}from'@messenger-box/core';import {format,isToday,isYesterday}from'date-fns';import {userSelector}from'@adminide-stack/user-auth0-client';import {config}from'../config/config.js';import Message from'../components/SlackMessageContainer/SlackMessage.js';import ImageViewerModal from'../components/SlackMessageContainer/ImageViewerModal.js';import CachedImage from'../components/CachedImage/index.js';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 {
2
21
  MESSAGES_PER_PAGE,
3
22
  CALL_TO_ACTION_BOX_BGCOLOR,
4
23
  CALL_TO_ACTION_PATH,
5
24
  CALL_TO_ACTION_BUTTON_BORDERCOLOR,
6
25
  CALL_TO_ACTION_TEXT_COLOR
7
26
  } = config;
8
- const createdAtText = value => {
9
- if (!value) return '';
27
+ const createdAtText = (value) => {
28
+ if (!value)
29
+ return "";
10
30
  let date = new Date(value);
11
- if (isToday(date)) return 'Today';
12
- if (isYesterday(date)) return 'Yesterday';
13
- return format(new Date(value), 'MMM dd, yyyy');
31
+ if (isToday(date))
32
+ return "Today";
33
+ if (isYesterday(date))
34
+ return "Yesterday";
35
+ return format(new Date(value), "MMM dd, yyyy");
14
36
  };
15
37
  const ThreadConversationViewComponent = ({
16
38
  channelId,
@@ -18,7 +40,7 @@ const ThreadConversationViewComponent = ({
18
40
  isPostParentIdThread,
19
41
  role
20
42
  }) => {
21
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
43
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
22
44
  const {
23
45
  params
24
46
  } = useRoute();
@@ -26,13 +48,13 @@ const ThreadConversationViewComponent = ({
26
48
  const [channelMessages, setChannelMessages] = useState([]);
27
49
  const auth = useSelector(userSelector);
28
50
  const [totalCount, setTotalCount] = useState(0);
29
- const [selectedImage, setImage] = useState('');
51
+ const [selectedImage, setImage] = useState("");
30
52
  const [loadingOldMessages, setLoadingOldMessages] = useState(false);
31
53
  const [loadEarlierMsg, setLoadEarlierMsg] = useState(false);
32
54
  const navigation = useNavigation();
33
55
  const [files, setFiles] = useState([]);
34
56
  const [images, setImages] = useState([]);
35
- const [msg, setMsg] = useState('');
57
+ const [msg, setMsg] = useState("");
36
58
  const [loading, setLoading] = useState(false);
37
59
  const [imageLoading, setImageLoading] = useState(false);
38
60
  const [expoTokens, setExpoTokens] = useState([]);
@@ -46,7 +68,6 @@ const ThreadConversationViewComponent = ({
46
68
  const [threadPost, setThreadPost] = useState([]);
47
69
  const [isScrollToBottom, setIsScrollToBottom] = useState(false);
48
70
  const threadMessageListRef = useRef(null);
49
- // const [sendThreadMessage] = useSendThreadMessageMutation();
50
71
  const [sendThreadMessage] = useCreatePostThreadMutation();
51
72
  const [sendExpoNotificationOnPostMutation] = useSendExpoNotificationOnPostMutation();
52
73
  const [getThreadMessages, {
@@ -56,30 +77,20 @@ const ThreadConversationViewComponent = ({
56
77
  refetch: refetchThreadMessages,
57
78
  subscribeToMore
58
79
  }] = useGetPostThreadLazyQuery({
59
- fetchPolicy: 'cache-and-network'
80
+ fetchPolicy: "cache-and-network"
60
81
  });
61
82
  useFocusEffect(React__default.useCallback(() => {
62
- // navigation?.setOptions({ title: params?.title ?? 'Thread' });
63
- var _a;
83
+ var _a2;
64
84
  navigation.setOptions({
65
- title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : 'Thread',
66
- headerLeft: props => React__default.createElement(Button, {
67
- bg: 'transparent',
68
- "$pressed-bg": "$trueGray200",
69
- "$active-bg": '$trueGray200',
70
- onPress: () => navigation.goBack()
71
- }, React__default.createElement(MaterialIcons, {
72
- size: 20,
73
- name: "arrow-back-ios",
74
- color: 'black'
75
- }))
85
+ title: (_a2 = params == null ? void 0 : params.title) != null ? _a2 : "Thread",
86
+ headerLeft: (props) => /* @__PURE__ */ React__default.createElement(Button, { bg: "transparent", "$pressed-bg": "$trueGray200", "$active-bg": "$trueGray200", onPress: () => navigation.goBack() }, /* @__PURE__ */ React__default.createElement(MaterialIcons, { size: 20, name: "arrow-back-ios", color: "black" }))
76
87
  });
77
88
  if (postParentId) {
78
89
  refetchThreadMessages({
79
- channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
80
- role: role === null || role === void 0 ? void 0 : role.toString(),
81
- postParentId: postParentId === null || postParentId === void 0 ? void 0 : postParentId.toString(),
82
- selectedFields: 'id channel post replies replyCount lastReplyAt createdAt updatedAt',
90
+ channelId: channelId == null ? void 0 : channelId.toString(),
91
+ role: role == null ? void 0 : role.toString(),
92
+ postParentId: postParentId == null ? void 0 : postParentId.toString(),
93
+ selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
83
94
  limit: MESSAGES_PER_PAGE
84
95
  });
85
96
  }
@@ -91,49 +102,45 @@ const ThreadConversationViewComponent = ({
91
102
  };
92
103
  }, [postParentId]));
93
104
  useEffect(() => {
94
- //if (parentId && parentId == 0) {
95
105
  if (channelId && parentId) {
96
106
  getThreadMessages({
97
107
  variables: {
98
- channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
99
- role: role === null || role === void 0 ? void 0 : role.toString(),
100
- postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
101
- selectedFields: 'id channel post replies replyCount lastReplyAt createdAt updatedAt',
108
+ channelId: channelId == null ? void 0 : channelId.toString(),
109
+ role: role == null ? void 0 : role.toString(),
110
+ postParentId: !parentId || parentId == 0 ? null : parentId == null ? void 0 : parentId.toString(),
111
+ selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
102
112
  limit: MESSAGES_PER_PAGE
103
113
  }
104
114
  });
105
115
  }
106
116
  }, [parentId]);
107
117
  React__default.useEffect(() => {
108
- var _a, _b, _c;
109
- if (data === null || data === void 0 ? void 0 : data.getPostThread) {
118
+ var _a2, _b2, _c2;
119
+ if (data == null ? void 0 : data.getPostThread) {
110
120
  const threads = data.getPostThread;
111
- const threadPost = (_a = threads === null || threads === void 0 ? void 0 : threads.post) !== null && _a !== void 0 ? _a : [];
112
- const threadReplies = (_b = threads === null || threads === void 0 ? void 0 : threads.replies) !== null && _b !== void 0 ? _b : [];
113
- const messeageTotalCount = (_c = threads === null || threads === void 0 ? void 0 : threads.replyCount) !== null && _c !== void 0 ? _c : 0;
114
- const messages = [threadPost, ...threadReplies];
115
- if (messages.length > 0 && messeageTotalCount > totalCount || messages.length > 0 && channelMessages.length === 0) {
121
+ const threadPost2 = (_a2 = threads == null ? void 0 : threads.post) != null ? _a2 : [];
122
+ const threadReplies = (_b2 = threads == null ? void 0 : threads.replies) != null ? _b2 : [];
123
+ const messeageTotalCount = (_c2 = threads == null ? void 0 : threads.replyCount) != null ? _c2 : 0;
124
+ const messages = [threadPost2, ...threadReplies];
125
+ if (messages && messages.length > 0 && messeageTotalCount > totalCount || messages && messages.length > 0 && channelMessages.length === 0) {
116
126
  setThreadMessages(messages, messeageTotalCount);
117
127
  }
118
128
  }
119
- if (isScrollToBottom && channelMessages) scrollToBottom();
120
- // scrollToBottom();
121
- // if (!isPostParentIdThread) {
122
- // // setTotalCount((pc: any) => pc + threadTotalCount);
123
- // setChannelMessages((oldMessages: any) => uniqBy([...threadMessage, ...oldMessages], ({ id }) => id));
124
- // }
129
+ if (isScrollToBottom && channelMessages)
130
+ scrollToBottom();
125
131
  }, [data, channelMessages, loadingOldMessages, totalCount, isPostParentIdThread, isScrollToBottom]);
126
132
  const setThreadMessages = (messages, messagesTotalCount) => {
127
- setChannelMessages(oldMessages => uniqBy([...messages, ...oldMessages], ({
133
+ setChannelMessages((oldMessages) => uniqBy([...messages, ...oldMessages], ({
128
134
  id
129
135
  }) => id));
130
136
  setTotalCount(messagesTotalCount);
131
137
  };
132
138
  React__default.useEffect(() => {
133
- if (selectedImage) setImageLoading(false);
139
+ if (selectedImage)
140
+ setImageLoading(false);
134
141
  }, [selectedImage]);
135
142
  const scrollToBottom = React__default.useCallback(() => {
136
- if (threadMessageListRef === null || threadMessageListRef === void 0 ? void 0 : threadMessageListRef.current) {
143
+ if (threadMessageListRef == null ? void 0 : threadMessageListRef.current) {
137
144
  setIsScrollToBottom(false);
138
145
  threadMessageListRef.current.scrollTop = threadMessageListRef.current.scrollHeight;
139
146
  }
@@ -143,33 +150,30 @@ const ThreadConversationViewComponent = ({
143
150
  setLoadEarlierMsg(true);
144
151
  fetchMoreMessages({
145
152
  variables: {
146
- channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
147
- role: role === null || role === void 0 ? void 0 : role.toString(),
148
- postParentId: parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
149
- selectedFields: 'id channel post replies replyCount lastReplyAt createdAt updatedAt',
153
+ channelId: channelId == null ? void 0 : channelId.toString(),
154
+ role: role == null ? void 0 : role.toString(),
155
+ postParentId: parentId == null ? void 0 : parentId.toString(),
156
+ selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
150
157
  limit: MESSAGES_PER_PAGE,
151
158
  skip: channelMessages.length - 1
152
159
  }
153
- }).then(res => {
154
- var _a, _b, _c, _d;
155
- if ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.getPostThread) {
156
- const threads = (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.getPostThread;
157
- const threadReplies = (_c = threads === null || threads === void 0 ? void 0 : threads.replies) !== null && _c !== void 0 ? _c : [];
158
- const messeageTotalCount = (_d = threads === null || threads === void 0 ? void 0 : threads.replyCount) !== null && _d !== void 0 ? _d : 0;
160
+ }).then((res) => {
161
+ var _a2, _b2, _c2, _d2;
162
+ if ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.getPostThread) {
163
+ const threads = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.getPostThread;
164
+ const threadReplies = (_c2 = threads == null ? void 0 : threads.replies) != null ? _c2 : [];
165
+ const messeageTotalCount = (_d2 = threads == null ? void 0 : threads.replyCount) != null ? _d2 : 0;
159
166
  setThreadMessages(threadReplies, messeageTotalCount);
160
167
  }
161
168
  }).finally(() => {
162
169
  setLoadEarlierMsg(false);
163
170
  setLoadingOldMessages(false);
164
- }).catch(error => {
171
+ }).catch((error) => {
165
172
  setLoadEarlierMsg(false);
166
173
  setLoadingOldMessages(false);
167
174
  });
168
175
  }
169
176
  }, [parentId, channelId, totalCount, channelMessages]);
170
- // const isCloseToTop = ({ layoutMeasurement, contentOffset, contentSize }) => {
171
- // return contentOffset.y <= 100; // 100px from top
172
- // };
173
177
  const isCloseToTop = ({
174
178
  layoutMeasurement,
175
179
  contentOffset,
@@ -179,11 +183,7 @@ const ThreadConversationViewComponent = ({
179
183
  return contentSize.height - layoutMeasurement.height - paddingToTop <= contentOffset.y;
180
184
  };
181
185
  const dataURLtoFile = (dataurl, filename) => {
182
- var arr = dataurl.split(','),
183
- mime = arr[0].match(/:(.*?);/)[1],
184
- bstr = encode(arr[1]),
185
- n = bstr.length,
186
- u8arr = new Uint8Array(n);
186
+ var arr = dataurl.split(","), mime = arr[0].match(/:(.*?);/)[1], bstr = encode(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
187
187
  while (n--) {
188
188
  u8arr[n] = bstr.charCodeAt(n);
189
189
  }
@@ -191,10 +191,10 @@ const ThreadConversationViewComponent = ({
191
191
  type: mime
192
192
  });
193
193
  };
194
- const onSelectImages = () => __awaiter(void 0, void 0, void 0, function* () {
195
- var _a;
194
+ const onSelectImages = async () => {
195
+ var _a2;
196
196
  setImageLoading(true);
197
- let imageSource = yield ImagePicker.launchImageLibraryAsync({
197
+ let imageSource = await ImagePicker.launchImageLibraryAsync({
198
198
  mediaTypes: ImagePicker.MediaTypeOptions.Images,
199
199
  allowsEditing: true,
200
200
  aspect: [4, 3],
@@ -202,22 +202,25 @@ const ThreadConversationViewComponent = ({
202
202
  base64: true
203
203
  });
204
204
  if (!imageSource.canceled) {
205
- const image = 'data:image/jpeg;base64,' + ((_a = imageSource.assets[0]) === null || _a === void 0 ? void 0 : _a.base64);
205
+ const image = "data:image/jpeg;base64," + ((_a2 = imageSource.assets[0]) == null ? void 0 : _a2.base64);
206
206
  setImage(image);
207
- const file = dataURLtoFile(image, 'inputImage.jpg');
208
- setFiles(files => files.concat(file));
209
- setImages(images => images.concat(imageSource.assets[0]));
207
+ const file = dataURLtoFile(image, "inputImage.jpg");
208
+ setFiles((files2) => files2.concat(file));
209
+ setImages((images2) => images2.concat(imageSource.assets[0]));
210
210
  }
211
- if (imageSource.canceled) setLoading(false);
212
- });
213
- const handleSend = useCallback(message => __awaiter(void 0, void 0, void 0, function* () {
214
- var _a;
215
- if (!channelId) return;
216
- if (!message && message != ' ' && images.length == 0) return;
211
+ if (imageSource.canceled)
212
+ setLoading(false);
213
+ };
214
+ const handleSend = useCallback(async (message) => {
215
+ var _a2;
216
+ if (!channelId)
217
+ return;
218
+ if (!message && message != " " && images.length == 0)
219
+ return;
217
220
  const postId = objectId();
218
221
  if (images && images.length > 0) {
219
222
  setLoading(true);
220
- const uploadResponse = yield startUpload({
223
+ const uploadResponse = await startUpload({
221
224
  file: images,
222
225
  saveUploadedFile: {
223
226
  variables: {
@@ -230,53 +233,53 @@ const ThreadConversationViewComponent = ({
230
233
  }
231
234
  }
232
235
  });
233
- if (uploadResponse === null || uploadResponse === void 0 ? void 0 : uploadResponse.error) setLoading(false);
236
+ if (uploadResponse == null ? void 0 : uploadResponse.error)
237
+ setLoading(false);
234
238
  const uploadedFiles = uploadResponse.data;
235
239
  if (uploadResponse.data) {
236
- setImage('');
240
+ setImage("");
237
241
  setFiles([]);
238
242
  setImages([]);
239
- //setLoading(false);
240
- const files = (_a = uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles.map(f => f.id)) !== null && _a !== void 0 ? _a : null;
241
- yield sendThreadMessage({
243
+ const files2 = (_a2 = uploadedFiles == null ? void 0 : uploadedFiles.map((f) => f.id)) != null ? _a2 : null;
244
+ await sendThreadMessage({
242
245
  variables: {
243
246
  postId,
244
247
  channelId,
245
- postThreadId: postThread && (postThread === null || postThread === void 0 ? void 0 : postThread.id),
248
+ postThreadId: postThread && (postThread == null ? void 0 : postThread.id),
246
249
  postParentId: !parentId || parentId == 0 ? null : parentId,
247
250
  threadMessageInput: {
248
251
  content: message,
249
- files,
252
+ files: files2,
250
253
  role
251
254
  }
252
255
  },
253
256
  update: (cache, {
254
- data,
257
+ data: data2,
255
258
  errors
256
259
  }) => {
257
- var _a, _b, _c, _d, _e, _f, _g;
258
- if (!data || errors) {
260
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2;
261
+ if (!data2 || errors) {
259
262
  setLoading(false);
260
263
  return;
261
264
  }
262
- setPostThread((_a = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _a === void 0 ? void 0 : _a.data);
263
- const lastMessageId = (_c = (_b = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _b === void 0 ? void 0 : _b.lastMessage) === null || _c === void 0 ? void 0 : _c.id;
265
+ setPostThread((_a3 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _a3.data);
266
+ const lastMessageId = (_c2 = (_b2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _b2.lastMessage) == null ? void 0 : _c2.id;
264
267
  if (!parentId || parentId == 0) {
265
- setParentId((_e = (_d = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _d === void 0 ? void 0 : _d.lastMessage) === null || _e === void 0 ? void 0 : _e.id);
268
+ setParentId((_e2 = (_d2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _d2.lastMessage) == null ? void 0 : _e2.id);
266
269
  }
267
270
  setChannelToTop(channelToTop + 1);
268
271
  setLoading(false);
269
- setMsg('');
270
- sendPushNotification(lastMessageId, channelId, parentId, (_g = (_f = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.id);
272
+ setMsg("");
273
+ sendPushNotification(lastMessageId, channelId, parentId, (_g2 = (_f2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _f2.data) == null ? void 0 : _g2.id);
271
274
  }
272
275
  });
273
276
  }
274
277
  } else {
275
278
  setLoading(true);
276
- yield sendThreadMessage({
279
+ await sendThreadMessage({
277
280
  variables: {
278
281
  channelId,
279
- postThreadId: postThread && (postThread === null || postThread === void 0 ? void 0 : postThread.id),
282
+ postThreadId: postThread && (postThread == null ? void 0 : postThread.id),
280
283
  postParentId: !parentId || parentId == 0 ? null : parentId,
281
284
  threadMessageInput: {
282
285
  content: message,
@@ -284,383 +287,286 @@ const ThreadConversationViewComponent = ({
284
287
  }
285
288
  },
286
289
  update: (cache, {
287
- data,
290
+ data: data2,
288
291
  errors
289
292
  }) => {
290
- var _a, _b, _c, _d, _e, _f;
291
- if (!data || errors) {
293
+ var _a3, _b2, _c2, _d2, _e2, _f2;
294
+ if (!data2 || errors) {
292
295
  setLoading(false);
293
296
  return;
294
297
  }
295
- setPostThread(data === null || data === void 0 ? void 0 : data.createPostThread.data);
296
- const lastMessageId = (_b = (_a = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.id;
298
+ setPostThread(data2 == null ? void 0 : data2.createPostThread.data);
299
+ const lastMessageId = (_b2 = (_a3 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _a3.lastMessage) == null ? void 0 : _b2.id;
297
300
  if (!parentId || parentId == 0) {
298
- setParentId((_d = (_c = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _c === void 0 ? void 0 : _c.lastMessage) === null || _d === void 0 ? void 0 : _d.id);
301
+ setParentId((_d2 = (_c2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _c2.lastMessage) == null ? void 0 : _d2.id);
299
302
  }
300
303
  setChannelToTop(channelToTop + 1);
301
304
  setLoading(false);
302
- setMsg('');
303
- sendPushNotification(lastMessageId, channelId, parentId, (_f = (_e = data === null || data === void 0 ? void 0 : data.createPostThread) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.id);
305
+ setMsg("");
306
+ sendPushNotification(lastMessageId, channelId, parentId, (_f2 = (_e2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _e2.data) == null ? void 0 : _f2.id);
304
307
  }
305
308
  });
306
309
  }
307
- }), [setChannelMessages, channelId, images, parentId, expoTokens]);
308
- const sendPushNotification = (messageId, channelId, parentId, threadId) => __awaiter(void 0, void 0, void 0, function* () {
309
- var _a;
310
+ }, [setChannelMessages, channelId, images, parentId, expoTokens]);
311
+ const sendPushNotification = async (messageId, channelId2, parentId2, threadId) => {
312
+ var _a2;
310
313
  const notificationData = {
311
314
  url: config.THREAD_MESSEGE_PATH,
312
315
  params: {
313
- channelId,
314
- title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : 'Thread',
315
- postParentId: parentId,
316
+ channelId: channelId2,
317
+ title: (_a2 = params == null ? void 0 : params.title) != null ? _a2 : "Thread",
318
+ postParentId: parentId2,
316
319
  hideTabBar: true
317
320
  },
318
- screen: 'DialogThreadMessages',
321
+ screen: "DialogThreadMessages",
319
322
  thread: {
320
323
  id: threadId
321
324
  },
322
325
  other: {
323
- sound: Platform.OS === 'android' ? undefined : 'default'
326
+ sound: Platform.OS === "android" ? void 0 : "default"
324
327
  }
325
328
  };
326
- if (parentId || parentId == 0) {
327
- yield sendExpoNotificationOnPostMutation({
329
+ if (parentId2 || parentId2 == 0) {
330
+ await sendExpoNotificationOnPostMutation({
328
331
  variables: {
329
- postId: messageId === null || messageId === void 0 ? void 0 : messageId.toString(),
332
+ postId: messageId == null ? void 0 : messageId.toString(),
330
333
  notificationData
331
334
  }
332
335
  });
333
336
  }
334
- });
337
+ };
335
338
  const messageList = useMemo(() => {
336
339
  let res = [];
337
- const filteredMessages = channelMessages && (channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length) > 0 ? uniqBy([...channelMessages], ({
340
+ const filteredMessages = channelMessages && (channelMessages == null ? void 0 : channelMessages.length) > 0 ? uniqBy([...channelMessages], ({
338
341
  id
339
342
  }) => id) : [];
340
- if (filteredMessages === null || filteredMessages === void 0 ? void 0 : filteredMessages.length) {
341
- orderBy(filteredMessages, ['createdAt'], ['desc']).map(msg => {
342
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
343
+ if (filteredMessages == null ? void 0 : filteredMessages.length) {
344
+ orderBy(filteredMessages, ["createdAt"], ["desc"]).map((msg2) => {
345
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
343
346
  let message = {
344
- _id: '',
345
- text: '',
347
+ _id: "",
348
+ text: "",
346
349
  createdAt: 0,
347
350
  user: {
348
- _id: '',
349
- name: '',
350
- avatar: ''
351
+ _id: "",
352
+ name: "",
353
+ avatar: ""
351
354
  },
352
- type: ''
355
+ type: ""
353
356
  };
354
- const date = new Date(msg.createdAt);
355
- message._id = msg.id;
356
- message.text = msg.message;
357
+ const date = new Date(msg2.createdAt);
358
+ message._id = msg2.id;
359
+ message.text = msg2.message;
357
360
  message.createdAt = date;
358
361
  message.user = {
359
- _id: (_b = (_a = msg === null || msg === void 0 ? void 0 : msg.author) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.id,
360
- name: (_h = (_e = (_d = msg === null || msg === void 0 ? void 0 : msg.author) === null || _d === void 0 ? void 0 : _d.givenName) !== null && _e !== void 0 ? _e : ((_f = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _f === void 0 ? void 0 : _f.given_name) + ' ' + ((_g = msg === null || msg === void 0 ? void 0 : msg.author) === null || _g === void 0 ? void 0 : _g.familyName)) !== null && _h !== void 0 ? _h : (_j = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _j === void 0 ? void 0 : _j.family_name,
361
- avatar: (_l = (_k = msg === null || msg === void 0 ? void 0 : msg.author) === null || _k === void 0 ? void 0 : _k.picture) !== null && _l !== void 0 ? _l : (_m = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _m === void 0 ? void 0 : _m.picture
362
- }, message.image = (_p = (_o = msg.files) === null || _o === void 0 ? void 0 : _o.data[0]) === null || _p === void 0 ? void 0 : _p.url, message.sent = msg === null || msg === void 0 ? void 0 : msg.isDelivered, message.received = msg === null || msg === void 0 ? void 0 : msg.isRead;
363
- message.type = msg === null || msg === void 0 ? void 0 : msg.type;
364
- message.propsConfiguration = msg === null || msg === void 0 ? void 0 : msg.propsConfiguration;
362
+ _id: (_c2 = (_a2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _b2.id,
363
+ name: (_i2 = (_g2 = (_d2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _d2.givenName) != null ? _g2 : ((_e2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _e2.given_name) + " " + ((_f2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _f2.familyName)) != null ? _i2 : (_h2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _h2.family_name,
364
+ avatar: (_l2 = (_j2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _j2.picture) != null ? _l2 : (_k2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _k2.picture
365
+ }, message.image = (_n2 = (_m2 = msg2.files) == null ? void 0 : _m2.data[0]) == null ? void 0 : _n2.url, message.sent = msg2 == null ? void 0 : msg2.isDelivered, message.received = msg2 == null ? void 0 : msg2.isRead;
366
+ message.type = msg2 == null ? void 0 : msg2.type;
367
+ message.propsConfiguration = msg2 == null ? void 0 : msg2.propsConfiguration;
365
368
  res.push(message);
366
369
  });
367
370
  }
368
- return (res === null || res === void 0 ? void 0 : res.length) > 0 ? uniqBy([...res], ({
371
+ return (res == null ? void 0 : res.length) > 0 ? uniqBy([...res], ({
369
372
  _id
370
373
  }) => _id) : [];
371
- //return res;
372
374
  }, [channelMessages]);
373
- const renderSend = props => {
374
- return React__default.createElement(Send, Object.assign({}, props), React__default.createElement(Box, null, React__default.createElement(MaterialCommunityIcons, {
375
- name: "send-circle",
376
- style: {
377
- marginBottom: 5,
378
- marginRight: 5
379
- },
380
- size: 32,
381
- color: "#2e64e5"
382
- })));
375
+ const renderSend = (props) => {
376
+ return /* @__PURE__ */ React__default.createElement(Send, __spreadValues({}, props), /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(MaterialCommunityIcons, { name: "send-circle", style: {
377
+ marginBottom: 5,
378
+ marginRight: 5
379
+ }, size: 32, color: "#2e64e5" })));
383
380
  };
384
- const renderMessageText = props => {
385
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
381
+ const renderMessageText = (props) => {
382
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t, _u, _v, _w, _x, _y;
386
383
  const {
387
384
  currentMessage
388
385
  } = props;
389
- if (currentMessage.type === 'ALERT') {
390
- const attachment = (_b = (_a = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.propsConfiguration) === null || _a === void 0 ? void 0 : _a.contents) === null || _b === void 0 ? void 0 : _b.attachment;
391
- let action = '';
392
- let actionId = '';
393
- let params = {};
394
- if ((_c = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _c === void 0 ? void 0 : _c.extraParams) {
395
- const extraParams = (_d = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _d === void 0 ? void 0 : _d.extraParams;
396
- const route = (_e = extraParams === null || extraParams === void 0 ? void 0 : extraParams.route) !== null && _e !== void 0 ? _e : null;
386
+ if (currentMessage.type === "ALERT") {
387
+ const attachment = (_b2 = (_a2 = currentMessage == null ? void 0 : currentMessage.propsConfiguration) == null ? void 0 : _a2.contents) == null ? void 0 : _b2.attachment;
388
+ let action = "";
389
+ let actionId = "";
390
+ let params2 = {};
391
+ if ((_c2 = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _c2.extraParams) {
392
+ const extraParams = (_d2 = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _d2.extraParams;
393
+ const route = (_e2 = extraParams == null ? void 0 : extraParams.route) != null ? _e2 : null;
397
394
  let path = null;
398
395
  let param = null;
399
396
  if (role && role == PreDefinedRole.Guest) {
400
- path = ((_f = route === null || route === void 0 ? void 0 : route.guest) === null || _f === void 0 ? void 0 : _f.name) ? (_h = (_g = route === null || route === void 0 ? void 0 : route.guest) === null || _g === void 0 ? void 0 : _g.name) !== null && _h !== void 0 ? _h : null : null;
401
- param = ((_j = route === null || route === void 0 ? void 0 : route.guest) === null || _j === void 0 ? void 0 : _j.params) ? (_l = (_k = route === null || route === void 0 ? void 0 : route.guest) === null || _k === void 0 ? void 0 : _k.params) !== null && _l !== void 0 ? _l : null : null;
397
+ path = ((_f2 = route == null ? void 0 : route.guest) == null ? void 0 : _f2.name) ? (_h2 = (_g2 = route == null ? void 0 : route.guest) == null ? void 0 : _g2.name) != null ? _h2 : null : null;
398
+ param = ((_i2 = route == null ? void 0 : route.guest) == null ? void 0 : _i2.params) ? (_k2 = (_j2 = route == null ? void 0 : route.guest) == null ? void 0 : _j2.params) != null ? _k2 : null : null;
402
399
  } else if (role && role == PreDefinedRole.Owner) {
403
- path = ((_m = route === null || route === void 0 ? void 0 : route.host) === null || _m === void 0 ? void 0 : _m.name) ? (_p = (_o = route === null || route === void 0 ? void 0 : route.host) === null || _o === void 0 ? void 0 : _o.name) !== null && _p !== void 0 ? _p : null : null;
404
- param = ((_q = route === null || route === void 0 ? void 0 : route.host) === null || _q === void 0 ? void 0 : _q.params) ? (_s = (_r = route === null || route === void 0 ? void 0 : route.host) === null || _r === void 0 ? void 0 : _r.params) !== null && _s !== void 0 ? _s : null : null;
400
+ path = ((_l2 = route == null ? void 0 : route.host) == null ? void 0 : _l2.name) ? (_n2 = (_m2 = route == null ? void 0 : route.host) == null ? void 0 : _m2.name) != null ? _n2 : null : null;
401
+ param = ((_o2 = route == null ? void 0 : route.host) == null ? void 0 : _o2.params) ? (_q2 = (_p2 = route == null ? void 0 : route.host) == null ? void 0 : _p2.params) != null ? _q2 : null : null;
405
402
  } else {
406
- path = ((_t = route === null || route === void 0 ? void 0 : route.host) === null || _t === void 0 ? void 0 : _t.name) ? (_v = (_u = route === null || route === void 0 ? void 0 : route.host) === null || _u === void 0 ? void 0 : _u.name) !== null && _v !== void 0 ? _v : null : null;
407
- param = ((_w = route === null || route === void 0 ? void 0 : route.host) === null || _w === void 0 ? void 0 : _w.params) ? (_y = (_x = route === null || route === void 0 ? void 0 : route.host) === null || _x === void 0 ? void 0 : _x.params) !== null && _y !== void 0 ? _y : null : null;
403
+ path = ((_r2 = route == null ? void 0 : route.host) == null ? void 0 : _r2.name) ? (_t = (_s2 = route == null ? void 0 : route.host) == null ? void 0 : _s2.name) != null ? _t : null : null;
404
+ param = ((_u = route == null ? void 0 : route.host) == null ? void 0 : _u.params) ? (_w = (_v = route == null ? void 0 : route.host) == null ? void 0 : _v.params) != null ? _w : null : null;
408
405
  }
409
406
  action = path;
410
- params = Object.assign({}, param);
411
- } else if ((_z = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _z === void 0 ? void 0 : _z.link) {
407
+ params2 = __spreadValues({}, param);
408
+ } else if ((_x = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _x.link) {
412
409
  action = CALL_TO_ACTION_PATH;
413
- actionId = (_0 = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _0 === void 0 ? void 0 : _0.link.split('/').pop();
414
- params = {
410
+ actionId = (_y = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _y.link.split("/").pop();
411
+ params2 = {
415
412
  reservationId: actionId
416
413
  };
417
414
  }
418
- // if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
419
- // action = CALL_TO_ACTION_PATH;
420
- // actionId = attachment?.callToAction?.link.split('/').pop();
421
- // }
422
- return React__default.createElement(React__default.Fragment, null, (attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) && action ? React__default.createElement(Box, {
423
- bg: CALL_TO_ACTION_BOX_BGCOLOR,
424
- borderRadius: 15,
425
- pb: 2
426
- }, React__default.createElement(Button, {
427
- variant: 'outline',
428
- size: 'sm',
429
- borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR,
430
- onPress: () => action && params && navigation.navigate(action, params)
431
- }, React__default.createElement(ButtonText, {
432
- color: CALL_TO_ACTION_TEXT_COLOR
433
- }, attachment.callToAction.title)), React__default.createElement(MessageText, Object.assign({}, props, {
434
- textStyle: {
435
- left: {
436
- marginLeft: 5,
437
- color: CALL_TO_ACTION_TEXT_COLOR,
438
- paddingHorizontal: 2
439
- }
415
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (attachment == null ? void 0 : attachment.callToAction) && action ? /* @__PURE__ */ React__default.createElement(Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 }, /* @__PURE__ */ React__default.createElement(
416
+ Button,
417
+ {
418
+ variant: "outline",
419
+ size: "sm",
420
+ borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR,
421
+ onPress: () => action && params2 && navigation.navigate(action, params2)
422
+ },
423
+ /* @__PURE__ */ React__default.createElement(ButtonText, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title)
424
+ ), /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
425
+ left: {
426
+ marginLeft: 5,
427
+ color: CALL_TO_ACTION_TEXT_COLOR,
428
+ paddingHorizontal: 2
440
429
  }
441
- }))) : React__default.createElement(MessageText, Object.assign({}, props, {
442
- textStyle: {
443
- left: {
444
- marginLeft: 5
445
- }
430
+ } }))) : /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
431
+ left: {
432
+ marginLeft: 5
446
433
  }
447
- })));
434
+ } })));
448
435
  } else {
449
- return React__default.createElement(MessageText, Object.assign({}, props, {
450
- textStyle: {
451
- left: {
452
- marginLeft: 5
453
- }
436
+ return /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
437
+ left: {
438
+ marginLeft: 5
454
439
  }
455
- }));
440
+ } }));
456
441
  }
457
442
  };
458
- const renderActions = props => {
459
- return React__default.createElement(Actions, Object.assign({}, props, {
460
- icon: () => React__default.createElement(Ionicons, {
461
- name: 'image',
462
- size: 30,
463
- color: 'black',
464
- onPress: onSelectImages
465
- })
466
- }));
443
+ const renderActions = (props) => {
444
+ return /* @__PURE__ */ React__default.createElement(Actions, __spreadProps(__spreadValues({}, props), { icon: () => /* @__PURE__ */ React__default.createElement(Ionicons, { name: "image", size: 30, color: "black", onPress: onSelectImages }) }));
467
445
  };
468
- const renderAccessory = props => {
469
- return React__default.createElement(Box, null, selectedImage !== '' ? React__default.createElement(HStack, {
470
- alignItems: 'center'
471
- }, React__default.createElement(Image, {
472
- ml: '$3',
473
- key: selectedImage,
474
- alt: 'image',
475
- source: {
476
- uri: selectedImage
446
+ const renderAccessory = (props) => {
447
+ return /* @__PURE__ */ React__default.createElement(Box, null, selectedImage !== "" ? /* @__PURE__ */ React__default.createElement(HStack, { alignItems: "center" }, /* @__PURE__ */ React__default.createElement(Image, { ml: "$3", key: selectedImage, alt: "image", source: {
448
+ uri: selectedImage
449
+ }, size: "xs" }), /* @__PURE__ */ React__default.createElement(
450
+ Button,
451
+ {
452
+ variant: "solid",
453
+ bg: "transparent",
454
+ onPress: () => {
455
+ setFiles([]);
456
+ setImage("");
457
+ setImages([]);
458
+ }
477
459
  },
478
- size: 'xs'
479
- }), React__default.createElement(Button, {
480
- variant: 'solid',
481
- //bg={'$secondary400'}
482
- bg: 'transparent',
483
- onPress: () => {
484
- setFiles([]);
485
- setImage('');
486
- setImages([]);
487
- }
488
- }, React__default.createElement(ButtonText, {
489
- color: '$black'
490
- }, "Cancel"))) : null);
460
+ /* @__PURE__ */ React__default.createElement(ButtonText, { color: "$black" }, "Cancel")
461
+ )) : null);
491
462
  };
492
463
  const setImageViewerObject = (obj, v) => {
493
464
  setImageObject(obj);
494
465
  setImageViewer(v);
495
466
  };
496
467
  const modalContent = React__default.useMemo(() => {
497
- if (!imageObject) return React__default.createElement(React__default.Fragment, null);
468
+ if (!imageObject)
469
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
498
470
  const {
499
471
  image,
500
472
  _id
501
473
  } = imageObject;
502
- return React__default.createElement(CachedImage, {
503
- style: {
504
- width: '100%',
505
- height: '100%'
506
- },
507
- resizeMode: 'cover',
508
- // cacheKey={`${_id}-conversation-modal-image-key`}
509
- cacheKey: `${_id}-slack-bubble-imageKey`,
510
- source: {
511
- uri: image,
512
- //headers: `Authorization: Bearer ${token}`,
513
- expiresIn: 86400
514
- },
515
- alt: 'image'
516
- });
474
+ return /* @__PURE__ */ React__default.createElement(
475
+ CachedImage,
476
+ {
477
+ style: {
478
+ width: "100%",
479
+ height: "100%"
480
+ },
481
+ resizeMode: "cover",
482
+ cacheKey: `${_id}-slack-bubble-imageKey`,
483
+ source: {
484
+ uri: image,
485
+ expiresIn: 86400
486
+ },
487
+ alt: "image"
488
+ }
489
+ );
517
490
  }, [imageObject]);
518
- const renderMessage = props => {
519
- return React__default.createElement(Message, Object.assign({}, props, {
520
- isShowImageViewer: isShowImageViewer,
521
- setImageViewer: setImageViewerObject
522
- }));
491
+ const renderMessage = (props) => {
492
+ return /* @__PURE__ */ React__default.createElement(Message, __spreadProps(__spreadValues({}, props), { isShowImageViewer, setImageViewer: setImageViewerObject }));
523
493
  };
524
494
  let onScroll = false;
525
495
  const onMomentumScrollBegin = ({
526
496
  nativeEvent
527
497
  }) => {
528
498
  onScroll = true;
529
- console.log('scroll top');
530
- if (!loadingOldMessages && isCloseToTop(nativeEvent) && totalCount > (channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length)) {
499
+ console.log("scroll top");
500
+ if (!loadingOldMessages && isCloseToTop(nativeEvent) && totalCount > (channelMessages == null ? void 0 : channelMessages.length)) {
531
501
  onFetchOld();
532
502
  }
533
503
  };
534
504
  const onEndReached = () => {
535
- console.log('on end reached');
536
- if (!onScroll) return;
537
- // load messages, show ActivityIndicator
505
+ console.log("on end reached");
506
+ if (!onScroll)
507
+ return;
538
508
  onScroll = false;
539
- // setLoadingOldMessages(true);
540
509
  };
541
- return React__default.createElement(React__default.Fragment, null, (loadingOldMessages || loadEarlierMsg) && React__default.createElement(Spinner, {
542
- color: '$blue500'
543
- }), isPostParentIdThread && React__default.createElement(React__default.Fragment, null, (threadPost === null || threadPost === void 0 ? void 0 : threadPost.length) > 0 && React__default.createElement(React__default.Fragment, null, React__default.createElement(VStack, {
544
- px: '$2',
545
- pt: '$2',
546
- pb: '$0',
547
- space: 'sm'
548
- }, React__default.createElement(HStack, {
549
- space: 'sm',
550
- alignItems: 'center'
551
- }, React__default.createElement(Avatar, {
552
- bg: 'transparent',
553
- size: 'md'
554
- }, React__default.createElement(AvatarFallbackText, null, startCase((_c = (_b = (_a = threadPost[0]) === null || _a === void 0 ? void 0 : _a.author) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt(0))), React__default.createElement(AvatarImage, {
555
- alt: "image",
556
- style: {
557
- borderRadius: 6,
558
- borderWidth: 2,
559
- borderColor: '#fff'
560
- },
561
- source: {
562
- uri: (_e = (_d = threadPost[0]) === null || _d === void 0 ? void 0 : _d.author) === null || _e === void 0 ? void 0 : _e.picture
563
- }
564
- })), React__default.createElement(Box, null, React__default.createElement(Text, {
565
- color: '$black',
566
- fontWeight: '$bold'
567
- }, (_h = (_g = (_f = threadPost[0]) === null || _f === void 0 ? void 0 : _f.author) === null || _g === void 0 ? void 0 : _g.givenName) !== null && _h !== void 0 ? _h : '', ' ', (_l = (_k = (_j = threadPost[0]) === null || _j === void 0 ? void 0 : _j.author) === null || _k === void 0 ? void 0 : _k.familyName) !== null && _l !== void 0 ? _l : ''), React__default.createElement(Text, {
568
- color: '$trueGray500',
569
- pl: '$0'
570
- }, createdAtText((_m = threadPost[0]) === null || _m === void 0 ? void 0 : _m.createdAt), " at", ' ', format(new Date((_o = threadPost[0]) === null || _o === void 0 ? void 0 : _o.createdAt), 'hh:ss:a')))), React__default.createElement(HStack, {
571
- px: '$2',
572
- space: 'sm',
573
- alignItems: 'center'
574
- }, React__default.createElement(Text, null, (_q = (_p = threadPost[0]) === null || _p === void 0 ? void 0 : _p.message) !== null && _q !== void 0 ? _q : ''))), React__default.createElement(Box, {
575
- py: '$4'
576
- }, React__default.createElement(Box, {
577
- px: '$4',
578
- borderTopWidth: '$1',
579
- borderBottomWidth: '$1',
580
- py: '$2',
581
- borderColor: '$trueGray200'
582
- }, React__default.createElement(Text, {
583
- color: '$trueGray600',
584
- fontWeight: '$bold'
585
- }, (_s = (_r = threadPost[0]) === null || _r === void 0 ? void 0 : _r.replies) === null || _s === void 0 ? void 0 : _s.totalCount, ' ', ((_u = (_t = threadPost[0]) === null || _t === void 0 ? void 0 : _t.replies) === null || _u === void 0 ? void 0 : _u.totalCount) > 0 ? 'replies' : 'reply'))))), React__default.createElement(GiftedChat, {
586
- ref: threadMessageListRef,
587
- wrapInSafeArea: false,
588
- renderLoading: () => React__default.createElement(Spinner, {
589
- color: '$blue500'
590
- }),
591
- messages: messageList,
592
- listViewProps: {
593
- onEndReached: onEndReached,
594
- onEndReachedThreshold: 0.5,
595
- onMomentumScrollBegin: onMomentumScrollBegin
596
- },
597
- onSend: messages => {
598
- var _a, _b;
599
- return handleSend((_b = (_a = messages[0]) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : ' ');
600
- },
601
- text: msg ? msg : ' ',
602
- onInputTextChanged: text => setMsg(text),
603
- renderFooter: () => loading ? React__default.createElement(Spinner, {
604
- color: '$blue500'
605
- }) : imageLoading ? React__default.createElement(Spinner, {
606
- color: '$blue500'
607
- }) : '',
608
- scrollToBottom: true,
609
- user: {
610
- _id: (auth === null || auth === void 0 ? void 0 : auth.id) || ''
611
- },
612
- isTyping: true,
613
- alwaysShowSend: loading ? false : true,
614
- // onLoadEarlier={onFetchOld}
615
- infiniteScroll: true,
616
- renderSend: renderSend,
617
- // loadEarlier={data?.messages?.totalCount > channelMessages.length}
618
- // isLoadingEarlier={loadEarlierMsg}
619
- // renderLoadEarlier={() =>
620
- // !loadEarlierMsg && (
621
- // <Center py={2}>
622
- // <Button
623
- // onPress={() => onFetchOld(channelMessages?.length)}
624
- // variant={'outline'}
625
- // _text={{ color: 'black', fontSize: 15, fontWeight: 'bold' }}
626
- // >
627
- // Load earlier messages
628
- // </Button>
629
- // </Center>
630
- // )
631
- // }
632
- renderMessageText: renderMessageText,
633
- minInputToolbarHeight: 50,
634
- renderActions: renderActions,
635
- renderAccessory: renderAccessory,
636
- renderMessage: renderMessage,
637
- renderChatFooter: () => React__default.createElement(React__default.Fragment, null, React__default.createElement(ImageViewerModal, {
638
- isVisible: isShowImageViewer,
639
- setVisible: setImageViewer,
640
- modalContent: modalContent
641
- }), React__default.createElement(SubscriptionHandler, {
642
- channelId: channelId,
643
- subscribeToNewMessages: () => subscribeToMore({
510
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (loadingOldMessages || loadEarlierMsg) && /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }), isPostParentIdThread && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (threadPost == null ? void 0 : threadPost.length) > 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(VStack, { px: "$2", pt: "$2", pb: "$0", space: "sm" }, /* @__PURE__ */ React__default.createElement(HStack, { space: "sm", alignItems: "center" }, /* @__PURE__ */ React__default.createElement(Avatar, { bg: "transparent", size: "md" }, /* @__PURE__ */ React__default.createElement(AvatarFallbackText, null, startCase((_c = (_b = (_a = threadPost[0]) == null ? void 0 : _a.author) == null ? void 0 : _b.username) == null ? void 0 : _c.charAt(0))), /* @__PURE__ */ React__default.createElement(AvatarImage, { alt: "image", style: {
511
+ borderRadius: 6,
512
+ borderWidth: 2,
513
+ borderColor: "#fff"
514
+ }, source: {
515
+ uri: (_e = (_d = threadPost[0]) == null ? void 0 : _d.author) == null ? void 0 : _e.picture
516
+ } })), /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(Text, { color: "$black", fontWeight: "$bold" }, (_h = (_g = (_f = threadPost[0]) == null ? void 0 : _f.author) == null ? void 0 : _g.givenName) != null ? _h : "", " ", (_k = (_j = (_i = threadPost[0]) == null ? void 0 : _i.author) == null ? void 0 : _j.familyName) != null ? _k : ""), /* @__PURE__ */ React__default.createElement(Text, { color: "$trueGray500", pl: "$0" }, createdAtText((_l = threadPost[0]) == null ? void 0 : _l.createdAt), " at", " ", format(new Date((_m = threadPost[0]) == null ? void 0 : _m.createdAt), "hh:ss:a")))), /* @__PURE__ */ React__default.createElement(HStack, { px: "$2", space: "sm", alignItems: "center" }, /* @__PURE__ */ React__default.createElement(Text, null, (_o = (_n = threadPost[0]) == null ? void 0 : _n.message) != null ? _o : ""))), /* @__PURE__ */ React__default.createElement(Box, { py: "$4" }, /* @__PURE__ */ React__default.createElement(Box, { px: "$4", borderTopWidth: "$1", borderBottomWidth: "$1", py: "$2", borderColor: "$trueGray200" }, /* @__PURE__ */ React__default.createElement(Text, { color: "$trueGray600", fontWeight: "$bold" }, (_q = (_p = threadPost[0]) == null ? void 0 : _p.replies) == null ? void 0 : _q.totalCount, " ", ((_s = (_r = threadPost[0]) == null ? void 0 : _r.replies) == null ? void 0 : _s.totalCount) > 0 ? "replies" : "reply"))))), /* @__PURE__ */ React__default.createElement(
517
+ GiftedChat,
518
+ {
519
+ ref: threadMessageListRef,
520
+ wrapInSafeArea: false,
521
+ renderLoading: () => /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }),
522
+ messages: messageList,
523
+ listViewProps: {
524
+ onEndReached,
525
+ onEndReachedThreshold: 0.5,
526
+ onMomentumScrollBegin
527
+ },
528
+ onSend: (messages) => {
529
+ var _a2, _b2;
530
+ return handleSend((_b2 = (_a2 = messages[0]) == null ? void 0 : _a2.text) != null ? _b2 : " ");
531
+ },
532
+ text: msg ? msg : " ",
533
+ onInputTextChanged: (text) => setMsg(text),
534
+ renderFooter: () => loading ? /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }) : imageLoading ? /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }) : "",
535
+ scrollToBottom: true,
536
+ user: {
537
+ _id: (auth == null ? void 0 : auth.id) || ""
538
+ },
539
+ isTyping: true,
540
+ alwaysShowSend: loading ? false : true,
541
+ infiniteScroll: true,
542
+ renderSend,
543
+ renderMessageText,
544
+ minInputToolbarHeight: 50,
545
+ renderActions,
546
+ renderAccessory,
547
+ renderMessage,
548
+ renderChatFooter: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(ImageViewerModal, { isVisible: isShowImageViewer, setVisible: setImageViewer, modalContent }), /* @__PURE__ */ React__default.createElement(SubscriptionHandler, { channelId, subscribeToNewMessages: () => subscribeToMore({
644
549
  document: OnThreadChatMessageAddedDocument,
645
550
  variables: {
646
- channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
647
- postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString()
551
+ channelId: channelId == null ? void 0 : channelId.toString(),
552
+ postParentId: !parentId || parentId == 0 ? null : parentId == null ? void 0 : parentId.toString()
648
553
  },
649
554
  updateQuery: (prev, {
650
555
  subscriptionData
651
556
  }) => {
652
- var _a, _b, _c;
653
- if (!subscriptionData.data) return prev;
654
- const newMessage = (_a = subscriptionData === null || subscriptionData === void 0 ? void 0 : subscriptionData.data) === null || _a === void 0 ? void 0 : _a.threadChatMessageAdded;
655
- const prevReplyCount = (_b = prev === null || prev === void 0 ? void 0 : prev.getPostThread) === null || _b === void 0 ? void 0 : _b.replyCount;
557
+ var _a2, _b2, _c2;
558
+ if (!subscriptionData.data)
559
+ return prev;
560
+ const newMessage = (_a2 = subscriptionData == null ? void 0 : subscriptionData.data) == null ? void 0 : _a2.threadChatMessageAdded;
561
+ const prevReplyCount = (_b2 = prev == null ? void 0 : prev.getPostThread) == null ? void 0 : _b2.replyCount;
656
562
  const newReplyCount = prevReplyCount || 0 + 1;
657
- const replies = ((_c = prev === null || prev === void 0 ? void 0 : prev.getPostThread) === null || _c === void 0 ? void 0 : _c.replies) || [];
658
- setChannelMessages(oldMessages => uniqBy([...oldMessages, newMessage], ({
563
+ const replies = ((_c2 = prev == null ? void 0 : prev.getPostThread) == null ? void 0 : _c2.replies) || [];
564
+ setChannelMessages((oldMessages) => uniqBy([...oldMessages, newMessage], ({
659
565
  id
660
566
  }) => id));
661
567
  setTotalCount(newReplyCount);
662
568
  return Object.assign({}, prev, {
663
- getPostThread: Object.assign(Object.assign({}, prev === null || prev === void 0 ? void 0 : prev.getPostThread), {
569
+ getPostThread: __spreadProps(__spreadValues({}, prev == null ? void 0 : prev.getPostThread), {
664
570
  lastReplyAt: newMessage.createdAt,
665
571
  replies: [newMessage, ...replies],
666
572
  replyCount: newReplyCount,
@@ -668,38 +574,29 @@ const ThreadConversationViewComponent = ({
668
574
  })
669
575
  });
670
576
  }
671
- })
672
- })),
673
- messagesContainerStyle: (messageList === null || messageList === void 0 ? void 0 : messageList.length) == 0 && {
674
- transform: [{
675
- scaleY: -1
676
- }]
677
- },
678
- renderChatEmpty: () => React__default.createElement(React__default.Fragment, null, !threadLoading && messageList && (messageList === null || messageList === void 0 ? void 0 : messageList.length) == 0 && React__default.createElement(Box, {
679
- p: '$5'
680
- }, React__default.createElement(Center, {
681
- mt: '$6'
682
- }, React__default.createElement(Ionicons, {
683
- name: "chatbubbles",
684
- size: 30
685
- }), React__default.createElement(Text, null, "You don't have any message yet!")))),
686
- lightboxProps: {
687
- underlayColor: 'transparent',
688
- springConfig: {
689
- tension: 90000,
690
- friction: 90000
577
+ }) })),
578
+ messagesContainerStyle: (messageList == null ? void 0 : messageList.length) == 0 && {
579
+ transform: [{
580
+ scaleY: -1
581
+ }]
691
582
  },
692
- disabled: true
583
+ renderChatEmpty: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !threadLoading && messageList && (messageList == null ? void 0 : messageList.length) == 0 && /* @__PURE__ */ React__default.createElement(Box, { p: "$5" }, /* @__PURE__ */ React__default.createElement(Center, { mt: "$6" }, /* @__PURE__ */ React__default.createElement(Ionicons, { name: "chatbubbles", size: 30 }), /* @__PURE__ */ React__default.createElement(Text, null, "You don't have any message yet!")))),
584
+ lightboxProps: {
585
+ underlayColor: "transparent",
586
+ springConfig: {
587
+ tension: 9e4,
588
+ friction: 9e4
589
+ },
590
+ disabled: true
591
+ }
693
592
  }
694
- }));
593
+ ));
695
594
  };
696
595
  const SubscriptionHandler = ({
697
596
  subscribeToNewMessages,
698
597
  channelId
699
598
  }) => {
700
599
  useEffect(() => subscribeToNewMessages(), [channelId]);
701
- return React__default.createElement(React__default.Fragment, null);
600
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
702
601
  };
703
- const ThreadConversationView = ThreadConversationViewComponent;
704
- // export const ThreadConversationView = React.memo(ThreadConversationViewComponent);
705
- export{ThreadConversationView};//# sourceMappingURL=ThreadConversationView.js.map
602
+ const ThreadConversationView = ThreadConversationViewComponent;export{ThreadConversationView};//# sourceMappingURL=ThreadConversationView.js.map