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

Desktop,Mobile: Resolves #10073, #10080: Fix conflicts notebook doesn't work with the trash feature (#10104)

This commit is contained in:
Henry Heino
2024-03-14 11:30:49 -07:00
committed by GitHub
parent 8eea3953f3
commit c16ce1c434
16 changed files with 193 additions and 15 deletions

View File

@ -405,6 +405,7 @@ export default class Note extends BaseItem {
if (parentId === Folder.conflictFolderId()) {
options.conditions.push('is_conflict = 1');
options.conditions.push('deleted_time = 0');
} else if (withinTrash) {
options.conditions.push('deleted_time > 0');
} else {
@ -502,7 +503,8 @@ export default class Note extends BaseItem {
public static preview(noteId: string, options: any = null) {
if (!options) options = { fields: null };
return this.modelSelectOne(`SELECT ${this.previewFieldsSql(options.fields)} FROM notes WHERE is_conflict = 0 AND id = ?`, [noteId]);
const excludeConflictsSql = options.excludeConflicts ? 'is_conflict = 0 AND' : '';
return this.modelSelectOne(`SELECT ${this.previewFieldsSql(options.fields)} FROM notes WHERE ${excludeConflictsSql} id = ?`, [noteId]);
}
public static async search(options: any = null): Promise<NoteEntity[]> {
@ -520,11 +522,11 @@ export default class Note extends BaseItem {
}
public static conflictedNotes() {
return this.modelSelectAll('SELECT * FROM notes WHERE is_conflict = 1');
return this.modelSelectAll('SELECT * FROM notes WHERE is_conflict = 1 AND deleted_time = 0');
}
public static async conflictedCount() {
const r = await this.db().selectOne('SELECT count(*) as total FROM notes WHERE is_conflict = 1');
const r = await this.db().selectOne('SELECT count(*) as total FROM notes WHERE is_conflict = 1 AND deleted_time = 0');
return r && r.total ? r.total : 0;
}