Skip to content

Commit

Permalink
fix: startup crash, language text lengths, offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Oct 28, 2022
1 parent e5d153b commit 34fb9cf
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 120 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ android {
applicationId "io.filen.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 220
versionName "2.0.20"
versionCode 221
versionName "2.0.21"
}
splits {
abi {
Expand Down Expand Up @@ -256,4 +256,4 @@ task copyDownloadableDepsToLibs(type: Copy) {
apply from: "../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"
applyNativeModulesAppBuildGradle(project)

//apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.gms.google-services'
6 changes: 4 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ allprojects {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))
// url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))
url("../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../dist"))
// url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../dist"))
url("../../node_modules/jsc-android/dist")
}

google()
Expand Down
8 changes: 4 additions & 4 deletions ios/Filen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Filen/Filen.entitlements;
CURRENT_PROJECT_VERSION = 220;
CURRENT_PROJECT_VERSION = 221;
DEVELOPMENT_TEAM = 7YTW5D2K7P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Filen/Info.plist;
Expand All @@ -738,7 +738,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.20;
MARKETING_VERSION = 2.0.21;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -763,15 +763,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Filen/Filen.entitlements;
CURRENT_PROJECT_VERSION = 220;
CURRENT_PROJECT_VERSION = 221;
DEVELOPMENT_TEAM = 7YTW5D2K7P;
INFOPLIST_FILE = Filen/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.20;
MARKETING_VERSION = 2.0.21;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
6 changes: 0 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ PODS:
- React-perflogger (= 0.67.1)
- ReactNativeART (1.2.0):
- React
- ReactNativeExceptionHandler (2.10.10):
- React-Core
- RNCMaskedView (0.1.11):
- React
- RNCPicker (2.2.1):
Expand Down Expand Up @@ -578,7 +576,6 @@ DEPENDENCIES:
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "ReactNativeART (from `../node_modules/@react-native-community/art`)"
- ReactNativeExceptionHandler (from `../node_modules/react-native-exception-handler`)
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
Expand Down Expand Up @@ -742,8 +739,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
ReactNativeART:
:path: "../node_modules/@react-native-community/art"
ReactNativeExceptionHandler:
:path: "../node_modules/react-native-exception-handler"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNCPicker:
Expand Down Expand Up @@ -855,7 +850,6 @@ SPEC CHECKSUMS:
React-runtimeexecutor: 2c92a8bddd1a3e72c7513d1e74235c2d9c84875c
ReactCommon: 2e816fad39f65f2a94a5999d5be463a6b620dcf6
ReactNativeART: 78edc68dd4a1e675338cd0cd113319cf3a65f2ab
ReactNativeExceptionHandler: b11ff67c78802b2f62eed0e10e75cb1ef7947c60
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
RNCPicker: cb57c823d5ce8d2d0b5dfb45ad97b737260dc59e
RNDeviceInfo: 4944cf8787b9c5bffaf301fda68cc1a2ec003341
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "filen-mobile",
"version": "2.0.20",
"version": "2.0.21",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"dist-android": "cd ./android && ./gradlew bundleRelease && ./gradlew assembleRelease && cd ..",
"clear-cache": "watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-*",
"dist-android": "watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && cd ./android && ./gradlew clean && ./gradlew bundleRelease && ./gradlew assembleRelease && cd ..",
"splash": "react-native generate-bootsplash bootsplash.png --background-color=#263179 --logo-width=100 --flavor=main --assets-path=src/assets",
"icons": "react-native-svg-app-icon",
"install-release-apk": "adb install android/app/build/outputs/apk/release/app-release.apk"
Expand Down Expand Up @@ -50,7 +51,6 @@
"react-native-device-info": "^8.4.9",
"react-native-dialog": "^9.2.1",
"react-native-document-picker": "^8.1.1",
"react-native-exception-handler": "^2.10.10",
"react-native-fast-image": "^8.5.11",
"react-native-file-viewer": "^2.1.5",
"react-native-fs": "^2.19.0",
Expand Down
131 changes: 68 additions & 63 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,87 +245,92 @@ export const App = Sentry.wrap(memo(() => {
})

const offlineSetup = () => {
if(
typeof storage.getString("masterKeys") == "string"
&& typeof storage.getString("apiKey") == "string"
&& typeof storage.getString("privateKey") == "string"
&& typeof storage.getString("publicKey") == "string"
&& typeof storage.getNumber("userId") == "number"
){
// @ts-ignore
if(storage.getString("masterKeys").length > 16 && storage.getString("apiKey").length > 16 && storage.getString("privateKey").length > 16 && storage.getString("publicKey").length > 16 && storage.getNumber("userId") !== 0){
setSetupDone(true)

if(
storage.getBoolean("biometricPinAuth:" + userId)
&& Math.floor(+new Date()) > storage.getNumber("biometricPinAuthTimeout:" + userId)
&& !isRouteInStack(navigationRef, ["BiometricAuthScreen"])
){
setBiometricAuthScreenState("auth")

navigationRef.current?.dispatch(StackActions.push("BiometricAuthScreen"))
try{
if(
typeof storage.getString("masterKeys") == "string"
&& typeof storage.getString("apiKey") == "string"
&& typeof storage.getString("privateKey") == "string"
&& typeof storage.getString("publicKey") == "string"
&& typeof storage.getNumber("userId") == "number"
){
// @ts-ignore
if(storage.getString("masterKeys").length > 16 && storage.getString("apiKey").length > 16 && storage.getString("privateKey").length > 16 && storage.getString("publicKey").length > 16 && storage.getNumber("userId") !== 0){
setSetupDone(true)

if(
storage.getBoolean("biometricPinAuth:" + userId)
&& Math.floor(+new Date()) > storage.getNumber("biometricPinAuthTimeout:" + userId)
&& !isRouteInStack(navigationRef, ["BiometricAuthScreen"])
){
setBiometricAuthScreenState("auth")

navigationRef.current?.dispatch(StackActions.push("BiometricAuthScreen"))
}
else{
navigationRef.current?.dispatch(CommonActions.reset({
index: 0,
routes: [
{
name: "MainScreen",
params: {
parent: startOnCloudScreen ? (storage.getBoolean("defaultDriveOnly:" + userId) ? storage.getString("defaultDriveUUID:" + userId) : "base") : "recents"
}
}
]
}))
}
}
else{
navigationRef.current?.dispatch(CommonActions.reset({
index: 0,
routes: [
{
name: "MainScreen",
params: {
parent: startOnCloudScreen ? (storage.getBoolean("defaultDriveOnly:" + userId) ? storage.getString("defaultDriveUUID:" + userId) : "base") : "recents"
}
}
]
}))
setSetupDone(false)

showToast({ message: i18n(lang, "appSetupNotPossible") })
}
}
else{
setSetupDone(false)

showToast({ message: i18n(lang, "appSetupNotPossible") })
}
}
else{
setSetupDone(false)
catch(e){
console.error(e)

setSetupDone(false)

showToast({ message: i18n(lang, "appSetupNotPossible") })
}
}

if(isLoggedIn && !setupDone){
NetInfo.fetch().then((state) => {
if(!state.isConnected){
return setTimeout(() => offlineSetup(), 2500)
if(isLoggedIn && !setupDone && navigationRef && navigationRef.current){
setup({ navigation: navigationRef }).then(() => {
setSetupDone(true)

if(
storage.getBoolean("biometricPinAuth:" + userId)
&& Math.floor(+new Date()) > storage.getNumber("biometricPinAuthTimeout:" + userId)
&& !isRouteInStack(navigationRef, ["BiometricAuthScreen"])
){
setBiometricAuthScreenState("auth")

navigationRef.current?.dispatch(StackActions.push("BiometricAuthScreen"))
}

setup({ navigation: navigationRef }).then(() => {
setSetupDone(true)

if(storage.getBoolean("biometricPinAuth:" + userId) && Math.floor(+new Date()) > storage.getNumber("biometricPinAuthTimeout:" + userId) && !isRouteInStack(navigationRef, ["BiometricAuthScreen"])){
setBiometricAuthScreenState("auth")

navigationRef.current?.dispatch(StackActions.push("BiometricAuthScreen"))
}
else{
navigationRef.current?.dispatch(CommonActions.reset({
index: 0,
routes: [
{
name: "MainScreen",
params: {
parent: startOnCloudScreen ? (storage.getBoolean("defaultDriveOnly:" + userId) ? storage.getString("defaultDriveUUID:" + userId) : "base") : "recents"
}
else{
navigationRef.current?.dispatch(CommonActions.reset({
index: 0,
routes: [
{
name: "MainScreen",
params: {
parent: startOnCloudScreen ? (storage.getBoolean("defaultDriveOnly:" + userId) ? storage.getString("defaultDriveUUID:" + userId) : "base") : "recents"
}
]
}))
}
}).catch((err) => {
console.log(err)

offlineSetup()
})
}
]
}))
}
}).catch((err) => {
console.log(err)

offlineSetup()
})
}

Expand Down
21 changes: 17 additions & 4 deletions src/components/BottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const BottomBar = memo(({ navigation }: BottomBarProps) => {
const [userId, setUserId] = useMMKVNumber("userId", storage)
const [defaultDriveOnly, setDefaultDriveOnly] = useMMKVBoolean("defaultDriveOnly:" + userId, storage)
const [defaultDriveUUID, setDefaultDriveUUID] = useMMKVString("defaultDriveUUID:" + userId, storage)
const dimensions = useStore(state => state.dimensions)

const iconTextMaxWidth: number = useMemo(() => {
return (dimensions.window.width / 5) - 25
}, [dimensions])

const [showHome, showCloud, canOpenBottomAddActionSheet, isPhotosScreen, showSettings] = useMemo(() => {
const parent: string = getParent()
Expand Down Expand Up @@ -146,8 +151,10 @@ export const BottomBar = memo(({ navigation }: BottomBarProps) => {
style={{
color: showHome ? "#0A84FF" : (darkMode ? "gray" : "gray"),
fontSize: 10,
marginTop: 3
marginTop: 3,
maxWidth: iconTextMaxWidth
}}
numberOfLines={1}
>
{i18n(lang, "home")}
</Text>
Expand Down Expand Up @@ -182,8 +189,10 @@ export const BottomBar = memo(({ navigation }: BottomBarProps) => {
style={{
color: showCloud ? "#0A84FF" : (darkMode ? "gray" : "gray"),
fontSize: 10,
marginTop: 3
marginTop: 3,
maxWidth: iconTextMaxWidth
}}
numberOfLines={1}
>
{i18n(lang, "cloud")}
</Text>
Expand Down Expand Up @@ -236,8 +245,10 @@ export const BottomBar = memo(({ navigation }: BottomBarProps) => {
style={{
color: isPhotosScreen ? "#0A84FF" : (darkMode ? "gray" : "gray"),
fontSize: 10,
marginTop: 3
marginTop: 3,
maxWidth: iconTextMaxWidth
}}
numberOfLines={1}
>
{i18n(lang, "photos")}
</Text>
Expand Down Expand Up @@ -269,8 +280,10 @@ export const BottomBar = memo(({ navigation }: BottomBarProps) => {
style={{
color: showSettings ? "#0A84FF" : (darkMode ? "gray" : "gray"),
fontSize: 10,
marginTop: 3
marginTop: 3,
maxWidth: iconTextMaxWidth
}}
numberOfLines={1}
>
{i18n(lang, "settings")}
</Text>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Toasts/Toasts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ export const NormalToast = memo(({ message }: { message?: string | undefined })

return (
<View
pointerEvents="box-none" style={{
pointerEvents="box-none"
style={{
zIndex: 99999
}}
>
Expand Down
Loading

0 comments on commit 34fb9cf

Please sign in to comment.