Skip to content

Commit

Permalink
Fix: #71 Suppress error: There is no Data to export
Browse files Browse the repository at this point in the history
  • Loading branch information
JackGruber committed Mar 6, 2024
1 parent 2d814a5 commit 13ee489
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/Backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -1281,6 +1289,22 @@ class Backup {
});
return true;
}

private async isThereData(): Promise<boolean> {
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 };

0 comments on commit 13ee489

Please sign in to comment.