Skip to content

Commit

Permalink
fix: error when merge conflic
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisandra-dev committed Apr 1, 2024
1 parent 0bc7c1b commit c78c0fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
7 changes: 3 additions & 4 deletions src/GitHub/upload.ts
Expand Up @@ -31,6 +31,7 @@ import {
logs,
noticeMobile,
notif,
notifError,
} from "../utils";
import {
checkEmptyConfiguration,
Expand All @@ -39,7 +40,7 @@ import {
isAttachment,
isShared,
} from "../utils/data_validation_test";
import { ERROR_ICONS, LOADING_ICON } from "../utils/icons";
import { LOADING_ICON } from "../utils/icons";
import { frontmatterFromFile, getFrontmatterSettings, getRepoFrontmatter } from "../utils/parse_frontmatter";
import { ShareStatusBar } from "../utils/status_bar";
import { deleteFromGithub } from "./delete";
Expand Down Expand Up @@ -146,9 +147,7 @@ export default class Publisher {
statusBar.finish(8000);
} catch (e) {
logs({ settings: this.settings, e: true }, e);
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 });
notifError(repoFrontmatter);
statusBar.error(repoFrontmatter);
}
}
Expand Down
18 changes: 4 additions & 14 deletions src/commands/index.ts
Expand Up @@ -11,7 +11,7 @@ import {
createListEdited,
getSettingsOfMetadataExtractor,
logs,
notif, publisherNotification} from "../utils";
notif, notifError, publisherNotification} from "../utils";
import {checkRepositoryValidityWithRepoFrontmatter} from "../utils/data_validation_test";
import { frontmatterFromFile, getRepoFrontmatter } from "../utils/parse_frontmatter";
import { ShareStatusBar } from "../utils/status_bar";
Expand Down Expand Up @@ -102,11 +102,7 @@ export async function shareAllMarkedNotes(
new ListChangedFiles(PublisherManager.plugin.app, listEdited).open();
}
} else {
const errorFrag = document.createDocumentFragment();
errorFrag.createSpan({ cls: ["error", "obsidian-publisher", "icons", "notification"]}).innerHTML = ERROR_ICONS;
errorFrag.createSpan({ cls: ["error", "obsidian-publisher", "notification"] }).innerHTML = i18next.t("error.errorPublish", { repo: repoFrontmatter });

new Notice(errorFrag);
notifError(repoFrontmatter);
}
}
} catch (error) {
Expand Down Expand Up @@ -234,19 +230,13 @@ export async function shareOneNote(
}

} else {
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 });
new Notice(notif);
notifError(repoFrontmatter);
}
}
} catch (error) {
if (!(error instanceof DOMException)) {
logs({settings, e: true}, 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: getRepoFrontmatter(settings, repository, frontmatter) });
new Notice(notif);
notifError(getRepoFrontmatter(settings, repository, frontmatter));
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/utils/index.ts
Expand Up @@ -15,7 +15,7 @@ import {
MultiRepoProperties,
RepoFrontmatter, TOKEN_PATH,
UploadedFiles} from "../settings/interface";
import { HOURGLASS_ICON, SUCCESS_ICON } from "./icons";
import { ERROR_ICONS, HOURGLASS_ICON, SUCCESS_ICON } from "./icons";
import { frontmatterFromFile } from "./parse_frontmatter";

type LogsParameters = {
Expand Down Expand Up @@ -330,6 +330,16 @@ export async function publisherNotification(
}
}

export function notifError(repoFrontmatter: RepoFrontmatter | RepoFrontmatter[]) {
const repo = Array.isArray(repoFrontmatter) ? repoFrontmatter : [repoFrontmatter];
for (const repository of repo) {
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: repository });
new Notice(notif);
}
}

/**
* Create a notice message for the sharing ; the message can be delayed if a workflow is used.
* @param {Publisher} PublisherManager
Expand Down

0 comments on commit c78c0fe

Please sign in to comment.