1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Desktop: New: Display selected tags under a note title (#2217)

Follow up to #893

Now using middleware to set the tags when a note is selected

This avoids the ugly code in the NoteTextComponent where we determine
if tags are to be fetched, identify if they have been modified, fetch
them  and then dispatch an action to update the store which might
again re-render the component.

Also implements style related fixes from #1000

Signed-off-by: Abijeet <abijeetpatro@gmail.com>
Fixes: #469
This commit is contained in:
Abijeet Patro
2020-01-07 02:53:22 +05:30
committed by Laurent Cozic
parent 42ada7123c
commit ae3a278ac4
3 changed files with 38 additions and 29 deletions

View File

@ -28,6 +28,26 @@ const reduxSharedMiddleware = async function(store, next, action) {
refreshTags = true;
}
if (action.type === 'NOTE_SELECT' ||
action.type === 'NOTE_SELECT_TOGGLE' ||
action.type === 'NOTE_SET_NEW_ONE') {
let noteTags = [];
// We don't need to show tags unless only one note is selected.
// For new notes, the old note is still selected, but we don't want to show any tags.
if (action.type !== 'NOTE_SET_NEW_ONE' &&
newState.selectedNoteIds &&
newState.selectedNoteIds.length === 1) {
noteTags = await Tag.tagsByNoteId(newState.selectedNoteIds[0]);
}
store.dispatch({
type: 'SET_NOTE_TAGS',
items: noteTags,
});
}
if (refreshTags) {
store.dispatch({
type: 'TAG_UPDATE_ALL',
@ -37,3 +57,4 @@ const reduxSharedMiddleware = async function(store, next, action) {
};
module.exports = reduxSharedMiddleware;