@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@messenger-box/platform-mobile",
3
- "version": "0.0.1-alpha.379",
3
+ "version": "0.0.1-alpha.382",
4
4
  "description": "Sample core for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -19,8 +19,8 @@
19
19
  "watch": "yarn build:lib:watch"
20
20
  },
21
21
  "dependencies": {
22
- "@messenger-box/core": "0.0.1-alpha.379",
23
- "@messenger-box/platform-client": "0.0.1-alpha.379",
22
+ "@messenger-box/core": "0.0.1-alpha.382",
23
+ "@messenger-box/platform-client": "0.0.1-alpha.382",
24
24
  "base-64": "1.0.0",
25
25
  "react-native-gifted-chat": "1.0.4"
26
26
  },
@@ -40,5 +40,5 @@
40
40
  "typescript": {
41
41
  "definition": "lib/index.d.ts"
42
42
  },
43
- "gitHead": "de3199a861a5d9a761aeeccf4ad0e8324eec58bd"
43
+ "gitHead": "c724886c4c94ddf72d0ee9c5acf253c699050830"
44
44
  }
@@ -30,8 +30,10 @@ import {
30
30
  useGetNewMongooseObjectIdQuery,
31
31
  useOnChatMessageAddedSubscription,
32
32
  IPreDefinedRole,
33
+ useSendExpoNotificationOnPostMutation,
34
+ IPost,
33
35
  } from '@messenger-box/platform-client';
34
- import { IFileInfo } from '@messenger-box/core';
36
+ import { IExpoNotificationData, IFileInfo } from '@messenger-box/core';
35
37
  import { config } from '../config';
36
38
  import { userSelector } from '@adminide-stack/user-auth0-client';
37
39
  import { SlackMessage, ImageViewerModal } from '../components/SlackMessageContainer';
@@ -108,6 +110,8 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
108
110
 
109
111
  const [sendMsg] = useSendMessagesMutation();
110
112
 
113
+ const [sendExpoNotificationOnPostMutation] = useSendExpoNotificationOnPostMutation();
114
+
111
115
  const {
112
116
  data,
113
117
  loading: messageLoading,
@@ -391,45 +395,45 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
391
395
  if (imageSource.cancelled) setLoading(false);
392
396
  };
393
397
 
394
- const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
395
- try {
396
- const response = await fetch('https://exp.host/--/api/v2/push/send/', {
397
- method: 'POST',
398
- headers: {
399
- Accept: 'application/json',
400
- 'Accept-Encoding': 'gzip, deflate',
401
- 'Content-Type': 'application/json',
402
- },
403
- body: JSON.stringify({
404
- to: to,
405
- data: data,
406
- title: title,
407
- body: body,
408
- sound: Platform.OS === 'android' ? undefined || null : 'default',
409
- }),
410
- });
411
- const result: any = await response.json();
412
- console.log('expo api response', result);
413
- } catch (error) {
414
- console.error('Error:', error);
415
- }
398
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
399
+ // try {
400
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
401
+ // method: 'POST',
402
+ // headers: {
403
+ // Accept: 'application/json',
404
+ // 'Accept-Encoding': 'gzip, deflate',
405
+ // 'Content-Type': 'application/json',
406
+ // },
407
+ // body: JSON.stringify({
408
+ // to: to,
409
+ // data: data,
410
+ // title: title,
411
+ // body: body,
412
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
413
+ // }),
414
+ // });
415
+ // const result: any = await response.json();
416
+ // console.log('expo api response', result);
417
+ // } catch (error) {
418
+ // console.error('Error:', error);
419
+ // }
416
420
 
417
- // fetch('https://exp.host/--/api/v2/push/send/', {
418
- // method: 'POST',
419
- // headers: {
420
- // Accept: 'application/json',
421
- // 'Accept-Encoding': 'gzip, deflate',
422
- // 'Content-Type': 'application/json',
423
- // },
424
- // body: JSON.stringify({
425
- // to: to,
426
- // data: data,
427
- // title: title,
428
- // body: body,
429
- // sound: Platform.OS === 'android' ? null : 'default',
430
- // }),
431
- // });
432
- };
421
+ // // fetch('https://exp.host/--/api/v2/push/send/', {
422
+ // // method: 'POST',
423
+ // // headers: {
424
+ // // Accept: 'application/json',
425
+ // // 'Accept-Encoding': 'gzip, deflate',
426
+ // // 'Content-Type': 'application/json',
427
+ // // },
428
+ // // body: JSON.stringify({
429
+ // // to: to,
430
+ // // data: data,
431
+ // // title: title,
432
+ // // body: body,
433
+ // // sound: Platform.OS === 'android' ? null : 'default',
434
+ // // }),
435
+ // // });
436
+ // };
433
437
 
434
438
  // const handleSend = useCallback(
435
439
  // async (message: string) => {
@@ -520,6 +524,13 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
520
524
  if (!channelId) return;
521
525
  if (!message && message != ' ' && images.length == 0) return;
522
526
 
527
+ const notificationData: IExpoNotificationData = {
528
+ url: config.INBOX_MESSEGE_PATH,
529
+ params: { channelId, hideTabBar: true },
530
+ screen: 'DialogMessages',
531
+ other: { sound: Platform.OS === 'android' ? undefined || null : 'default' },
532
+ };
533
+
523
534
  if (images && images.length > 0) {
524
535
  const postId: any = mongooseObjectId?.getNewMongooseObjectId;
525
536
  setLoading(true);
@@ -551,6 +562,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
551
562
  channelId,
552
563
  content: message,
553
564
  files,
565
+ notificationParams: notificationData,
554
566
  },
555
567
  update: (cache, { data, errors }: any) => {
556
568
  if (!data || errors) {
@@ -572,7 +584,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
572
584
  setLoading(false);
573
585
  setMsg('');
574
586
  const msg = message == '' ? 'Send a file' : message;
575
- fetchTokenAndSendPushNotification(msg, channelId);
587
+ //sendPushNotification(data?.sendMessage, channelId);
576
588
  },
577
589
  });
578
590
  }
@@ -582,6 +594,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
582
594
  variables: {
583
595
  channelId,
584
596
  content: message,
597
+ notificationParams: notificationData,
585
598
  },
586
599
  update: (cache, { data, errors }: any) => {
587
600
  if (!data || errors) {
@@ -593,7 +606,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
593
606
  setChannelToTop(channelToTop + 1);
594
607
  setLoading(false);
595
608
  setMsg('');
596
- fetchTokenAndSendPushNotification(message, channelId);
609
+ // sendPushNotification(data?.sendMessage, channelId);
597
610
  },
598
611
  });
599
612
  }
@@ -601,40 +614,56 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
601
614
  [mongooseObjectId, setChannelMessages, channelId, images, channelToTop, expoTokens],
602
615
  );
603
616
 
604
- const fetchTokenAndSendPushNotification = (message: any, channelId: any) => {
605
- const givenName = auth?.profile?.given_name ?? '';
606
- const familyName = auth?.profile?.family_name ?? '';
607
- const fullName = givenName ? givenName + ' ' + familyName : '';
608
- const title: String = fullName ? fullName : 'Message';
609
- const body: String = message;
610
- const notificationData: any = {
611
- url: config.INBOX_MESSEGE_PATH,
612
- params: { channelId, hideTabBar: true },
613
- screen: 'DialogMessages',
614
- };
615
- refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
616
- if (res?.data?.viewChannelDetail?.members?.length) {
617
- const channelData: any =
618
- res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
619
- const tokens: any =
620
- channelData
621
- ?.map(
622
- (u: any) =>
623
- u?.user?.tokens
624
- ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
625
- ?.map((et: any) => et?.token) ?? [],
626
- )
627
- ?.flat(1)
628
- ?.filter((t: any) => t)
629
- ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
630
- console.log('expo to', JSON.stringify(tokens));
631
- if (tokens?.length > 0) {
632
- const to: any = tokens?.length > 0 ? tokens : [];
633
- sendPushNotification(title, body, notificationData, to);
634
- }
635
- }
636
- });
637
- };
617
+ // const sendPushNotification = async (post: IPost, channelId: string) => {
618
+ // const notificationData: IExpoNotificationData = {
619
+ // url: config.INBOX_MESSEGE_PATH,
620
+ // params: { channelId, hideTabBar: true },
621
+ // screen: 'DialogMessages',
622
+ // other: { sound: Platform.OS === 'android' ? undefined || null : 'default' },
623
+ // };
624
+
625
+ // await sendExpoNotificationOnPostMutation({
626
+ // variables: {
627
+ // postId: post?.id?.toString(),
628
+ // notificationData,
629
+ // },
630
+ // });
631
+ // };
632
+
633
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any) => {
634
+ // const givenName = auth?.profile?.given_name ?? '';
635
+ // const familyName = auth?.profile?.family_name ?? '';
636
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
637
+ // const title: String = fullName ? fullName : 'Message';
638
+ // const body: String = message;
639
+ // const notificationData: any = {
640
+ // url: config.INBOX_MESSEGE_PATH,
641
+ // params: { channelId, hideTabBar: true },
642
+ // screen: 'DialogMessages',
643
+ // };
644
+ // refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
645
+ // if (res?.data?.viewChannelDetail?.members?.length) {
646
+ // const channelData: any =
647
+ // res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
648
+ // const tokens: any =
649
+ // channelData
650
+ // ?.map(
651
+ // (u: any) =>
652
+ // u?.user?.tokens
653
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
654
+ // ?.map((et: any) => et?.token) ?? [],
655
+ // )
656
+ // ?.flat(1)
657
+ // ?.filter((t: any) => t)
658
+ // ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
659
+ // console.log('expo to', JSON.stringify(tokens));
660
+ // if (tokens?.length > 0) {
661
+ // const to: any = tokens?.length > 0 ? tokens : [];
662
+ // sendPushNotification(title, body, notificationData, to);
663
+ // }
664
+ // }
665
+ // });
666
+ // };
638
667
 
639
668
  // const handleSend1 = async (message: string) => {
640
669
  // if (!channelId) return;
@@ -819,23 +848,88 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
819
848
  }
820
849
 
821
850
  return (
822
- <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
823
- {attachment?.callToAction ? (
824
- <Button
825
- variant={'outline'}
826
- size={'sm'}
827
- borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
828
- onPress={() => action && params && navigation.navigate(action, params)}
829
- // onPress={() => navigation.navigate(action, { reservationId: actionId })}
851
+ <>
852
+ {attachment?.callToAction && action ? (
853
+ <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
854
+ <Button
855
+ variant={'outline'}
856
+ size={'sm'}
857
+ borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
858
+ onPress={() => action && params && navigation.navigate(action, params)}
859
+ // onPress={() => navigation.navigate(action, { reservationId: actionId })}
860
+ >
861
+ <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
862
+ </Button>
863
+ <MessageText
864
+ {...props}
865
+ textStyle={{
866
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
867
+ }}
868
+ />
869
+ </Box>
870
+ ) : (
871
+ <TouchableHighlight
872
+ underlayColor={'#c0c0c0'}
873
+ style={{ width: '100%' }}
874
+ onPress={() =>
875
+ navigation.navigate(config.THREAD_MESSEGE_PATH, {
876
+ channelId: channelId,
877
+ title: 'Message',
878
+ postParentId: currentMessage?._id,
879
+ isPostParentIdThread: true,
880
+ })
881
+ }
830
882
  >
831
- <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
832
- </Button>
833
- ) : null}
834
- <MessageText
883
+ <>
884
+ <MessageText {...props} textStyle={{ left: { marginLeft: 5 } }} />
885
+ {currentMessage?.replies?.data?.length > 0 && (
886
+ <HStack space={1} px={1} alignItems={'center'}>
887
+ <HStack>
888
+ {currentMessage?.replies?.data
889
+ ?.filter(
890
+ (v: any, i: any, a: any) =>
891
+ a.findIndex((t: any) => t?.author?.id === v?.author?.id) === i,
892
+ )
893
+ ?.slice(0, 2)
894
+ ?.reverse()
895
+ ?.map((p: any, i: Number) => (
896
+ <Avatar
897
+ key={'key' + i}
898
+ bg={'transparent'}
899
+ size={6}
900
+ // top={i == 1 ? 4 : 0}
901
+ // right={i == 1 ? -2 : 0}
902
+ // zIndex={i == 1 ? 5 : 1}
903
+ _image={{
904
+ borderRadius: 6,
905
+ borderWidth: 2,
906
+ borderColor: '#fff',
907
+ }}
908
+ source={{
909
+ uri: p?.author?.picture,
910
+ }}
911
+ >
912
+ {startCase(p?.author?.username?.charAt(0))}
913
+ </Avatar>
914
+ ))}
915
+ </HStack>
916
+ <Text fontSize={12} fontWeight={'bold'} color={'blue.800'}>
917
+ {currentMessage?.replies?.totalCount}{' '}
918
+ {currentMessage?.replies?.totalCount == 1 ? 'reply' : 'replies'}
919
+ </Text>
920
+ <Text fontSize={12} fontWeight={'bold'} color={'gray.500'}>
921
+ {lastReply ? createdAtText(lastReply?.createdAt) : ''}
922
+ </Text>
923
+ </HStack>
924
+ )}
925
+ </>
926
+ </TouchableHighlight>
927
+ )}
928
+ {/* <MessageText
835
929
  {...props}
836
930
  textStyle={{ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } }}
837
- />
838
- </Box>
931
+ /> */}
932
+ </>
839
933
  );
840
934
  } else {
841
935
  return (
@@ -32,8 +32,11 @@ import {
32
32
  useUploadFilesNative,
33
33
  useGetNewMongooseObjectIdQuery,
34
34
  useOnThreadChatMessageAddedSubscription,
35
+ IPreDefinedRole,
36
+ useSendExpoNotificationOnPostMutation,
37
+ IPost,
35
38
  } from '@messenger-box/platform-client';
36
- import { IFileInfo } from '@messenger-box/core';
39
+ import { IExpoNotificationData, IFileInfo } from '@messenger-box/core';
37
40
  import { config } from '../config';
38
41
  import { userSelector } from '@adminide-stack/user-auth0-client';
39
42
  import { SlackMessage, ImageViewerModal } from '../components/SlackMessageContainer';
@@ -110,6 +113,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
110
113
  });
111
114
 
112
115
  const [sendThreadMessage] = useSendThreadMessageMutation();
116
+ const [sendExpoNotificationOnPostMutation] = useSendExpoNotificationOnPostMutation();
113
117
 
114
118
  const [getThreadMessages, { data: threadMessagesData, loading: threadLoading, refetch: refetchThreadMessages }] =
115
119
  useThreadMessagesLazyQuery({
@@ -327,29 +331,29 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
327
331
  if (imageSource.cancelled) setLoading(false);
328
332
  };
329
333
 
330
- const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
331
- try {
332
- const response = await fetch('https://exp.host/--/api/v2/push/send/', {
333
- method: 'POST',
334
- headers: {
335
- Accept: 'application/json',
336
- 'Accept-Encoding': 'gzip, deflate',
337
- 'Content-Type': 'application/json',
338
- },
339
- body: JSON.stringify({
340
- to: to,
341
- data: data,
342
- title: title,
343
- body: body,
344
- sound: Platform.OS === 'android' ? undefined || null : 'default',
345
- }),
346
- });
347
- const result: any = await response.json();
348
- console.log('expo api response', result);
349
- } catch (error) {
350
- console.error('Error:', error);
351
- }
352
- };
334
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
335
+ // try {
336
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
337
+ // method: 'POST',
338
+ // headers: {
339
+ // Accept: 'application/json',
340
+ // 'Accept-Encoding': 'gzip, deflate',
341
+ // 'Content-Type': 'application/json',
342
+ // },
343
+ // body: JSON.stringify({
344
+ // to: to,
345
+ // data: data,
346
+ // title: title,
347
+ // body: body,
348
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
349
+ // }),
350
+ // });
351
+ // const result: any = await response.json();
352
+ // console.log('expo api response', result);
353
+ // } catch (error) {
354
+ // console.error('Error:', error);
355
+ // }
356
+ // };
353
357
 
354
358
  // const ObjectId = (m = Math, d = Date, h = 16, s = (s:any) => m.floor(s).toString(h)) =>
355
359
  // s(d.now() / 1000) + ' '.repeat(h).replace(/./g, () => s(m.random() * h))
@@ -424,7 +428,12 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
424
428
  // setParentId(responseMessage?.id);
425
429
  // }
426
430
  const msg = message == '' ? 'Send a file' : message;
427
- fetchTokenAndSendPushNotification(msg, channelId, parentId);
431
+ sendPushNotification(
432
+ responseMessage,
433
+ channelId,
434
+ parentId,
435
+ data?.sendThreadMessage?.data?.id,
436
+ );
428
437
  },
429
438
  });
430
439
  }
@@ -456,7 +465,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
456
465
  // if (!parentId || parentId == 0) {
457
466
  // setParentId(responseMessage?.id);
458
467
  // }
459
- fetchTokenAndSendPushNotification(message, channelId, parentId);
468
+ sendPushNotification(responseMessage, channelId, parentId, data?.sendThreadMessage?.data?.id);
460
469
  },
461
470
  });
462
471
  }
@@ -464,48 +473,66 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
464
473
  [mongooseObjectId, setChannelMessages, channelId, images, parentId, expoTokens],
465
474
  );
466
475
 
467
- const fetchTokenAndSendPushNotification = (message: any, channelId: any, parentId: any) => {
468
- const givenName = auth?.profile?.given_name ?? '';
469
- const familyName = auth?.profile?.family_name ?? '';
470
- const fullName = givenName ? givenName + ' ' + familyName : '';
471
- const title: String = fullName ? fullName : 'Message';
472
- const body: String = message;
473
- const notificationData: any = {
476
+ const sendPushNotification = async (post: IPost, channelId: string, parentId: any, threadId: string) => {
477
+ const notificationData: IExpoNotificationData = {
474
478
  url: config.THREAD_MESSEGE_PATH,
475
479
  params: { channelId, title: params?.title ?? 'Thread', postParentId: parentId, hideTabBar: true },
476
480
  screen: 'DialogThreadMessages',
481
+ thread: { id: threadId },
482
+ other: { sound: Platform.OS === 'android' ? undefined || null : 'default' },
477
483
  };
478
484
  if (parentId || parentId == 0) {
479
- refetchThreadMessages({
480
- channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
481
- role: role?.toString(),
482
- postParentId: !parentId || parentId == 0 ? null : parentId?.toString(),
483
- })?.then((res: any) => {
484
- if (res?.data?.threadMessages?.data?.length > 0) {
485
- const participants =
486
- res?.data?.threadMessages?.data?.map((t: any) => t?.participants)?.flat(1) ?? [];
487
- const participantsTokens =
488
- participants?.length > 0
489
- ? participants
490
- ?.filter((u: any) => u?.id != auth?.id)
491
- ?.map((p: any) => p.tokens)
492
- ?.flat(1)
493
- : [];
494
- const expoTokens =
495
- participantsTokens?.length > 0
496
- ? participantsTokens
497
- ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
498
- ?.map((et: any) => et?.token)
499
- : [];
500
- if (expoTokens?.length > 0) {
501
- const to: any = expoTokens;
502
- sendPushNotification(title, body, notificationData, to);
503
- }
504
- }
485
+ await sendExpoNotificationOnPostMutation({
486
+ variables: {
487
+ postId: post?.id?.toString(),
488
+ notificationData,
489
+ },
505
490
  });
506
491
  }
507
492
  };
508
493
 
494
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any, parentId: any) => {
495
+ // const givenName = auth?.profile?.given_name ?? '';
496
+ // const familyName = auth?.profile?.family_name ?? '';
497
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
498
+ // const title: String = fullName ? fullName : 'Message';
499
+ // const body: String = message;
500
+ // const notificationData: any = {
501
+ // url: config.THREAD_MESSEGE_PATH,
502
+ // params: { channelId, title: params?.title ?? 'Thread', postParentId: parentId, hideTabBar: true },
503
+ // screen: 'DialogThreadMessages',
504
+ // };
505
+ // if (parentId || parentId == 0) {
506
+ // refetchThreadMessages({
507
+ // channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
508
+ // role: role?.toString(),
509
+ // postParentId: !parentId || parentId == 0 ? null : parentId?.toString(),
510
+ // })?.then((res: any) => {
511
+ // if (res?.data?.threadMessages?.data?.length > 0) {
512
+ // const participants =
513
+ // res?.data?.threadMessages?.data?.map((t: any) => t?.participants)?.flat(1) ?? [];
514
+ // const participantsTokens =
515
+ // participants?.length > 0
516
+ // ? participants
517
+ // ?.filter((u: any) => u?.id != auth?.id)
518
+ // ?.map((p: any) => p.tokens)
519
+ // ?.flat(1)
520
+ // : [];
521
+ // const expoTokens =
522
+ // participantsTokens?.length > 0
523
+ // ? participantsTokens
524
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
525
+ // ?.map((et: any) => et?.token)
526
+ // : [];
527
+ // if (expoTokens?.length > 0) {
528
+ // const to: any = expoTokens;
529
+ // sendPushNotification(title, body, notificationData, to);
530
+ // }
531
+ // }
532
+ // });
533
+ // }
534
+ // };
535
+
509
536
  const messageList = useMemo(() => {
510
537
  let currentDate = '';
511
538
  let res: any = [];
@@ -566,28 +593,64 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
566
593
  const attachment = currentMessage?.propsConfiguration?.contents?.attachment;
567
594
  let action: string = '';
568
595
  let actionId: any = '';
569
- if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
596
+ let params: any = {};
597
+ if (attachment?.callToAction?.extraParams) {
598
+ const extraParams: any = attachment?.callToAction?.extraParams;
599
+ const route: any = extraParams?.route ?? null;
600
+ let path: any = null;
601
+ let param: any = null;
602
+ if (role && role == IPreDefinedRole.Guest) {
603
+ path = route?.guest?.name ? route?.guest?.name ?? null : null;
604
+ param = route?.guest?.params ? route?.guest?.params ?? null : null;
605
+ } else if (role && role == IPreDefinedRole.Owner) {
606
+ path = route?.host?.name ? route?.host?.name ?? null : null;
607
+ param = route?.host?.params ? route?.host?.params ?? null : null;
608
+ } else {
609
+ path = route?.host?.name ? route?.host?.name ?? null : null;
610
+ param = route?.host?.params ? route?.host?.params ?? null : null;
611
+ }
612
+
613
+ action = path;
614
+ params = { ...param };
615
+ } else if (attachment?.callToAction?.link) {
570
616
  action = CALL_TO_ACTION_PATH;
571
617
  actionId = attachment?.callToAction?.link.split('/').pop();
618
+ params = { reservationId: actionId };
572
619
  }
573
620
 
621
+ // if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
622
+ // action = CALL_TO_ACTION_PATH;
623
+ // actionId = attachment?.callToAction?.link.split('/').pop();
624
+ // }
625
+
574
626
  return (
575
- <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
576
- {attachment?.callToAction ? (
577
- <Button
578
- variant={'outline'}
579
- size={'sm'}
580
- borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
581
- onPress={() => navigation.navigate(action, { reservationId: actionId })}
582
- >
583
- <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
584
- </Button>
585
- ) : null}
586
- <MessageText
627
+ <>
628
+ {attachment?.callToAction && action ? (
629
+ <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
630
+ <Button
631
+ variant={'outline'}
632
+ size={'sm'}
633
+ borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
634
+ onPress={() => action && params && navigation.navigate(action, params)}
635
+ //onPress={() => navigation.navigate(action, { reservationId: actionId })}
636
+ >
637
+ <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
638
+ </Button>
639
+ <MessageText
640
+ {...props}
641
+ textStyle={{
642
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
643
+ }}
644
+ />
645
+ </Box>
646
+ ) : (
647
+ <MessageText {...props} textStyle={{ left: { marginLeft: 5 } }} />
648
+ )}
649
+ {/* <MessageText
587
650
  {...props}
588
651
  textStyle={{ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } }}
589
- />
590
- </Box>
652
+ /> */}
653
+ </>
591
654
  );
592
655
  } else {
593
656
  return <MessageText {...props} textStyle={{ left: { marginLeft: 5 } }} />;