From d6d0cc0d0301182f55bbce801f931fde11dfcfd6 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sat, 7 Jan 2023 23:37:30 +0100 Subject: [PATCH] Fix Android crashing Somehow get MMKV number would crash --- android/app/build.gradle | 1 + android/app/src/main/AndroidManifest.xml | 3 +- android/build.gradle | 2 +- android/gradle.properties | 2 +- package.json | 7 +-- src/utils/storage/actions.ts | 20 +++++++-- yarn.lock | 55 ++++++++++++++---------- 7 files changed, 58 insertions(+), 32 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9826e70f..947ce178 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -231,6 +231,7 @@ android { proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } + namespace 'com.xmflsct.app.tooot' // applicationVariants are e.g. debug, release applicationVariants.all { variant -> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 85aa5430..545f156f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools" + package="com.xmflsct.app.tooot"> diff --git a/android/build.gradle b/android/build.gradle index e90d3c65..02553cd8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,7 +22,7 @@ buildscript { jcenter() } dependencies { - classpath("com.android.tools.build:gradle:7.2.1") + classpath('com.android.tools.build:gradle:7.3.1') classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:5.0.1") diff --git a/android/gradle.properties b/android/gradle.properties index 2f0b0ba8..717237a0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -26,7 +26,7 @@ android.useAndroidX=true android.enableJetifier=true # Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.125.0 +FLIPPER_VERSION=0.176.1 # Use this property to specify which architecture you want to build. # You can also override it from the CLI using diff --git a/package.json b/package.json index 7dea8757..3c1a4309 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@mattermost/react-native-paste-input": "^0.5.2", "@neverdull-agency/expo-unlimited-secure-store": "^1.0.10", "@react-native-async-storage/async-storage": "~1.17.11", - "@react-native-camera-roll/camera-roll": "^5.2.0", + "@react-native-camera-roll/camera-roll": "^5.2.1", "@react-native-clipboard/clipboard": "^1.11.1", "@react-native-community/blur": "^4.3.0", "@react-native-community/netinfo": "9.3.7", @@ -42,7 +42,7 @@ "@tanstack/react-query": "^4.20.9", "axios": "^1.2.2", "diff": "^5.1.0", - "expo": "^47.0.11", + "expo": "^47.0.12", "expo-auth-session": "^3.8.0", "expo-av": "^13.1.0", "expo-constants": "^14.1.0", @@ -65,7 +65,7 @@ "lodash": "^4.17.21", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-i18next": "^12.1.1", + "react-i18next": "^12.1.4", "react-intl": "^6.2.5", "react-native": "^0.70.6", "react-native-animated-spinkit": "^1.5.2", @@ -73,6 +73,7 @@ "react-native-fast-image": "^8.6.3", "react-native-feather": "^1.1.2", "react-native-flash-message": "^0.4.0", + "react-native-flipper": "^0.176.1", "react-native-gesture-handler": "~2.8.0", "react-native-image-picker": "^4.10.3", "react-native-ios-context-menu": "^1.15.1", diff --git a/src/utils/storage/actions.ts b/src/utils/storage/actions.ts index 2fdec586..88c234e3 100644 --- a/src/utils/storage/actions.ts +++ b/src/utils/storage/actions.ts @@ -1,5 +1,6 @@ import { queryClient } from '@utils/queryHooks' import { storage } from '@utils/storage' +import { Platform } from 'react-native' import { MMKV, useMMKVBoolean, @@ -40,10 +41,21 @@ export const useGlobalStorage = { useMMKVString(key, storage.global) as NonNullable extends string ? [StorageGlobal[T], (valud: StorageGlobal[T]) => void] : never, - number: (key: T) => - useMMKVNumber(key, storage.global) as NonNullable extends number - ? [StorageGlobal[T], (valud: StorageGlobal[T]) => void] - : never, + number: (key: T) => { + if (Platform.OS === 'ios') { + return useMMKVString(key, storage.global) as NonNullable extends number + ? [StorageGlobal[T], (valud: StorageGlobal[T]) => void] + : never + } else { + const [num, setNum] = useMMKVString(key, storage.global) + // @ts-ignore + return [parseInt(num), v => setNum(v.toString())] as NonNullable< + StorageGlobal[T] + > extends number + ? [StorageGlobal[T], (valud: StorageGlobal[T]) => void] + : never + } + }, boolean: (key: T) => useMMKVBoolean(key, storage.global) as NonNullable extends boolean ? [StorageGlobal[T], (valud: StorageGlobal[T]) => void] diff --git a/yarn.lock b/yarn.lock index 4925bcac..e667382c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1476,7 +1476,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.0, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.20.6, @babel/runtime@npm:^7.8.4": +"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.0, @babel/runtime@npm:^7.20.6, @babel/runtime@npm:^7.8.4": version: 7.20.7 resolution: "@babel/runtime@npm:7.20.7" dependencies: @@ -2744,12 +2744,12 @@ __metadata: languageName: node linkType: hard -"@react-native-camera-roll/camera-roll@npm:^5.2.0": - version: 5.2.0 - resolution: "@react-native-camera-roll/camera-roll@npm:5.2.0" +"@react-native-camera-roll/camera-roll@npm:^5.2.1": + version: 5.2.1 + resolution: "@react-native-camera-roll/camera-roll@npm:5.2.1" peerDependencies: react-native: ">=0.59" - checksum: 27800224bdbd128800e6a64046d76865814a43215ad3a0df9a93eeac64b523e3b68382d7cabb79b574e354d03dddc625b93fa2b6010ed04f6a89296038e3eabf + checksum: db901554170cced81db4b01c0e89324905fe4c6915a41e4cf4b6d1fa35f5894d18d1d734304d516824bff434784e4b571e9fa379e850f8dd4d42a28e3eab9eee languageName: node linkType: hard @@ -5692,13 +5692,13 @@ __metadata: languageName: node linkType: hard -"expo-modules-core@npm:1.1.0": - version: 1.1.0 - resolution: "expo-modules-core@npm:1.1.0" +"expo-modules-core@npm:1.1.1": + version: 1.1.1 + resolution: "expo-modules-core@npm:1.1.1" dependencies: compare-versions: ^3.4.0 invariant: ^2.2.4 - checksum: f5add659b2f43c2784dce86986ec709feac38a60881afd013049ef86b106eeba9217427d01b9da27e00b678e9f47518ffa5d7676f95408c6e3966093d48252e8 + checksum: 6a2b6b5d1f56f197ddf8b3f3a638d8f15534657218bdf895bd96c07cb34fc8404761d6a9206527fa5b67baade60858b4530de147fe1f3b7db8205c5d9d059b31 languageName: node linkType: hard @@ -5791,9 +5791,9 @@ __metadata: languageName: node linkType: hard -"expo@npm:^47.0.11": - version: 47.0.11 - resolution: "expo@npm:47.0.11" +"expo@npm:^47.0.12": + version: 47.0.12 + resolution: "expo@npm:47.0.12" dependencies: "@babel/runtime": ^7.14.0 "@expo/cli": 0.4.11 @@ -5810,7 +5810,7 @@ __metadata: expo-font: ~11.0.1 expo-keep-awake: ~11.0.1 expo-modules-autolinking: 1.0.1 - expo-modules-core: 1.1.0 + expo-modules-core: 1.1.1 fbemitter: ^3.0.0 getenv: ^1.0.0 invariant: ^2.2.4 @@ -5823,7 +5823,7 @@ __metadata: optional: true bin: expo: bin/cli.js - checksum: 5e470d7b0c94ddade3f77e4e5038f025635f432f1e56a9e541455f5e71b5f4919c7c756639b5bf31ff6b877ad254a77290efe0305d48712e5406c76f3c8b7e77 + checksum: 24f7073660fb4c4c76a398d722d1fcae1ea654463faf2a730e986f884618a93618d1ee9116fe6c8199338c2e8aa716c2d389344a967824d264e2440eb7f16340 languageName: node linkType: hard @@ -9416,11 +9416,11 @@ __metadata: languageName: node linkType: hard -"react-i18next@npm:^12.1.1": - version: 12.1.1 - resolution: "react-i18next@npm:12.1.1" +"react-i18next@npm:^12.1.4": + version: 12.1.4 + resolution: "react-i18next@npm:12.1.4" dependencies: - "@babel/runtime": ^7.14.5 + "@babel/runtime": ^7.20.6 html-parse-stringify: ^3.0.1 peerDependencies: i18next: ">= 19.0.0" @@ -9430,7 +9430,7 @@ __metadata: optional: true react-native: optional: true - checksum: baeb1957d70281d1a95ef0b94801bc2e6bf17066a49a45f32cd1a706ead3ddce2ab3e7b321e07c43f082efa9987c2d55856a5bdf419d9ad628dbfa9ec87af8ea + checksum: 6f0f8a47f0bf7da2c9ac383c88b6ef02446d9d1aa2609cfcc98d8a28999da85361f065fbe7f7f4af910df4e8d53af7879db4b9cd681274d582fc7bdd1b07813b languageName: node linkType: hard @@ -9564,6 +9564,16 @@ __metadata: languageName: node linkType: hard +"react-native-flipper@npm:^0.176.1": + version: 0.176.1 + resolution: "react-native-flipper@npm:0.176.1" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-native: ">0.62.0" + checksum: f8ba597190baaed791a73d474ab8c2410048025f6bf8b1e49b5b64b71f08453d50fa118113a4c37e5fd8bb1c7700f8afe84671afeab6ad912a5f0c4da41a35be + languageName: node + linkType: hard + "react-native-gesture-handler@npm:~2.8.0": version: 2.8.0 resolution: "react-native-gesture-handler@npm:2.8.0" @@ -11254,7 +11264,7 @@ __metadata: "@mattermost/react-native-paste-input": ^0.5.2 "@neverdull-agency/expo-unlimited-secure-store": ^1.0.10 "@react-native-async-storage/async-storage": ~1.17.11 - "@react-native-camera-roll/camera-roll": ^5.2.0 + "@react-native-camera-roll/camera-roll": ^5.2.1 "@react-native-clipboard/clipboard": ^1.11.1 "@react-native-community/blur": ^4.3.0 "@react-native-community/netinfo": 9.3.7 @@ -11281,7 +11291,7 @@ __metadata: chalk: ^4.1.2 diff: ^5.1.0 dotenv: ^16.0.3 - expo: ^47.0.11 + expo: ^47.0.12 expo-auth-session: ^3.8.0 expo-av: ^13.1.0 expo-constants: ^14.1.0 @@ -11304,7 +11314,7 @@ __metadata: lodash: ^4.17.21 react: ^18.2.0 react-dom: ^18.2.0 - react-i18next: ^12.1.1 + react-i18next: ^12.1.4 react-intl: ^6.2.5 react-native: ^0.70.6 react-native-animated-spinkit: ^1.5.2 @@ -11313,6 +11323,7 @@ __metadata: react-native-fast-image: ^8.6.3 react-native-feather: ^1.1.2 react-native-flash-message: ^0.4.0 + react-native-flipper: ^0.176.1 react-native-gesture-handler: ~2.8.0 react-native-image-picker: ^4.10.3 react-native-ios-context-menu: ^1.15.1