Skip to content

Commit

Permalink
fix: commands with force not array was, in fact, array.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jan 18, 2024
1 parent e22cf01 commit 0435ffc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/commands/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import i18next from "i18next";
import {Command, Notice } from "obsidian";

import GithubPublisher from "../main";
import {MonoRepoProperties, MultiRepoProperties, RepoFrontmatter, Repository} from "../settings/interface";
import {MonoRepoProperties, MultiRepoProperties, Repository} from "../settings/interface";
import {createLink, logs} from "../utils";
import {checkRepositoryValidity, isShared} from "../utils/data_validation_test";
import { getRepoFrontmatter } from "../utils/parse_frontmatter";
Expand Down Expand Up @@ -78,9 +78,10 @@ export async function purgeNotesRemoteCallback(plugin: GithubPublisher, repo: Re
//@ts-ignore
callback: async () => {
logs({settings: plugin.settings}, "Enabling purge command");
const frontmatter = getRepoFrontmatter(plugin.settings, repo);
const monoRepo: MonoRepoProperties = {
frontmatter: getRepoFrontmatter(plugin.settings, repo) as RepoFrontmatter,
repo: repo,
frontmatter: Array.isArray(frontmatter) ? frontmatter[0] : frontmatter,
repo,
};
//@ts-ignore
const publisher = await plugin.reloadOctokit();
Expand Down
13 changes: 8 additions & 5 deletions src/commands/plugin_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import i18next from "i18next";
import { Notice } from "obsidian";

import GithubPublisher from "../main";
import {MonoRepoProperties, MultiRepoProperties, RepoFrontmatter, Repository} from "../settings/interface";
import {MonoRepoProperties, MultiRepoProperties, Repository} from "../settings/interface";
import {createLink} from "../utils";
import {checkRepositoryValidity, isShared} from "../utils/data_validation_test";
import { getRepoFrontmatter } from "../utils/parse_frontmatter";
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function deleteCommands(plugin : GithubPublisher, repo: Repository
const repoFrontmatter = getRepoFrontmatter(plugin.settings, repo);
const publisher = await plugin.reloadOctokit();
const mono: MonoRepoProperties = {
frontmatter: repoFrontmatter as RepoFrontmatter,
frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter,
repo
};
await purgeNotesRemote(
Expand All @@ -106,8 +106,9 @@ export async function uploadAllNotes(plugin: GithubPublisher, repo: Repository |
const statusBarItems = plugin.addStatusBarItem();
const publisher = await plugin.reloadOctokit();
const sharedFiles = publisher.getSharedFiles(repo);
const repoFrontmatter = getRepoFrontmatter(plugin.settings, repo);
const mono: MonoRepoProperties = {
frontmatter: getRepoFrontmatter(plugin.settings, repo) as RepoFrontmatter,
frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter,
repo
};
await shareAllMarkedNotes(
Expand All @@ -131,11 +132,12 @@ export async function uploadAllNotes(plugin: GithubPublisher, repo: Repository |

export async function uploadNewNotes(plugin: GithubPublisher, branchName: string, repo: Repository|null): Promise<void> {
const publisher = await plugin.reloadOctokit();
const repoFrontmatter = getRepoFrontmatter(plugin.settings, repo);
await shareNewNote(
publisher,
branchName,
{
frontmatter: getRepoFrontmatter(plugin.settings, repo) as RepoFrontmatter,
frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter,
repo
} as MonoRepoProperties,
);
Expand Down Expand Up @@ -193,11 +195,12 @@ export async function uploadAllEditedNotes(plugin: GithubPublisher ,branchName:
*/
export async function shareEditedOnly(branchName: string, repo: Repository|null, plugin: GithubPublisher) {
const publisher = await plugin.reloadOctokit();
const repoFrontmatter = getRepoFrontmatter(plugin.settings, repo);
await shareOnlyEdited(
publisher,
branchName,
{
frontmatter: getRepoFrontmatter(plugin.settings, repo) as RepoFrontmatter,
frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter,
repo
} as MonoRepoProperties,
);
Expand Down

0 comments on commit 0435ffc

Please sign in to comment.