Skip to content

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

do not rerun sync when it is already working

ammarahm-ede2f51ba547e0
diff --git a/apps/mobile/src/services/Sync.js b/apps/mobile/src/services/Sync.js
index b924592a9..b3ca04aeb 100644
--- a/apps/mobile/src/services/Sync.js
+++ b/apps/mobile/src/services/Sync.js
@@ -3,11 +3,19 @@ import {initialize, useUserStore} from '../provider/stores';
import {doInBackground} from '../utils';
import {db} from '../utils/DB';
import {eOpenLoginDialog} from '../utils/Events';
-import { getNote, updateNoteInEditor } from '../views/Editor/Functions';
+import {getNote, updateNoteInEditor} from '../views/Editor/Functions';
import {eSendEvent, ToastEvent} from './EventManager';
const run = async (context = 'global', forced) => {
let userstore = useUserStore.getState();
+ if (userstore.syncing) {
+ ToastEvent.show({
+ heading: 'Sync running already',
+ message:"Please wait a few moments",
+ type: 'success'
+ });
+ return;
+ }
userstore.setSyncing(true);
try {
let res = await doInBackground(async () => {
@@ -25,7 +33,7 @@ const run = async (context = 'global', forced) => {
heading: 'Sync complete',
type: 'success',
message: 'All your notes are encrypted and synced!',
- context: context,
+ context: context
});
} catch (e) {
console.log(e);
@@ -37,7 +45,7 @@ const run = async (context = 'global', forced) => {
func: () => {
eSendEvent(eOpenLoginDialog);
},
- actionText: 'Login',
+ actionText: 'Login'
});
} else {
userstore.setSyncing(false);
@@ -46,7 +54,7 @@ const run = async (context = 'global', forced) => {
ToastEvent.show({
heading: 'Sync failed',
message: e.message,
- context: context,
+ context: context
});
}
}
@@ -61,5 +69,5 @@ const run = async (context = 'global', forced) => {
};
export default {
- run,
+ run
};