@developer_tribe/react-native-comnyx 0.12.15 → 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/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/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/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/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 +1 -1
- 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 +19 -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
|
@@ -0,0 +1,53 @@
|
|
|
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: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#import "RNComnyxSpec.h"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@implementation NativeComnyxSpecBase
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
21
|
+
{
|
|
22
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
|
|
23
|
+
}
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
namespace facebook::react {
|
|
28
|
+
|
|
29
|
+
static facebook::jsi::Value __hostFunction_NativeComnyxSpecJSI_initialize(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
30
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "initialize", @selector(initialize:reject:), args, count);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static facebook::jsi::Value __hostFunction_NativeComnyxSpecJSI_checkOptIn(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
34
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "checkOptIn", @selector(checkOptIn:reject:), args, count);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static facebook::jsi::Value __hostFunction_NativeComnyxSpecJSI_optIn(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
38
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "optIn", @selector(optIn:reject:), args, count);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
NativeComnyxSpecJSI::NativeComnyxSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
42
|
+
: ObjCTurboModule(params) {
|
|
43
|
+
|
|
44
|
+
methodMap_["initialize"] = MethodMetadata {0, __hostFunction_NativeComnyxSpecJSI_initialize};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
methodMap_["checkOptIn"] = MethodMetadata {0, __hostFunction_NativeComnyxSpecJSI_checkOptIn};
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
methodMap_["optIn"] = MethodMetadata {0, __hostFunction_NativeComnyxSpecJSI_optIn};
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,67 @@
|
|
|
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: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef __cplusplus
|
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
// Avoid multiple includes of RNComnyxSpec symbols
|
|
19
|
+
#ifndef RNComnyxSpec_H
|
|
20
|
+
#define RNComnyxSpec_H
|
|
21
|
+
|
|
22
|
+
#import <Foundation/Foundation.h>
|
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
|
26
|
+
#import <React/RCTBridgeModule.h>
|
|
27
|
+
#import <React/RCTCxxConvert.h>
|
|
28
|
+
#import <React/RCTManagedPointer.h>
|
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
30
|
+
#import <optional>
|
|
31
|
+
#import <vector>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
35
|
+
|
|
36
|
+
@protocol NativeComnyxSpec <RCTBridgeModule, RCTTurboModule>
|
|
37
|
+
|
|
38
|
+
- (void)initialize:(RCTPromiseResolveBlock)resolve
|
|
39
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
40
|
+
- (void)checkOptIn:(RCTPromiseResolveBlock)resolve
|
|
41
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
42
|
+
- (void)optIn:(RCTPromiseResolveBlock)resolve
|
|
43
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
44
|
+
|
|
45
|
+
@end
|
|
46
|
+
|
|
47
|
+
@interface NativeComnyxSpecBase : NSObject {
|
|
48
|
+
@protected
|
|
49
|
+
facebook::react::EventEmitterCallback _eventEmitterCallback;
|
|
50
|
+
}
|
|
51
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@end
|
|
55
|
+
|
|
56
|
+
namespace facebook::react {
|
|
57
|
+
/**
|
|
58
|
+
* ObjC++ class for module 'NativeComnyx'
|
|
59
|
+
*/
|
|
60
|
+
class JSI_EXPORT NativeComnyxSpecJSI : public ObjCTurboModule {
|
|
61
|
+
public:
|
|
62
|
+
NativeComnyxSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
|
63
|
+
};
|
|
64
|
+
} // namespace facebook::react
|
|
65
|
+
|
|
66
|
+
NS_ASSUME_NONNULL_END
|
|
67
|
+
#endif // RNComnyxSpec_H
|
|
@@ -0,0 +1,38 @@
|
|
|
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: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNComnyxSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeComnyxCxxSpecJSI_initialize(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeComnyxCxxSpecJSI *>(&turboModule)->initialize(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeComnyxCxxSpecJSI_checkOptIn(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeComnyxCxxSpecJSI *>(&turboModule)->checkOptIn(
|
|
21
|
+
rt
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
static jsi::Value __hostFunction_NativeComnyxCxxSpecJSI_optIn(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
25
|
+
return static_cast<NativeComnyxCxxSpecJSI *>(&turboModule)->optIn(
|
|
26
|
+
rt
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
NativeComnyxCxxSpecJSI::NativeComnyxCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
31
|
+
: TurboModule("Comnyx", jsInvoker) {
|
|
32
|
+
methodMap_["initialize"] = MethodMetadata {0, __hostFunction_NativeComnyxCxxSpecJSI_initialize};
|
|
33
|
+
methodMap_["checkOptIn"] = MethodMetadata {0, __hostFunction_NativeComnyxCxxSpecJSI_checkOptIn};
|
|
34
|
+
methodMap_["optIn"] = MethodMetadata {0, __hostFunction_NativeComnyxCxxSpecJSI_optIn};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -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.ChatList = ChatList;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
9
10
|
var _index = require("../api/index.js");
|
|
10
11
|
var _MessageItem = require("./MessageItem.js");
|
|
11
12
|
var _MessageInput = require("./MessageInput.js");
|
|
@@ -91,6 +92,7 @@ function ChatList({
|
|
|
91
92
|
const {
|
|
92
93
|
height: windowHeight
|
|
93
94
|
} = (0, _reactNative.useWindowDimensions)();
|
|
95
|
+
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
94
96
|
const MESSAGE_MIN_HEIGHT = 60;
|
|
95
97
|
const FLATLIST_PADDING = 20;
|
|
96
98
|
const MESSAGES_PER_PAGE = Math.ceil((windowHeight - FLATLIST_PADDING) / MESSAGE_MIN_HEIGHT);
|
|
@@ -114,15 +116,11 @@ function ChatList({
|
|
|
114
116
|
const nextPageStatus = (0, _react.useRef)();
|
|
115
117
|
const [nexPageFailed, setNexPageFailed] = (0, _react.useState)(false);
|
|
116
118
|
const [initFailed, setInitFailed] = (0, _react.useState)(false);
|
|
117
|
-
const [
|
|
119
|
+
const [showScrollDownButton, setShowScrollDownButton] = (0, _react.useState)(false);
|
|
118
120
|
const [isKeyboardVisible, setIsKeyboardVisible] = (0, _react.useState)(false);
|
|
119
121
|
const listChangedRef = (0, _react.useRef)(false);
|
|
120
122
|
const [popupVisible, setPopupVisible] = (0, _react.useState)(false);
|
|
121
123
|
const [selectedMessage, setSelectedMessage] = (0, _react.useState)('');
|
|
122
|
-
const [currentSection, setCurrentSection] = (0, _react.useState)('');
|
|
123
|
-
const lastSectionChangeTime = (0, _react.useRef)(0);
|
|
124
|
-
const pendingSectionRef = (0, _react.useRef)(null);
|
|
125
|
-
const MIN_SECTION_CHANGE_INTERVAL = 150;
|
|
126
124
|
const sections = (0, _react.useMemo)(() => {
|
|
127
125
|
if (!data || data.length === 0) return [];
|
|
128
126
|
const validData = data.map(message => {
|
|
@@ -136,25 +134,32 @@ function ChatList({
|
|
|
136
134
|
});
|
|
137
135
|
const messagesByDate = {};
|
|
138
136
|
validData.forEach(message => {
|
|
139
|
-
|
|
137
|
+
if (!message.created_at) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const createdAt = message.created_at instanceof Date ? message.created_at : new Date(message.created_at);
|
|
141
|
+
const dateKey = (0, _formatDate.getDateKey)(createdAt);
|
|
142
|
+
if (!dateKey) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const dayStart = new Date(createdAt.getFullYear(), createdAt.getMonth(), createdAt.getDate()).getTime();
|
|
140
146
|
if (!messagesByDate[dateKey]) {
|
|
141
|
-
messagesByDate[dateKey] =
|
|
147
|
+
messagesByDate[dateKey] = {
|
|
148
|
+
label: (0, _formatDate.formatDate)(language, createdAt),
|
|
149
|
+
timestamp: dayStart,
|
|
150
|
+
messages: []
|
|
151
|
+
};
|
|
142
152
|
}
|
|
143
|
-
|
|
144
|
-
messagesByDate[dateKey].push(message);
|
|
153
|
+
messagesByDate[dateKey].messages.push(message);
|
|
145
154
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
title,
|
|
155
|
+
return Object.values(messagesByDate).sort((a, b) => b.timestamp - a.timestamp).map(({
|
|
156
|
+
label,
|
|
157
|
+
messages
|
|
158
|
+
}) => ({
|
|
159
|
+
title: label,
|
|
152
160
|
data: messages.sort((a, b) => {
|
|
153
161
|
try {
|
|
154
|
-
if (!a.created_at) {
|
|
155
|
-
return 0;
|
|
156
|
-
}
|
|
157
|
-
if (!b.created_at) {
|
|
162
|
+
if (!a.created_at || !b.created_at) {
|
|
158
163
|
return 0;
|
|
159
164
|
}
|
|
160
165
|
const dateA = a.created_at instanceof Date ? a.created_at : new Date(a.created_at);
|
|
@@ -302,80 +307,31 @@ function ChatList({
|
|
|
302
307
|
}
|
|
303
308
|
});
|
|
304
309
|
}, []);
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
setCurrentSection(newSection);
|
|
321
|
-
lastSectionChangeTime.current = Date.now();
|
|
322
|
-
pendingSectionRef.current = null;
|
|
323
|
-
}
|
|
324
|
-
}, MIN_SECTION_CHANGE_INTERVAL - timeSinceLastChange);
|
|
325
|
-
} else {
|
|
326
|
-
// Enough time has passed, update immediately
|
|
327
|
-
setCurrentSection(newSection);
|
|
328
|
-
lastSectionChangeTime.current = now;
|
|
329
|
-
pendingSectionRef.current = null;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}, [currentSection]);
|
|
310
|
+
const renderSectionFooter = (0, _react.useCallback)(({
|
|
311
|
+
section
|
|
312
|
+
}) => {
|
|
313
|
+
const title = section.title;
|
|
314
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
315
|
+
style: styles.sectionHeaderContainer,
|
|
316
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppText.AppText, {
|
|
317
|
+
style: [styles.sectionHeader, {
|
|
318
|
+
color: themeColors.slate,
|
|
319
|
+
backgroundColor: themeColors.ghost
|
|
320
|
+
}],
|
|
321
|
+
children: title
|
|
322
|
+
})
|
|
323
|
+
});
|
|
324
|
+
}, [themeColors]);
|
|
333
325
|
const handleScroll = (0, _react.useCallback)(event => {
|
|
334
326
|
const currentScrollY = event.nativeEvent.contentOffset.y;
|
|
335
327
|
const contentHeight = event.nativeEvent.contentSize.height;
|
|
336
328
|
const scrollViewHeight = event.nativeEvent.layoutMeasurement.height;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
// Determine the section at the bottom of the window based on scroll position
|
|
340
|
-
if (sections && sections.length > 0) {
|
|
341
|
-
let accumulatedHeight = 0;
|
|
342
|
-
let lastVisibleSection = null;
|
|
343
|
-
|
|
344
|
-
// Check all sections
|
|
345
|
-
for (let i = 0; i < sections.length; i++) {
|
|
346
|
-
const section = sections[i];
|
|
347
|
-
if (!section || !section.data) continue;
|
|
348
|
-
|
|
349
|
-
// Calculate section height
|
|
350
|
-
const sectionHeight = section.data.length * (MESSAGE_MIN_HEIGHT + 10);
|
|
351
|
-
|
|
352
|
-
// Section positions
|
|
353
|
-
const sectionStart = accumulatedHeight;
|
|
354
|
-
const sectionEnd = sectionStart + sectionHeight;
|
|
355
|
-
|
|
356
|
-
// Visible area
|
|
357
|
-
const visibleTop = currentScrollY;
|
|
358
|
-
const visibleBottom = visibleTop + scrollViewHeight;
|
|
359
|
-
|
|
360
|
-
// Find the section visible at the bottom of the screen
|
|
361
|
-
const isSectionVisibleAtBottom = visibleBottom >= sectionStart && visibleBottom <= sectionEnd || sectionStart <= visibleTop && sectionEnd >= visibleBottom;
|
|
362
|
-
if (isSectionVisibleAtBottom) {
|
|
363
|
-
lastVisibleSection = section;
|
|
364
|
-
}
|
|
365
|
-
accumulatedHeight += sectionHeight;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// Display the found section using our safe updater
|
|
369
|
-
if (lastVisibleSection?.title && lastVisibleSection.title !== currentSection) {
|
|
370
|
-
updateSectionSafely(lastVisibleSection.title);
|
|
371
|
-
} else if (!lastVisibleSection && currentScrollY <= 10 && sections[0]?.title) {
|
|
372
|
-
updateSectionSafely(sections[0].title);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
329
|
+
const shouldShowScrollButton = currentScrollY > 300;
|
|
330
|
+
setShowScrollDownButton(shouldShowScrollButton);
|
|
375
331
|
if (currentScrollY >= contentHeight - scrollViewHeight - 200) {
|
|
376
332
|
nextPage();
|
|
377
333
|
}
|
|
378
|
-
}, [nextPage
|
|
334
|
+
}, [nextPage]);
|
|
379
335
|
const scrollToBottom = (0, _react.useCallback)(animated => {
|
|
380
336
|
if (ref.current && sections.length) {
|
|
381
337
|
ref.current.scrollToLocation({
|
|
@@ -434,13 +390,6 @@ function ChatList({
|
|
|
434
390
|
}
|
|
435
391
|
}, [MESSAGES_PER_PAGE, customer?.external_id, initFailed, setData]);
|
|
436
392
|
|
|
437
|
-
// Initialize the current section when sections are loaded
|
|
438
|
-
(0, _react.useEffect)(() => {
|
|
439
|
-
if (sections.length > 0 && sections[0]?.title) {
|
|
440
|
-
setCurrentSection(sections[0].title);
|
|
441
|
-
}
|
|
442
|
-
}, [sections]);
|
|
443
|
-
|
|
444
393
|
// Add keyboard listeners
|
|
445
394
|
(0, _react.useEffect)(() => {
|
|
446
395
|
const keyboardDidShowListener = _reactNative.Keyboard.addListener('keyboardDidShow', () => {
|
|
@@ -456,13 +405,6 @@ function ChatList({
|
|
|
456
405
|
keyboardDidHideListener.remove();
|
|
457
406
|
};
|
|
458
407
|
}, []);
|
|
459
|
-
|
|
460
|
-
// Clear pending updates on unmount
|
|
461
|
-
(0, _react.useEffect)(() => {
|
|
462
|
-
return () => {
|
|
463
|
-
pendingSectionRef.current = null;
|
|
464
|
-
};
|
|
465
|
-
}, []);
|
|
466
408
|
if (nexPageFailed) {
|
|
467
409
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
468
410
|
style: [styles.retryContainer, {
|
|
@@ -505,10 +447,13 @@ function ChatList({
|
|
|
505
447
|
},
|
|
506
448
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
507
449
|
style: [styles.container, {
|
|
508
|
-
backgroundColor: themeColors.background
|
|
450
|
+
backgroundColor: themeColors.background,
|
|
451
|
+
paddingTop: insets.top || 40
|
|
509
452
|
}],
|
|
510
453
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
511
|
-
style: [styles.iconContainer
|
|
454
|
+
style: [styles.iconContainer, {
|
|
455
|
+
top: insets.top || 40
|
|
456
|
+
}],
|
|
512
457
|
onPress: onBack,
|
|
513
458
|
activeOpacity: _activeOpacity.activeOpacity,
|
|
514
459
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
@@ -548,19 +493,14 @@ function ChatList({
|
|
|
548
493
|
}]
|
|
549
494
|
})]
|
|
550
495
|
})]
|
|
551
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
496
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
552
497
|
style: styles.listContainer,
|
|
553
|
-
children:
|
|
554
|
-
style: [styles.dateText, {
|
|
555
|
-
color: themeColors.slate,
|
|
556
|
-
backgroundColor: themeColors.ghost
|
|
557
|
-
}],
|
|
558
|
-
children: currentSection
|
|
559
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SectionList, {
|
|
498
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SectionList, {
|
|
560
499
|
ref: ref,
|
|
561
500
|
sections: sections,
|
|
562
501
|
inverted: true,
|
|
563
502
|
renderItem: renderItem,
|
|
503
|
+
renderSectionFooter: renderSectionFooter,
|
|
564
504
|
contentContainerStyle: [styles.contentContainer, {
|
|
565
505
|
backgroundColor: themeColors.background
|
|
566
506
|
}],
|
|
@@ -581,8 +521,8 @@ function ChatList({
|
|
|
581
521
|
scrollEventThrottle: 1,
|
|
582
522
|
stickySectionHeadersEnabled: false,
|
|
583
523
|
showsVerticalScrollIndicator: false
|
|
584
|
-
})
|
|
585
|
-
}),
|
|
524
|
+
})
|
|
525
|
+
}), showScrollDownButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
586
526
|
activeOpacity: _activeOpacity.activeOpacity,
|
|
587
527
|
style: [styles.scrollDownButton, {
|
|
588
528
|
backgroundColor: themeColors.ghost
|
|
@@ -619,7 +559,6 @@ const styles = _ScaledSheet.ScaledSheet.create({
|
|
|
619
559
|
container: {
|
|
620
560
|
flex: 1,
|
|
621
561
|
paddingBottom: '20@vs',
|
|
622
|
-
paddingTop: '40@vs',
|
|
623
562
|
position: 'relative'
|
|
624
563
|
},
|
|
625
564
|
list: {
|
|
@@ -698,7 +637,7 @@ const styles = _ScaledSheet.ScaledSheet.create({
|
|
|
698
637
|
},
|
|
699
638
|
iconContainer: {
|
|
700
639
|
paddingHorizontal: '20@s',
|
|
701
|
-
paddingVertical: '
|
|
640
|
+
paddingVertical: '10@vs',
|
|
702
641
|
position: 'absolute',
|
|
703
642
|
zIndex: 9999
|
|
704
643
|
},
|
|
@@ -725,17 +664,6 @@ const styles = _ScaledSheet.ScaledSheet.create({
|
|
|
725
664
|
alignSelf: 'center',
|
|
726
665
|
marginVertical: '8@vs'
|
|
727
666
|
},
|
|
728
|
-
dateText: {
|
|
729
|
-
fontSize: '14@vs',
|
|
730
|
-
fontWeight: '500',
|
|
731
|
-
borderRadius: '12@s',
|
|
732
|
-
paddingHorizontal: '8@s',
|
|
733
|
-
paddingVertical: '2@s',
|
|
734
|
-
position: 'absolute',
|
|
735
|
-
top: '10@vs',
|
|
736
|
-
zIndex: 10,
|
|
737
|
-
alignSelf: 'center'
|
|
738
|
-
},
|
|
739
667
|
listContainer: {
|
|
740
668
|
flex: 1,
|
|
741
669
|
position: 'relative'
|