@developer_tribe/react-native-comnyx 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/lib/commonjs/Accumulator.js +28 -1
  2. package/lib/commonjs/Accumulator.js.map +1 -1
  3. package/lib/commonjs/api/customers.js +1 -1
  4. package/lib/commonjs/api/customers.js.map +1 -1
  5. package/lib/commonjs/components/ChatList.js +13 -11
  6. package/lib/commonjs/components/ChatList.js.map +1 -1
  7. package/lib/commonjs/components/CustomerForm.js +2 -0
  8. package/lib/commonjs/components/CustomerForm.js.map +1 -1
  9. package/lib/commonjs/components/MessageInput.js +2 -1
  10. package/lib/commonjs/components/MessageInput.js.map +1 -1
  11. package/lib/commonjs/hooks/usePolling.js +7 -7
  12. package/lib/commonjs/hooks/usePolling.js.map +1 -1
  13. package/lib/module/Accumulator.js +28 -1
  14. package/lib/module/Accumulator.js.map +1 -1
  15. package/lib/module/api/customers.js +1 -1
  16. package/lib/module/api/customers.js.map +1 -1
  17. package/lib/module/components/ChatList.js +13 -11
  18. package/lib/module/components/ChatList.js.map +1 -1
  19. package/lib/module/components/CustomerForm.js +2 -0
  20. package/lib/module/components/CustomerForm.js.map +1 -1
  21. package/lib/module/components/MessageInput.js +2 -1
  22. package/lib/module/components/MessageInput.js.map +1 -1
  23. package/lib/module/hooks/usePolling.js +7 -7
  24. package/lib/module/hooks/usePolling.js.map +1 -1
  25. package/lib/typescript/commonjs/src/Accumulator.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/src/components/CustomerForm.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/src/types/Customer.d.ts +1 -0
  30. package/lib/typescript/commonjs/src/types/Customer.d.ts.map +1 -1
  31. package/lib/typescript/module/src/Accumulator.d.ts.map +1 -1
  32. package/lib/typescript/module/src/components/ChatList.d.ts.map +1 -1
  33. package/lib/typescript/module/src/components/CustomerForm.d.ts.map +1 -1
  34. package/lib/typescript/module/src/components/MessageInput.d.ts.map +1 -1
  35. package/lib/typescript/module/src/types/Customer.d.ts +1 -0
  36. package/lib/typescript/module/src/types/Customer.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/Accumulator.ts +31 -4
  39. package/src/api/customers.ts +1 -1
  40. package/src/components/ChatList.tsx +14 -18
  41. package/src/components/CustomerForm.tsx +2 -0
  42. package/src/components/MessageInput.tsx +2 -1
  43. package/src/hooks/usePolling.ts +5 -5
  44. package/src/types/Customer.ts +1 -0
@@ -47,10 +47,11 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
47
47
  (windowHeight - FLATLIST_PADDING) / MESSAGE_MIN_HEIGHT
48
48
  );
49
49
  const [loading, setLoading] = useState(true);
50
- const { customer, data, setData } = useAppStore((s) => ({
50
+ const { customer, data, setData, externalId } = useAppStore((s) => ({
51
51
  customer: s.customer,
52
52
  data: s.data,
53
53
  setData: s.setData,
54
+ externalId: s.externalId,
54
55
  }));
55
56
  const ref = useRef<SectionList<AppConversationMessage>>(null);
56
57
  const [page, setPage] = useState(1);
@@ -131,7 +132,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
131
132
  }, [data]);
132
133
 
133
134
  const resendMessage = useCallback(() => {
134
- if (selectedMessage && customer?.external_id) {
135
+ if (selectedMessage && externalId) {
135
136
  const currentMessage = useAppStore.getState().data || [];
136
137
  const messageIndex = currentMessage.findIndex(
137
138
  (msg) => msg.content === selectedMessage
@@ -155,7 +156,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
155
156
  data: updatedValue,
156
157
  });
157
158
 
158
- sendCustomerMessage(customer.external_id, selectedMessage, {
159
+ sendCustomerMessage(externalId, selectedMessage, {
159
160
  fake: useAppStore.getState().fake,
160
161
  })
161
162
  .then((res: any) => {
@@ -221,19 +222,14 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
221
222
  return;
222
223
  }
223
224
  nextPageStatus.current = 'loading';
224
- if (customer?.external_id) {
225
+ if (externalId) {
225
226
  const newPage = page + 1;
226
227
  setPage(newPage);
227
228
  const firstMessage = useAppStore.getState().firstMessage;
228
- getCustomerConversation(
229
- customer?.external_id,
230
- firstMessage?.created_at,
231
- newPage,
232
- {
233
- fake: useAppStore.getState().fake,
234
- per_page: MESSAGES_PER_PAGE,
235
- }
236
- )
229
+ getCustomerConversation(externalId, firstMessage?.created_at, newPage, {
230
+ fake: useAppStore.getState().fake,
231
+ per_page: MESSAGES_PER_PAGE,
232
+ })
237
233
  .then((newData) => {
238
234
  listChangedRef.current = true;
239
235
  setData((prevData) => {
@@ -282,7 +278,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
282
278
  setLoading(false);
283
279
  });
284
280
  }
285
- }, [MESSAGES_PER_PAGE, customer?.external_id, page, setData]);
281
+ }, [MESSAGES_PER_PAGE, externalId, page, setData]);
286
282
 
287
283
  const renderItem = useCallback(
288
284
  ({ item }: { item: AppConversationMessage }) => {
@@ -417,8 +413,8 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
417
413
  );
418
414
 
419
415
  useEffect(() => {
420
- if (customer?.external_id && !initFailed) {
421
- getCustomerConversation(customer?.external_id, new Date(), 1, {
416
+ if (externalId && !initFailed) {
417
+ getCustomerConversation(externalId, new Date(), 1, {
422
418
  fake: useAppStore.getState().fake,
423
419
  per_page: MESSAGES_PER_PAGE,
424
420
  })
@@ -468,7 +464,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
468
464
  setLoading(false);
469
465
  });
470
466
  }
471
- }, [MESSAGES_PER_PAGE, customer?.external_id, initFailed, setData]);
467
+ }, [MESSAGES_PER_PAGE, externalId, initFailed, setData]);
472
468
 
473
469
  // Initialize the current section when sections are loaded
474
470
  useEffect(() => {
@@ -747,7 +743,7 @@ const styles = ScaledSheet.create({
747
743
  liveChat: {
748
744
  fontSize: '16@vs',
749
745
  textAlign: 'center',
750
- fontWeight: 400,
746
+ fontWeight: 600,
751
747
  },
752
748
  headerContainer: {
753
749
  alignItems: 'center',
@@ -65,6 +65,8 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
65
65
  setLoading(false);
66
66
  }, 100);
67
67
  });
68
+ } else {
69
+ setLoading(false);
68
70
  }
69
71
  }, []);
70
72
 
@@ -17,6 +17,7 @@ export function MessageInput({
17
17
  }) {
18
18
  const [value, setValue] = useState('');
19
19
  const customer = useAppStore((s) => s.customer!);
20
+ const externalId = useAppStore((s) => s.externalId);
20
21
  const themeColors = useThemeColors();
21
22
  const localize = useLocalize();
22
23
 
@@ -36,7 +37,7 @@ export function MessageInput({
36
37
  },
37
38
  ...(data ?? []),
38
39
  ]);
39
- sendCustomerMessage(customer.external_id, value, {
40
+ sendCustomerMessage(externalId as string, value, {
40
41
  fake: useAppStore.getState().fake,
41
42
  })
42
43
  .then((res) => {
@@ -5,18 +5,18 @@ import { getNewCustomerConversation } from '../api';
5
5
  const NEW_MESSAGES_CHECK_INTERVAL = 10000;
6
6
 
7
7
  export function usePolling() {
8
- const { customer, data, setData } = useAppStore((s) => ({
9
- customer: s.customer,
8
+ const { data, setData, externalId } = useAppStore((s) => ({
10
9
  data: s.data,
11
10
  setData: s.setData,
11
+ externalId: s.externalId,
12
12
  }));
13
13
  const lastMessage = data ? data[data.length - 1] : null;
14
14
  useEffect(() => {
15
15
  const created_at = lastMessage?.created_at;
16
16
  let interval: NodeJS.Timeout | null = null;
17
- if (customer?.external_id && created_at) {
17
+ if (externalId && created_at) {
18
18
  interval = setInterval(() => {
19
- getNewCustomerConversation(customer.external_id, created_at, {
19
+ getNewCustomerConversation(externalId, created_at, {
20
20
  fake: useAppStore.getState().fake,
21
21
  }).then((newData) => {
22
22
  setData((prevData) => {
@@ -42,5 +42,5 @@ export function usePolling() {
42
42
  clearInterval(interval);
43
43
  }
44
44
  };
45
- }, [customer?.external_id, lastMessage?.created_at, setData]);
45
+ }, [externalId, lastMessage?.created_at, setData]);
46
46
  }
@@ -40,4 +40,5 @@ export interface Customer {
40
40
  created_at: string;
41
41
  updated_at: string;
42
42
  deleted_at: null | string;
43
+ integration_parameters: IntegrationParameters;
43
44
  }