1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Mobile: Resolves #10245: Allow marking items as "ignored" in sync status (#10261)

This commit is contained in:
Henry Heino
2024-04-08 04:35:57 -07:00
committed by GitHub
parent b3f4414026
commit 03c3feef16
12 changed files with 290 additions and 44 deletions

View File

@ -14,6 +14,7 @@ import JoplinError from '../JoplinError';
import { LoadOptions, SaveOptions } from './utils/types';
import { State as ShareState } from '../services/share/reducer';
import { checkIfItemCanBeAddedToFolder, checkIfItemCanBeChanged, checkIfItemsCanBeChanged, needsShareReadOnlyChecks } from './utils/readOnly';
import { checkObjectHasProperties } from '@joplin/utils/object';
const { sprintf } = require('sprintf-js');
const moment = require('moment');
@ -820,16 +821,26 @@ export default class BaseItem extends BaseModel {
syncInfo: row,
location: row.item_location,
item: item,
warning_ignored: row.sync_warning_ignored,
});
}
return output;
}
public static async syncDisabledItemsCount(syncTargetId: number) {
const r = await this.db().selectOne('SELECT count(*) as total FROM sync_items WHERE sync_disabled = 1 AND sync_target = ?', [syncTargetId]);
public static async syncDisabledItemsCount(syncTargetId: number, includeIgnored = false) {
const whereQueries = ['sync_disabled = 1', 'sync_target = ?'];
const whereArgs = [syncTargetId];
if (!includeIgnored) {
whereQueries.push('sync_warning_ignored = 0');
}
const r = await this.db().selectOne(`SELECT count(*) as total FROM sync_items WHERE ${whereQueries.join(' AND ')}`, whereArgs);
return r ? r.total : 0;
}
public static async syncDisabledItemsCountIncludingIgnored(syncTargetId: number) {
return this.syncDisabledItemsCount(syncTargetId, true);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
public static updateSyncTimeQueries(syncTarget: number, item: any, syncTime: number, syncDisabled = false, syncDisabledReason = '', itemLocation: number = null) {
const itemType = item.type_;
@ -867,6 +878,15 @@ export default class BaseItem extends BaseModel {
await this.db().exec('DELETE FROM sync_items WHERE item_type = ? AND item_id = ?', [itemType, itemId]);
}
public static async ignoreItemSyncWarning(syncTarget: number, item: { type_?: number; id?: string }) {
checkObjectHasProperties(item, ['type_', 'id']);
const itemType = item.type_;
const itemId = item.id;
const sql = 'UPDATE sync_items SET sync_warning_ignored = ? WHERE item_id = ? AND item_type = ? AND sync_target = ?';
const params = [1, itemId, itemType, syncTarget];
await this.db().exec(sql, params);
}
// When an item is deleted, its associated sync_items data is not immediately deleted for
// performance reason. So this function is used to look for these remaining sync_items and
// delete them.