Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: re-enable trash auto cleanup after 7 days

thecodrrbb41b8c9cbe5
diff --git a/packages/core/api/index.js b/packages/core/api/index.js
index 7303c3e7b..583fca928 100644
--- a/packages/core/api/index.js
+++ b/packages/core/api/index.js
@@ -83,6 +83,7 @@ class Database {
this.trash = new Trash(this);
+ await this.trash.cleanup();
await this.settings.init();
await this.outbox.init();
await this.user.init();
diff --git a/packages/core/collections/trash.js b/packages/core/collections/trash.js
index 89d136794..4d70ddc3b 100644
--- a/packages/core/collections/trash.js
+++ b/packages/core/collections/trash.js
@@ -19,14 +19,18 @@ export default class Trash {
// await this.cleanup();
// }
- // async cleanup() {
- // const sevenDayPreviousTimestamp = Date.now() - get7DayTimestamp();
- // this.all.forEach(async (item) => {
- // if (item.dateDeleted < sevenDayPreviousTimestamp) {
- // await this.delete(item.id);
- // }
- // });
- // }
+ async init() {
+ await this.cleanup();
+ }
+
+ async cleanup() {
+ const sevenDayPreviousTimestamp = Date.now() - get7DayTimestamp();
+ this.all.forEach(async (item) => {
+ if (item.dateDeleted < sevenDayPreviousTimestamp) {
+ await this.delete(item.id);
+ }
+ });
+ }
get all() {
let trashItems = [];