mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
feat: add new version available dialog
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, {useEffect, useRef, useState} from 'react';
|
import React, {useEffect, useRef, useState} from 'react';
|
||||||
import {Appearance, Platform, SafeAreaView, View} from 'react-native';
|
import {Appearance, Linking, Platform, SafeAreaView, View} from 'react-native';
|
||||||
import Animated, {Easing} from 'react-native-reanimated';
|
import Animated, {Easing} from 'react-native-reanimated';
|
||||||
import AnimatedProgress from 'react-native-reanimated-progress-bar';
|
import AnimatedProgress from 'react-native-reanimated-progress-bar';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
ToastEvent
|
ToastEvent
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
import PremiumService from '../../services/PremiumService';
|
import PremiumService from '../../services/PremiumService';
|
||||||
import {editing} from '../../utils';
|
import {editing, STORE_LINK} from '../../utils';
|
||||||
import {COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT} from '../../utils/Colors';
|
import {COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT} from '../../utils/Colors';
|
||||||
import {db} from '../../utils/database';
|
import {db} from '../../utils/database';
|
||||||
import {
|
import {
|
||||||
@@ -40,6 +40,9 @@ import Seperator from '../Seperator';
|
|||||||
import SplashScreen from '../SplashScreen';
|
import SplashScreen from '../SplashScreen';
|
||||||
import Heading from '../Typography/Heading';
|
import Heading from '../Typography/Heading';
|
||||||
import Paragraph from '../Typography/Paragraph';
|
import Paragraph from '../Typography/Paragraph';
|
||||||
|
import {checkVersion} from 'react-native-check-version';
|
||||||
|
import {Placeholder, SvgToPngView} from '../ListPlaceholders';
|
||||||
|
import {Update} from '../Update';
|
||||||
|
|
||||||
let passwordValue = null;
|
let passwordValue = null;
|
||||||
let didVerifyUser = false;
|
let didVerifyUser = false;
|
||||||
@@ -93,6 +96,8 @@ const AppLoader = ({onLoad}) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await checkAppUpdateAvailable()) return;
|
||||||
|
|
||||||
let settingsStore = useSettingStore.getState();
|
let settingsStore = useSettingStore.getState();
|
||||||
if (await Backup.checkBackupRequired(settingsStore.settings.reminder)) {
|
if (await Backup.checkBackupRequired(settingsStore.settings.reminder)) {
|
||||||
await Backup.checkAndRun();
|
await Backup.checkAndRun();
|
||||||
@@ -113,6 +118,23 @@ const AppLoader = ({onLoad}) => {
|
|||||||
}
|
}
|
||||||
}, [_loading]);
|
}, [_loading]);
|
||||||
|
|
||||||
|
const checkAppUpdateAvailable = async () => {
|
||||||
|
try {
|
||||||
|
const version = await checkVersion();
|
||||||
|
if (!version.needsUpdate) return false;
|
||||||
|
|
||||||
|
presentSheet({
|
||||||
|
noIcon: true,
|
||||||
|
noProgess: true,
|
||||||
|
component:(ref) => <Update version={version} fwdRef={ref} />
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const restoreEditorState = async () => {
|
const restoreEditorState = async () => {
|
||||||
let appState = await MMKV.getItem('appState');
|
let appState = await MMKV.getItem('appState');
|
||||||
if (appState) {
|
if (appState) {
|
||||||
@@ -321,9 +343,17 @@ const AppLoader = ({onLoad}) => {
|
|||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
width: 100
|
width: 100
|
||||||
}}>
|
}}>
|
||||||
<AnimatedProgress style={{
|
<AnimatedProgress
|
||||||
backgroundColor:Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK.nav : COLOR_SCHEME_LIGHT.nav
|
style={{
|
||||||
}} fill={colors.accent} current={4} total={4} />
|
backgroundColor:
|
||||||
|
Appearance.getColorScheme() === 'dark'
|
||||||
|
? COLOR_SCHEME_DARK.nav
|
||||||
|
: COLOR_SCHEME_LIGHT.nav
|
||||||
|
}}
|
||||||
|
fill={colors.accent}
|
||||||
|
current={4}
|
||||||
|
total={4}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
|
|||||||
88
apps/mobile/src/components/Update/index.js
Normal file
88
apps/mobile/src/components/Update/index.js
Normal file
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@ import {
|
|||||||
ToastEvent
|
ToastEvent
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
import Navigation from '../../services/Navigation';
|
import Navigation from '../../services/Navigation';
|
||||||
import {InteractionManager} from '../../utils';
|
import {InteractionManager, STORE_LINK} from '../../utils';
|
||||||
import { APP_VERSION } from "../../../version";
|
import { APP_VERSION } from "../../../version";
|
||||||
import {db} from '../../utils/database';
|
import {db} from '../../utils/database';
|
||||||
import {eScrollEvent, eUpdateSearchState} from '../../utils/Events';
|
import {eScrollEvent, eUpdateSearchState} from '../../utils/Events';
|
||||||
@@ -278,11 +278,7 @@ export const Settings = ({navigation}) => {
|
|||||||
}`}
|
}`}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
try {
|
try {
|
||||||
await Linking.openURL(
|
await Linking.openURL(STORE_LINK);
|
||||||
Platform.OS === 'ios'
|
|
||||||
? 'https://bit.ly/notesnook-ios'
|
|
||||||
: 'https://bit.ly/notesnook-and'
|
|
||||||
);
|
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user