diff --git a/ReactNativeClient/lib/components/screens/folders-utils.js b/ReactNativeClient/lib/components/screens/folders-utils.js new file mode 100644 index 0000000000..b323a270fe --- /dev/null +++ b/ReactNativeClient/lib/components/screens/folders-utils.js @@ -0,0 +1,15 @@ +import { Folder } from 'lib/models/folder.js' + +class FoldersScreenUtils { + + static async refreshFolders() { + let initialFolders = await Folder.all({ includeConflictFolder: true }); + this.dispatch({ + type: 'FOLDERS_UPDATE_ALL', + folders: initialFolders, + }); + } + +} + +export { FoldersScreenUtils } \ No newline at end of file diff --git a/ReactNativeClient/lib/components/screens/notes.js b/ReactNativeClient/lib/components/screens/notes.js index 1489648b37..f8759f55c2 100644 --- a/ReactNativeClient/lib/components/screens/notes.js +++ b/ReactNativeClient/lib/components/screens/notes.js @@ -41,22 +41,25 @@ class NotesScreenComponent extends BaseScreenComponent { } menuOptions() { + if (this.props.selectedFolderId == Folder.conflictFolderId()) return []; + return [ - { title: _('Delete folder'), onPress: () => { this.deleteFolder_onPress(this.props.selectedFolderId); } }, - { title: _('Edit folder'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } }, + { title: _('Delete notebook'), onPress: () => { this.deleteFolder_onPress(this.props.selectedFolderId); } }, + { title: _('Edit notebook'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } }, ]; } render() { let folder = Folder.byId(this.props.folders, this.props.selectedFolderId); let title = folder ? folder.title : null; + const addFolderNoteButtons = folder.id != Folder.conflictFolderId(); const { navigate } = this.props.navigation; return ( - + { this.dialogbox = dialogbox }}/> ); diff --git a/ReactNativeClient/lib/components/side-menu-content.js b/ReactNativeClient/lib/components/side-menu-content.js index 99cc981a19..28412072e5 100644 --- a/ReactNativeClient/lib/components/side-menu-content.js +++ b/ReactNativeClient/lib/components/side-menu-content.js @@ -63,7 +63,13 @@ class SideMenuContentComponent extends Component { }; try { - sync.start(options); + sync.start(options).then(async () => { + let initialFolders = await Folder.all({ includeConflictFolder: true }); + dispatch({ + type: 'FOLDERS_UPDATE_ALL', + folders: initialFolders, + }); + }); } catch (error) { Log.error(error); } diff --git a/ReactNativeClient/root.js b/ReactNativeClient/root.js index 51663b3572..667645cd28 100644 --- a/ReactNativeClient/root.js +++ b/ReactNativeClient/root.js @@ -8,6 +8,7 @@ import { AppNav } from 'lib/components/app-nav.js' import { Logger } from 'lib/logger.js' import { Note } from 'lib/models/note.js' import { Folder } from 'lib/models/folder.js' +import { FoldersScreenUtils } from 'lib/components/screens/folders-utils.js'; import { Resource } from 'lib/models/resource.js' import { Tag } from 'lib/models/tag.js' import { NoteTag } from 'lib/models/note-tag.js' @@ -267,6 +268,7 @@ async function initialize(dispatch, backButtonHandler) { BaseModel.dispatch = dispatch; NotesScreenUtils.dispatch = dispatch; + FoldersScreenUtils.dispatch = dispatch; BaseModel.db_ = db; BaseItem.loadClass('Note', Note); @@ -287,6 +289,8 @@ async function initialize(dispatch, backButtonHandler) { // await db.exec('DELETE FROM note_tags'); // await db.exec('DELETE FROM resources'); // await db.exec('DELETE FROM deleted_items'); + + // await db.exec('UPDATE notes SET is_conflict = 1 where id like "546f%"'); } reg.logger().info('Database is ready.'); @@ -294,12 +298,8 @@ async function initialize(dispatch, backButtonHandler) { await Setting.load(); reg.logger().info('Loading folders...'); - let initialFolders = await Folder.all(); - dispatch({ - type: 'FOLDERS_UPDATE_ALL', - folders: initialFolders, - }); + await FoldersScreenUtils.refreshFolders(); dispatch({ type: 'APPLICATION_LOADING_DONE',