Skip to content

Commit 13ee489

Browse files
committed
Fix: #71 Suppress error: There is no Data to export
1 parent 2d814a5 commit 13ee489

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## not released
44

5+
- Fix: Don't show `There is no Data to export` on empty profiles and automatic backups #71
6+
57
## v1.4.0 (2024-02-22)
68

79
- Changes that are required for the Joplin default plugin

src/Backup.ts

+24
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ class Backup {
504504
}
505505

506506
public async start(showDoneMsg: boolean = false) {
507+
// Prevent error message for empty profile on automatic backup
508+
// https://github.com/JackGruber/joplin-plugin-backup/issues/71
509+
// https://github.com/laurent22/joplin/issues/10046
510+
if (showDoneMsg == false && (await this.isThereData()) === false) {
511+
this.log.warn(`Empty Joplin profile (No notes), skipping backup`);
512+
return;
513+
}
514+
507515
if (this.backupStartTime === null) {
508516
this.backupStartTime = new Date();
509517

@@ -1281,6 +1289,22 @@ class Backup {
12811289
});
12821290
return true;
12831291
}
1292+
1293+
private async isThereData(): Promise<boolean> {
1294+
let check = await joplin.data.get(["notes"], {
1295+
fields: "title, id, updated_time",
1296+
order_by: "updated_time",
1297+
order_dir: "DESC",
1298+
limit: 1,
1299+
page: 1,
1300+
});
1301+
1302+
if (check.items.length > 0) {
1303+
return true;
1304+
} else {
1305+
return false;
1306+
}
1307+
}
12841308
}
12851309

12861310
export { Backup, i18n };

0 commit comments

Comments
 (0)