diff --git a/apps/mobile/App.js b/apps/mobile/App.js index f6430d38f..2529727ad 100644 --- a/apps/mobile/App.js +++ b/apps/mobile/App.js @@ -15,6 +15,7 @@ import { eSubscribeEvent, eUnSubscribeEvent, } from './src/services/EventManager'; +import Navigation from './src/services/Navigation'; import SettingsService from './src/services/SettingsService'; import {changeAppScale} from './src/utils/Animations'; import {db} from './src/utils/DB'; @@ -96,11 +97,8 @@ const Overlay = ({onLoad}) => { const load = async () => { db.notes.init().then(() => { init = true; - if (SettingsService.get().homepage === 'Notes') { - dispatch({type: Actions.NOTES}); - } else { - dispatch({type: Actions.FAVORITES}); - } + dispatch({type: Actions.NOTES}); + dispatch({type: Actions.FAVORITES}); // if (!animation) { dispatch({type: Actions.LOADING, loading: false}); // } diff --git a/apps/mobile/AppRootEvents.js b/apps/mobile/AppRootEvents.js index 73ad01af0..2347acf28 100644 --- a/apps/mobile/AppRootEvents.js +++ b/apps/mobile/AppRootEvents.js @@ -14,6 +14,7 @@ import { setEmailVerifyMessage, setLoginMessage, } from './src/services/Message'; +import Navigation from './src/services/Navigation'; import PremiumService from './src/services/PremiumService'; import SettingsService from './src/services/SettingsService'; import Sync from './src/services/Sync'; @@ -21,6 +22,7 @@ import {APP_VERSION, editing} from './src/utils'; import {COLOR_SCHEME} from './src/utils/Colors'; import {db} from './src/utils/DB'; import { + eClearEditor, eCloseProgressDialog, eOpenLoginDialog, eOpenProgressDialog, @@ -120,12 +122,14 @@ export const AppRootEvents = React.memo( EV.subscribe(EVENTS.userEmailConfirmed, onEmailVerified); EV.subscribe(EVENTS.userCheckStatus, PremiumService.onUserStatusCheck); EV.subscribe(EVENTS.userSubscriptionUpdated, onAccountStatusChange); + EV.subscribe(EVENTS.noteRemoved, onNoteRemoved); return () => { EV.unsubscribe(EVENTS.appRefreshRequested, onSyncComplete); EV.unsubscribe(EVENTS.databaseSyncRequested, partialSync); EV.unsubscribe(EVENTS.userLoggedOut, onLogout); EV.unsubscribe(EVENTS.userEmailConfirmed, onEmailVerified); + EV.unsubscribe(EVENTS.noteRemoved, onNoteRemoved); EV.unsubscribe( EVENTS.userCheckStatus, PremiumService.onUserStatusCheck, @@ -137,6 +141,21 @@ export const AppRootEvents = React.memo( }; }, []); + const onNoteRemoved = async (id) => { + try { + console.log("removing note"); + await db.notes.remove(id); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.Favorites, + Navigation.routeNames.Notes, + Navigation.routeNames.NotesPage, + Navigation.routeNames.Trash, + Navigation.routeNames.Notebook, + ]); + eSendEvent(eClearEditor); + } catch (e) {} + }; + useEffect(() => { let unsubscribe; if (!loading) { @@ -208,7 +227,7 @@ export const AppRootEvents = React.memo( ? 'Thank you for signing up for Notesnook Beta Program. Enjoy all premium features for free for the next 3 months.' : 'Your Notesnook Pro Trial has been activated. Enjoy all premium features for free for the next 14 days!'; eSendEvent(eOpenProgressDialog, { - title: 'Email Confirmed!', + title: 'Email confirmed!', paragraph: message, noProgress: true, }); @@ -270,7 +289,7 @@ export const AppRootEvents = React.memo( setLoginMessage(dispatch); await PremiumService.setPremiumStatus(); eSendEvent(eOpenProgressDialog, { - title: reason ? reason : 'User Logged Out', + title: reason ? reason : 'User logged out', paragraph: `You have been logged out of your account.`, action: async () => { eSendEvent(eCloseProgressDialog); diff --git a/apps/mobile/NotesnookShare.js b/apps/mobile/NotesnookShare.js index e2c55b250..c2f33a254 100644 --- a/apps/mobile/NotesnookShare.js +++ b/apps/mobile/NotesnookShare.js @@ -260,7 +260,7 @@ export default class NotesnookShare extends Component { this.textInputRef.current?.focus(); }} blurOnSubmit={false} - placeholder="Note Title" + placeholder="Note title" /> { const [state, dispatch] = useTracked(); const {colors} = state; @@ -40,7 +41,7 @@ export const ActionIcon = ({ } }} disabled={disabled} - type="gray" + type={type} customStyle={{ width: 40, height: 40, diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js index 60975091c..86212e730 100644 --- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js +++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js @@ -9,6 +9,7 @@ import { sendNoteEditedEvent, ToastEvent, } from '../../services/EventManager'; +import Navigation from '../../services/Navigation'; import {db} from '../../utils/DB'; import {refreshNotesPage} from '../../utils/Events'; import {SIZE} from '../../utils/SizeUtils'; @@ -23,16 +24,18 @@ let backPressCount = 0; export const ActionSheetTagsSection = ({item, close}) => { const [state, dispatch] = useTracked(); - const {colors, tags, premiumUser} = state; + const {colors, } = state; const [suggestions, setSuggestions] = useState([]); const [focused, setFocused] = useState(false); const [note, setNote] = useState(item); const localRefresh = () => { toAdd = db.notes.note(note.id).data; - dispatch({type: Actions.NOTES}); - dispatch({type: Actions.TAGS}); - eSendEvent(refreshNotesPage); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.Tags, + Navigation.routeNames.Notes, + Navigation.routeNames.NotesPage + ]) setNote({...toAdd}); if (prevQuery) { getSuggestions(prevQuery, toAdd); @@ -61,7 +64,9 @@ export const ActionSheetTagsSection = ({item, close}) => { } try { await db.notes.note(note.id).tag(tag); - dispatch({type: Actions.TAGS}); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.Tags, + ]) localRefresh(note.type); prevQuery = null; tagsInputRef.current?.setNativeProps({ diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js index c04d5b89e..b0da548eb 100644 --- a/apps/mobile/src/components/ActionSheetComponent/index.js +++ b/apps/mobile/src/components/ActionSheetComponent/index.js @@ -20,6 +20,7 @@ import { sendNoteEditedEvent, ToastEvent, } from '../../services/EventManager'; +import Navigation from '../../services/Navigation'; import PremiumService from '../../services/PremiumService'; import Sync from '../../services/Sync'; import {editing, toTXT} from '../../utils'; @@ -123,9 +124,11 @@ export const ActionSheetComponent = ({ if (!nodispatch) { dispatch({type: type}); if (type === 'note') { - eSendEvent(refreshNotesPage); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.NotesPage, + Navigation.routeNames.Favorites, + ]) } - dispatch({type: Actions.FAVORITES}); } setNote({...toAdd}); }; @@ -153,6 +156,8 @@ export const ActionSheetComponent = ({ novault: true, locked: true, share: true, + title:'Share note', + description:"Unlock note to share it." }); } else { let text = await db.notes.note(note.id).export('txt'); @@ -184,6 +189,8 @@ export const ActionSheetComponent = ({ novault: true, locked: true, item: note, + title:'Delete note', + description:"Unlock note to delete it." }); } else { try { @@ -219,6 +226,8 @@ export const ActionSheetComponent = ({ novault: true, locked: true, item: note, + title:'Copy note', + description:"Unlock note to copy to clipboard." }); } else { let text = await db.notes.note(note.id).content(); @@ -234,10 +243,14 @@ export const ActionSheetComponent = ({ icon: 'delete-restore', func: async () => { await db.trash.restore(note.id); - dispatch({type: Actions.TRASH}); - dispatch({type: note.itemType}); - dispatch({type: Actions.FAVORITES}); - eSendEvent(refreshNotesPage); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.Tags, + Navigation.routeNames.Notes, + Navigation.routeNames.Notebooks, + Navigation.routeNames.NotesPage, + Navigation.routeNames.Favorites, + Navigation.routeNames.Trash + ]) type = note.type === 'trash' ? note.itemType : note.type; ToastEvent.show( type === 'note' ? 'Note restored' : 'Notebook restored', @@ -717,11 +730,12 @@ export const ActionSheetComponent = ({ .notebook(editing.actionAfterFirstSave.notebook) .topics.topic(editing.actionAfterFirstSave.id) .delete(note.id); - - eSendEvent(refreshNotesPage); - eSendEvent(eOnNewTopicAdded); - dispatch({type: Actions.NOTEBOOKS}); - dispatch({type: Actions.NOTES}); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.Notebooks, + Navigation.routeNames.Notes, + Navigation.routeNames.NotesPage, + Navigation.routeNames.Notebook, + ]); setNote(db.notes.note(note.id).data); close(); }} diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js index 962e1f107..3ba9f0845 100644 --- a/apps/mobile/src/components/AddNotebookDialog/index.js +++ b/apps/mobile/src/components/AddNotebookDialog/index.js @@ -192,8 +192,7 @@ export class AddNotebookDialog extends React.Component { }); } this.close(); - updateEvent({type: Actions.NOTEBOOKS}); - updateEvent({type: Actions.PINNED}); + Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]); }; onSubmit = (forward = true) => { @@ -303,7 +302,7 @@ export class AddNotebookDialog extends React.Component { onChangeText={(value) => { this.title = value; }} - placeholder="Enter a Title" + placeholder="Enter a title" onSubmit={() => { this.descriptionRef.focus(); }} diff --git a/apps/mobile/src/components/AddTopicDialog/index.js b/apps/mobile/src/components/AddTopicDialog/index.js index 8344e36fd..1bd58dd98 100644 --- a/apps/mobile/src/components/AddTopicDialog/index.js +++ b/apps/mobile/src/components/AddTopicDialog/index.js @@ -1,24 +1,21 @@ -import React, {createRef} from 'react'; -import {Actions} from '../../provider/Actions'; +import React, { createRef } from 'react'; import { - eSendEvent, eSubscribeEvent, eUnSubscribeEvent, - ToastEvent, + ToastEvent } from '../../services/EventManager'; -import {db} from '../../utils/DB'; +import { db } from '../../utils/DB'; import { eCloseAddTopicDialog, - eOnNewTopicAdded, - eOpenAddTopicDialog, + + eOpenAddTopicDialog } from '../../utils/Events'; import BaseDialog from '../Dialog/base-dialog'; import DialogButtons from '../Dialog/dialog-buttons'; import DialogContainer from '../Dialog/dialog-container'; import DialogHeader from '../Dialog/dialog-header'; -import {updateEvent} from '../DialogManager/recievers'; import Input from '../Input'; -import {Toast} from '../Toast'; +import { Toast } from '../Toast'; export class AddTopicDialog extends React.Component { constructor(props) { @@ -26,7 +23,7 @@ export class AddTopicDialog extends React.Component { this.state = { visible: false, titleFocused: false, - loading:false + loading: false, }; this.title; @@ -35,7 +32,7 @@ export class AddTopicDialog extends React.Component { } addNewTopic = async () => { - this.setState({loading:true}) + this.setState({loading: true}); if (!this.title) return ToastEvent.show('Title is required', 'error', 'local'); @@ -48,8 +45,10 @@ export class AddTopicDialog extends React.Component { await db.notebooks.notebook(topic.notebookId).topics.add(topic); } this.close(); - updateEvent({type: Actions.NOTEBOOKS}); - eSendEvent(eOnNewTopicAdded); + Navigation.setRoutesToUpdate([ + Navigation.routeNames.Notebooks, + Navigation.routeNames.Notebook, + ]); }; componentDidMount() { diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js index b9e234535..933e10803 100644 --- a/apps/mobile/src/components/DialogManager/index.js +++ b/apps/mobile/src/components/DialogManager/index.js @@ -239,6 +239,8 @@ export class DialogManager extends Component { novault: true, locked: true, deleteNote: true, + title:'Delete note', + description:"Unlock to delete note." }); } else { this._showSimpleDialog(TEMPLATE_DELETE(this.state.item.type)); @@ -253,8 +255,8 @@ export class DialogManager extends Component { openVault({ item: this.state.item, novault: false, - locked: true, - deleteNote: true, + title:'Create vault', + description:"Set a password to create a vault and lock note." }); break; } @@ -263,6 +265,8 @@ export class DialogManager extends Component { item: this.state.item, novault: true, locked: true, + title:'Open note', + description:"Unlock note to open in editor" }); break; } @@ -272,6 +276,8 @@ export class DialogManager extends Component { novault: true, locked: true, permanant: true, + title:'Unlock note', + description:"Remove note from the vault." }); break; } diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.js index 89753064d..91ff46942 100644 --- a/apps/mobile/src/components/ExportDialog/index.js +++ b/apps/mobile/src/components/ExportDialog/index.js @@ -196,7 +196,7 @@ const ExportDialog = () => { { diff --git a/apps/mobile/src/components/Header/HeaderLeftMenu.js b/apps/mobile/src/components/Header/HeaderLeftMenu.js index a03e00210..7eaf22947 100644 --- a/apps/mobile/src/components/Header/HeaderLeftMenu.js +++ b/apps/mobile/src/components/Header/HeaderLeftMenu.js @@ -41,7 +41,7 @@ export const HeaderLeftMenu = () => { return ( <> {deviceMode === 'mobile' || - currentScreen === 'search' || + currentScreen === 'Search' || !headerMenuState ? ( { {syncing && } - {currentScreen !== 'settings' && ( + {currentScreen !== 'Settings' && ( { Navigation.navigate('Search', { @@ -55,7 +55,7 @@ export const HeaderRightMenu = () => { containerBottomButton.onPress(); }} testID={notesnook.ids.default.addBtn} - icon={currentScreen === 'trash' ? 'delete' : 'plus'} + icon={currentScreen === 'Trash' ? 'delete' : 'plus'} iconSize={SIZE.xl} type="shade" style={{ diff --git a/apps/mobile/src/components/Header/index.js b/apps/mobile/src/components/Header/index.js index e69cc4da9..782498ac8 100644 --- a/apps/mobile/src/components/Header/index.js +++ b/apps/mobile/src/components/Header/index.js @@ -73,17 +73,17 @@ export const Header = ({root}) => { {(Platform.OS === 'android' || - Platform.isPad) && currentScreen !== 'search' ? ( + Platform.isPad) && currentScreen !== 'Search' ? ( ) : null} {Platform.OS !== 'android' && !Platform.isPad && - currentScreen !== 'search' ? ( + currentScreen !== 'Search' ? ( ) : null} - {currentScreen === 'search' ? ( + {currentScreen === 'Search' ? ( { ) : null} - {currentScreen === 'search' ? ( + {currentScreen === 'Search' ? ( { diff --git a/apps/mobile/src/components/Loading/index.js b/apps/mobile/src/components/Loading/index.js index 20cf8856d..1dec4fdb1 100644 --- a/apps/mobile/src/components/Loading/index.js +++ b/apps/mobile/src/components/Loading/index.js @@ -32,7 +32,7 @@ export const Loading = ({ {doneText} -