diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f4c945..4aa9722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## not released +- Fix: Don't show `There is no Data to export` on empty profiles and automatic backups #71 + ## v1.4.0 (2024-02-22) - Changes that are required for the Joplin default plugin diff --git a/src/Backup.ts b/src/Backup.ts index 183b3b7..91d6c79 100644 --- a/src/Backup.ts +++ b/src/Backup.ts @@ -504,6 +504,14 @@ class Backup { } public async start(showDoneMsg: boolean = false) { + // Prevent error message for empty profile on automatic backup + // https://github.com/JackGruber/joplin-plugin-backup/issues/71 + // https://github.com/laurent22/joplin/issues/10046 + if (showDoneMsg == false && (await this.isThereData()) === false) { + this.log.warn(`Empty Joplin profile (No notes), skipping backup`); + return; + } + if (this.backupStartTime === null) { this.backupStartTime = new Date(); @@ -1281,6 +1289,22 @@ class Backup { }); return true; } + + private async isThereData(): Promise { + let check = await joplin.data.get(["notes"], { + fields: "title, id, updated_time", + order_by: "updated_time", + order_dir: "DESC", + limit: 1, + page: 1, + }); + + if (check.items.length > 0) { + return true; + } else { + return false; + } + } } export { Backup, i18n };