From 95a06c45315b94d44e5e3122566f9ff0c1672a94 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 30 Sep 2018 20:43:46 +0100 Subject: [PATCH] All: Fixes #818: Use sort options when displayed tagged notes --- ReactNativeClient/lib/BaseApplication.js | 2 +- ReactNativeClient/lib/components/screens/notes.js | 2 +- ReactNativeClient/lib/models/Tag.js | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ReactNativeClient/lib/BaseApplication.js b/ReactNativeClient/lib/BaseApplication.js index ee5390b21..1676be312 100644 --- a/ReactNativeClient/lib/BaseApplication.js +++ b/ReactNativeClient/lib/BaseApplication.js @@ -215,7 +215,7 @@ class BaseApplication { if (parentType === Folder.modelType()) { notes = await Note.previews(parentId, options); } else if (parentType === Tag.modelType()) { - notes = await Tag.notes(parentId); + notes = await Tag.notes(parentId, options); } else if (parentType === BaseModel.TYPE_SEARCH) { let fields = Note.previewFields(); let search = BaseModel.byId(state.searches, parentId); diff --git a/ReactNativeClient/lib/components/screens/notes.js b/ReactNativeClient/lib/components/screens/notes.js index 08cb1247d..3f99d9cd7 100644 --- a/ReactNativeClient/lib/components/screens/notes.js +++ b/ReactNativeClient/lib/components/screens/notes.js @@ -114,7 +114,7 @@ class NotesScreenComponent extends BaseScreenComponent { if (props.notesParentType == 'Folder') { notes = await Note.previews(props.selectedFolderId, options); } else { - notes = await Tag.notes(props.selectedTagId); // TODO: should also return previews + notes = await Tag.notes(props.selectedTagId, options); // TODO: should also return previews } this.props.dispatch({ diff --git a/ReactNativeClient/lib/models/Tag.js b/ReactNativeClient/lib/models/Tag.js index 68ab68404..9d5cf3b75 100644 --- a/ReactNativeClient/lib/models/Tag.js +++ b/ReactNativeClient/lib/models/Tag.js @@ -30,13 +30,15 @@ class Tag extends BaseItem { return output; } - static async notes(tagId) { + static async notes(tagId, options = null) { + if (options === null) options = {}; + let noteIds = await this.noteIds(tagId); if (!noteIds.length) return []; - return Note.search({ + return Note.search(Object.assign({}, options, { conditions: ['id IN ("' + noteIds.join('","') + '")'], - }); + })) } // Untag all the notes and delete tag