@developer_tribe/react-native-comnyx 0.12.14 → 0.13.1

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 (98) hide show
  1. package/Comnyx.podspec +23 -10
  2. package/android/build.gradle +60 -4
  3. package/android/generated/RCTAppDependencyProvider.h +25 -0
  4. package/android/generated/RCTAppDependencyProvider.mm +55 -0
  5. package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  6. package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  7. package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
  8. package/android/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  9. package/android/generated/ReactAppDependencyProvider.podspec +34 -0
  10. package/android/generated/java/com/comnyx/NativeComnyxSpec.java +46 -0
  11. package/android/generated/jni/CMakeLists.txt +36 -0
  12. package/android/generated/jni/RNComnyxSpec-generated.cpp +44 -0
  13. package/android/generated/jni/RNComnyxSpec.h +31 -0
  14. package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +38 -0
  15. package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +89 -0
  16. package/android/src/main/java/com/comnyx/ComnyxModule.kt +15 -16
  17. package/ios/Comnyx.h +17 -0
  18. package/ios/Comnyx.m +7 -5
  19. package/ios/Comnyx.swift +11 -10
  20. package/ios/ComnyxObjC.h +19 -0
  21. package/ios/ComnyxObjC.m +28 -0
  22. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  23. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  24. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  25. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  26. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  27. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  28. package/ios/generated/RNComnyxSpec/RNComnyxSpec-generated.mm +53 -0
  29. package/ios/generated/RNComnyxSpec/RNComnyxSpec.h +67 -0
  30. package/ios/generated/RNComnyxSpecJSI-generated.cpp +38 -0
  31. package/ios/generated/RNComnyxSpecJSI.h +89 -0
  32. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  33. package/lib/commonjs/NativeComnyx.js +5 -2
  34. package/lib/commonjs/NativeComnyx.js.map +1 -1
  35. package/lib/commonjs/components/ChatList.js +53 -125
  36. package/lib/commonjs/components/ChatList.js.map +1 -1
  37. package/lib/commonjs/constants/translations.js +58 -0
  38. package/lib/commonjs/constants/translations.js.map +1 -1
  39. package/lib/commonjs/hooks/usePolling.js.map +1 -1
  40. package/lib/commonjs/register/Accumulator.js.map +1 -1
  41. package/lib/commonjs/store/store.js +2 -3
  42. package/lib/commonjs/store/store.js.map +1 -1
  43. package/lib/commonjs/utils/formatDate.js +30 -9
  44. package/lib/commonjs/utils/formatDate.js.map +1 -1
  45. package/lib/commonjs/utils/mmkvStorage.js +21 -0
  46. package/lib/commonjs/utils/mmkvStorage.js.map +1 -0
  47. package/lib/commonjs/version.js +1 -1
  48. package/lib/commonjs/version.js.map +1 -1
  49. package/lib/module/NativeComnyx.js +8 -2
  50. package/lib/module/NativeComnyx.js.map +1 -1
  51. package/lib/module/components/ChatList.js +54 -126
  52. package/lib/module/components/ChatList.js.map +1 -1
  53. package/lib/module/constants/translations.js +58 -0
  54. package/lib/module/constants/translations.js.map +1 -1
  55. package/lib/module/hooks/usePolling.js.map +1 -1
  56. package/lib/module/register/Accumulator.js.map +1 -1
  57. package/lib/module/store/store.js +2 -2
  58. package/lib/module/store/store.js.map +1 -1
  59. package/lib/module/utils/formatDate.js +28 -8
  60. package/lib/module/utils/formatDate.js.map +1 -1
  61. package/lib/module/utils/mmkvStorage.js +17 -0
  62. package/lib/module/utils/mmkvStorage.js.map +1 -0
  63. package/lib/module/version.js +1 -1
  64. package/lib/module/version.js.map +1 -1
  65. package/lib/typescript/src/NativeComnyx.d.ts +21 -8
  66. package/lib/typescript/src/NativeComnyx.d.ts.map +1 -1
  67. package/lib/typescript/src/api/conversations.d.ts +1 -1
  68. package/lib/typescript/src/api/conversations.d.ts.map +1 -1
  69. package/lib/typescript/src/components/AppText.d.ts +1 -1
  70. package/lib/typescript/src/components/AppText.d.ts.map +1 -1
  71. package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
  72. package/lib/typescript/src/constants/translations.d.ts.map +1 -1
  73. package/lib/typescript/src/hooks/useListenNativeTokenForDebug.d.ts +1 -1
  74. package/lib/typescript/src/hooks/useListenNativeTokenForDebug.d.ts.map +1 -1
  75. package/lib/typescript/src/register/Accumulator.d.ts +1 -1
  76. package/lib/typescript/src/register/Accumulator.d.ts.map +1 -1
  77. package/lib/typescript/src/store/store.d.ts.map +1 -1
  78. package/lib/typescript/src/types/LocalizationKeys.d.ts +2 -0
  79. package/lib/typescript/src/types/LocalizationKeys.d.ts.map +1 -1
  80. package/lib/typescript/src/utils/formatDate.d.ts +1 -0
  81. package/lib/typescript/src/utils/formatDate.d.ts.map +1 -1
  82. package/lib/typescript/src/utils/mmkvStorage.d.ts +3 -0
  83. package/lib/typescript/src/utils/mmkvStorage.d.ts.map +1 -0
  84. package/lib/typescript/src/version.d.ts +1 -1
  85. package/lib/typescript/src/version.d.ts.map +1 -1
  86. package/package.json +21 -12
  87. package/src/NativeComnyx.ts +30 -10
  88. package/src/components/ChatList.tsx +101 -174
  89. package/src/constants/translations.ts +58 -0
  90. package/src/hooks/usePolling.ts +1 -1
  91. package/src/register/Accumulator.ts +1 -1
  92. package/src/store/store.ts +2 -2
  93. package/src/types/LocalizationKeys.ts +2 -0
  94. package/src/utils/formatDate.ts +46 -9
  95. package/src/utils/mmkvStorage.ts +17 -0
  96. package/src/version.ts +1 -1
  97. package/lib/typescript/jest.config.d.ts +0 -4
  98. package/lib/typescript/jest.config.d.ts.map +0 -1
@@ -2,11 +2,11 @@ import { createJSONStorage, persist } from 'zustand/middleware';
2
2
  import { shallow } from 'zustand/shallow';
3
3
  import { createWithEqualityFn } from 'zustand/traditional';
4
4
  import type { StateCreator } from 'zustand';
5
- import AsyncStorage from '@react-native-async-storage/async-storage';
6
5
  import type { AppConversationMessage } from '../types/Conversation';
7
6
  import type { LanguageCode } from '../types/Language';
8
7
  import type { Customer } from '../types/Customer';
9
8
  import type { LocalizationKeys } from '../types/LocalizationKeys';
9
+ import { mmkvStorage } from '../utils/mmkvStorage';
10
10
 
11
11
  interface AppStoreState {
12
12
  baseHeight: number;
@@ -115,7 +115,7 @@ export const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
115
115
  export const useAppStore = createWithEqualityFn<AppStoreState>()(
116
116
  persist(storeCreator, {
117
117
  name: 'commonyx_appStore-12',
118
- storage: createJSONStorage(() => AsyncStorage),
118
+ storage: createJSONStorage(() => mmkvStorage),
119
119
  skipHydration: false,
120
120
  partialize: (state) => ({
121
121
  customer: state.customer,
@@ -27,6 +27,8 @@ export type LocalizationKeys = {
27
27
  'chat.empty.description': string;
28
28
  'chat.live': string;
29
29
  'chat.support-team': string;
30
+ 'chat.date.today': string;
31
+ 'chat.date.yesterday': string;
30
32
  'customer.form.resend': string;
31
33
  'chat.list-failed-message.title': string;
32
34
  'chat.list-failed-message.description': string;
@@ -1,13 +1,50 @@
1
+ import { LocalizationList } from '../constants/translations';
2
+ import type { LanguageCode } from '../types/Language';
3
+
4
+ const MS_PER_DAY = 24 * 60 * 60 * 1000;
5
+
6
+ const toStartOfDay = (value: Date) =>
7
+ new Date(value.getFullYear(), value.getMonth(), value.getDate());
8
+
9
+ export const getDateKey = (date?: Date | null): string => {
10
+ if (!date) {
11
+ return '';
12
+ }
13
+
14
+ const year = date.getFullYear();
15
+ const month = String(date.getMonth() + 1).padStart(2, '0');
16
+ const day = String(date.getDate()).padStart(2, '0');
17
+
18
+ return `${year}-${month}-${day}`;
19
+ };
20
+
21
+ const resolveLocalization = (language: string) =>
22
+ LocalizationList[language as LanguageCode] ?? LocalizationList.en;
23
+
1
24
  export const formatDate = (language: string, date?: Date | null): string => {
2
- if (!date) return '';
3
-
4
- try {
5
- return date.toLocaleDateString(language, {
6
- weekday: 'short',
7
- month: 'short',
8
- day: 'numeric',
9
- });
10
- } catch (error) {
25
+ if (!date) {
11
26
  return '';
12
27
  }
28
+
29
+ const localization = resolveLocalization(language);
30
+ const today = toStartOfDay(new Date());
31
+ const targetDate = toStartOfDay(date);
32
+
33
+ const diffInDays = Math.round(
34
+ (today.getTime() - targetDate.getTime()) / MS_PER_DAY
35
+ );
36
+
37
+ if (diffInDays === 0) {
38
+ return localization['chat.date.today'] ?? 'Today';
39
+ }
40
+
41
+ if (diffInDays === 1) {
42
+ return localization['chat.date.yesterday'] ?? 'Yesterday';
43
+ }
44
+
45
+ const day = String(targetDate.getDate()).padStart(2, '0');
46
+ const month = String(targetDate.getMonth() + 1).padStart(2, '0');
47
+ const year = targetDate.getFullYear();
48
+
49
+ return `${day}.${month}.${year}`;
13
50
  };
@@ -0,0 +1,17 @@
1
+ import { MMKV } from 'react-native-mmkv';
2
+ import type { StateStorage } from 'zustand/middleware';
3
+
4
+ const storage = new MMKV();
5
+
6
+ export const mmkvStorage: StateStorage = {
7
+ getItem: (name: string): string | null => {
8
+ const value = storage.getString(name);
9
+ return value ?? null;
10
+ },
11
+ setItem: (name: string, value: string): void => {
12
+ storage.set(name, value);
13
+ },
14
+ removeItem: (name: string): void => {
15
+ storage.delete(name);
16
+ },
17
+ };
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const VERSION = '0.12.14';
2
+ export const VERSION = '0.13.1';
@@ -1,4 +0,0 @@
1
- import type { JestConfigWithTsJest } from 'ts-jest';
2
- declare const jestConfig: JestConfigWithTsJest;
3
- export default jestConfig;
4
- //# sourceMappingURL=jest.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../../jest.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,QAAA,MAAM,UAAU,EAAE,oBAgBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}