@messenger-box/platform-mobile 0.0.1-alpha.379 → 0.0.1-alpha.382

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.382](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.381...v0.0.1-alpha.382) (2023-08-14)
7
+
8
+ **Note:** Version bump only for package @messenger-box/platform-mobile
9
+
10
+ ## [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)
11
+
12
+ **Note:** Version bump only for package @messenger-box/platform-mobile
13
+
6
14
  ## [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)
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)) {
@@ -2060,6 +2060,12 @@ const ConversationViewComponent = ({ channelId, role }) => {
2060
2060
  return;
2061
2061
  if (!message && message != ' ' && images.length == 0)
2062
2062
  return;
2063
+ const notificationData = {
2064
+ url: config_1.config.INBOX_MESSEGE_PATH,
2065
+ params: { channelId, hideTabBar: true },
2066
+ screen: 'DialogMessages',
2067
+ other: { sound: react_native_1.Platform.OS === 'android' ? false || null : 'default' },
2068
+ };
2063
2069
  if (images && images.length > 0) {
2064
2070
  const postId = mongooseObjectId === null || mongooseObjectId === void 0 ? void 0 : mongooseObjectId.getNewMongooseObjectId;
2065
2071
  setLoading(true);
@@ -2091,6 +2097,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
2091
2097
  channelId,
2092
2098
  content: message,
2093
2099
  files,
2100
+ notificationParams: notificationData,
2094
2101
  },
2095
2102
  update: (cache, { data, errors }) => {
2096
2103
  if (!data || errors) {
@@ -2112,7 +2119,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
2112
2119
  setLoading(false);
2113
2120
  setMsg('');
2114
2121
  const msg = message == '' ? 'Send a file' : message;
2115
- fetchTokenAndSendPushNotification(msg, channelId);
2122
+ //sendPushNotification(data?.sendMessage, channelId);
2116
2123
  },
2117
2124
  });
2118
2125
  }
@@ -2123,6 +2130,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
2123
2130
  variables: {
2124
2131
  channelId,
2125
2132
  content: message,
2133
+ notificationParams: notificationData,
2126
2134
  },
2127
2135
  update: (cache, { data, errors }) => {
2128
2136
  if (!data || errors) {
@@ -2134,39 +2142,59 @@ const ConversationViewComponent = ({ channelId, role }) => {
2134
2142
  setChannelToTop(channelToTop + 1);
2135
2143
  setLoading(false);
2136
2144
  setMsg('');
2137
- fetchTokenAndSendPushNotification(message, channelId);
2145
+ // sendPushNotification(data?.sendMessage, channelId);
2138
2146
  },
2139
2147
  });
2140
2148
  }
2141
2149
  }, [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;
2149
- const notificationData = {
2150
- url: config_1.config.INBOX_MESSEGE_PATH,
2151
- params: { channelId, hideTabBar: true },
2152
- screen: 'DialogMessages',
2153
- };
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
- }
2168
- });
2169
- };
2150
+ // const sendPushNotification = async (post: IPost, channelId: string) => {
2151
+ // const notificationData: IExpoNotificationData = {
2152
+ // url: config.INBOX_MESSEGE_PATH,
2153
+ // params: { channelId, hideTabBar: true },
2154
+ // screen: 'DialogMessages',
2155
+ // other: { sound: Platform.OS === 'android' ? undefined || null : 'default' },
2156
+ // };
2157
+ // await sendExpoNotificationOnPostMutation({
2158
+ // variables: {
2159
+ // postId: post?.id?.toString(),
2160
+ // notificationData,
2161
+ // },
2162
+ // });
2163
+ // };
2164
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any) => {
2165
+ // const givenName = auth?.profile?.given_name ?? '';
2166
+ // const familyName = auth?.profile?.family_name ?? '';
2167
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
2168
+ // const title: String = fullName ? fullName : 'Message';
2169
+ // const body: String = message;
2170
+ // const notificationData: any = {
2171
+ // url: config.INBOX_MESSEGE_PATH,
2172
+ // params: { channelId, hideTabBar: true },
2173
+ // screen: 'DialogMessages',
2174
+ // };
2175
+ // refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
2176
+ // if (res?.data?.viewChannelDetail?.members?.length) {
2177
+ // const channelData: any =
2178
+ // res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
2179
+ // const tokens: any =
2180
+ // channelData
2181
+ // ?.map(
2182
+ // (u: any) =>
2183
+ // u?.user?.tokens
2184
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
2185
+ // ?.map((et: any) => et?.token) ?? [],
2186
+ // )
2187
+ // ?.flat(1)
2188
+ // ?.filter((t: any) => t)
2189
+ // ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
2190
+ // console.log('expo to', JSON.stringify(tokens));
2191
+ // if (tokens?.length > 0) {
2192
+ // const to: any = tokens?.length > 0 ? tokens : [];
2193
+ // sendPushNotification(title, body, notificationData, to);
2194
+ // }
2195
+ // }
2196
+ // });
2197
+ // };
2170
2198
  // const handleSend1 = async (message: string) => {
2171
2199
  // if (!channelId) return;
2172
2200
  // if (!message && message != ' ' && images.length == 0) return;
@@ -2303,7 +2331,7 @@ const ConversationViewComponent = ({ channelId, role }) => {
2303
2331
  react_1.default.createElement(vector_icons_1.MaterialCommunityIcons, { name: "send-circle", style: { marginBottom: 5, marginRight: 5 }, size: 32, color: "#2e64e5" }))));
2304
2332
  };
2305
2333
  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;
2334
+ 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
2335
  const { currentMessage } = props;
2308
2336
  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
2337
  if (currentMessage.type === 'ALERT') {
@@ -2336,13 +2364,12 @@ const ConversationViewComponent = ({ channelId, role }) => {
2336
2364
  actionId = (_4 = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _4 === void 0 ? void 0 : _4.link.split('/').pop();
2337
2365
  params = { reservationId: actionId };
2338
2366
  }
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, {
2367
+ 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 },
2368
+ 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) },
2369
+ react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title)),
2370
+ react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: {
2371
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
2372
+ } })))) : (react_1.default.createElement(react_native_1.TouchableHighlight, { underlayColor: '#c0c0c0', style: { width: '100%' }, onPress: () => navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
2346
2373
  channelId: channelId,
2347
2374
  title: 'Message',
2348
2375
  postParentId: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage._id,
@@ -2357,7 +2384,11 @@ const ConversationViewComponent = ({ channelId, role }) => {
2357
2384
  // top={i == 1 ? 4 : 0}
2358
2385
  // right={i == 1 ? -2 : 0}
2359
2386
  // zIndex={i == 1 ? 5 : 1}
2360
- _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
2387
+ _image: {
2388
+ borderRadius: 6,
2389
+ borderWidth: 2,
2390
+ borderColor: '#fff',
2391
+ }, source: {
2361
2392
  uri: (_a = p === null || p === void 0 ? void 0 : p.author) === null || _a === void 0 ? void 0 : _a.picture,
2362
2393
  } }, (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
2394
  })),
@@ -2365,6 +2396,32 @@ const ConversationViewComponent = ({ channelId, role }) => {
2365
2396
  _12.totalCount,
2366
2397
  ' ',
2367
2398
  ((_13 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _13 === void 0 ? void 0 : _13.totalCount) == 1 ? 'reply' : 'replies'),
2399
+ 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) : ''))))))));
2400
+ }
2401
+ else {
2402
+ return (react_1.default.createElement(react_native_1.TouchableHighlight, { underlayColor: '#c0c0c0', style: { width: '100%' }, onPress: () => navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
2403
+ channelId: channelId,
2404
+ title: 'Message',
2405
+ postParentId: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage._id,
2406
+ isPostParentIdThread: true,
2407
+ }) },
2408
+ react_1.default.createElement(react_1.default.Fragment, null,
2409
+ react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } })),
2410
+ ((_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' },
2411
+ 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) => {
2412
+ var _a, _b, _c;
2413
+ return (react_1.default.createElement(native_base_1.Avatar, { key: 'key' + i, bg: 'transparent', size: 6,
2414
+ // top={i == 1 ? 4 : 0}
2415
+ // right={i == 1 ? -2 : 0}
2416
+ // zIndex={i == 1 ? 5 : 1}
2417
+ _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
2418
+ uri: (_a = p === null || p === void 0 ? void 0 : p.author) === null || _a === void 0 ? void 0 : _a.picture,
2419
+ } }, (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))));
2420
+ })),
2421
+ 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 :
2422
+ _21.totalCount,
2423
+ ' ',
2424
+ ((_22 = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _22 === void 0 ? void 0 : _22.totalCount) == 1 ? 'reply' : 'replies'),
2368
2425
  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
2426
  }
2370
2427
  };
@@ -2828,6 +2885,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
2828
2885
  },
2829
2886
  });
2830
2887
  const [sendThreadMessage] = (0, platform_client_1.useSendThreadMessageMutation)();
2888
+ const [sendExpoNotificationOnPostMutation] = (0, platform_client_1.useSendExpoNotificationOnPostMutation)();
2831
2889
  const [getThreadMessages, { data: threadMessagesData, loading: threadLoading, refetch: refetchThreadMessages }] = (0, platform_client_1.useThreadMessagesLazyQuery)({
2832
2890
  variables: {
2833
2891
  channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
@@ -3021,30 +3079,29 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3021
3079
  if (imageSource.cancelled)
3022
3080
  setLoading(false);
3023
3081
  };
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
- };
3082
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
3083
+ // try {
3084
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
3085
+ // method: 'POST',
3086
+ // headers: {
3087
+ // Accept: 'application/json',
3088
+ // 'Accept-Encoding': 'gzip, deflate',
3089
+ // 'Content-Type': 'application/json',
3090
+ // },
3091
+ // body: JSON.stringify({
3092
+ // to: to,
3093
+ // data: data,
3094
+ // title: title,
3095
+ // body: body,
3096
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
3097
+ // }),
3098
+ // });
3099
+ // const result: any = await response.json();
3100
+ // console.log('expo api response', result);
3101
+ // } catch (error) {
3102
+ // console.error('Error:', error);
3103
+ // }
3104
+ // };
3048
3105
  // const ObjectId = (m = Math, d = Date, h = 16, s = (s:any) => m.floor(s).toString(h)) =>
3049
3106
  // s(d.now() / 1000) + ' '.repeat(h).replace(/./g, () => s(m.random() * h))
3050
3107
  const handleSend = (0, react_1.useCallback)(async (message) => {
@@ -3090,7 +3147,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3090
3147
  },
3091
3148
  },
3092
3149
  update: (cache, { data, errors }) => {
3093
- var _a;
3150
+ var _a, _b, _c;
3094
3151
  if (!data || errors) {
3095
3152
  setLoading(false);
3096
3153
  return;
@@ -3114,7 +3171,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3114
3171
  // setParentId(responseMessage?.id);
3115
3172
  // }
3116
3173
  const msg = message == '' ? 'Send a file' : message;
3117
- fetchTokenAndSendPushNotification(msg, channelId, parentId);
3174
+ 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
3175
  },
3119
3176
  });
3120
3177
  }
@@ -3131,7 +3188,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3131
3188
  },
3132
3189
  },
3133
3190
  update: (cache, { data, errors }) => {
3134
- var _a;
3191
+ var _a, _b, _c;
3135
3192
  if (!data || errors) {
3136
3193
  setLoading(false);
3137
3194
  return;
@@ -3148,46 +3205,70 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3148
3205
  // if (!parentId || parentId == 0) {
3149
3206
  // setParentId(responseMessage?.id);
3150
3207
  // }
3151
- fetchTokenAndSendPushNotification(message, channelId, parentId);
3208
+ 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
3209
  },
3153
3210
  });
3154
3211
  }
3155
3212
  }, [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;
3213
+ const sendPushNotification = async (post, channelId, parentId, threadId) => {
3214
+ var _a, _b;
3163
3215
  const notificationData = {
3164
3216
  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 },
3217
+ params: { channelId, title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : 'Thread', postParentId: parentId, hideTabBar: true },
3166
3218
  screen: 'DialogThreadMessages',
3219
+ thread: { id: threadId },
3220
+ other: { sound: react_native_1.Platform.OS === 'android' ? false || null : 'default' },
3167
3221
  };
3168
3222
  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
- }
3223
+ await sendExpoNotificationOnPostMutation({
3224
+ variables: {
3225
+ postId: (_b = post === null || post === void 0 ? void 0 : post.id) === null || _b === void 0 ? void 0 : _b.toString(),
3226
+ notificationData,
3227
+ },
3188
3228
  });
3189
3229
  }
3190
3230
  };
3231
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any, parentId: any) => {
3232
+ // const givenName = auth?.profile?.given_name ?? '';
3233
+ // const familyName = auth?.profile?.family_name ?? '';
3234
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
3235
+ // const title: String = fullName ? fullName : 'Message';
3236
+ // const body: String = message;
3237
+ // const notificationData: any = {
3238
+ // url: config.THREAD_MESSEGE_PATH,
3239
+ // params: { channelId, title: params?.title ?? 'Thread', postParentId: parentId, hideTabBar: true },
3240
+ // screen: 'DialogThreadMessages',
3241
+ // };
3242
+ // if (parentId || parentId == 0) {
3243
+ // refetchThreadMessages({
3244
+ // channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
3245
+ // role: role?.toString(),
3246
+ // postParentId: !parentId || parentId == 0 ? null : parentId?.toString(),
3247
+ // })?.then((res: any) => {
3248
+ // if (res?.data?.threadMessages?.data?.length > 0) {
3249
+ // const participants =
3250
+ // res?.data?.threadMessages?.data?.map((t: any) => t?.participants)?.flat(1) ?? [];
3251
+ // const participantsTokens =
3252
+ // participants?.length > 0
3253
+ // ? participants
3254
+ // ?.filter((u: any) => u?.id != auth?.id)
3255
+ // ?.map((p: any) => p.tokens)
3256
+ // ?.flat(1)
3257
+ // : [];
3258
+ // const expoTokens =
3259
+ // participantsTokens?.length > 0
3260
+ // ? participantsTokens
3261
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
3262
+ // ?.map((et: any) => et?.token)
3263
+ // : [];
3264
+ // if (expoTokens?.length > 0) {
3265
+ // const to: any = expoTokens;
3266
+ // sendPushNotification(title, body, notificationData, to);
3267
+ // }
3268
+ // }
3269
+ // });
3270
+ // }
3271
+ // };
3191
3272
  const messageList = (0, react_1.useMemo)(() => {
3192
3273
  let currentDate = '';
3193
3274
  let res = [];
@@ -3230,20 +3311,48 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
3230
3311
  react_1.default.createElement(vector_icons_1.MaterialCommunityIcons, { name: "send-circle", style: { marginBottom: 5, marginRight: 5 }, size: 32, color: "#2e64e5" }))));
3231
3312
  };
3232
3313
  const renderMessageText = (props) => {
3233
- var _a, _b, _c, _d, _e;
3314
+ 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
3315
  const { currentMessage } = props;
3235
3316
  if (currentMessage.type === 'ALERT') {
3236
3317
  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
3318
  let action = '';
3238
3319
  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')) {
3320
+ let params = {};
3321
+ if ((_c = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _c === void 0 ? void 0 : _c.extraParams) {
3322
+ const extraParams = (_d = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _d === void 0 ? void 0 : _d.extraParams;
3323
+ const route = (_e = extraParams === null || extraParams === void 0 ? void 0 : extraParams.route) !== null && _e !== void 0 ? _e : null;
3324
+ let path = null;
3325
+ let param = null;
3326
+ if (role && role == platform_client_1.IPreDefinedRole.Guest) {
3327
+ 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;
3328
+ 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;
3329
+ }
3330
+ else if (role && role == platform_client_1.IPreDefinedRole.Owner) {
3331
+ 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;
3332
+ 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;
3333
+ }
3334
+ else {
3335
+ 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;
3336
+ 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;
3337
+ }
3338
+ action = path;
3339
+ params = Object.assign({}, param);
3340
+ }
3341
+ else if ((_z = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _z === void 0 ? void 0 : _z.link) {
3240
3342
  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();
3343
+ actionId = (_0 = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _0 === void 0 ? void 0 : _0.link.split('/').pop();
3344
+ params = { reservationId: actionId };
3242
3345
  }
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 } } }))));
3346
+ // if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
3347
+ // action = CALL_TO_ACTION_PATH;
3348
+ // actionId = attachment?.callToAction?.link.split('/').pop();
3349
+ // }
3350
+ 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 },
3351
+ 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) },
3352
+ react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title)),
3353
+ react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: {
3354
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
3355
+ } })))) : (react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } })))));
3247
3356
  }
3248
3357
  else {
3249
3358
  return react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } }));