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

All: Added concept of provisional note to simplify creation and handling of newly created notes

This commit is contained in:
Laurent Cozic
2020-02-29 12:39:15 +00:00
parent 6542a60d61
commit 6ca0e6adcc
6 changed files with 63 additions and 65 deletions

View File

@ -1,5 +1,6 @@
const Setting = require('lib/models/Setting');
const Tag = require('lib/models/Tag');
const Note = require('lib/models/Note');
const { reg } = require('lib/registry.js');
const ResourceFetcher = require('lib/services/ResourceFetcher');
@ -28,16 +29,22 @@ const reduxSharedMiddleware = async function(store, next, action) {
refreshTags = true;
}
if (action.type === 'NOTE_SELECT') {
const noteIds = newState.provisionalNoteIds.slice();
for (const noteId of noteIds) {
if (action.id === noteId) continue;
await Note.delete(noteId);
}
}
if (action.type === 'NOTE_DELETE' ||
action.type === 'NOTE_SELECT' ||
action.type === 'NOTE_SELECT_TOGGLE' ||
action.type === 'NOTE_SET_NEW_ONE') {
action.type === 'NOTE_SELECT_TOGGLE') {
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 &&
if (newState.selectedNoteIds &&
newState.selectedNoteIds.length === 1) {
noteTags = await Tag.tagsByNoteId(newState.selectedNoteIds[0]);
}