From d8af5017289ccb24b6c280f86b0c3da65def16c2 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Sat, 18 Apr 2026 11:21:20 +0200 Subject: [PATCH] Remove dependency on @react-native-async-storage/async-storage --- ios/Podfile.lock | 32 -------------------- licenses.json | 6 ---- package.json | 1 - src/App.tsx | 22 ++++++-------- src/components/StorageMigrator.tsx | 45 ---------------------------- src/storage.ts | 47 ------------------------------ yarn.lock | 28 ------------------ 7 files changed, 9 insertions(+), 172 deletions(-) delete mode 100644 src/components/StorageMigrator.tsx delete mode 100644 src/storage.ts diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d0a5899d..7ddc812d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2489,34 +2489,6 @@ PODS: - React-perflogger (= 0.81.4) - React-utils (= 0.81.4) - SocketRocket - - RNCAsyncStorage (2.2.0): - - boost - - DoubleConversion - - fast_float - - fmt - - glog - - hermes-engine - - RCT-Folly - - RCT-Folly/Fabric - - RCTRequired - - RCTTypeSafety - - React-Core - - React-debug - - React-Fabric - - React-featureflags - - React-graphics - - React-ImageManager - - React-jsi - - React-NativeModulesApple - - React-RCTFabric - - React-renderercss - - React-rendererdebug - - React-utils - - ReactCodegen - - ReactCommon/turbomodule/bridging - - ReactCommon/turbomodule/core - - SocketRocket - - Yoga - RNCClipboard (1.16.3): - boost - DoubleConversion @@ -3026,7 +2998,6 @@ DEPENDENCIES: - ReactAppDependencyProvider (from `build/generated/ios`) - ReactCodegen (from `build/generated/ios`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" - "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)" - "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)" - RNFastImage (from `../node_modules/react-native-fast-image`) @@ -3215,8 +3186,6 @@ EXTERNAL SOURCES: :path: build/generated/ios ReactCommon: :path: "../node_modules/react-native/ReactCommon" - RNCAsyncStorage: - :path: "../node_modules/@react-native-async-storage/async-storage" RNCClipboard: :path: "../node_modules/@react-native-clipboard/clipboard" RNCMaskedView: @@ -3325,7 +3294,6 @@ SPEC CHECKSUMS: ReactAppDependencyProvider: 433ddfb4536948630aadd5bd925aff8a632d2fe3 ReactCodegen: 1d05923ad119796be9db37830d5e5dc76586aa00 ReactCommon: 394c6b92765cf6d211c2c3f7f6bc601dffb316a6 - RNCAsyncStorage: 29f0230e1a25f36c20b05f65e2eb8958d6526e82 RNCClipboard: 4b58c780f63676367640f23c8e114e9bd0cf86ac RNCMaskedView: 5ef8c95cbab95334a32763b72896a7b7d07e6299 RNFastImage: 462a183c4b0b6b26fdfd639e1ed6ba37536c3b87 diff --git a/licenses.json b/licenses.json index 601a973b..f0b49cdc 100644 --- a/licenses.json +++ b/licenses.json @@ -17,12 +17,6 @@ "licenseUrl": "https://github.com/pchmn/expo-material3-theme/raw/master/LICENSE", "parents": "opendtu-react-native" }, - "@react-native-async-storage/async-storage@2.2.0": { - "licenses": "MIT", - "repository": "https://github.com/react-native-async-storage/async-storage", - "licenseUrl": "https://github.com/react-native-async-storage/async-storage/raw/master/LICENSE", - "parents": "opendtu-react-native" - }, "@react-native-clipboard/clipboard@1.16.3": { "licenses": "MIT", "repository": "https://github.com/react-native-clipboard/clipboard", diff --git a/package.json b/package.json index 44be4fda..7f512b80 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "@octokit/rest": "^22.0.1", "@os-team/i18next-react-native-language-detector": "^1.1.6", "@pchmn/expo-material3-theme": "^1.4.0", - "@react-native-async-storage/async-storage": "^2.0.0", "@react-native-clipboard/clipboard": "^1.16.0", "@react-native-community/netinfo": "^11.3.3", "@react-native-masked-view/masked-view": "^0.3.2", diff --git a/src/App.tsx b/src/App.tsx index bc82126b..683bb240 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,8 +4,6 @@ import { Provider as ReduxProvider } from 'react-redux'; import { PersistGate as ReduxPersistGate } from 'redux-persist/integration/react'; -import StorageMigrator from '@/components/StorageMigrator'; - import ApiProvider from '@/api/ApiHandler'; import DatabaseProvider from '@/database'; import GithubProvider from '@/github'; @@ -28,17 +26,15 @@ const App = () => { loading={null} // onBeforeLift={onBeforeLift} > - - - - - - - - - - - + + + + + + + + + diff --git a/src/components/StorageMigrator.tsx b/src/components/StorageMigrator.tsx deleted file mode 100644 index 6648f0c3..00000000 --- a/src/components/StorageMigrator.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import type { FC, PropsWithChildren } from 'react'; -import { useEffect, useState } from 'react'; -import { ActivityIndicator } from 'react-native-paper'; - -import { InteractionManager, View } from 'react-native'; - -import { rootLogging } from '@/utils/log'; - -import { - hasMigratedFromAsyncStorage, - migrateFromAsyncStorage, -} from '@/storage'; - -const log = rootLogging.extend('StorageMigrator'); - -const StorageMigrator: FC = ({ children }) => { - const [hasMigrated, setHasMigrated] = useState(hasMigratedFromAsyncStorage); - - useEffect(() => { - if (!hasMigratedFromAsyncStorage) { - InteractionManager.runAfterInteractions(async () => { - try { - await migrateFromAsyncStorage(); - setHasMigrated(true); - } catch (error) { - // TODO: fall back to AsyncStorage? Wipe storage clean and use MMKV? Crash app? - log.error('Failed to migrate storage:', error); - } - }); - } - }, []); - - if (!hasMigrated) { - // show loading indicator while app is migrating storage... - return ( - - - - ); - } - - return <>{children}; -}; - -export default StorageMigrator; diff --git a/src/storage.ts b/src/storage.ts deleted file mode 100644 index 19708c71..00000000 --- a/src/storage.ts +++ /dev/null @@ -1,47 +0,0 @@ -// https://github.com/mrousavy/react-native-mmkv/blob/main/docs/MIGRATE_FROM_ASYNC_STORAGE.md - -import { MMKV } from 'react-native-mmkv'; - -import AsyncStorage from '@react-native-async-storage/async-storage'; - -export const storage = new MMKV(); - -// TODO: Remove `hasMigratedFromAsyncStorage` after a while (when everyone has migrated) -export const hasMigratedFromAsyncStorage = storage.getBoolean( - 'hasMigratedFromAsyncStorage', -); - -// TODO: Remove `hasMigratedFromAsyncStorage` after a while (when everyone has migrated) -export async function migrateFromAsyncStorage(): Promise { - console.log('Migrating from AsyncStorage -> MMKV...'); - const start = global.performance.now(); - - const keys = await AsyncStorage.getAllKeys(); - - for (const key of keys) { - try { - const value = await AsyncStorage.getItem(key); - - if (value != null) { - if (['true', 'false'].includes(value)) { - storage.set(key, value === 'true'); - } else { - storage.set(key, value); - } - - AsyncStorage.removeItem(key); - } - } catch (error) { - console.error( - `Failed to migrate key "${key}" from AsyncStorage to MMKV!`, - error, - ); - throw error; - } - } - - storage.set('hasMigratedFromAsyncStorage', true); - - const end = global.performance.now(); - console.log(`Migrated from AsyncStorage -> MMKV in ${end - start}ms!`); -} diff --git a/yarn.lock b/yarn.lock index b7bf3d39..cd8586c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3959,17 +3959,6 @@ __metadata: languageName: node linkType: hard -"@react-native-async-storage/async-storage@npm:^2.0.0": - version: 2.2.0 - resolution: "@react-native-async-storage/async-storage@npm:2.2.0" - dependencies: - merge-options: "npm:^3.0.4" - peerDependencies: - react-native: ^0.0.0-0 || >=0.65 <1.0 - checksum: 10/625e42134f0c487acfd4ba9b3ba182e6f6f29581485004cc658850ef024372cdb7381b7399393f4416fda39df2d822e3008427d7671d635a7363f9a65430a2dd - languageName: node - linkType: hard - "@react-native-clipboard/clipboard@npm:^1.16.0": version: 1.16.3 resolution: "@react-native-clipboard/clipboard@npm:1.16.3" @@ -10240,13 +10229,6 @@ __metadata: languageName: node linkType: hard -"is-plain-obj@npm:^2.1.0": - version: 2.1.0 - resolution: "is-plain-obj@npm:2.1.0" - checksum: 10/cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa - languageName: node - linkType: hard - "is-plain-object@npm:^2.0.4": version: 2.0.4 resolution: "is-plain-object@npm:2.0.4" @@ -11369,15 +11351,6 @@ __metadata: languageName: node linkType: hard -"merge-options@npm:^3.0.4": - version: 3.0.4 - resolution: "merge-options@npm:3.0.4" - dependencies: - is-plain-obj: "npm:^2.1.0" - checksum: 10/d86ddb3dd6e85d558dbf25dc944f3527b6bacb944db3fdda6e84a3f59c4e4b85231095f58b835758b9a57708342dee0f8de0dffa352974a48221487fe9f4584f - languageName: node - linkType: hard - "merge-stream@npm:^2.0.0": version: 2.0.0 resolution: "merge-stream@npm:2.0.0" @@ -12892,7 +12865,6 @@ __metadata: "@octokit/webhooks-types": "npm:^7.6.1" "@os-team/i18next-react-native-language-detector": "npm:^1.1.6" "@pchmn/expo-material3-theme": "npm:^1.4.0" - "@react-native-async-storage/async-storage": "npm:^2.0.0" "@react-native-clipboard/clipboard": "npm:^1.16.0" "@react-native-community/cli": "npm:20.0.0" "@react-native-community/cli-platform-android": "npm:20.0.0"