You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2026-05-22 09:05:38 +02:00
Electron: Fixed issue with conflict folder and fixed sync tests
This commit is contained in:
@@ -136,8 +136,6 @@ class BaseApplication {
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
//async refreshNotes(parentType, parentId) {
|
||||
//async refreshNotes(parentType, parentId) {
|
||||
async refreshNotes(state) {
|
||||
let parentType = state.notesParentType;
|
||||
let parentId = null;
|
||||
@@ -245,6 +243,13 @@ class BaseApplication {
|
||||
await this.refreshNotes(newState);
|
||||
}
|
||||
|
||||
if (action.type === 'NOTE_UPDATE_ONE') {
|
||||
// If there is a conflict, we refresh the folders so as to display "Conflicts" folder
|
||||
if (action.note && action.note.is_conflict) {
|
||||
await FoldersScreenUtils.refreshFolders();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.hasGui() && action.type == 'SETTING_UPDATE_ONE' && action.key == 'sync.interval' || action.type == 'SETTING_UPDATE_ALL') {
|
||||
reg.setupRecurrentSync();
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class Tag extends BaseItem {
|
||||
}
|
||||
|
||||
static async save(o, options = null) {
|
||||
if (options.userSideValidation) {
|
||||
if (options && options.userSideValidation) {
|
||||
if ('title' in o) {
|
||||
o.title = o.title.trim().toLowerCase();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Note } = require('lib/models/note.js');
|
||||
const { Folder } = require('lib/models/folder.js');
|
||||
|
||||
const defaultState = {
|
||||
notes: [],
|
||||
@@ -160,6 +161,12 @@ const reducer = (state = defaultState, action) => {
|
||||
|
||||
const modNote = action.note;
|
||||
|
||||
const noteIsInFolder = function(note, folderId) {
|
||||
if (note.is_conflict) return folderId === Folder.conflictFolderId();
|
||||
if (!('parent_id' in modNote) || note.parent_id == folderId) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
let noteFolderHasChanged = false;
|
||||
let newNotes = state.notes.slice();
|
||||
var found = false;
|
||||
@@ -168,7 +175,7 @@ const reducer = (state = defaultState, action) => {
|
||||
if (n.id == modNote.id) {
|
||||
|
||||
// Note is still in the same folder
|
||||
if (!('parent_id' in modNote) || modNote.parent_id == n.parent_id) {
|
||||
if (noteIsInFolder(modNote, n.parent_id)) {
|
||||
// Merge the properties that have changed (in modNote) into
|
||||
// the object we already have.
|
||||
newNotes[i] = Object.assign({}, newNotes[i]);
|
||||
@@ -187,7 +194,13 @@ const reducer = (state = defaultState, action) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && ('parent_id' in modNote) && modNote.parent_id == state.selectedFolderId) newNotes.push(modNote);
|
||||
// Note was not found - if the current folder is the same as the note folder,
|
||||
// add it to it.
|
||||
if (!found) {
|
||||
if (noteIsInFolder(modNote, state.selectedFolderId)) {
|
||||
newNotes.push(modNote);
|
||||
}
|
||||
}
|
||||
|
||||
newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
|
||||
newState = Object.assign({}, state);
|
||||
|
||||
Reference in New Issue
Block a user