diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 832040b35..140a890e4 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -7,6 +7,7 @@ import {
TouchableOpacity,
View,
KeyboardAvoidingView,
+ ActivityIndicator,
} from 'react-native';
import Share from 'react-native-share';
@@ -28,9 +29,13 @@ import {ACTIONS} from '../../provider/actions';
import NavigationService from '../../services/NavigationService';
import {timeConverter, ToastEvent, DDS, db} from '../../utils/utils';
import {openVault, eSendEvent} from '../../services/eventManager';
-import {refreshNotesPage, eOpenPremiumDialog, eOpenExportDialog} from '../../services/events';
+import {
+ refreshNotesPage,
+ eOpenPremiumDialog,
+ eOpenExportDialog,
+} from '../../services/events';
import {PremiumTag} from '../Premium/PremiumTag';
-import { MMKV } from '../../utils/storage';
+import {MMKV} from '../../utils/storage';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -45,8 +50,9 @@ export const ActionSheetComponent = ({
columnItems = [],
}) => {
const [state, dispatch] = useTracked();
- const {colors, tags, premiumUser} = state;
+ const {colors, tags, premiumUser, user} = state;
const [focused, setFocused] = useState(false);
+ const [refreshing, setRefreshing] = useState(false);
const [note, setNote] = useState(
item
? item
@@ -74,6 +80,7 @@ export const ActionSheetComponent = ({
useEffect(() => {
if (item.dateCreated !== null) {
setNote({...item});
+ console.log(item);
}
}, [item]);
@@ -226,7 +233,7 @@ export const ActionSheetComponent = ({
name: 'Export',
icon: 'export',
func: () => {
- close('export')
+ close('export');
},
},
{
@@ -287,7 +294,7 @@ export const ActionSheetComponent = ({
icon: 'theme-light-dark',
func: () => {
if (!colors.night) {
- MMKV .setStringAsync('theme', JSON.stringify({night: true}));
+ MMKV.setStringAsync('theme', JSON.stringify({night: true}));
changeColorScheme(COLOR_SCHEME_DARK);
} else {
MMKV.setStringAsync('theme', JSON.stringify({night: false}));
@@ -571,6 +578,32 @@ export const ActionSheetComponent = ({
) : null;
+ const onPressSync = async () => {
+ if (!user) {
+ NavigationService.navigate('Login', {
+ root: true,
+ });
+ close();
+ return;
+ }
+ if (user?.lastSynced < note?.dateEdited) {
+ setRefreshing(true);
+ try {
+ let user = await db.user.get();
+ dispatch({type: ACTIONS.USER, user: user});
+ await db.sync();
+ localRefresh();
+ setRefreshing(false);
+
+ ToastEvent.show('Sync Complete', 'success', 'local');
+ } catch (e) {
+ setRefreshing(false);
+ ToastEvent.show(e.message, 'error', 'local');
+ }
+ dispatch({type: ACTIONS.ALL});
+ }
+ };
+
return (
{
@@ -605,7 +638,7 @@ export const ActionSheetComponent = ({
)}
- {note.type !== 'note' ? null : (
+ {note.type !== 'note' || refreshing ? null : (
- Synced
+ {user && user.lastSynced > note.dateEdited
+ ? 'Synced'
+ : 'Sync Now'}
)}
+
+ {refreshing ? (
+
+ ) : null}
)}
diff --git a/apps/mobile/src/components/Menu/MenuListItem.js b/apps/mobile/src/components/Menu/MenuListItem.js
index c6bb6c41b..7348f0299 100644
--- a/apps/mobile/src/components/Menu/MenuListItem.js
+++ b/apps/mobile/src/components/Menu/MenuListItem.js
@@ -31,7 +31,7 @@ export const MenuListItem = ({item, index, noTextMode, ignore}) => {
return (