You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Fixed synchronizer conflict handling when deleting folders
This commit is contained in:
@@ -177,7 +177,7 @@ class BaseItem extends BaseModel {
|
||||
}
|
||||
|
||||
static serialize_format(propName, propValue) {
|
||||
if (['created_time', 'updated_time'].indexOf(propName) >= 0) {
|
||||
if (['created_time', 'updated_time', 'sync_time'].indexOf(propName) >= 0) {
|
||||
if (!propValue) return '';
|
||||
propValue = moment.unix(propValue / 1000).utc().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z';
|
||||
} else if (propValue === null || propValue === undefined) {
|
||||
@@ -207,18 +207,20 @@ class BaseItem extends BaseModel {
|
||||
|
||||
let output = [];
|
||||
|
||||
if ('title' in item) {
|
||||
if ('title' in item && shownKeys.indexOf('title') >= 0) {
|
||||
output.push(item.title);
|
||||
output.push('');
|
||||
}
|
||||
|
||||
if ('body' in item) {
|
||||
if ('body' in item && shownKeys.indexOf('body') >= 0) {
|
||||
output.push(item.body);
|
||||
if (shownKeys.length) output.push('');
|
||||
}
|
||||
|
||||
for (let i = 0; i < shownKeys.length; i++) {
|
||||
let key = shownKeys[i];
|
||||
if (key == 'title' || key == 'body') continue;
|
||||
|
||||
let value = null;
|
||||
if (typeof key === 'function') {
|
||||
let r = await key();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Log } from 'lib/log.js';
|
||||
import { promiseChain } from 'lib/promise-utils.js';
|
||||
import { Note } from 'lib/models/note.js';
|
||||
import { Setting } from 'lib/models/setting.js';
|
||||
import { Database } from 'lib/database.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import moment from 'moment';
|
||||
import { BaseItem } from 'lib/models/base-item.js';
|
||||
@@ -48,13 +49,23 @@ class Folder extends BaseItem {
|
||||
return r ? r.total : 0;
|
||||
}
|
||||
|
||||
static markNotesAsConflict(parentId) {
|
||||
let query = Database.updateQuery('notes', { is_conflict: 1 }, { parent_id: parentId });
|
||||
return this.db().exec(query);
|
||||
}
|
||||
|
||||
static async delete(folderId, options = null) {
|
||||
if (!options) options = {};
|
||||
if (!('deleteChildren' in options)) options.deleteChildren = true;
|
||||
|
||||
let folder = await Folder.load(folderId);
|
||||
if (!folder) throw new Error('Trying to delete non-existing notebook: ' + folderId);
|
||||
|
||||
let noteIds = await Folder.noteIds(folderId);
|
||||
for (let i = 0; i < noteIds.length; i++) {
|
||||
await Note.delete(noteIds[i]);
|
||||
if (!folder) return; // noop
|
||||
|
||||
if (options.deleteChildren) {
|
||||
let noteIds = await Folder.noteIds(folderId);
|
||||
for (let i = 0; i < noteIds.length; i++) {
|
||||
await Note.delete(noteIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
await super.delete(folderId, options);
|
||||
|
||||
@@ -17,12 +17,12 @@ class Note extends BaseItem {
|
||||
static async serialize(note, type = null, shownKeys = null) {
|
||||
let fieldNames = this.fieldNames();
|
||||
fieldNames.push('type_');
|
||||
lodash.pull(fieldNames, 'is_conflict', 'sync_time', 'body'); // Exclude 'body' since it's going to be added separately at the top of the note
|
||||
lodash.pull(fieldNames, 'is_conflict', 'sync_time');
|
||||
return super.serialize(note, 'note', fieldNames);
|
||||
}
|
||||
|
||||
static async serializeForEdit(note) {
|
||||
return super.serialize(note, 'note', []);
|
||||
return super.serialize(note, 'note', ['title', 'body']);
|
||||
}
|
||||
|
||||
static async unserializeForEdit(content) {
|
||||
@@ -30,6 +30,13 @@ class Note extends BaseItem {
|
||||
return super.unserialize(content);
|
||||
}
|
||||
|
||||
static async serializeAllProps(note) {
|
||||
let fieldNames = this.fieldNames();
|
||||
fieldNames.push('type_');
|
||||
lodash.pull(fieldNames, 'title', 'body');
|
||||
return super.serialize(note, 'note', fieldNames);
|
||||
}
|
||||
|
||||
static modelType() {
|
||||
return BaseModel.TYPE_NOTE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user