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

All: Resolves #483: Add trash folder (#9671)

This commit is contained in:
Laurent Cozic
2024-03-02 14:25:27 +00:00
committed by GitHub
parent 07fbd547dc
commit f19b1c5364
112 changed files with 2322 additions and 966 deletions

View File

@ -13,7 +13,7 @@ import { getEncryptionEnabled } from '../services/synchronizer/syncInfoUtils';
import JoplinError from '../JoplinError';
import { LoadOptions, SaveOptions } from './utils/types';
import { State as ShareState } from '../services/share/reducer';
import { checkIfItemCanBeAddedToFolder, checkIfItemCanBeChanged, checkIfItemsCanBeChanged, needsReadOnlyChecks } from './utils/readOnly';
import { checkIfItemCanBeAddedToFolder, checkIfItemCanBeChanged, checkIfItemsCanBeChanged, needsShareReadOnlyChecks } from './utils/readOnly';
const { sprintf } = require('sprintf-js');
const moment = require('moment');
@ -293,7 +293,7 @@ export default class BaseItem extends BaseModel {
});
}
if (needsReadOnlyChecks(this.modelType(), options.changeSource, this.syncShareCache, options.disableReadOnlyCheck)) {
if (needsShareReadOnlyChecks(this.modelType(), options.changeSource, this.syncShareCache, options.disableReadOnlyCheck)) {
const previousItems = await this.loadItemsByTypeAndIds(this.modelType(), ids, { fields: ['share_id', 'id'] });
checkIfItemsCanBeChanged(this.modelType(), options.changeSource, previousItems, this.syncShareCache);
}
@ -338,6 +338,15 @@ export default class BaseItem extends BaseModel {
return r['total'];
}
public static async allItemsInTrash() {
const noteRows = await this.db().selectAll('SELECT id FROM notes WHERE deleted_time != 0');
const folderRows = await this.db().selectAll('SELECT id FROM folders WHERE deleted_time != 0');
return {
noteIds: noteRows.map(r => r.id),
folderIds: folderRows.map(r => r.id),
};
}
public static remoteDeletedItem(syncTarget: number, itemId: string) {
return this.db().exec('DELETE FROM deleted_items WHERE item_id = ? AND sync_target = ?', [itemId, syncTarget]);
}
@ -488,7 +497,7 @@ export default class BaseItem extends BaseModel {
// List of keys that won't be encrypted - mostly foreign keys required to link items
// with each others and timestamp required for synchronisation.
const keepKeys = ['id', 'note_id', 'tag_id', 'parent_id', 'share_id', 'updated_time', 'type_'];
const keepKeys = ['id', 'note_id', 'tag_id', 'parent_id', 'share_id', 'updated_time', 'deleted_time', 'type_'];
const reducedItem: any = {};
for (let i = 0; i < keepKeys.length; i++) {
@ -917,7 +926,7 @@ export default class BaseItem extends BaseModel {
const isNew = this.isNew(o, options);
if (needsReadOnlyChecks(this.modelType(), options.changeSource, this.syncShareCache)) {
if (needsShareReadOnlyChecks(this.modelType(), options.changeSource, this.syncShareCache)) {
if (!isNew) {
const previousItem = await this.loadItemByTypeAndId(this.modelType(), o.id, { fields: ['id', 'share_id'] });
checkIfItemCanBeChanged(this.modelType(), options.changeSource, previousItem, this.syncShareCache);