From 53d305eb2eddfb2e55e2eed715fd6e1d66fb1d50 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 24 Jul 2017 22:52:30 +0100 Subject: [PATCH] Various fixes --- .../lib/components/screen-header.js | 2 +- .../lib/components/screens/note.js | 16 ++++++++++++-- .../lib/components/screens/onedrive-login.js | 1 + .../lib/components/side-menu-content.js | 22 ++++++++++--------- ReactNativeClient/root.js | 20 ++++++++--------- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/ReactNativeClient/lib/components/screen-header.js b/ReactNativeClient/lib/components/screen-header.js index d15efb6c7..34f4bb6ae 100644 --- a/ReactNativeClient/lib/components/screen-header.js +++ b/ReactNativeClient/lib/components/screen-header.js @@ -243,7 +243,7 @@ class ScreenHeaderComponent extends Component { ); } else { - let title = 'title' in this.props && this.props.title !== null ? this.props.title : _(this.props.navState.routeName); + let title = 'title' in this.props && this.props.title !== null ? this.props.title : ''; return {title} } } diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index e01c0f40b..bab3000c3 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -71,6 +71,7 @@ class NoteScreenComponent extends BaseScreenComponent { showNoteMetadata: false, folder: null, lastSavedNote: null, + isLoading: true, }; this.saveButtonHasBeenShown_ = false; @@ -116,6 +117,7 @@ class NoteScreenComponent extends BaseScreenComponent { note: note, mode: mode, folder: await Folder.load(note.parent_id), + isLoading: false, }); this.refreshNoteMetadata(); @@ -270,9 +272,18 @@ class NoteScreenComponent extends BaseScreenComponent { } render() { + if (this.state.isLoading) { + return ( + + + + ); + } + const note = this.state.note; const isTodo = !!Number(note.is_todo); const folder = this.state.folder; + const isNew = !note.id; let bodyComponent = null; if (this.state.mode == 'view') { @@ -395,10 +406,11 @@ class NoteScreenComponent extends BaseScreenComponent { ); } else { + const focusBody = !isNew && !!note.title; bodyComponent = ( this.saveNoteButton_press()} /> - { isTodo && { this.todoCheckbox_change(checked) }} /> } this.title_changeText(text)} /> + { isTodo && { this.todoCheckbox_change(checked) }} /> } this.title_changeText(text)} /> { bodyComponent } { actionButtonComp } diff --git a/ReactNativeClient/lib/components/screens/onedrive-login.js b/ReactNativeClient/lib/components/screens/onedrive-login.js index 7ae1fee89..fa261d361 100644 --- a/ReactNativeClient/lib/components/screens/onedrive-login.js +++ b/ReactNativeClient/lib/components/screens/onedrive-login.js @@ -50,6 +50,7 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent { try { await reg.oneDriveApi().execTokenRequest(this.authCode_, this.redirectUrl(), true); this.props.dispatch({ type: 'Navigation/BACK' }); + reg.scheduleSync(0); } catch (error) { alert(error.message); } diff --git a/ReactNativeClient/lib/components/side-menu-content.js b/ReactNativeClient/lib/components/side-menu-content.js index af3ad2f65..e5cb104a3 100644 --- a/ReactNativeClient/lib/components/side-menu-content.js +++ b/ReactNativeClient/lib/components/side-menu-content.js @@ -4,6 +4,7 @@ import { connect } from 'react-redux' import Icon from 'react-native-vector-icons/Ionicons'; import { Log } from 'lib/log.js'; import { Note } from 'lib/models/note.js'; +import { Setting } from 'lib/models/setting.js'; import { FoldersScreenUtils } from 'lib/components/screens/folders-utils.js' import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js' import { Synchronizer } from 'lib/synchronizer.js'; @@ -70,21 +71,22 @@ class SideMenuContentComponent extends Component { } async synchronize_press() { + if (Setting.value('sync.target') == Setting.SYNC_TARGET_ONEDRIVE && !reg.oneDriveApi().auth()) { + this.props.dispatch({ type: 'SIDE_MENU_CLOSE' }); + + this.props.dispatch({ + type: 'Navigation/NAVIGATE', + routeName: 'OneDriveLogin', + }); + return; + } + const sync = await reg.synchronizer(Setting.value('sync.target')) if (this.props.syncStarted) { sync.cancel(); } else { - if (reg.oneDriveApi().auth()) { - reg.scheduleSync(1); - } else { - this.props.dispatch({ type: 'SIDE_MENU_CLOSE' }); - - this.props.dispatch({ - type: 'Navigation/NAVIGATE', - routeName: 'OneDriveLogin', - }); - } + reg.scheduleSync(0); } } diff --git a/ReactNativeClient/root.js b/ReactNativeClient/root.js index ce55c962c..58f1b2456 100644 --- a/ReactNativeClient/root.js +++ b/ReactNativeClient/root.js @@ -409,16 +409,16 @@ async function initialize(dispatch, backButtonHandler) { let folderId = Setting.value('activeFolderId'); let folder = await Folder.load(folderId); - dispatch({ - type: 'Navigation/NAVIGATE', - routeName: 'Config', - }); + // dispatch({ + // type: 'Navigation/NAVIGATE', + // routeName: 'Config', + // }); - // if (folder) { - // await NotesScreenUtils.openNoteList(folderId); - // } else { - // await NotesScreenUtils.openDefaultNoteList(); - // } + if (folder) { + await NotesScreenUtils.openNoteList(folderId); + } else { + await NotesScreenUtils.openDefaultNoteList(); + } } catch (error) { reg.logger().error('Initialization error:', error); } @@ -429,7 +429,7 @@ async function initialize(dispatch, backButtonHandler) { PoorManIntervals.setInterval(() => { reg.logger().info('Running background sync on timer...'); - reg.scheduleSync(1); + reg.scheduleSync(0); }, 1000 * 60 * 5); if (Setting.value('env') == 'dev') {