Skip to content

Commit

Permalink
fix: TypeError: settings.github.otherRepo is not iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li authored Jun 7, 2023
1 parent bb03108 commit 5a2d248
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class GithubPublisher extends Plugin {
}

cleanOldCommands() {
const allRepo:Repository[] = this.settings.github.otherRepo ?? [];
const allRepo:Repository[] = this.settings.github?.otherRepo ?? [];
//@ts-ignore
const allCommands = this.app.commands.listCommands();
for (const command of allCommands) {
Expand All @@ -99,7 +99,7 @@ export default class GithubPublisher extends Plugin {
async reloadCommands(branchName: string) {
//compare old and new repo to delete old commands
noticeLog("Reloading commands", this.settings);
const newRepo:Repository[] = this.settings.github.otherRepo ?? [];
const newRepo:Repository[] = this.settings.github?.otherRepo ?? [];
this.cleanOldCommands();
for (const repo of newRepo) {
if (repo.createShortcuts) {
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class GithubPublisherSettingsTab extends PluginSettingTab {
button
.setButtonText(i18next.t("settings.github.smartRepo.button"))
.onClick(async () => {
const repository: Repository[] = this.plugin.settings.github.otherRepo ? this.plugin.settings.github.otherRepo : [];
const repository: Repository[] = this.plugin.settings.github?.otherRepo ?? [];
new ModalAddingNewRepository(this.app, this.plugin.settings, this.branchName, this.plugin, repository, (result => {
this.plugin.settings.github.otherRepo = result;
this.plugin.saveSettings();
Expand Down
6 changes: 3 additions & 3 deletions src/settings/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {FolderSettings, GithubTiersVersion, TextCleaner, TypeOfEditRegex} from "
import GithubPublisher from "../main";
import {noticeLog} from "../src/utils";
import i18next from "i18next";
import settings from "../../tests/fixtures/githubPublisherSettings";

export interface OldSettings {
githubRepo: string;
Expand Down Expand Up @@ -187,8 +186,8 @@ export async function migrateSettings(old: OldSettings, plugin: GithubPublisher)
delete plugin.settings.github.worflow;
await plugin.saveSettings();
}
const otherRepo = plugin.settings.github.otherRepo ?? [];
for (const repo of plugin.settings.github.otherRepo) {
const otherRepo = plugin.settings.github?.otherRepo ?? [];
for (const repo of otherRepo) {
const workflow = {
//@ts-ignore
name: plugin.settings.github.worflow?.workflowName ?? plugin.settings.github.workflow.name,
Expand Down Expand Up @@ -221,4 +220,5 @@ export async function migrateSettings(old: OldSettings, plugin: GithubPublisher)
await plugin.saveSettings();
}
}
await plugin.saveSettings();
}

0 comments on commit 5a2d248

Please sign in to comment.