diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h @@ -49,6 +49,7 @@ initializeCryptoAccount(jsi::Runtime &rt, jsi::String userId) override; virtual jsi::Value getUserPublicKey(jsi::Runtime &rt) override; virtual jsi::Value getUserOneTimeKeys(jsi::Runtime &rt) override; + virtual void terminate(jsi::Runtime &rt) override; virtual double getCodeVersion(jsi::Runtime &rt) override; virtual jsi::Value setNotifyToken(jsi::Runtime &rt, jsi::String token) override; diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp @@ -4,6 +4,7 @@ #include "DraftStoreOperations.h" #include "InternalModules/GlobalDBSingleton.h" #include "MessageStoreOperations.h" +#include "TerminateApp.h" #include "ThreadStoreOperations.h" #include @@ -721,6 +722,10 @@ }); } +void CommCoreModule::terminate(jsi::Runtime &rt) { + TerminateApp::terminate(); +} + jsi::Value CommCoreModule::initializeCryptoAccount(jsi::Runtime &rt, jsi::String userId) { std::string userIdStr = userId.utf8(rt); diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp --- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp +++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp @@ -62,6 +62,10 @@ static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getCodeVersion(rt); } +static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_terminate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->terminate(rt); + return jsi::Value::undefined(); +} static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setNotifyToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->setNotifyToken(rt, args[0].asString(rt)); } @@ -105,6 +109,7 @@ methodMap_["getUserPublicKey"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getUserPublicKey}; methodMap_["getUserOneTimeKeys"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getUserOneTimeKeys}; methodMap_["getCodeVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion}; + methodMap_["terminate"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_terminate}; methodMap_["setNotifyToken"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setNotifyToken}; methodMap_["clearNotifyToken"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearNotifyToken}; methodMap_["setCurrentUserID"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setCurrentUserID}; diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h --- a/native/cpp/CommonCpp/_generated/commJSI.h +++ b/native/cpp/CommonCpp/_generated/commJSI.h @@ -36,6 +36,7 @@ virtual jsi::Value getUserPublicKey(jsi::Runtime &rt) = 0; virtual jsi::Value getUserOneTimeKeys(jsi::Runtime &rt) = 0; virtual double getCodeVersion(jsi::Runtime &rt) = 0; + virtual void terminate(jsi::Runtime &rt) = 0; virtual jsi::Value setNotifyToken(jsi::Runtime &rt, jsi::String token) = 0; virtual jsi::Value clearNotifyToken(jsi::Runtime &rt) = 0; virtual jsi::Value setCurrentUserID(jsi::Runtime &rt, jsi::String userID) = 0; @@ -193,6 +194,14 @@ return bridging::callFromJs( rt, &T::getCodeVersion, jsInvoker_, instance_); } + void terminate(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::terminate) == 1, + "Expected terminate(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::terminate, jsInvoker_, instance_); + } jsi::Value setNotifyToken(jsi::Runtime &rt, jsi::String token) override { static_assert( bridging::getParameterCount(&T::setNotifyToken) == 2, diff --git a/native/crash.react.js b/native/crash.react.js --- a/native/crash.react.js +++ b/native/crash.react.js @@ -13,7 +13,6 @@ ScrollView, ActivityIndicator, } from 'react-native'; -import ExitApp from 'react-native-exit-app'; import { sendReportActionTypes, @@ -44,6 +43,7 @@ import Button from './components/button.react.js'; import ConnectedStatusBar from './connected-status-bar.react.js'; +import { commCoreModule } from './native-modules.js'; import { persistConfig, codeVersion } from './redux/persist.js'; import { useSelector } from './redux/redux-utils.js'; import { wipeAndExit } from './utils/crash-utils.js'; @@ -183,7 +183,7 @@ if (!this.state.doneWaiting) { return; } - ExitApp.exitApp(); + commCoreModule.terminate(); }; onPressWipe = async () => { diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js --- a/native/data/sqlite-data-handler.js +++ b/native/data/sqlite-data-handler.js @@ -2,7 +2,6 @@ import * as React from 'react'; import { Alert } from 'react-native'; -import ExitApp from 'react-native-exit-app'; import { useDispatch } from 'react-redux'; import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js'; @@ -57,7 +56,7 @@ }. Please kill the app.`, ); } else { - ExitApp.exitApp(); + commCoreModule.terminate(); } } }, @@ -104,7 +103,7 @@ throw e; } else { console.log(e); - ExitApp.exitApp(); + commCoreModule.terminate(); } } }, [callClearSensitiveData, currentLoggedInUserID]); @@ -124,7 +123,7 @@ throw e; } else { console.log(e); - ExitApp.exitApp(); + commCoreModule.terminate(); } } await callFetchNewCookieFromNativeCredentials( diff --git a/native/ios/Podfile.lock b/native/ios/Podfile.lock --- a/native/ios/Podfile.lock +++ b/native/ios/Podfile.lock @@ -486,8 +486,6 @@ - React-Core - RNDeviceInfo (10.3.0): - React-Core - - RNExitApp (1.1.0): - - React - RNFastImage (8.3.0): - React - SDWebImage (~> 5.8) @@ -623,7 +621,6 @@ - "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)" - "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)" - RNDeviceInfo (from `../node_modules/react-native-device-info`) - - RNExitApp (from `../node_modules/react-native-exit-app`) - RNFastImage (from `../node_modules/react-native-fast-image`) - RNFS (from `../node_modules/react-native-fs`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) @@ -794,8 +791,6 @@ :path: "../node_modules/@react-native-masked-view/masked-view" RNDeviceInfo: :path: "../node_modules/react-native-device-info" - RNExitApp: - :path: "../node_modules/react-native-exit-app" RNFastImage: :path: "../node_modules/react-native-fast-image" RNFS: @@ -896,7 +891,6 @@ RNCClipboard: f66930407a30948ffdecf43a2459bcf05aa59804 RNCMaskedView: bc0170f389056201c82a55e242e5d90070e18e5a RNDeviceInfo: 4701f0bf2a06b34654745053db0ce4cb0c53ada7 - RNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3 RNFastImage: 2ed80661d5ef384fb1b539f1f3c81a1733f92bc9 RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 RNGestureHandler: 62232ba8f562f7dea5ba1b3383494eb5bf97a4d3 diff --git a/native/package.json b/native/package.json --- a/native/package.json +++ b/native/package.json @@ -90,7 +90,6 @@ "react-native-background-upload": "^6.6.0", "react-native-camera": "^3.31.0", "react-native-device-info": "^10.3.0", - "react-native-exit-app": "^1.1.0", "react-native-fast-image": "^8.3.0", "react-native-ffmpeg": "^0.4.4", "react-native-figma-squircle": "^0.1.2", diff --git a/native/profile/dev-tools.react.js b/native/profile/dev-tools.react.js --- a/native/profile/dev-tools.react.js +++ b/native/profile/dev-tools.react.js @@ -2,7 +2,6 @@ import * as React from 'react'; import { View, Text, Platform } from 'react-native'; -import ExitApp from 'react-native-exit-app'; import { ScrollView } from 'react-native-gesture-handler'; import { useDispatch } from 'react-redux'; @@ -12,6 +11,7 @@ import type { ProfileNavigationProp } from './profile.react.js'; import Button from '../components/button.react.js'; import SWMansionIcon from '../components/swmansion-icon.react.js'; +import { commCoreModule } from '../native-modules.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { CustomServerModalRouteName } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; @@ -151,7 +151,7 @@ }; onPressKill = () => { - ExitApp.exitApp(); + commCoreModule.terminate(); }; onPressWipe = async () => { diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -1,7 +1,6 @@ // @flow import { AppState as NativeAppState, Platform, Alert } from 'react-native'; -import ExitApp from 'react-native-exit-app'; import Orientation from 'react-native-orientation-locker'; import { createStore, applyMiddleware, type Store, compose } from 'redux'; import { persistStore, persistReducer } from 'redux-persist'; @@ -410,7 +409,7 @@ if (isTaskCancelledError(e)) { return; } - ExitApp.exitApp(); + commCoreModule.terminate(); } })(); diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js --- a/native/schema/CommCoreModuleSchema.js +++ b/native/schema/CommCoreModuleSchema.js @@ -56,6 +56,7 @@ +getUserPublicKey: () => Promise; +getUserOneTimeKeys: () => Promise; +getCodeVersion: () => number; + +terminate: () => void; +setNotifyToken: (token: string) => Promise; +clearNotifyToken: () => Promise; +setCurrentUserID: (userID: string) => Promise; diff --git a/native/utils/crash-utils.js b/native/utils/crash-utils.js --- a/native/utils/crash-utils.js +++ b/native/utils/crash-utils.js @@ -1,10 +1,10 @@ // @flow import AsyncStorage from '@react-native-async-storage/async-storage'; -import ExitApp from 'react-native-exit-app'; import sleep from 'lib/utils/sleep.js'; +import { commCoreModule } from '../native-modules.js'; import { navStateAsyncStorageKey } from '../navigation/persistance.js'; import { getPersistor } from '../redux/persist.js'; @@ -14,7 +14,7 @@ __DEV__ ? AsyncStorage.removeItem(navStateAsyncStorageKey) : null, ]); await sleep(50); - ExitApp.exitApp(); + commCoreModule.terminate(); } export { wipeAndExit }; diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -19452,11 +19452,6 @@ resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-10.3.0.tgz#6bab64d84d3415dd00cc446c73ec5e2e61fddbe7" integrity sha512-/ziZN1sA1REbJTv5mQZ4tXggcTvSbct+u5kCaze8BmN//lbxcTvWsU6NQd4IihLt89VkbX+14IGc9sVApSxd/w== -react-native-exit-app@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/react-native-exit-app/-/react-native-exit-app-1.1.0.tgz#5ec082152974240e2d6a93f1608efb49a4385f21" - integrity sha512-Spne19zfMfJvnUTX909EHUqWMk69rATtLJq9XMBGpNSHhx0M7v5yetx2Z87egBhLOqQm+CWfD/oxWzDG8rbIQA== - react-native-fast-image@^8.3.0: version "8.3.0" resolved "https://registry.yarnpkg.com/react-native-fast-image/-/react-native-fast-image-8.3.0.tgz#5821fac5e8759b3a87628600522eb72c579b0b9f"