diff --git a/ReactNativeClient/lib/components/select-date-time-dialog.js b/ReactNativeClient/lib/components/select-date-time-dialog.js index 1cf6380c9f..22538db24d 100644 --- a/ReactNativeClient/lib/components/select-date-time-dialog.js +++ b/ReactNativeClient/lib/components/select-date-time-dialog.js @@ -22,7 +22,7 @@ class SelectDateTimeDialog extends React.PureComponent { this.setState({ date: newProps.date }); } - if ('shown' in newProps) { + if ('shown' in newProps && newProps.shown != this.shown_) { this.show(newProps.shown); } } diff --git a/ReactNativeClient/setUpQuickActions.ts b/ReactNativeClient/setUpQuickActions.ts index c8aed0e192..cf37dc311d 100644 --- a/ReactNativeClient/setUpQuickActions.ts +++ b/ReactNativeClient/setUpQuickActions.ts @@ -4,6 +4,8 @@ const { DeviceEventEmitter } = require('react-native'); import * as QuickActions from 'react-native-quick-actions'; const { _ } = require('lib/locale.js'); +const Note = require('lib/models/Note.js'); +const { reg } = require('lib/registry.js'); type TData = { type: string @@ -16,7 +18,9 @@ export default (dispatch: Function, folderId: string) => { { type: 'New to-do', title: _('New to-do'), icon: 'Add', userInfo }, ]); - DeviceEventEmitter.addListener('quickActionShortcut', (data: TData) => { + const handleQuickAction = (data: TData) => { + if (!data) return; + // This dispatch is to momentarily go back to reset state, similar to what // happens in onJoplinLinkClick_(). Easier to just go back, then go to the // note since the Note screen doesn't handle reloading a different note. @@ -28,25 +32,25 @@ export default (dispatch: Function, folderId: string) => { // note. If you navigate around enough (which I think changes the redux // state sufficiently or something), then it'll work again. dispatch({ type: 'NAV_BACK' }); + dispatch({ type: 'SIDE_MENU_CLOSE' }); - if (data.type === 'New note') { + const isTodo = data.type === 'New to-do' ? 1 : 0; + + Note.save({ + parent_id: folderId, + is_todo: isTodo, + }, { provisional: true }).then((newNote: any) => { dispatch({ type: 'NAV_GO', - noteId: null, + noteId: newNote.id, folderId, routeName: 'Note', - itemType: 'note', }); - } + }); + }; - if (data.type === 'New to-do') { - dispatch({ - type: 'NAV_GO', - noteId: null, - folderId, - routeName: 'Note', - itemType: 'todo', - }); - } - }); + DeviceEventEmitter.addListener('quickActionShortcut', handleQuickAction); + + QuickActions.popInitialAction().then(handleQuickAction).catch((reason: any) => reg.logger().error(reason)); }; +