From 13ee4897d16bc5df99709888d5a456b22e505b83 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Wed, 6 Mar 2024 19:43:30 +0100 Subject: [PATCH 1/5] Fix: #71 Suppress error: There is no Data to export --- CHANGELOG.md | 2 ++ src/Backup.ts | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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 }; From 4b92f21c4e05c0432baf93416bc99b3ea343d5f2 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:01:18 +0100 Subject: [PATCH 2/5] FAQ: Import backup to speed up sync --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e626475..cc3a0c1 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,12 @@ Profiles that are not active are not backed up, even if a backup has been config Yes, the build-in version only gets updates with Joplin updates, but can be replaced as described in the [Installation](#installation) step. +### Can I use a Backup to speed up first Joplin sync? + +No, because new IDs are assigned in Joplin during the import. +If this device is then synchronized with a synchronization target in which other clients already synchronize with the same notes, all notes are then available multiple times on the devices. +Therefore, the same note is then available with different IDs in Joplin. + ## Changelog See [CHANGELOG.md](CHANGELOG.md) From 871c5799fdf3491bb14573c5b1cc06a9964732f5 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:27:14 +0100 Subject: [PATCH 3/5] Fix test after isThereData implementation --- __test__/backup.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/__test__/backup.test.ts b/__test__/backup.test.ts index 2f3f9f4..4101b1f 100644 --- a/__test__/backup.test.ts +++ b/__test__/backup.test.ts @@ -29,6 +29,7 @@ let spyOnLogError = null; let spyOnShowError = null; let spyOnSaveBackupInfo = null; let spyOnDataGet = null; +let spyOnIsThereData = null; const spyOnsSettingsValue = jest.spyOn(joplin.settings, "value"); const spyOnGlobalValue = jest.spyOn(joplin.settings, "globalValue"); @@ -1119,6 +1120,15 @@ describe("Backup", function () { }); describe("create backup readme", () => { + beforeEach(async () => { + spyOnIsThereData = jest + .spyOn(backup, "isThereData") + .mockImplementation(() => Promise.resolve(true)); + }); + afterEach(async () => { + spyOnIsThereData.mockRestore(); + }); + it.each([ { backupRetention: 1, createSubfolderPerProfile: false }, { backupRetention: 2, createSubfolderPerProfile: false }, From f8f51fe51888fc1598b62367f03a7fa8995fec76 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Sun, 10 Mar 2024 12:07:19 +0100 Subject: [PATCH 4/5] Remove links --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index cc3a0c1..6e3fdd2 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ A plugin to extend Joplin with a manual and automatic backup function. - [Are Note History Revisions backed up?](#are-note-history-revisions-backed-up) - [Are all Joplin profiles backed up?](#are-all-joplin-profiles-backed-up) - [The Joplin build-in version of the plugin cannot be updated](#the-joplin-build-in-version-of-the-plugin-cannot-be-updated) + - [Can I use a Backup to speed up first Joplin sync?](#can-i-use-a-backup-to-speed-up-first-joplin-sync) - [Changelog](#changelog) -- [Links](#links) @@ -155,10 +155,3 @@ Therefore, the same note is then available with different IDs in Joplin. ## Changelog See [CHANGELOG.md](CHANGELOG.md) - -## Links - -- [Joplin - Getting started with plugin development](https://joplinapp.org/api/get_started/plugins/) -- [Joplin - Plugin API reference](https://joplinapp.org/api/references/plugin_api/classes/joplin.html) -- [Joplin - Data API reference](https://joplinapp.org/api/references/rest_api/) -- [Joplin - Plugin examples](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins) From ec89e4a7048515e461f621ccc71eacbdd7d36225 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Sun, 10 Mar 2024 12:10:11 +0100 Subject: [PATCH 5/5] bump version 1.4.1 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- src/manifest.json | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4aa9722..ba14d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## not released +## v1.4.1 (2024-03-10) + - Fix: Don't show `There is no Data to export` on empty profiles and automatic backups #71 ## v1.4.0 (2024-02-22) diff --git a/package-lock.json b/package-lock.json index bc4f08a..dc5cd8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "joplin-plugin-backup", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "joplin-plugin-backup", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "dependencies": { "@types/i18n": "^0.13.6", diff --git a/package.json b/package.json index 7c29698..35ce947 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "joplin-plugin-backup", - "version": "1.4.0", + "version": "1.4.1", "scripts": { "dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive", "prepare": "npm run dist && husky install", diff --git a/src/manifest.json b/src/manifest.json index 0af6002..4075dc9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 1, "id": "io.github.jackgruber.backup", "app_min_version": "2.1.3", - "version": "1.4.0", + "version": "1.4.1", "name": "Backup", "description": "Plugin to create manual and automatic backups.", "author": "JackGruber",