diff --git a/src/sync-manager.ts b/src/sync-manager.ts index 440f137..a639ee9 100644 --- a/src/sync-manager.ts +++ b/src/sync-manager.ts @@ -1,4 +1,4 @@ -import { Vault, normalizePath, base64ToArrayBuffer } from "obsidian"; +import { Vault, Notice, normalizePath, base64ToArrayBuffer } from "obsidian"; import GithubClient, { GetTreeResponseItem, NewTreeRequestItem, @@ -262,12 +262,19 @@ export default class SyncManager { return; } + const notice = new Notice("Syncing..."); this.syncing = true; try { await this.syncImpl(); - } finally { - this.syncing = false; + // Shown only if sync doesn't fail + new Notice("Sync successful", 5000); + } catch (err) { + // Show the error to the user, it's not automatically dismissed to make sure + // the user sees it. + new Notice(`Error syncing. ${err}`); } + this.syncing = false; + notice.hide(); } private async syncImpl() {