fix syncing from note menu

This commit is contained in:
ammarahm-ed
2020-10-31 13:29:36 +05:00
parent a1e7863b32
commit aa814fcec6

View File

@@ -595,20 +595,23 @@ export const ActionSheetComponent = ({
);
return;
}
if (user?.lastSynced < note?.dateEdited) {
if (user?.lastSynced < note?.dateEdited || !user.lastSynced) {
setRefreshing(true);
try {
let user = await db.user.get();
dispatch({type: Actions.USER, user: user});
await db.sync();
localRefresh();
ToastEvent.show('Note synced', 'success', 'local');
} catch (e) {
ToastEvent.show(e.message, 'error', 'local');
} finally {
let user = await db.user.get();
dispatch({type: Actions.USER, user: user});
dispatch({type: Actions.ALL});
setRefreshing(false);
}
dispatch({type: Actions.ALL});
} else {
console.log('here',user?.lastSynced,user?.lastSynced < note?.dateEdited)
}
};