Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add version update

ammarahm-ed2a03fb19fb9b
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 7e1bf3b81..ba2b7db3c 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -34,6 +34,7 @@ import PremiumService from './src/services/PremiumService';
import SettingsService from './src/services/SettingsService';
import Sync from './src/services/Sync';
import {
+ APP_VERSION,
editing,
getAppIsIntialized,
getIntentOnAppLoadProcessed,
@@ -326,7 +327,18 @@ const App = () => {
}
});
setIntentOnAppLoadProcessed(true);
- sleep(300).then(() => eSendEvent(eOpenSideMenu));
+ sleep(300).then(() => {
+ eSendEvent(eOpenSideMenu);
+ db.version()
+ .then((ver) => {
+ console.log(ver,'version');
+ if (ver.mobile > APP_VERSION - 1) {
+ eSendEvent('updateDialog', ver);
+ }
+ })
+ .catch(console.log);
+ });
+
//Sentry = require('@sentry/react-native');
// Sentry.init({
// dsn:
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index 69ff1fbdb..39b33997c 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -40,6 +40,7 @@ import RecoveryKeyDialog from '../RecoveryKeyDialog';
import RestoreDialog from '../RestoreDialog';
import ResultDialog from '../ResultDialog';
import SortDialog from '../SortDialog';
+import { UpdateDialog } from '../UpdateDialog';
import { VaultDialog } from '../VaultDialog';
import { TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE } from './Templates';
@@ -363,6 +364,7 @@ export class DialogManager extends Component {
<MoveNoteDialog colors={colors} />
<SortDialog colors={colors} />
<JumpToDialog />
+ <UpdateDialog/>
</>
);
}
diff --git a/apps/mobile/src/components/UpdateDialog/index.js b/apps/mobile/src/components/UpdateDialog/index.js
new file mode 100644
index 000000000..50883d56d
--- /dev/null
+++ b/apps/mobile/src/components/UpdateDialog/index.js
@@ -0,0 +1,122 @@
+import React, {useEffect, useState} from 'react';
+import {Linking} from 'react-native';
+import {Platform} from 'react-native';
+import {View} from 'react-native';
+import {useTracked} from '../../provider';
+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
+import {SIZE} from '../../utils/SizeUtils';
+import {Button} from '../Button';
+import BaseDialog from '../Dialog/base-dialog';
+import DialogContainer from '../Dialog/dialog-container';
+import Seperator from '../Seperator';
+import Heading from '../Typography/Heading';
+import Paragraph from '../Typography/Paragraph';
+
+export const UpdateDialog = () => {
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+ const [visible, setVisible] = useState(false);
+ const [version, setVersion] = useState(null);
+
+ const open = (version) => {
+ setVersion(version);
+ setVisible(true);
+ };
+
+ useEffect(() => {
+ eSubscribeEvent('updateDialog', open);
+
+ return () => {
+ eUnSubscribeEvent('updateDialog', open);
+ };
+ });
+
+ const format = (ver) => {
+ let parts = ver.toString().split('');
+ return `v${parts[0]}.${parts[1]}.${parts[2]}${
+ parts[3] === '0' ? '' : parts[3]
+ } `;
+ };
+
+ return (
+ visible && (
+ <BaseDialog
+ onRequestClose={() => {
+ setVisible(false);
+ }}
+ visible={true}>
+ <DialogContainer>
+ <View
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ <Heading>New Update Available!</Heading>
+ <Paragraph
+ style={{
+ textAlign: 'center',
+ }}
+ size={SIZE.sm}>
+ We recommend updating to the latest version to enjoy latest
+ features and bug fixes.
+ </Paragraph>
+ </View>
+
+ <View
+ style={{
+ minHeight: 50,
+ borderRadius: 5,
+ alignItems: 'center',
+ marginTop: 10,
+ }}>
+ <View
+ style={{
+ width: '100%',
+ backgroundColor: colors.nav,
+ padding: 10,
+ borderRadius: 5,
+ }}>
+ <Paragraph
+ style={{
+ fontFamily:
+ Platform.OS === 'ios' ? 'Courier New' : 'monospace',
+ fontWeight: 'bold',
+ }}
+ size={SIZE.sm}>
+ Changelog {format(version.mobile)}
+ </Paragraph>
+ <Paragraph
+ style={{
+ fontFamily:
+ Platform.OS === 'ios' ? 'Courier New' : 'monospace',
+ }}
+ size={SIZE.xs}>
+ {version.changelog && version.changelog !== ''
+ ? version.changelog
+ : 'No changelog provided.'}
+ </Paragraph>
+ </View>
+ </View>
+
+ <Seperator />
+ <Button
+ title="Update Now"
+ onPress={async () => {
+ let url_android =
+ 'https://play.google.com/store/apps/details?id=com.streetwriters.notesnook';
+ let url_ios = 'itms-apps://itunes.apple.com/app/id1544027013';
+ setVisible(false);
+ await Linking.openURL(
+ Platform.OS === 'android' ? url_android : url_ios,
+ );
+ }}
+ type="accent"
+ width="100%"
+ fontSize={SIZE.md}
+ height={50}
+ />
+ </DialogContainer>
+ </BaseDialog>
+ )
+ );
+};
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index 10b06a19b..9a54763e3 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -11,6 +11,8 @@ import {SIZE} from './SizeUtils';
import RNTooltips from 'react-native-tooltips';
import {tabBarRef} from './Refs';
+export const APP_VERSION = 1000
+
export async function setSetting(settings, name, value) {
let s = {...settings};
s[name] = value;
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 92c275fd4..5dc4edaf8 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -18,6 +18,8 @@ const Editor = () => {
const [state] = useTracked();
const {colors} = state;
+
+
return (
<>
<TextInput
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index eb914bdd0..a3a237669 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -85,9 +85,6 @@ export const Home = ({route, navigation}) => {
};
const _onPressBottomButton = async (event) => {
- console.log(await Storage.read("token"));
-
- return;
if (!DDS.isLargeTablet()) {
tabBarRef.current?.goToPage(1);
} else {
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 95666c23e..5c55c4992 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -41,6 +41,7 @@ import PremiumService from '../../services/PremiumService';
import SettingsService from '../../services/SettingsService';
import {
AndroidModule,
+ APP_VERSION,
dWidth,
MenuItemsList,
setSetting,
@@ -70,34 +71,20 @@ import {pv, SIZE} from '../../utils/SizeUtils';
import Storage from '../../utils/storage';
import {timeConverter} from '../../utils/TimeUtils';
-const otherItems = [
- {
- name: 'Privacy Policy',
- func: async () => {
- await Linking.openURL('https://www.notesnook.com/privacy.html');
- },
- desc: 'Read our privacy policy',
- },
- {
- name: 'Check for updates',
- func: async () => {
- await Linking.openURL('https://www.notesnook.com/privacy.html');
- },
- desc: 'Check for a newer version of app',
- },
- {
- name: 'About',
- func: async () => {
- await Linking.openURL('https://www.notesnook.com');
- },
- desc: 'You are using the latest version of our app.',
- },
-];
-
let menuRef = createRef();
+
+const format = (ver) => {
+ let parts = ver.toString().split('');
+ return `v${parts[0]}.${parts[1]}.${parts[2]}${
+ parts[3] === '0' ? '' : parts[3]
+ } `;
+};
+
export const Settings = ({navigation}) => {
const [state, dispatch] = useTracked();
const {colors} = state;
+ const [version, setVersion] = useState(null);
+
let pageIsLoaded = false;
const onFocus = useCallback(() => {
@@ -137,6 +124,13 @@ export const Settings = ({navigation}) => {
useEffect(() => {
navigation.addListener('focus', onFocus);
+ db.version()
+ .then((ver) => {
+ console.log(ver);
+ setVersion(ver);
+ })
+ .catch(console.log);
+
return () => {
pageIsLoaded = false;
eSendEvent(eScrollEvent, {name: 'Settings', type: 'back'});
@@ -144,12 +138,46 @@ export const Settings = ({navigation}) => {
};
}, []);
+ const otherItems = [
+ {
+ name: 'Privacy Policy',
+ func: async () => {
+ await Linking.openURL('https://www.notesnook.com/privacy.html');
+ },
+ desc: 'Read our privacy policy',
+ },
+ {
+ name: 'Check for updates',
+ func: async () => {
+ if (version?.mobile === APP_VERSION - 1) {
+ ToastEvent.show('You are using the latest version', 'success');
+ return;
+ }
+ eSendEvent("updateDialog",version)
+ },
+
+ desc:
+ version?.mobile > APP_VERSION
+ ? 'New update available.'
+ : 'You are using the latest version',
+ },
+ {
+ name: 'About',
+ func: async () => {
+ await Linking.openURL('https://www.notesnook.com');
+ },
+ desc: version && format(APP_VERSION),
+ },
+ ];
+
return (
<View
style={{
height: '100%',
backgroundColor: colors.bg,
}}>
+
+
<ScrollView
onScroll={(e) =>
eSendEvent(eScrollEvent, e.nativeEvent.contentOffset.y)
@@ -220,7 +248,7 @@ const AccoutLogoutSection = () => {
const [state, dispatch] = useTracked();
const {colors, user} = state;
const [visible, setVisible] = useState(false);
- const [deleteAccount, setDeleteAccount] = useState(true);
+ const [deleteAccount, setDeleteAccount] = useState(false);
return (
user && (