From c5dd498a9ac3452b049ab05fd40322e374241346 Mon Sep 17 00:00:00 2001 From: Mara Date: Mon, 1 Apr 2024 01:49:31 +0200 Subject: [PATCH] fix: notification without proper name --- src/GitHub/upload.ts | 10 +++++----- src/commands/index.ts | 2 +- src/utils/status_bar.ts | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/GitHub/upload.ts b/src/GitHub/upload.ts index 696b89a6..1ae2edbe 100644 --- a/src/GitHub/upload.ts +++ b/src/GitHub/upload.ts @@ -39,7 +39,7 @@ import { isAttachment, isShared, } from "../utils/data_validation_test"; -import { LOADING_ICON } from "../utils/icons"; +import { ERROR_ICONS, LOADING_ICON } from "../utils/icons"; import { frontmatterFromFile, getFrontmatterSettings, getRepoFrontmatter } from "../utils/parse_frontmatter"; import { ShareStatusBar } from "../utils/status_bar"; import { deleteFromGithub } from "./delete"; @@ -146,10 +146,10 @@ export default class Publisher { statusBar.finish(8000); } catch (e) { logs({ settings: this.settings, e: true }, e); - new Notice( - (i18next.t("error.errorPublish", { repo: repoFrontmatter })) - ); - statusBar.error(); + const notif = document.createDocumentFragment(); + notif.createSpan({ cls: ["error", "obsidian-publisher", "icons", "notification"] }).innerHTML = ERROR_ICONS; + notif.createSpan({ cls: ["error", "obsidian-publisher", "notification"] }).innerHTML = i18next.t("error.errorPublish", { repo: repoFrontmatter }); + statusBar.error(repoFrontmatter); } } return { diff --git a/src/commands/index.ts b/src/commands/index.ts index 31a0ab58..5da9cb59 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -114,7 +114,7 @@ export async function shareAllMarkedNotes( const errorFrag = document.createDocumentFragment(); errorFrag.createSpan({ cls: ["error", "obsidian-publisher", "icons", "notification"] }).innerHTML = ERROR_ICONS; errorFrag.createSpan({ cls: ["error", "obsidian-publisher", "notification"], text: i18next.t("error.unablePublishMultiNotes") }); - statusBar.error(); + statusBar.error(repoFrontmatter); } } diff --git a/src/utils/status_bar.ts b/src/utils/status_bar.ts index 595c5745..713936ad 100644 --- a/src/utils/status_bar.ts +++ b/src/utils/status_bar.ts @@ -1,6 +1,7 @@ import i18next from "i18next"; import { Notice } from "obsidian"; +import { RepoFrontmatter } from "../settings/interface"; import { noticeMobile } from "."; import { ERROR_ICONS, FOUND_ATTACHMENTS, HOURGLASS_ICON, SUCCESS_ICON } from "./icons"; @@ -106,12 +107,12 @@ export class ShareStatusBar { * Remove the status bar if error occurs */ - error() { + error(repoFrontmatter: RepoFrontmatter) { this.statusBarItem.addClass("error"); this.statusBarItem.removeClass("sharing"); this.statusBarItem.removeClass("found-attachments"); this.icon.innerHTML = ERROR_ICONS; - this.status.innerHTML = i18next.t("error.errorPublish"); + this.status.innerHTML = i18next.t("error.errorPublish", {repo: repoFrontmatter}); this.noticeMobile?.hide(); setTimeout(() => { this.statusBarItem.remove();