mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
core: run trash cleanup after sync completion
This commit is contained in:
@@ -286,7 +286,7 @@ class Sync {
|
||||
// refresh monographs
|
||||
await this.db.monographs.refresh().catch(this.logger.error);
|
||||
// update trash cache
|
||||
await this.db.trash.buildCache();
|
||||
await this.db.trash.cleanup();
|
||||
|
||||
this.logger.info("Stopping sync");
|
||||
await this.db.setLastSynced(Date.now());
|
||||
|
||||
@@ -55,7 +55,6 @@ export default class Trash {
|
||||
|
||||
async init() {
|
||||
await this.buildCache();
|
||||
await this.cleanup();
|
||||
}
|
||||
|
||||
async buildCache() {
|
||||
@@ -92,7 +91,11 @@ export default class Trash {
|
||||
const duration = this.db.settings.getTrashCleanupInterval();
|
||||
if (duration === -1 || !duration) return;
|
||||
|
||||
const maxMs = dayjs().subtract(duration, "days").toDate().getTime();
|
||||
const maxMs = dayjs()
|
||||
.startOf("day")
|
||||
.subtract(duration, "days")
|
||||
.toDate()
|
||||
.getTime();
|
||||
const expiredItems = await this.db
|
||||
.sql()
|
||||
.selectNoFrom((eb) => [
|
||||
@@ -120,6 +123,7 @@ export default class Trash {
|
||||
);
|
||||
|
||||
await this._delete(noteIds, notebookIds);
|
||||
await this.buildCache();
|
||||
}
|
||||
|
||||
async add(
|
||||
|
||||
Reference in New Issue
Block a user