@messenger-box/platform-mobile 0.0.1-alpha.377 → 0.0.1-alpha.381

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.0.1-alpha.381](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.380...v0.0.1-alpha.381) (2023-08-09)
7
+
8
+ **Note:** Version bump only for package @messenger-box/platform-mobile
9
+
10
+ ## [0.0.1-alpha.379](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.378...v0.0.1-alpha.379) (2023-08-04)
11
+
12
+ **Note:** Version bump only for package @messenger-box/platform-mobile
13
+
6
14
  ## [0.0.1-alpha.377](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.376...v0.0.1-alpha.377) (2023-07-29)
7
15
 
8
16
  **Note:** Version bump only for package @messenger-box/platform-mobile
package/lib/index.js CHANGED
@@ -1689,6 +1689,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
1689
1689
  });
1690
1690
  const { startUpload } = (0, platform_client_1.useUploadFilesNative)();
1691
1691
  const [sendMsg] = (0, platform_client_1.useSendMessagesMutation)();
1692
+ const [sendExpoNotificationOnPostMutation] = (0, platform_client_1.useSendExpoNotificationOnPostMutation)();
1692
1693
  const { data, loading: messageLoading, refetch, } = (0, platform_client_1.useMessagesQuery)({
1693
1694
  variables: {
1694
1695
  channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
@@ -1936,45 +1937,44 @@ const ConversationViewComponent = ({ channelId, role }) => {
1936
1937
  if (imageSource.cancelled)
1937
1938
  setLoading(false);
1938
1939
  };
1939
- const sendPushNotification = async (title, body, data, to) => {
1940
- try {
1941
- const response = await fetch('https://exp.host/--/api/v2/push/send/', {
1942
- method: 'POST',
1943
- headers: {
1944
- Accept: 'application/json',
1945
- 'Accept-Encoding': 'gzip, deflate',
1946
- 'Content-Type': 'application/json',
1947
- },
1948
- body: JSON.stringify({
1949
- to: to,
1950
- data: data,
1951
- title: title,
1952
- body: body,
1953
- sound: react_native_1.Platform.OS === 'android' ? false || null : 'default',
1954
- }),
1955
- });
1956
- const result = await response.json();
1957
- console.log('expo api response', result);
1958
- }
1959
- catch (error) {
1960
- console.error('Error:', error);
1961
- }
1962
- // fetch('https://exp.host/--/api/v2/push/send/', {
1963
- // method: 'POST',
1964
- // headers: {
1965
- // Accept: 'application/json',
1966
- // 'Accept-Encoding': 'gzip, deflate',
1967
- // 'Content-Type': 'application/json',
1968
- // },
1969
- // body: JSON.stringify({
1970
- // to: to,
1971
- // data: data,
1972
- // title: title,
1973
- // body: body,
1974
- // sound: Platform.OS === 'android' ? null : 'default',
1975
- // }),
1976
- // });
1977
- };
1940
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
1941
+ // try {
1942
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
1943
+ // method: 'POST',
1944
+ // headers: {
1945
+ // Accept: 'application/json',
1946
+ // 'Accept-Encoding': 'gzip, deflate',
1947
+ // 'Content-Type': 'application/json',
1948
+ // },
1949
+ // body: JSON.stringify({
1950
+ // to: to,
1951
+ // data: data,
1952
+ // title: title,
1953
+ // body: body,
1954
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
1955
+ // }),
1956
+ // });
1957
+ // const result: any = await response.json();
1958
+ // console.log('expo api response', result);
1959
+ // } catch (error) {
1960
+ // console.error('Error:', error);
1961
+ // }
1962
+ // // fetch('https://exp.host/--/api/v2/push/send/', {
1963
+ // // method: 'POST',
1964
+ // // headers: {
1965
+ // // Accept: 'application/json',
1966
+ // // 'Accept-Encoding': 'gzip, deflate',
1967
+ // // 'Content-Type': 'application/json',
1968
+ // // },
1969
+ // // body: JSON.stringify({
1970
+ // // to: to,
1971
+ // // data: data,
1972
+ // // title: title,
1973
+ // // body: body,
1974
+ // // sound: Platform.OS === 'android' ? null : 'default',
1975
+ // // }),
1976
+ // // });
1977
+ // };
1978
1978
  // const handleSend = useCallback(
1979
1979
  // async (message: string) => {
1980
1980
  // // if (!(message && channelId)) {
@@ -2112,7 +2112,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
2112
2112
  setLoading(false);
2113
2113
  setMsg('');
2114
2114
  const msg = message == '' ? 'Send a file' : message;
2115
- fetchTokenAndSendPushNotification(msg, channelId);
2115
+ sendPushNotification(data === null || data === void 0 ? void 0 : data.sendMessage, channelId);
2116
2116
  },
2117
2117
  });
2118
2118
  }
@@ -2134,39 +2134,60 @@ const ConversationViewComponent = ({ channelId, role }) => {
2134
2134
  setChannelToTop(channelToTop + 1);
2135
2135
  setLoading(false);
2136
2136
  setMsg('');
2137
- fetchTokenAndSendPushNotification(message, channelId);
2137
+ sendPushNotification(data === null || data === void 0 ? void 0 : data.sendMessage, channelId);
2138
2138
  },
2139
2139
  });
2140
2140
  }
2141
2141
  }, [mongooseObjectId, setChannelMessages, channelId, images, channelToTop, expoTokens]);
2142
- const fetchTokenAndSendPushNotification = (message, channelId) => {
2143
- var _a, _b, _c, _d, _e;
2144
- const givenName = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _a === void 0 ? void 0 : _a.given_name) !== null && _b !== void 0 ? _b : '';
2145
- const familyName = (_d = (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.family_name) !== null && _d !== void 0 ? _d : '';
2146
- const fullName = givenName ? givenName + ' ' + familyName : '';
2147
- const title = fullName ? fullName : 'Message';
2148
- const body = message;
2142
+ const sendPushNotification = async (post, channelId) => {
2143
+ var _a;
2149
2144
  const notificationData = {
2150
2145
  url: config_1.config.INBOX_MESSEGE_PATH,
2151
2146
  params: { channelId, hideTabBar: true },
2152
2147
  screen: 'DialogMessages',
2148
+ other: { sound: react_native_1.Platform.OS === 'android' ? false || null : 'default' },
2153
2149
  };
2154
- (_e = refetchChannelDetail({ id: channelId === null || channelId === void 0 ? void 0 : channelId.toString() })) === null || _e === void 0 ? void 0 : _e.then((res) => {
2155
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2156
- if ((_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.viewChannelDetail) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.length) {
2157
- const channelData = (_g = (_f = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.viewChannelDetail) === null || _e === void 0 ? void 0 : _e.members) === null || _f === void 0 ? void 0 : _f.filter((mu) => { var _a; return ((_a = mu === null || mu === void 0 ? void 0 : mu.user) === null || _a === void 0 ? void 0 : _a.id) != (auth === null || auth === void 0 ? void 0 : auth.id); })) !== null && _g !== void 0 ? _g : [];
2158
- const tokens = (_l = (_k = (_j = (_h = channelData === null || channelData === void 0 ? void 0 : channelData.map((u) => {
2159
- var _a, _b, _c, _d;
2160
- return (_d = (_c = (_b = (_a = u === null || u === void 0 ? void 0 : u.user) === null || _a === void 0 ? void 0 : _a.tokens) === null || _b === void 0 ? void 0 : _b.filter((t) => (t === null || t === void 0 ? void 0 : t.type) == 'EXPO_NOTIFICATION_TOKEN')) === null || _c === void 0 ? void 0 : _c.map((et) => et === null || et === void 0 ? void 0 : et.token)) !== null && _d !== void 0 ? _d : [];
2161
- })) === null || _h === void 0 ? void 0 : _h.flat(1)) === null || _j === void 0 ? void 0 : _j.filter((t) => t)) === null || _k === void 0 ? void 0 : _k.filter((value, index, array) => array.indexOf(value) === index)) !== null && _l !== void 0 ? _l : [];
2162
- console.log('expo to', JSON.stringify(tokens));
2163
- if ((tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0) {
2164
- const to = (tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0 ? tokens : [];
2165
- sendPushNotification(title, body, notificationData, to);
2166
- }
2167
- }
2150
+ await sendExpoNotificationOnPostMutation({
2151
+ variables: {
2152
+ postId: (_a = post === null || post === void 0 ? void 0 : post.id) === null || _a === void 0 ? void 0 : _a.toString(),
2153
+ notificationData,
2154
+ },
2168
2155
  });
2169
2156
  };
2157
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any) => {
2158
+ // const givenName = auth?.profile?.given_name ?? '';
2159
+ // const familyName = auth?.profile?.family_name ?? '';
2160
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
2161
+ // const title: String = fullName ? fullName : 'Message';
2162
+ // const body: String = message;
2163
+ // const notificationData: any = {
2164
+ // url: config.INBOX_MESSEGE_PATH,
2165
+ // params: { channelId, hideTabBar: true },
2166
+ // screen: 'DialogMessages',
2167
+ // };
2168
+ // refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
2169
+ // if (res?.data?.viewChannelDetail?.members?.length) {
2170
+ // const channelData: any =
2171
+ // res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
2172
+ // const tokens: any =
2173
+ // channelData
2174
+ // ?.map(
2175
+ // (u: any) =>
2176
+ // u?.user?.tokens
2177
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
2178
+ // ?.map((et: any) => et?.token) ?? [],
2179
+ // )
2180
+ // ?.flat(1)
2181
+ // ?.filter((t: any) => t)
2182
+ // ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
2183
+ // console.log('expo to', JSON.stringify(tokens));
2184
+ // if (tokens?.length > 0) {
2185
+ // const to: any = tokens?.length > 0 ? tokens : [];
2186
+ // sendPushNotification(title, body, notificationData, to);
2187
+ // }
2188
+ // }
2189
+ // });
2190
+ // };
2170
2191
  // const handleSend1 = async (message: string) => {
2171
2192
  // if (!channelId) return;
2172
2193
  // if (!message && message != ' ' && images.length == 0) return;
@@ -2303,7 +2324,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
2303
2324
  react_1.default.createElement(vector_icons_1.MaterialCommunityIcons, { name: "send-circle", style: { marginBottom: 5, marginRight: 5 }, size: 32, color: "#2e64e5" }))));
2304
2325
  };
2305
2326
  const renderMessageText = (props) => {
2306
- 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, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
2327
+ 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, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22;
2307
2328
  const { currentMessage } = props;
2308
2329
  const lastReply = ((_b = (_a = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) > 0 ? (_d = (_c = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0] : null;
2309
2330
  if (currentMessage.type === 'ALERT') {
@@ -2336,13 +2357,12 @@ const ConversationViewComponent = ({ channelId, role }) => {
2336
2357
  actionId = (_4 = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _4 === void 0 ? void 0 : _4.link.split('/').pop();
2337
2358
  params = { reservationId: actionId };
2338
2359
  }
2339
- return (react_1.default.createElement(native_base_1.Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 },
2340
- (attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) ? (react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR, onPress: () => action && params && navigation.navigate(action, params) },
2341
- react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title))) : null,
2342
- react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } } }))));
2343
- }
2344
- else {
2345
- return (react_1.default.createElement(react_native_1.TouchableHighlight, { underlayColor: '#c0c0c0', style: { width: '100%' }, onPress: () => navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
2360
+ return (react_1.default.createElement(react_1.default.Fragment, null, (attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) && action ? (react_1.default.createElement(native_base_1.Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 },
2361
+ react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR, onPress: () => action && params && navigation.navigate(action, params) },
2362
+ react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title)),
2363
+ react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: {
2364
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
2365
+ } })))) : (react_1.default.createElement(react_native_1.TouchableHighlight, { underlayColor: '#c0c0c0', style: { width: '100%' }, onPress: () => navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
2346
2366
  channelId: channelId,
2347
2367
  title: 'Message',
2348
2368
  postParentId: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage._id,
@@ -2357,7 +2377,11 @@ const ConversationViewComponent = ({ channelId, role }) => {
2357
2377
  // top={i == 1 ? 4 : 0}
2358
2378
  // right={i == 1 ? -2 : 0}
2359
2379
  // zIndex={i == 1 ? 5 : 1}
2360
- _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
2380
+ _image: {
2381
+ borderRadius: 6,
2382
+ borderWidth: 2,
2383
+ borderColor: '#fff',
2384
+ }, source: {
2361
2385
  uri: (_a = p === null || p === void 0 ? void 0 : p.author) === null || _a === void 0 ? void 0 : _a.picture,
2362
2386
  } }, (0, lodash_1.startCase)((_c = (_b = p === null || p === void 0 ? void 0 : p.author) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt(0))));
2363
2387
  })),
@@ -2365,6 +2389,32 @@ const ConversationViewComponent = ({ channelId, role }) => {
2365
2389
  _12.totalCount,
2366
2390
  ' ',
2367
2391
  ((_13 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _13 === void 0 ? void 0 : _13.totalCount) == 1 ? 'reply' : 'replies'),
2392
+ react_1.default.createElement(native_base_1.Text, { fontSize: 12, fontWeight: 'bold', color: 'gray.500' }, lastReply ? createdAtText(lastReply === null || lastReply === void 0 ? void 0 : lastReply.createdAt) : ''))))))));
2393
+ }
2394
+ else {
2395
+ return (react_1.default.createElement(react_native_1.TouchableHighlight, { underlayColor: '#c0c0c0', style: { width: '100%' }, onPress: () => navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
2396
+ channelId: channelId,
2397
+ title: 'Message',
2398
+ postParentId: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage._id,
2399
+ isPostParentIdThread: true,
2400
+ }) },
2401
+ react_1.default.createElement(react_1.default.Fragment, null,
2402
+ react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } })),
2403
+ ((_15 = (_14 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _14 === void 0 ? void 0 : _14.data) === null || _15 === void 0 ? void 0 : _15.length) > 0 && (react_1.default.createElement(native_base_1.HStack, { space: 1, px: 1, alignItems: 'center' },
2404
+ react_1.default.createElement(native_base_1.HStack, null, (_20 = (_19 = (_18 = (_17 = (_16 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _16 === void 0 ? void 0 : _16.data) === null || _17 === void 0 ? void 0 : _17.filter((v, i, a) => a.findIndex((t) => { var _a, _b; return ((_a = t === null || t === void 0 ? void 0 : t.author) === null || _a === void 0 ? void 0 : _a.id) === ((_b = v === null || v === void 0 ? void 0 : v.author) === null || _b === void 0 ? void 0 : _b.id); }) === i)) === null || _18 === void 0 ? void 0 : _18.slice(0, 2)) === null || _19 === void 0 ? void 0 : _19.reverse()) === null || _20 === void 0 ? void 0 : _20.map((p, i) => {
2405
+ var _a, _b, _c;
2406
+ return (react_1.default.createElement(native_base_1.Avatar, { key: 'key' + i, bg: 'transparent', size: 6,
2407
+ // top={i == 1 ? 4 : 0}
2408
+ // right={i == 1 ? -2 : 0}
2409
+ // zIndex={i == 1 ? 5 : 1}
2410
+ _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
2411
+ uri: (_a = p === null || p === void 0 ? void 0 : p.author) === null || _a === void 0 ? void 0 : _a.picture,
2412
+ } }, (0, lodash_1.startCase)((_c = (_b = p === null || p === void 0 ? void 0 : p.author) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt(0))));
2413
+ })),
2414
+ react_1.default.createElement(native_base_1.Text, { fontSize: 12, fontWeight: 'bold', color: 'blue.800' }, (_21 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _21 === void 0 ? void 0 :
2415
+ _21.totalCount,
2416
+ ' ',
2417
+ ((_22 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _22 === void 0 ? void 0 : _22.totalCount) == 1 ? 'reply' : 'replies'),
2368
2418
  react_1.default.createElement(native_base_1.Text, { fontSize: 12, fontWeight: 'bold', color: 'gray.500' }, lastReply ? createdAtText(lastReply === null || lastReply === void 0 ? void 0 : lastReply.createdAt) : ''))))));
2369
2419
  }
2370
2420
  };
@@ -2828,6 +2878,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
2828
2878
  },
2829
2879
  });
2830
2880
  const [sendThreadMessage] = (0, platform_client_1.useSendThreadMessageMutation)();
2881
+ const [sendExpoNotificationOnPostMutation] = (0, platform_client_1.useSendExpoNotificationOnPostMutation)();
2831
2882
  const [getThreadMessages, { data: threadMessagesData, loading: threadLoading, refetch: refetchThreadMessages }] = (0, platform_client_1.useThreadMessagesLazyQuery)({
2832
2883
  variables: {
2833
2884
  channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
@@ -3021,30 +3072,29 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3021
3072
  if (imageSource.cancelled)
3022
3073
  setLoading(false);
3023
3074
  };
3024
- const sendPushNotification = async (title, body, data, to) => {
3025
- try {
3026
- const response = await fetch('https://exp.host/--/api/v2/push/send/', {
3027
- method: 'POST',
3028
- headers: {
3029
- Accept: 'application/json',
3030
- 'Accept-Encoding': 'gzip, deflate',
3031
- 'Content-Type': 'application/json',
3032
- },
3033
- body: JSON.stringify({
3034
- to: to,
3035
- data: data,
3036
- title: title,
3037
- body: body,
3038
- sound: react_native_1.Platform.OS === 'android' ? false || null : 'default',
3039
- }),
3040
- });
3041
- const result = await response.json();
3042
- console.log('expo api response', result);
3043
- }
3044
- catch (error) {
3045
- console.error('Error:', error);
3046
- }
3047
- };
3075
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
3076
+ // try {
3077
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
3078
+ // method: 'POST',
3079
+ // headers: {
3080
+ // Accept: 'application/json',
3081
+ // 'Accept-Encoding': 'gzip, deflate',
3082
+ // 'Content-Type': 'application/json',
3083
+ // },
3084
+ // body: JSON.stringify({
3085
+ // to: to,
3086
+ // data: data,
3087
+ // title: title,
3088
+ // body: body,
3089
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
3090
+ // }),
3091
+ // });
3092
+ // const result: any = await response.json();
3093
+ // console.log('expo api response', result);
3094
+ // } catch (error) {
3095
+ // console.error('Error:', error);
3096
+ // }
3097
+ // };
3048
3098
  // const ObjectId = (m = Math, d = Date, h = 16, s = (s:any) => m.floor(s).toString(h)) =>
3049
3099
  // s(d.now() / 1000) + ' '.repeat(h).replace(/./g, () => s(m.random() * h))
3050
3100
  const handleSend = (0, react_1.useCallback)(async (message) => {
@@ -3090,7 +3140,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3090
3140
  },
3091
3141
  },
3092
3142
  update: (cache, { data, errors }) => {
3093
- var _a;
3143
+ var _a, _b, _c;
3094
3144
  if (!data || errors) {
3095
3145
  setLoading(false);
3096
3146
  return;
@@ -3114,7 +3164,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3114
3164
  // setParentId(responseMessage?.id);
3115
3165
  // }
3116
3166
  const msg = message == '' ? 'Send a file' : message;
3117
- fetchTokenAndSendPushNotification(msg, channelId, parentId);
3167
+ sendPushNotification(responseMessage, channelId, parentId, (_c = (_b = data === null || data === void 0 ? void 0 : data.sendThreadMessage) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.id);
3118
3168
  },
3119
3169
  });
3120
3170
  }
@@ -3131,7 +3181,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3131
3181
  },
3132
3182
  },
3133
3183
  update: (cache, { data, errors }) => {
3134
- var _a;
3184
+ var _a, _b, _c;
3135
3185
  if (!data || errors) {
3136
3186
  setLoading(false);
3137
3187
  return;
@@ -3148,46 +3198,70 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3148
3198
  // if (!parentId || parentId == 0) {
3149
3199
  // setParentId(responseMessage?.id);
3150
3200
  // }
3151
- fetchTokenAndSendPushNotification(message, channelId, parentId);
3201
+ sendPushNotification(responseMessage, channelId, parentId, (_c = (_b = data === null || data === void 0 ? void 0 : data.sendThreadMessage) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.id);
3152
3202
  },
3153
3203
  });
3154
3204
  }
3155
3205
  }, [mongooseObjectId, setChannelMessages, channelId, images, parentId, expoTokens]);
3156
- const fetchTokenAndSendPushNotification = (message, channelId, parentId) => {
3157
- var _a, _b, _c, _d, _e, _f;
3158
- const givenName = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _a === void 0 ? void 0 : _a.given_name) !== null && _b !== void 0 ? _b : '';
3159
- const familyName = (_d = (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.family_name) !== null && _d !== void 0 ? _d : '';
3160
- const fullName = givenName ? givenName + ' ' + familyName : '';
3161
- const title = fullName ? fullName : 'Message';
3162
- const body = message;
3206
+ const sendPushNotification = async (post, channelId, parentId, threadId) => {
3207
+ var _a, _b;
3163
3208
  const notificationData = {
3164
3209
  url: config_1.config.THREAD_MESSEGE_PATH,
3165
- params: { channelId, title: (_e = params === null || params === void 0 ? void 0 : params.title) !== null && _e !== void 0 ? _e : 'Thread', postParentId: parentId, hideTabBar: true },
3210
+ params: { channelId, title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : 'Thread', postParentId: parentId, hideTabBar: true },
3166
3211
  screen: 'DialogThreadMessages',
3212
+ thread: { id: threadId },
3213
+ other: { sound: react_native_1.Platform.OS === 'android' ? false || null : 'default' },
3167
3214
  };
3168
3215
  if (parentId || parentId == 0) {
3169
- (_f = refetchThreadMessages({
3170
- channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
3171
- role: role === null || role === void 0 ? void 0 : role.toString(),
3172
- postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
3173
- })) === null || _f === void 0 ? void 0 : _f.then((res) => {
3174
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
3175
- if (((_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.threadMessages) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.length) > 0) {
3176
- const participants = (_h = (_g = (_f = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.threadMessages) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.map((t) => t === null || t === void 0 ? void 0 : t.participants)) === null || _g === void 0 ? void 0 : _g.flat(1)) !== null && _h !== void 0 ? _h : [];
3177
- const participantsTokens = (participants === null || participants === void 0 ? void 0 : participants.length) > 0
3178
- ? (_k = (_j = participants === null || participants === void 0 ? void 0 : participants.filter((u) => (u === null || u === void 0 ? void 0 : u.id) != (auth === null || auth === void 0 ? void 0 : auth.id))) === null || _j === void 0 ? void 0 : _j.map((p) => p.tokens)) === null || _k === void 0 ? void 0 : _k.flat(1)
3179
- : [];
3180
- const expoTokens = (participantsTokens === null || participantsTokens === void 0 ? void 0 : participantsTokens.length) > 0
3181
- ? (_l = participantsTokens === null || participantsTokens === void 0 ? void 0 : participantsTokens.filter((t) => (t === null || t === void 0 ? void 0 : t.type) == 'EXPO_NOTIFICATION_TOKEN')) === null || _l === void 0 ? void 0 : _l.map((et) => et === null || et === void 0 ? void 0 : et.token)
3182
- : [];
3183
- if ((expoTokens === null || expoTokens === void 0 ? void 0 : expoTokens.length) > 0) {
3184
- const to = expoTokens;
3185
- sendPushNotification(title, body, notificationData, to);
3186
- }
3187
- }
3216
+ await sendExpoNotificationOnPostMutation({
3217
+ variables: {
3218
+ postId: (_b = post === null || post === void 0 ? void 0 : post.id) === null || _b === void 0 ? void 0 : _b.toString(),
3219
+ notificationData,
3220
+ },
3188
3221
  });
3189
3222
  }
3190
3223
  };
3224
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any, parentId: any) => {
3225
+ // const givenName = auth?.profile?.given_name ?? '';
3226
+ // const familyName = auth?.profile?.family_name ?? '';
3227
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
3228
+ // const title: String = fullName ? fullName : 'Message';
3229
+ // const body: String = message;
3230
+ // const notificationData: any = {
3231
+ // url: config.THREAD_MESSEGE_PATH,
3232
+ // params: { channelId, title: params?.title ?? 'Thread', postParentId: parentId, hideTabBar: true },
3233
+ // screen: 'DialogThreadMessages',
3234
+ // };
3235
+ // if (parentId || parentId == 0) {
3236
+ // refetchThreadMessages({
3237
+ // channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
3238
+ // role: role?.toString(),
3239
+ // postParentId: !parentId || parentId == 0 ? null : parentId?.toString(),
3240
+ // })?.then((res: any) => {
3241
+ // if (res?.data?.threadMessages?.data?.length > 0) {
3242
+ // const participants =
3243
+ // res?.data?.threadMessages?.data?.map((t: any) => t?.participants)?.flat(1) ?? [];
3244
+ // const participantsTokens =
3245
+ // participants?.length > 0
3246
+ // ? participants
3247
+ // ?.filter((u: any) => u?.id != auth?.id)
3248
+ // ?.map((p: any) => p.tokens)
3249
+ // ?.flat(1)
3250
+ // : [];
3251
+ // const expoTokens =
3252
+ // participantsTokens?.length > 0
3253
+ // ? participantsTokens
3254
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
3255
+ // ?.map((et: any) => et?.token)
3256
+ // : [];
3257
+ // if (expoTokens?.length > 0) {
3258
+ // const to: any = expoTokens;
3259
+ // sendPushNotification(title, body, notificationData, to);
3260
+ // }
3261
+ // }
3262
+ // });
3263
+ // }
3264
+ // };
3191
3265
  const messageList = (0, react_1.useMemo)(() => {
3192
3266
  let currentDate = '';
3193
3267
  let res = [];
@@ -3230,20 +3304,48 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3230
3304
  react_1.default.createElement(vector_icons_1.MaterialCommunityIcons, { name: "send-circle", style: { marginBottom: 5, marginRight: 5 }, size: 32, color: "#2e64e5" }))));
3231
3305
  };
3232
3306
  const renderMessageText = (props) => {
3233
- var _a, _b, _c, _d, _e;
3307
+ 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;
3234
3308
  const { currentMessage } = props;
3235
3309
  if (currentMessage.type === 'ALERT') {
3236
3310
  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;
3237
3311
  let action = '';
3238
3312
  let actionId = '';
3239
- if ((_d = (_c = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _c === void 0 ? void 0 : _c.link) === null || _d === void 0 ? void 0 : _d.includes('my-reservation-details')) {
3313
+ let params = {};
3314
+ if ((_c = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _c === void 0 ? void 0 : _c.extraParams) {
3315
+ const extraParams = (_d = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _d === void 0 ? void 0 : _d.extraParams;
3316
+ const route = (_e = extraParams === null || extraParams === void 0 ? void 0 : extraParams.route) !== null && _e !== void 0 ? _e : null;
3317
+ let path = null;
3318
+ let param = null;
3319
+ if (role && role == platform_client_1.IPreDefinedRole.Guest) {
3320
+ 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;
3321
+ 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;
3322
+ }
3323
+ else if (role && role == platform_client_1.IPreDefinedRole.Owner) {
3324
+ 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;
3325
+ 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;
3326
+ }
3327
+ else {
3328
+ 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;
3329
+ 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;
3330
+ }
3331
+ action = path;
3332
+ params = Object.assign({}, param);
3333
+ }
3334
+ else if ((_z = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _z === void 0 ? void 0 : _z.link) {
3240
3335
  action = CALL_TO_ACTION_PATH;
3241
- actionId = (_e = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _e === void 0 ? void 0 : _e.link.split('/').pop();
3336
+ actionId = (_0 = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _0 === void 0 ? void 0 : _0.link.split('/').pop();
3337
+ params = { reservationId: actionId };
3242
3338
  }
3243
- return (react_1.default.createElement(native_base_1.Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 },
3244
- (attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) ? (react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR, onPress: () => navigation.navigate(action, { reservationId: actionId }) },
3245
- react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title))) : null,
3246
- react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } } }))));
3339
+ // if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
3340
+ // action = CALL_TO_ACTION_PATH;
3341
+ // actionId = attachment?.callToAction?.link.split('/').pop();
3342
+ // }
3343
+ return (react_1.default.createElement(react_1.default.Fragment, null, (attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) && action ? (react_1.default.createElement(native_base_1.Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 },
3344
+ react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR, onPress: () => action && params && navigation.navigate(action, params) },
3345
+ react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title)),
3346
+ react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: {
3347
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
3348
+ } })))) : (react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } })))));
3247
3349
  }
3248
3350
  else {
3249
3351
  return react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } }));