fix login flow

This commit is contained in:
ammarahm-ed
2020-09-14 13:14:07 +05:00
parent facc4f2cfa
commit da35ee06ae
4 changed files with 28 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ import {
TextInput, TextInput,
TouchableOpacity, TouchableOpacity,
View, View,
Clipboard,
} from 'react-native'; } from 'react-native';
import Share from 'react-native-share'; import Share from 'react-native-share';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -26,7 +27,7 @@ import {
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions'; import {ACTIONS} from '../../provider/actions';
import {eSendEvent, openVault} from '../../services/eventManager'; import {eSendEvent, openVault} from '../../services/eventManager';
import {refreshNotesPage} from '../../services/events'; import {eOpenLoginDialog, refreshNotesPage} from '../../services/events';
import NavigationService from '../../services/NavigationService'; import NavigationService from '../../services/NavigationService';
import {MMKV} from '../../utils/storage'; import {MMKV} from '../../utils/storage';
import { import {
@@ -39,6 +40,7 @@ import {
} from '../../utils/utils'; } from '../../utils/utils';
import {PremiumTag} from '../Premium/PremiumTag'; import {PremiumTag} from '../Premium/PremiumTag';
import {PressableButton} from '../PressableButton'; import {PressableButton} from '../PressableButton';
import {Toast} from '../Toast';
const w = Dimensions.get('window').width; const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height; const h = Dimensions.get('window').height;
@@ -83,7 +85,6 @@ export const ActionSheetComponent = ({
useEffect(() => { useEffect(() => {
if (item.dateCreated !== null) { if (item.dateCreated !== null) {
setNote({...item}); setNote({...item});
console.log(item);
} }
}, [item]); }, [item]);
@@ -259,20 +260,18 @@ export const ActionSheetComponent = ({
}, },
}, },
{ {
name: 'Open', name: 'Copy',
icon: 'open-in-app', icon: 'content-copy',
func: () => { func: async () => {
NavigationService.navigate('Editor', { let text = await db.notes.note(note.id).text();
note: item, Clipboard.setString(text);
}); ToastEvent.show('Note copied to clipboard', 'success', 'local');
close();
}, },
}, },
{ {
name: 'Restore', name: 'Restore',
icon: 'delete-restore', icon: 'delete-restore',
func: async () => { func: async () => {
console.log(await db.trash.restore(note.id),"RESULT");
dispatch({type: ACTIONS.TRASH}); dispatch({type: ACTIONS.TRASH});
localRefresh(note.type); localRefresh(note.type);
ToastEvent.show( ToastEvent.show(
@@ -437,7 +436,6 @@ export const ActionSheetComponent = ({
); );
const _renderColor = (c) => { const _renderColor = (c) => {
console.log(COLORS_NOTE[c]);
const color = { const color = {
name: c, name: c,
value: COLORS_NOTE[c], value: COLORS_NOTE[c],
@@ -589,10 +587,19 @@ export const ActionSheetComponent = ({
const onPressSync = async () => { const onPressSync = async () => {
if (!user) { if (!user) {
NavigationService.navigate('Login', { ToastEvent.show(
root: true, 'You must login to sync',
}); 'error',
close(); 'local',
5000,
() => {
close();
setTimeout(() => {
eSendEvent(eOpenLoginDialog);
}, 500);
},
'Login',
);
return; return;
} }
if (user?.lastSynced < note?.dateEdited) { if (user?.lastSynced < note?.dateEdited) {
@@ -604,7 +611,7 @@ export const ActionSheetComponent = ({
localRefresh(); localRefresh();
setRefreshing(false); setRefreshing(false);
ToastEvent.show('Sync Complete', 'success', 'local'); ToastEvent.show('Note synced', 'success', 'local');
} catch (e) { } catch (e) {
setRefreshing(false); setRefreshing(false);
ToastEvent.show(e.message, 'error', 'local'); ToastEvent.show(e.message, 'error', 'local');
@@ -955,6 +962,7 @@ export const ActionSheetComponent = ({
}} }}
/> />
) : null} ) : null}
<Toast context="local" />
</View> </View>
); );
}; };

View File

@@ -181,11 +181,11 @@ export class DialogManager extends Component {
showLoginDialog = () => { showLoginDialog = () => {
this.loginDialog.open(); //this.loginDialog.open();
}; };
hideLoginDialog = () => { hideLoginDialog = () => {
this.loginDialog.close(); //this.loginDialog.close();
}; };
showAddNotebook = data => { showAddNotebook = data => {

View File

@@ -140,12 +140,7 @@ export const UserSection = ({noTextMode}) => {
) : ( ) : (
<PressableButton <PressableButton
onPress={() => { onPress={() => {
DDS.isTab eSendEvent(eOpenLoginDialog);
? eSendEvent(eOpenLoginDialog)
: NavigationService.navigate('Login', {
root: true,
});
sideMenuRef.current?.closeDrawer();
}} }}
color={colors.shade} color={colors.shade}
selectedColor={colors.accent} selectedColor={colors.accent}

View File

@@ -227,7 +227,7 @@ export default class NoteItem extends React.Component {
isTrash ? false : true, isTrash ? false : true,
isTrash isTrash
? ['Remove', 'Restore'] ? ['Remove', 'Restore']
: ['Add to', 'Share', 'Export', 'Delete', 'Open'], : ['Add to', 'Share', 'Export', 'Delete', 'Copy'],
isTrash ? [] : ['Pin', 'Favorite', 'Add to Vault'], isTrash ? [] : ['Pin', 'Favorite', 'Add to Vault'],
); );
}}> }}>