@developer_tribe/react-native-comnyx 0.15.0 → 0.16.0
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 +10 -2
- package/README.md +50 -0
- package/android/build.gradle +1 -0
- package/android/consumer-rules.pro +23 -0
- package/android/generated/java/com/comnyx/NativeComnyxSpec.java +46 -0
- package/android/generated/jni/RNComnyxSpec-generated.cpp +23 -1
- package/android/generated/jni/RNComnyxSpec.h +7 -0
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +21 -0
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +70 -0
- package/android/src/main/AndroidManifest.xml +11 -1
- package/android/src/main/AndroidManifestNew.xml +11 -1
- package/android/src/main/java/com/comnyx/ComnyxMediaPickerModule.kt +91 -51
- package/android/src/main/java/com/comnyx/ComnyxModule.kt +7 -0
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +4 -6
- package/android/src/main/res/xml/comnyx_file_paths.xml +12 -0
- package/ios/APNService.swift +9 -9
- package/ios/Comnyx.swift +17 -8
- package/ios/ComnyxMediaPicker.swift +47 -26
- package/ios/ComnyxMessaging.swift +2 -0
- package/ios/PrivacyInfo.xcprivacy +32 -0
- package/ios/comnyx_post_install.rb +25 -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/NativeComnyxMediaPicker.js +19 -0
- package/lib/commonjs/NativeComnyxMediaPicker.js.map +1 -1
- package/lib/commonjs/api/conversations.js +6 -6
- package/lib/commonjs/api/conversations.js.map +1 -1
- package/lib/commonjs/api/customers.js +3 -2
- package/lib/commonjs/api/customers.js.map +1 -1
- package/lib/commonjs/api/media.js +20 -6
- package/lib/commonjs/api/media.js.map +1 -1
- package/lib/commonjs/api/messages.js +3 -2
- package/lib/commonjs/api/messages.js.map +1 -1
- package/lib/commonjs/components/ChatList.js +93 -45
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/components/ComnyxErrorBoundary.js +92 -0
- package/lib/commonjs/components/ComnyxErrorBoundary.js.map +1 -0
- package/lib/commonjs/components/CustomerForm.js +2 -2
- package/lib/commonjs/components/CustomerForm.js.map +1 -1
- package/lib/commonjs/components/MediaMessageItem.js +4 -3
- package/lib/commonjs/components/MediaMessageItem.js.map +1 -1
- package/lib/commonjs/components/MessageInput.js +63 -13
- package/lib/commonjs/components/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageItem.js +1 -1
- package/lib/commonjs/components/MessageItem.js.map +1 -1
- package/lib/commonjs/hooks/usePolling.js +25 -21
- package/lib/commonjs/hooks/usePolling.js.map +1 -1
- package/lib/commonjs/hooks/useThemeColors.js +12 -1
- package/lib/commonjs/hooks/useThemeColors.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/notifications/initializeNotifications.js +19 -16
- package/lib/commonjs/notifications/initializeNotifications.js.map +1 -1
- package/lib/commonjs/register/Accumulator.js +19 -6
- package/lib/commonjs/register/Accumulator.js.map +1 -1
- package/lib/commonjs/register/collectData.js +1 -1
- package/lib/commonjs/register/collectData.js.map +1 -1
- package/lib/commonjs/store/store.js +6 -0
- package/lib/commonjs/store/store.js.map +1 -1
- package/lib/commonjs/support/ComnyxSupport.js +60 -15
- package/lib/commonjs/support/ComnyxSupport.js.map +1 -1
- package/lib/commonjs/support/SupportConfigContext.js +24 -0
- package/lib/commonjs/support/SupportConfigContext.js.map +1 -0
- package/lib/commonjs/types/Theme.js +30 -2
- package/lib/commonjs/types/Theme.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/NativeComnyxMediaPicker.js +18 -0
- package/lib/module/NativeComnyxMediaPicker.js.map +1 -1
- package/lib/module/api/conversations.js +6 -6
- package/lib/module/api/conversations.js.map +1 -1
- package/lib/module/api/customers.js +3 -2
- package/lib/module/api/customers.js.map +1 -1
- package/lib/module/api/media.js +21 -6
- package/lib/module/api/media.js.map +1 -1
- package/lib/module/api/messages.js +3 -2
- package/lib/module/api/messages.js.map +1 -1
- package/lib/module/components/ChatList.js +94 -46
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/components/ComnyxErrorBoundary.js +87 -0
- package/lib/module/components/ComnyxErrorBoundary.js.map +1 -0
- package/lib/module/components/CustomerForm.js +2 -2
- package/lib/module/components/CustomerForm.js.map +1 -1
- package/lib/module/components/MediaMessageItem.js +4 -3
- package/lib/module/components/MediaMessageItem.js.map +1 -1
- package/lib/module/components/MessageInput.js +64 -14
- package/lib/module/components/MessageInput.js.map +1 -1
- package/lib/module/components/MessageItem.js +1 -1
- package/lib/module/components/MessageItem.js.map +1 -1
- package/lib/module/hooks/usePolling.js +25 -21
- package/lib/module/hooks/usePolling.js.map +1 -1
- package/lib/module/hooks/useThemeColors.js +13 -2
- package/lib/module/hooks/useThemeColors.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/notifications/initializeNotifications.js +19 -16
- package/lib/module/notifications/initializeNotifications.js.map +1 -1
- package/lib/module/register/Accumulator.js +19 -6
- package/lib/module/register/Accumulator.js.map +1 -1
- package/lib/module/register/collectData.js +1 -1
- package/lib/module/register/collectData.js.map +1 -1
- package/lib/module/store/store.js +6 -0
- package/lib/module/store/store.js.map +1 -1
- package/lib/module/support/ComnyxSupport.js +61 -16
- package/lib/module/support/ComnyxSupport.js.map +1 -1
- package/lib/module/support/SupportConfigContext.js +19 -0
- package/lib/module/support/SupportConfigContext.js.map +1 -0
- package/lib/module/types/Theme.js +30 -2
- package/lib/module/types/Theme.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/NativeComnyxMediaPicker.d.ts +9 -0
- package/lib/typescript/src/NativeComnyxMediaPicker.d.ts.map +1 -1
- package/lib/typescript/src/api/conversations.d.ts +2 -2
- package/lib/typescript/src/api/conversations.d.ts.map +1 -1
- package/lib/typescript/src/api/customers.d.ts +1 -1
- package/lib/typescript/src/api/customers.d.ts.map +1 -1
- package/lib/typescript/src/api/media.d.ts +3 -3
- package/lib/typescript/src/api/media.d.ts.map +1 -1
- package/lib/typescript/src/api/messages.d.ts +1 -1
- package/lib/typescript/src/api/messages.d.ts.map +1 -1
- package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/src/components/ComnyxErrorBoundary.d.ts +18 -0
- package/lib/typescript/src/components/ComnyxErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/src/components/MediaMessageItem.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageInput.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageItem.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePolling.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useThemeColors.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -1
- package/lib/typescript/src/register/Accumulator.d.ts.map +1 -1
- package/lib/typescript/src/register/collectData.d.ts +4 -1
- package/lib/typescript/src/register/collectData.d.ts.map +1 -1
- package/lib/typescript/src/store/store.d.ts +6 -2
- package/lib/typescript/src/store/store.d.ts.map +1 -1
- package/lib/typescript/src/support/ComnyxSupport.d.ts +56 -2
- package/lib/typescript/src/support/ComnyxSupport.d.ts.map +1 -1
- package/lib/typescript/src/support/SupportConfigContext.d.ts +58 -0
- package/lib/typescript/src/support/SupportConfigContext.d.ts.map +1 -0
- package/lib/typescript/src/support/index.d.ts +1 -0
- package/lib/typescript/src/support/index.d.ts.map +1 -1
- package/lib/typescript/src/types/Conversation.d.ts +2 -2
- package/lib/typescript/src/types/Conversation.d.ts.map +1 -1
- package/lib/typescript/src/types/Customer.d.ts +1 -1
- package/lib/typescript/src/types/Customer.d.ts.map +1 -1
- package/lib/typescript/src/types/MessageResponse.d.ts +7 -4
- package/lib/typescript/src/types/MessageResponse.d.ts.map +1 -1
- package/lib/typescript/src/types/Theme.d.ts +26 -0
- package/lib/typescript/src/types/Theme.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +12 -25
- package/src/NativeComnyxMediaPicker.ts +18 -0
- package/src/api/conversations.ts +6 -4
- package/src/api/customers.ts +3 -1
- package/src/api/media.ts +32 -10
- package/src/api/messages.ts +3 -1
- package/src/components/ChatList.tsx +115 -55
- package/src/components/ComnyxErrorBoundary.tsx +91 -0
- package/src/components/CustomerForm.tsx +2 -2
- package/src/components/MediaMessageItem.tsx +10 -3
- package/src/components/MessageInput.tsx +89 -16
- package/src/components/MessageItem.tsx +12 -13
- package/src/hooks/usePolling.ts +21 -11
- package/src/hooks/useThemeColors.ts +11 -2
- package/src/index.ts +12 -0
- package/src/notifications/initializeNotifications.ts +22 -20
- package/src/register/Accumulator.ts +26 -9
- package/src/register/collectData.ts +10 -2
- package/src/store/store.ts +11 -3
- package/src/support/ComnyxSupport.tsx +128 -22
- package/src/support/SupportConfigContext.tsx +79 -0
- package/src/support/index.ts +7 -0
- package/src/types/Conversation.ts +2 -2
- package/src/types/Customer.ts +1 -2
- package/src/types/MessageResponse.ts +4 -4
- package/src/types/Theme.ts +38 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeComnyxCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeComnyxCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual jsi::Value initialize(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual jsi::Value checkOptIn(jsi::Runtime &rt) = 0;
|
|
25
|
+
virtual jsi::Value optIn(jsi::Runtime &rt) = 0;
|
|
26
|
+
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
template <typename T>
|
|
30
|
+
class JSI_EXPORT NativeComnyxCxxSpec : public TurboModule {
|
|
31
|
+
public:
|
|
32
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
33
|
+
return delegate_.create(rt, propName);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
37
|
+
return delegate_.getPropertyNames(runtime);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static constexpr std::string_view kModuleName = "Comnyx";
|
|
41
|
+
|
|
42
|
+
protected:
|
|
43
|
+
NativeComnyxCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
44
|
+
: TurboModule(std::string{NativeComnyxCxxSpec::kModuleName}, jsInvoker),
|
|
45
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
class Delegate : public NativeComnyxCxxSpecJSI {
|
|
50
|
+
public:
|
|
51
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
52
|
+
NativeComnyxCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
jsi::Value initialize(jsi::Runtime &rt) override {
|
|
57
|
+
static_assert(
|
|
58
|
+
bridging::getParameterCount(&T::initialize) == 1,
|
|
59
|
+
"Expected initialize(...) to have 1 parameters");
|
|
60
|
+
|
|
61
|
+
return bridging::callFromJs<jsi::Value>(
|
|
62
|
+
rt, &T::initialize, jsInvoker_, instance_);
|
|
63
|
+
}
|
|
64
|
+
jsi::Value checkOptIn(jsi::Runtime &rt) override {
|
|
65
|
+
static_assert(
|
|
66
|
+
bridging::getParameterCount(&T::checkOptIn) == 1,
|
|
67
|
+
"Expected checkOptIn(...) to have 1 parameters");
|
|
68
|
+
|
|
69
|
+
return bridging::callFromJs<jsi::Value>(
|
|
70
|
+
rt, &T::checkOptIn, jsInvoker_, instance_);
|
|
71
|
+
}
|
|
72
|
+
jsi::Value optIn(jsi::Runtime &rt) override {
|
|
73
|
+
static_assert(
|
|
74
|
+
bridging::getParameterCount(&T::optIn) == 1,
|
|
75
|
+
"Expected optIn(...) to have 1 parameters");
|
|
76
|
+
|
|
77
|
+
return bridging::callFromJs<jsi::Value>(
|
|
78
|
+
rt, &T::optIn, jsInvoker_, instance_);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
friend class NativeComnyxCxxSpec;
|
|
83
|
+
T *instance_;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
Delegate delegate_;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
version = "0.78.1"
|
|
7
|
+
source = { :git => 'https://github.com/facebook/react-native.git' }
|
|
8
|
+
if version == '1000.0.0'
|
|
9
|
+
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
|
10
|
+
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
|
|
11
|
+
else
|
|
12
|
+
source[:tag] = "v#{version}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Pod::Spec.new do |s|
|
|
16
|
+
s.name = "ReactAppDependencyProvider"
|
|
17
|
+
s.version = version
|
|
18
|
+
s.summary = "The third party dependency provider for the app"
|
|
19
|
+
s.homepage = "https://reactnative.dev/"
|
|
20
|
+
s.documentation_url = "https://reactnative.dev/"
|
|
21
|
+
s.license = "MIT"
|
|
22
|
+
s.author = "Meta Platforms, Inc. and its affiliates"
|
|
23
|
+
s.platforms = min_supported_versions
|
|
24
|
+
s.source = source
|
|
25
|
+
s.source_files = "**/RCTAppDependencyProvider.{h,mm}"
|
|
26
|
+
|
|
27
|
+
# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
s.pod_target_xcconfig = {
|
|
29
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
30
|
+
"DEFINES_MODULE" => "YES"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
s.dependency "ReactCodegen"
|
|
34
|
+
end
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.cleanupTempFiles = cleanupTempFiles;
|
|
7
7
|
exports.deleteTempFile = deleteTempFile;
|
|
8
8
|
exports.generateThumbnail = generateThumbnail;
|
|
9
|
+
exports.getShareableUri = getShareableUri;
|
|
9
10
|
exports.openVideo = openVideo;
|
|
10
11
|
exports.pickImage = pickImage;
|
|
11
12
|
exports.pickMedia = pickMedia;
|
|
@@ -74,6 +75,24 @@ async function deleteTempFile(uri) {
|
|
|
74
75
|
}
|
|
75
76
|
return ComnyxMediaPicker.deleteTempFile(uri);
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Android only. Converts a local file URI returned by the picker into a
|
|
81
|
+
* `content://` URI served by the Comnyx FileProvider, suitable for crossing
|
|
82
|
+
* process boundaries (e.g. sharing to another app, system ACTION_VIEW).
|
|
83
|
+
*
|
|
84
|
+
* On iOS, returns the input URI unchanged since iOS does not have the
|
|
85
|
+
* FileUriExposedException problem.
|
|
86
|
+
*/
|
|
87
|
+
async function getShareableUri(fileUri) {
|
|
88
|
+
if (!ComnyxMediaPicker) {
|
|
89
|
+
return fileUri;
|
|
90
|
+
}
|
|
91
|
+
if (typeof ComnyxMediaPicker.getShareableUri !== 'function') {
|
|
92
|
+
return fileUri;
|
|
93
|
+
}
|
|
94
|
+
return ComnyxMediaPicker.getShareableUri(fileUri);
|
|
95
|
+
}
|
|
77
96
|
async function cleanupTempFiles() {
|
|
78
97
|
if (!ComnyxMediaPicker) {
|
|
79
98
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","ComnyxMediaPicker","NativeModules","mapResults","results","map","result","isImage","type","mimeType","startsWith","uri","fileName","fileSize","width","undefined","height","duration","thumbnailUri","pickMedia","Array","isArray","length","pickImage","pickVideo","openVideo","console","warn","generateThumbnail","videoUrl","deleteTempFile","cleanupTempFiles"],"sourceRoot":"../../src","sources":["NativeComnyxMediaPicker.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","ComnyxMediaPicker","NativeModules","mapResults","results","map","result","isImage","type","mimeType","startsWith","uri","fileName","fileSize","width","undefined","height","duration","thumbnailUri","pickMedia","Array","isArray","length","pickImage","pickVideo","openVideo","console","warn","generateThumbnail","videoUrl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,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeoB,eAAeA,CAACC,OAAe,EAAmB;EACtE,IAAI,CAAC/B,iBAAiB,EAAE;IACtB,OAAO+B,OAAO;EAChB;EACA,IAAI,OAAO/B,iBAAiB,CAAC8B,eAAe,KAAK,UAAU,EAAE;IAC3D,OAAOC,OAAO;EAChB;EACA,OAAO/B,iBAAiB,CAAC8B,eAAe,CAACC,OAAO,CAAC;AACnD;AAEO,eAAeC,gBAAgBA,CAAA,EAAkB;EACtD,IAAI,CAAChC,iBAAiB,EAAE;IACtB;EACF;EACA,OAAOA,iBAAiB,CAACgC,gBAAgB,CAAC,CAAC;AAC7C","ignoreList":[]}
|
|
@@ -9,29 +9,29 @@ var _conversations = require("../data/fake/conversations.js");
|
|
|
9
9
|
var _api = require("./api.js");
|
|
10
10
|
var _date = require("../utils/date.js");
|
|
11
11
|
const PER_PAGE = 25;
|
|
12
|
-
function getCustomerConversation(externalId, created_at, page = 0, options) {
|
|
12
|
+
function getCustomerConversation(externalId, created_at, page = 0, options, signal) {
|
|
13
13
|
if (options.fake) {
|
|
14
14
|
return (0, _conversations.getFakePaginatedConversationResponse)(page, options.per_page ?? PER_PAGE);
|
|
15
15
|
}
|
|
16
16
|
return _api.axiosInstance.get(`/api/customers/${externalId}/conversation`, {
|
|
17
17
|
params: {
|
|
18
18
|
page,
|
|
19
|
-
// per_page: PER_PAGE,
|
|
20
19
|
getOld: 1,
|
|
21
20
|
getFrom: (0, _date.dateToUnixTimestamp)(created_at)
|
|
22
|
-
}
|
|
21
|
+
},
|
|
22
|
+
signal
|
|
23
23
|
}).then(res => res.data);
|
|
24
24
|
}
|
|
25
|
-
function getNewCustomerConversation(externalId, created_at, options) {
|
|
25
|
+
function getNewCustomerConversation(externalId, created_at, options, signal) {
|
|
26
26
|
if (options.fake) {
|
|
27
27
|
return (0, _conversations.getFakeConversationResponse)(25, 0, 0, true);
|
|
28
28
|
}
|
|
29
29
|
return _api.axiosInstance.get(`/api/customers/${externalId}/conversation`, {
|
|
30
30
|
params: {
|
|
31
31
|
page: 1,
|
|
32
|
-
// per_page: 25,
|
|
33
32
|
getFrom: (0, _date.dateToUnixTimestamp)(created_at)
|
|
34
|
-
}
|
|
33
|
+
},
|
|
34
|
+
signal
|
|
35
35
|
}).then(res => res.data);
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=conversations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_conversations","require","_api","_date","PER_PAGE","getCustomerConversation","externalId","created_at","page","options","fake","getFakePaginatedConversationResponse","per_page","axiosInstance","get","params","getOld","getFrom","dateToUnixTimestamp","then","res","data","getNewCustomerConversation","getFakeConversationResponse"],"sourceRoot":"../../../src","sources":["api/conversations.ts"],"mappings":";;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,MAAMG,QAAQ,GAAG,EAAE;AAEZ,SAASC,uBAAuBA,CACrCC,UAAkB,EAClBC,UAA4B,EAC5BC,IAAY,GAAG,CAAC,EAChBC,OAA2C,
|
|
1
|
+
{"version":3,"names":["_conversations","require","_api","_date","PER_PAGE","getCustomerConversation","externalId","created_at","page","options","signal","fake","getFakePaginatedConversationResponse","per_page","axiosInstance","get","params","getOld","getFrom","dateToUnixTimestamp","then","res","data","getNewCustomerConversation","getFakeConversationResponse"],"sourceRoot":"../../../src","sources":["api/conversations.ts"],"mappings":";;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,MAAMG,QAAQ,GAAG,EAAE;AAEZ,SAASC,uBAAuBA,CACrCC,UAAkB,EAClBC,UAA4B,EAC5BC,IAAY,GAAG,CAAC,EAChBC,OAA2C,EAC3CC,MAAoB,EACW;EAC/B,IAAID,OAAO,CAACE,IAAI,EAAE;IAChB,OAAO,IAAAC,mDAAoC,EACzCJ,IAAI,EACJC,OAAO,CAACI,QAAQ,IAAIT,QACtB,CAAC;EACH;EACA,OAAOU,kBAAa,CACjBC,GAAG,CAAuB,kBAAkBT,UAAU,eAAe,EAAE;IACtEU,MAAM,EAAE;MACNR,IAAI;MACJS,MAAM,EAAE,CAAC;MACTC,OAAO,EAAE,IAAAC,yBAAmB,EAACZ,UAAU;IACzC,CAAC;IACDG;EACF,CAAC,CAAC,CACDU,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC;AAC5B;AAEO,SAASC,0BAA0BA,CACxCjB,UAAkB,EAClBC,UAA4B,EAC5BE,OAAmB,EACnBC,MAAoB,EACW;EAC/B,IAAID,OAAO,CAACE,IAAI,EAAE;IAChB,OAAO,IAAAa,0CAA2B,EAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;EACpD;EACA,OAAOV,kBAAa,CACjBC,GAAG,CAAuB,kBAAkBT,UAAU,eAAe,EAAE;IACtEU,MAAM,EAAE;MACNR,IAAI,EAAE,CAAC;MACPU,OAAO,EAAE,IAAAC,yBAAmB,EAACZ,UAAU;IACzC,CAAC;IACDG;EACF,CAAC,CAAC,CACDU,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.updateCustomer = updateCustomer;
|
|
7
7
|
var _api = require("./api.js");
|
|
8
8
|
// NOTE: This is not a REST API endpoint. Data is collected with debounce and sent to the server at an appropriate time.
|
|
9
|
-
function updateCustomer(customerData, externalId) {
|
|
9
|
+
function updateCustomer(customerData, externalId, signal) {
|
|
10
10
|
console.info('[Comnyx] Adding customer info');
|
|
11
11
|
return _api.axiosInstance.post('/api/customers/create', customerData, {
|
|
12
12
|
headers: {
|
|
13
13
|
'external-id': externalId
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
|
+
signal
|
|
15
16
|
}).then(res => res.data);
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=customers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_api","require","updateCustomer","customerData","externalId","console","info","axiosInstance","post","headers","then","res","data"],"sourceRoot":"../../../src","sources":["api/customers.ts"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAEA;AACO,SAASC,cAAcA,CAC5BC,YAAmC,EACnCC,UAAmB,
|
|
1
|
+
{"version":3,"names":["_api","require","updateCustomer","customerData","externalId","signal","console","info","axiosInstance","post","headers","then","res","data"],"sourceRoot":"../../../src","sources":["api/customers.ts"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAEA;AACO,SAASC,cAAcA,CAC5BC,YAAmC,EACnCC,UAAmB,EACnBC,MAAoB,EACa;EACjCC,OAAO,CAACC,IAAI,CAAC,+BAA+B,CAAC;EAC7C,OAAOC,kBAAa,CACjBC,IAAI,CAAC,uBAAuB,EAAEN,YAAY,EAAE;IAC3CO,OAAO,EAAE;MACP,aAAa,EAAEN;IACjB,CAAC;IACDC;EACF,CAAC,CAAC,CACDM,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -9,21 +9,33 @@ exports.uploadFileToS3 = uploadFileToS3;
|
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
var _api = require("./api.js");
|
|
11
11
|
var _media = require("../data/fake/media.js");
|
|
12
|
-
|
|
12
|
+
// React Native's XMLHttpRequest.send accepts this shape to stream a file URI
|
|
13
|
+
// without loading it into memory. Not in lib.dom, so typed locally.
|
|
14
|
+
|
|
15
|
+
function getUploadUrl(fileName, contentType, options, signal) {
|
|
13
16
|
if (options.fake) {
|
|
14
17
|
return (0, _media.getFakeUploadUrlResponse)(fileName);
|
|
15
18
|
}
|
|
16
19
|
return _api.axiosInstance.post('/api/media/presign', {
|
|
17
20
|
fileName,
|
|
18
21
|
fileType: contentType
|
|
22
|
+
}, {
|
|
23
|
+
signal
|
|
19
24
|
}).then(res => res.data);
|
|
20
25
|
}
|
|
21
|
-
function uploadFileToS3(uploadUrl, fileUri, contentType, onProgress, options) {
|
|
26
|
+
function uploadFileToS3(uploadUrl, fileUri, contentType, onProgress, options, signal) {
|
|
22
27
|
if (options?.fake) {
|
|
23
28
|
return (0, _media.fakeUploadToS3)(onProgress);
|
|
24
29
|
}
|
|
25
30
|
return new Promise((resolve, reject) => {
|
|
31
|
+
if (signal?.aborted) {
|
|
32
|
+
reject(new Error('Upload aborted'));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
26
35
|
const xhr = new XMLHttpRequest();
|
|
36
|
+
const onAbort = () => xhr.abort();
|
|
37
|
+
signal?.addEventListener('abort', onAbort);
|
|
38
|
+
const cleanup = () => signal?.removeEventListener('abort', onAbort);
|
|
27
39
|
xhr.upload.addEventListener('progress', event => {
|
|
28
40
|
if (event.lengthComputable && onProgress) {
|
|
29
41
|
const percentage = Math.min(100, Math.round(event.loaded / event.total * 100));
|
|
@@ -31,6 +43,7 @@ function uploadFileToS3(uploadUrl, fileUri, contentType, onProgress, options) {
|
|
|
31
43
|
}
|
|
32
44
|
});
|
|
33
45
|
xhr.addEventListener('load', () => {
|
|
46
|
+
cleanup();
|
|
34
47
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
35
48
|
resolve();
|
|
36
49
|
} else {
|
|
@@ -39,16 +52,16 @@ function uploadFileToS3(uploadUrl, fileUri, contentType, onProgress, options) {
|
|
|
39
52
|
}
|
|
40
53
|
});
|
|
41
54
|
xhr.addEventListener('error', () => {
|
|
55
|
+
cleanup();
|
|
42
56
|
console.error('[Comnyx] Upload XHR error, status:', xhr.status, 'response:', xhr.responseText);
|
|
43
57
|
reject(new Error('Upload failed'));
|
|
44
58
|
});
|
|
45
59
|
xhr.addEventListener('abort', () => {
|
|
60
|
+
cleanup();
|
|
46
61
|
reject(new Error('Upload aborted'));
|
|
47
62
|
});
|
|
48
63
|
xhr.open('PUT', uploadUrl);
|
|
49
64
|
xhr.setRequestHeader('Content-Type', contentType);
|
|
50
|
-
|
|
51
|
-
// React Native supports sending file URIs directly via XHR
|
|
52
65
|
const file = {
|
|
53
66
|
uri: _reactNative.Platform.OS === 'android' ? fileUri : fileUri.replace('file://', ''),
|
|
54
67
|
type: contentType,
|
|
@@ -57,7 +70,7 @@ function uploadFileToS3(uploadUrl, fileUri, contentType, onProgress, options) {
|
|
|
57
70
|
xhr.send(file);
|
|
58
71
|
});
|
|
59
72
|
}
|
|
60
|
-
function sendMediaMessage(externalId, fileUrls, mediaType, content, options) {
|
|
73
|
+
function sendMediaMessage(externalId, fileUrls, mediaType, content, options, signal) {
|
|
61
74
|
if (options.fake) {
|
|
62
75
|
return (0, _media.getFakeMediaMessageResponse)(fileUrls, mediaType);
|
|
63
76
|
}
|
|
@@ -70,7 +83,8 @@ function sendMediaMessage(externalId, fileUrls, mediaType, content, options) {
|
|
|
70
83
|
headers: {
|
|
71
84
|
'Accept': 'application/json',
|
|
72
85
|
'Content-Type': 'application/json'
|
|
73
|
-
}
|
|
86
|
+
},
|
|
87
|
+
signal
|
|
74
88
|
}).then(res => res.data);
|
|
75
89
|
}
|
|
76
90
|
//# sourceMappingURL=media.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_api","_media","getUploadUrl","fileName","contentType","options","fake","getFakeUploadUrlResponse","axiosInstance","post","fileType","then","res","data","uploadFileToS3","uploadUrl","fileUri","onProgress","fakeUploadToS3","Promise","resolve","reject","xhr","XMLHttpRequest","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_api","_media","getUploadUrl","fileName","contentType","options","signal","fake","getFakeUploadUrlResponse","axiosInstance","post","fileType","then","res","data","uploadFileToS3","uploadUrl","fileUri","onProgress","fakeUploadToS3","Promise","resolve","reject","aborted","Error","xhr","XMLHttpRequest","onAbort","abort","addEventListener","cleanup","removeEventListener","upload","event","lengthComputable","percentage","Math","min","round","loaded","total","status","console","error","responseText","open","setRequestHeader","file","uri","Platform","OS","replace","type","name","split","pop","send","sendMediaMessage","externalId","fileUrls","mediaType","content","getFakeMediaMessageResponse","files","media_type","headers"],"sourceRoot":"../../../src","sources":["api/media.ts"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAMA;AACA;;AAGO,SAASG,YAAYA,CAC1BC,QAAgB,EAChBC,WAAmB,EACnBC,OAAmB,EACnBC,MAAoB,EACQ;EAC5B,IAAID,OAAO,CAACE,IAAI,EAAE;IAChB,OAAO,IAAAC,+BAAwB,EAACL,QAAQ,CAAC;EAC3C;EACA,OAAOM,kBAAa,CACjBC,IAAI,CACH,oBAAoB,EACpB;IACEP,QAAQ;IACRQ,QAAQ,EAAEP;EACZ,CAAC,EACD;IAAEE;EAAO,CACX,CAAC,CACAM,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC;AAC5B;AAEO,SAASC,cAAcA,CAC5BC,SAAiB,EACjBC,OAAe,EACfb,WAAmB,EACnBc,UAAyC,EACzCb,OAAoB,EACpBC,MAAoB,EACL;EACf,IAAID,OAAO,EAAEE,IAAI,EAAE;IACjB,OAAO,IAAAY,qBAAc,EAACD,UAAU,CAAC;EACnC;EAEA,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,IAAIhB,MAAM,EAAEiB,OAAO,EAAE;MACnBD,MAAM,CAAC,IAAIE,KAAK,CAAC,gBAAgB,CAAC,CAAC;MACnC;IACF;IAEA,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;IAChC,MAAMC,OAAO,GAAGA,CAAA,KAAMF,GAAG,CAACG,KAAK,CAAC,CAAC;IACjCtB,MAAM,EAAEuB,gBAAgB,CAAC,OAAO,EAAEF,OA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,CAAC,gBAAgB,CAAC,CAAC;IACrC,CAAC,CAAC;IAEFC,GAAG,CAACoB,IAAI,CAAC,KAAK,EAAE7B,SAAS,CAAC;IAC1BS,GAAG,CAACqB,gBAAgB,CAAC,cAAc,EAAE1C,WAAW,CAAC;IAEjD,MAAM2C,IAAe,GAAG;MACtBC,GAAG,EAAEC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGjC,OAAO,GAAGA,OAAO,CAACkC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;MACzEC,IAAI,EAAEhD,WAAW;MACjBiD,IAAI,EAAEpC,OAAO,CAACqC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,IAAI;IACpC,CAAC;IAED9B,GAAG,CAAC+B,IAAI,CAACT,IAA2B,CAAC;EACvC,CAAC,CAAC;AACJ;AAEO,SAASU,gBAAgBA,CAC9BC,UAAkB,EAClBC,QAAkB,EAClBC,SAA4B,EAC5BC,OAAe,EACfxD,OAAmB,EACnBC,MAAoB,EACM;EAC1B,IAAID,OAAO,CAACE,IAAI,EAAE;IAChB,OAAO,IAAAuD,kCAA2B,EAACH,QAAQ,EAAEC,SAAS,CAAC;EACzD;EACA,OAAOnD,kBAAa,CACjBC,IAAI,CACH,wBAAwB,EACxB;IACEgD,UAAU;IACVG,OAAO;IACPE,KAAK,EAAEJ,QAAQ;IACfK,UAAU,EAAEJ;EACd,CAAC,EACD;IACEK,OAAO,EAAE;MACP,QAAQ,EAAE,kBAAkB;MAC5B,cAAc,EAAE;IAClB,CAAC;IACD3D;EACF,CACF,CAAC,CACAM,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.sendCustomerMessage = sendCustomerMessage;
|
|
7
7
|
var _messages = require("../data/fake/messages.js");
|
|
8
8
|
var _api = require("./api.js");
|
|
9
|
-
function sendCustomerMessage(externalId, content, options) {
|
|
9
|
+
function sendCustomerMessage(externalId, content, options, signal) {
|
|
10
10
|
if (options.fake) {
|
|
11
11
|
return new Promise((resolve, _) => {
|
|
12
12
|
setTimeout(() => {
|
|
@@ -21,7 +21,8 @@ function sendCustomerMessage(externalId, content, options) {
|
|
|
21
21
|
headers: {
|
|
22
22
|
'Accept': 'application/json',
|
|
23
23
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
|
+
signal
|
|
25
26
|
}).then(res => res.data);
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_messages","require","_api","sendCustomerMessage","externalId","content","options","fake","Promise","resolve","_","setTimeout","getFakeMessageResponse","axiosInstance","post","headers","then","res","data"],"sourceRoot":"../../../src","sources":["api/messages.ts"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEO,SAASE,mBAAmBA,CACjCC,UAAkB,EAClBC,OAAe,EACfC,OAAmB,
|
|
1
|
+
{"version":3,"names":["_messages","require","_api","sendCustomerMessage","externalId","content","options","signal","fake","Promise","resolve","_","setTimeout","getFakeMessageResponse","axiosInstance","post","headers","then","res","data"],"sourceRoot":"../../../src","sources":["api/messages.ts"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEO,SAASE,mBAAmBA,CACjCC,UAAkB,EAClBC,OAAe,EACfC,OAAmB,EACnBC,MAAoB,EACM;EAC1B,IAAID,OAAO,CAACE,IAAI,EAAE;IAChB,OAAO,IAAIC,OAAO,CAAkB,CAACC,OAAO,EAAEC,CAAC,KAAK;MAClDC,UAAU,CAAC,MAAM;QACfF,OAAO,CAAC,IAAAG,gCAAsB,EAACR,OAAO,CAAC,CAAC;MAC1C,CAAC,EAAE,GAAG,CAAC;IACT,CAAC,CAAC;EACJ;EACA,OAAOS,kBAAa,CACjBC,IAAI,CACH,wBAAwB,EACxB;IACEX,UAAU;IACVC;EACF,CAAC,EACD;IACEW,OAAO,EAAE;MACP,QAAQ,EAAE,kBAAkB;MAC5B,cAAc,EAAE;IAClB,CAAC;IACDT;EACF,CACF,CAAC,CACAU,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -19,6 +19,7 @@ var _ScaledSheet = require("./ScaledSheet.js");
|
|
|
19
19
|
var _formatDate = require("../utils/formatDate.js");
|
|
20
20
|
var _activeOpacity = require("../constants/activeOpacity.js");
|
|
21
21
|
var _store = require("../store/store.js");
|
|
22
|
+
var _SupportConfigContext = require("../support/SupportConfigContext.js");
|
|
22
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
24
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
25
|
const headphonesIcon = require('../assets/headphones-01.png');
|
|
@@ -76,6 +77,7 @@ function CustomToast() {
|
|
|
76
77
|
} = (0, _store.useAppStore)(s => ({
|
|
77
78
|
toastMessage: s.toastMessage
|
|
78
79
|
}));
|
|
80
|
+
const themeColors = (0, _useThemeColors.useThemeColors)();
|
|
79
81
|
const fadeAnim = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
80
82
|
const translateY = (0, _react.useRef)(new _reactNative.Animated.Value(50)).current;
|
|
81
83
|
(0, _react.useEffect)(() => {
|
|
@@ -111,9 +113,13 @@ function CustomToast() {
|
|
|
111
113
|
}]
|
|
112
114
|
}],
|
|
113
115
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
114
|
-
style: styles.toastContent,
|
|
116
|
+
style: [styles.toastContent, {
|
|
117
|
+
backgroundColor: themeColors.toastBackground
|
|
118
|
+
}],
|
|
115
119
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppText.AppText, {
|
|
116
|
-
style: styles.toastText,
|
|
120
|
+
style: [styles.toastText, {
|
|
121
|
+
color: themeColors.toastText
|
|
122
|
+
}],
|
|
117
123
|
localization: toastMessage
|
|
118
124
|
})
|
|
119
125
|
})
|
|
@@ -128,6 +134,12 @@ function ChatList({
|
|
|
128
134
|
height: windowHeight
|
|
129
135
|
} = (0, _reactNative.useWindowDimensions)();
|
|
130
136
|
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
137
|
+
const {
|
|
138
|
+
renderHeader: renderHeaderOverride,
|
|
139
|
+
renderEmptyState: renderEmptyStateOverride,
|
|
140
|
+
renderErrorState: renderErrorStateOverride,
|
|
141
|
+
renderMessage: renderMessageOverride
|
|
142
|
+
} = (0, _SupportConfigContext.useSupportConfig)();
|
|
131
143
|
const MESSAGE_MIN_HEIGHT = 60;
|
|
132
144
|
const FLATLIST_PADDING = 20;
|
|
133
145
|
const MESSAGES_PER_PAGE = Math.ceil((windowHeight - FLATLIST_PADDING) / MESSAGE_MIN_HEIGHT);
|
|
@@ -135,6 +147,16 @@ function ChatList({
|
|
|
135
147
|
(0, _react.useEffect)(() => {
|
|
136
148
|
setLoading(l => l && initLoading);
|
|
137
149
|
}, [initLoading]);
|
|
150
|
+
const lifecycleAbortRef = (0, _react.useRef)(null);
|
|
151
|
+
if (lifecycleAbortRef.current === null) {
|
|
152
|
+
lifecycleAbortRef.current = new AbortController();
|
|
153
|
+
}
|
|
154
|
+
(0, _react.useEffect)(() => {
|
|
155
|
+
const controller = lifecycleAbortRef.current;
|
|
156
|
+
return () => {
|
|
157
|
+
controller?.abort();
|
|
158
|
+
};
|
|
159
|
+
}, []);
|
|
138
160
|
const {
|
|
139
161
|
data,
|
|
140
162
|
setData,
|
|
@@ -148,7 +170,7 @@ function ChatList({
|
|
|
148
170
|
}));
|
|
149
171
|
const ref = (0, _react.useRef)(null);
|
|
150
172
|
const [page, setPage] = (0, _react.useState)(1);
|
|
151
|
-
const nextPageStatus = (0, _react.useRef)();
|
|
173
|
+
const nextPageStatus = (0, _react.useRef)(undefined);
|
|
152
174
|
const [nexPageFailed, setNexPageFailed] = (0, _react.useState)(false);
|
|
153
175
|
const [initFailed, setInitFailed] = (0, _react.useState)(false);
|
|
154
176
|
const [showScrollDownButton, setShowScrollDownButton] = (0, _react.useState)(false);
|
|
@@ -295,7 +317,7 @@ function ChatList({
|
|
|
295
317
|
(0, _index.getCustomerConversation)(customer.external_id, firstMessage?.created_at, newPage, {
|
|
296
318
|
fake: _store.useAppStore.getState().fake,
|
|
297
319
|
per_page: MESSAGES_PER_PAGE
|
|
298
|
-
}).then(newData => {
|
|
320
|
+
}, lifecycleAbortRef.current?.signal).then(newData => {
|
|
299
321
|
listChangedRef.current = true;
|
|
300
322
|
setData(prevData => {
|
|
301
323
|
const newMessages = newData?.page?.data ?? [];
|
|
@@ -333,14 +355,23 @@ function ChatList({
|
|
|
333
355
|
const renderItem = (0, _react.useCallback)(({
|
|
334
356
|
item
|
|
335
357
|
}) => {
|
|
336
|
-
|
|
358
|
+
const defaultNode = /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageItem.MessageItem, {
|
|
337
359
|
item: item,
|
|
338
360
|
onShowPopup: () => {
|
|
339
361
|
setSelectedMessage(item.content);
|
|
340
362
|
setPopupVisible(true);
|
|
341
363
|
}
|
|
342
364
|
});
|
|
343
|
-
|
|
365
|
+
if (renderMessageOverride) {
|
|
366
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
367
|
+
children: renderMessageOverride({
|
|
368
|
+
message: item,
|
|
369
|
+
defaultNode
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return defaultNode;
|
|
374
|
+
}, [renderMessageOverride]);
|
|
344
375
|
const renderSectionFooter = (0, _react.useCallback)(({
|
|
345
376
|
section
|
|
346
377
|
}) => {
|
|
@@ -380,7 +411,7 @@ function ChatList({
|
|
|
380
411
|
(0, _index.getCustomerConversation)(customer?.external_id, new Date(), 1, {
|
|
381
412
|
fake: _store.useAppStore.getState().fake,
|
|
382
413
|
per_page: MESSAGES_PER_PAGE
|
|
383
|
-
}).then(newData => {
|
|
414
|
+
}, lifecycleAbortRef.current?.signal).then(newData => {
|
|
384
415
|
setData(prevData => {
|
|
385
416
|
const newMessages = newData?.page?.data ?? [];
|
|
386
417
|
// Only proceed with filtering if we have previous data
|
|
@@ -456,6 +487,13 @@ function ChatList({
|
|
|
456
487
|
});
|
|
457
488
|
}
|
|
458
489
|
if (initFailed) {
|
|
490
|
+
if (renderErrorStateOverride) {
|
|
491
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
492
|
+
children: renderErrorStateOverride({
|
|
493
|
+
retry: () => setInitFailed(false)
|
|
494
|
+
})
|
|
495
|
+
});
|
|
496
|
+
}
|
|
459
497
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InitFailed.InitFailed, {
|
|
460
498
|
setInitFailed: setInitFailed
|
|
461
499
|
});
|
|
@@ -476,47 +514,55 @@ function ChatList({
|
|
|
476
514
|
backgroundColor: themeColors.background,
|
|
477
515
|
paddingTop: insets.top || 40
|
|
478
516
|
}],
|
|
479
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}],
|
|
483
|
-
onPress: onBack,
|
|
484
|
-
activeOpacity: _activeOpacity.activeOpacity,
|
|
485
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
486
|
-
source: closeIcon,
|
|
487
|
-
style: [styles.closeIcon, {
|
|
488
|
-
tintColor: themeColors.text
|
|
489
|
-
}]
|
|
517
|
+
children: [renderHeaderOverride ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
518
|
+
children: renderHeaderOverride({
|
|
519
|
+
onBack
|
|
490
520
|
})
|
|
491
|
-
})
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}],
|
|
496
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AppText.AppText, {
|
|
497
|
-
localization: "chat.support-team",
|
|
498
|
-
weight: '600',
|
|
499
|
-
style: [styles.header, {
|
|
500
|
-
color: themeColors.text
|
|
501
|
-
}]
|
|
502
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
503
|
-
style: [styles.headerText, {
|
|
504
|
-
backgroundColor: themeColors.background
|
|
521
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
522
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
523
|
+
style: [styles.iconContainer, {
|
|
524
|
+
top: insets.top || 40
|
|
505
525
|
}],
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
526
|
+
onPress: onBack,
|
|
527
|
+
activeOpacity: _activeOpacity.activeOpacity,
|
|
528
|
+
accessibilityRole: "button",
|
|
529
|
+
accessibilityLabel: "Close support",
|
|
530
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
531
|
+
source: closeIcon,
|
|
532
|
+
style: [styles.closeIcon, {
|
|
509
533
|
tintColor: themeColors.text
|
|
510
534
|
}]
|
|
511
|
-
})
|
|
512
|
-
|
|
513
|
-
|
|
535
|
+
})
|
|
536
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
537
|
+
style: [styles.headerContainer, {
|
|
538
|
+
backgroundColor: themeColors.background,
|
|
539
|
+
borderBottomColor: themeColors.lavender
|
|
540
|
+
}],
|
|
541
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AppText.AppText, {
|
|
542
|
+
localization: "chat.support-team",
|
|
543
|
+
weight: '600',
|
|
544
|
+
style: [styles.header, {
|
|
514
545
|
color: themeColors.text
|
|
515
546
|
}]
|
|
516
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
517
|
-
style: [styles.
|
|
518
|
-
backgroundColor: themeColors.
|
|
519
|
-
}]
|
|
547
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
548
|
+
style: [styles.headerText, {
|
|
549
|
+
backgroundColor: themeColors.background
|
|
550
|
+
}],
|
|
551
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
552
|
+
source: headphonesIcon,
|
|
553
|
+
style: [styles.headphonesIcon, {
|
|
554
|
+
tintColor: themeColors.text
|
|
555
|
+
}]
|
|
556
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppText.AppText, {
|
|
557
|
+
localization: "chat.live",
|
|
558
|
+
style: [styles.liveChat, {
|
|
559
|
+
color: themeColors.text
|
|
560
|
+
}]
|
|
561
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
562
|
+
style: [styles.dot, {
|
|
563
|
+
backgroundColor: themeColors.green
|
|
564
|
+
}]
|
|
565
|
+
})]
|
|
520
566
|
})]
|
|
521
567
|
})]
|
|
522
568
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
@@ -531,7 +577,9 @@ function ChatList({
|
|
|
531
577
|
backgroundColor: themeColors.background
|
|
532
578
|
}],
|
|
533
579
|
style: styles.list,
|
|
534
|
-
ListEmptyComponent: !loading && (!sections || sections.length === 0) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
580
|
+
ListEmptyComponent: !loading && (!sections || sections.length === 0) ? renderEmptyStateOverride ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
581
|
+
children: renderEmptyStateOverride()
|
|
582
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmptyList.EmptyList, {}) : null,
|
|
535
583
|
ListFooterComponent: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(LoadingItem, {}) : null,
|
|
536
584
|
keyExtractor: (item, index) => item.id?.toString() ?? item.local_id ?? `fake-${index}`,
|
|
537
585
|
removeClippedSubviews: false,
|
|
@@ -554,6 +602,8 @@ function ChatList({
|
|
|
554
602
|
backgroundColor: themeColors.ghost
|
|
555
603
|
}, isKeyboardVisible && styles.scrollDownButtonWithKeyboard],
|
|
556
604
|
onPress: () => scrollToBottom(true),
|
|
605
|
+
accessibilityRole: "button",
|
|
606
|
+
accessibilityLabel: "Scroll to latest message",
|
|
557
607
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
558
608
|
source: require('../assets/down.png'),
|
|
559
609
|
style: [styles.scrollUpIcon, {
|
|
@@ -707,7 +757,6 @@ const styles = _ScaledSheet.ScaledSheet.create({
|
|
|
707
757
|
zIndex: 9999
|
|
708
758
|
},
|
|
709
759
|
toastContent: {
|
|
710
|
-
backgroundColor: '#333333',
|
|
711
760
|
borderRadius: '8@s',
|
|
712
761
|
paddingHorizontal: '16@s',
|
|
713
762
|
paddingVertical: '12@vs',
|
|
@@ -722,7 +771,6 @@ const styles = _ScaledSheet.ScaledSheet.create({
|
|
|
722
771
|
maxWidth: '90%'
|
|
723
772
|
},
|
|
724
773
|
toastText: {
|
|
725
|
-
color: '#FFFFFF',
|
|
726
774
|
fontSize: '14@vs',
|
|
727
775
|
fontWeight: '400',
|
|
728
776
|
textAlign: 'center'
|