@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.
- package/Comnyx.podspec +23 -10
- package/android/build.gradle +60 -4
- package/android/generated/RCTAppDependencyProvider.h +25 -0
- package/android/generated/RCTAppDependencyProvider.mm +55 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/android/generated/ReactAppDependencyProvider.podspec +34 -0
- package/android/generated/java/com/comnyx/NativeComnyxSpec.java +46 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNComnyxSpec-generated.cpp +44 -0
- package/android/generated/jni/RNComnyxSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +38 -0
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +89 -0
- package/android/src/main/java/com/comnyx/ComnyxModule.kt +15 -16
- package/ios/Comnyx.h +17 -0
- package/ios/Comnyx.m +7 -5
- package/ios/Comnyx.swift +11 -10
- package/ios/ComnyxObjC.h +19 -0
- package/ios/ComnyxObjC.m +28 -0
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNComnyxSpec/RNComnyxSpec-generated.mm +53 -0
- package/ios/generated/RNComnyxSpec/RNComnyxSpec.h +67 -0
- package/ios/generated/RNComnyxSpecJSI-generated.cpp +38 -0
- package/ios/generated/RNComnyxSpecJSI.h +89 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/commonjs/NativeComnyx.js +5 -2
- package/lib/commonjs/NativeComnyx.js.map +1 -1
- package/lib/commonjs/components/ChatList.js +53 -125
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/constants/translations.js +58 -0
- package/lib/commonjs/constants/translations.js.map +1 -1
- package/lib/commonjs/hooks/usePolling.js.map +1 -1
- package/lib/commonjs/register/Accumulator.js.map +1 -1
- package/lib/commonjs/store/store.js +2 -3
- package/lib/commonjs/store/store.js.map +1 -1
- package/lib/commonjs/utils/formatDate.js +30 -9
- package/lib/commonjs/utils/formatDate.js.map +1 -1
- package/lib/commonjs/utils/mmkvStorage.js +21 -0
- package/lib/commonjs/utils/mmkvStorage.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/NativeComnyx.js +8 -2
- package/lib/module/NativeComnyx.js.map +1 -1
- package/lib/module/components/ChatList.js +54 -126
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/constants/translations.js +58 -0
- package/lib/module/constants/translations.js.map +1 -1
- package/lib/module/hooks/usePolling.js.map +1 -1
- package/lib/module/register/Accumulator.js.map +1 -1
- package/lib/module/store/store.js +2 -2
- package/lib/module/store/store.js.map +1 -1
- package/lib/module/utils/formatDate.js +28 -8
- package/lib/module/utils/formatDate.js.map +1 -1
- package/lib/module/utils/mmkvStorage.js +17 -0
- package/lib/module/utils/mmkvStorage.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/NativeComnyx.d.ts +21 -8
- package/lib/typescript/src/NativeComnyx.d.ts.map +1 -1
- package/lib/typescript/src/api/conversations.d.ts +1 -1
- package/lib/typescript/src/api/conversations.d.ts.map +1 -1
- package/lib/typescript/src/components/AppText.d.ts +1 -1
- package/lib/typescript/src/components/AppText.d.ts.map +1 -1
- package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/src/constants/translations.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useListenNativeTokenForDebug.d.ts +1 -1
- package/lib/typescript/src/hooks/useListenNativeTokenForDebug.d.ts.map +1 -1
- package/lib/typescript/src/register/Accumulator.d.ts +1 -1
- package/lib/typescript/src/register/Accumulator.d.ts.map +1 -1
- package/lib/typescript/src/store/store.d.ts.map +1 -1
- package/lib/typescript/src/types/LocalizationKeys.d.ts +2 -0
- package/lib/typescript/src/types/LocalizationKeys.d.ts.map +1 -1
- package/lib/typescript/src/utils/formatDate.d.ts +1 -0
- package/lib/typescript/src/utils/formatDate.d.ts.map +1 -1
- package/lib/typescript/src/utils/mmkvStorage.d.ts +3 -0
- package/lib/typescript/src/utils/mmkvStorage.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +1 -1
- package/lib/typescript/src/version.d.ts.map +1 -1
- package/package.json +21 -12
- package/src/NativeComnyx.ts +30 -10
- package/src/components/ChatList.tsx +101 -174
- package/src/constants/translations.ts +58 -0
- package/src/hooks/usePolling.ts +1 -1
- package/src/register/Accumulator.ts +1 -1
- package/src/store/store.ts +2 -2
- package/src/types/LocalizationKeys.ts +2 -0
- package/src/utils/formatDate.ts +46 -9
- package/src/utils/mmkvStorage.ts +17 -0
- package/src/version.ts +1 -1
- package/lib/typescript/jest.config.d.ts +0 -4
- package/lib/typescript/jest.config.d.ts.map +0 -1
package/src/store/store.ts
CHANGED
|
@@ -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(() =>
|
|
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;
|
package/src/utils/formatDate.ts
CHANGED
|
@@ -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)
|
|
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.
|
|
2
|
+
export const VERSION = '0.13.1';
|
|
@@ -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"}
|