From d8aede8a3dcab018cef15c8d4c01f161f0917796 Mon Sep 17 00:00:00 2001 From: Hyeonseo Nam Date: Sat, 6 May 2023 01:37:28 +0900 Subject: [PATCH] Fix toggle save and some error handlings --- src/main.ts | 6 +++--- src/settings.ts | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 064e03a..72f6b7b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -81,7 +81,7 @@ export default class AutoClassifierPlugin extends Plugin { // ------- [Input] ------- const refs = this.settings.commandOption.refs; // reference check - if (!refs || refs.length == 0) { + if (this.settings.commandOption.useRef && (!refs || refs.length == 0)) { new Notice(`⛔ ${this.manifest.name}: no reference tags`); return null } @@ -121,11 +121,11 @@ export default class AutoClassifierPlugin extends Plugin { const match = responseRaw.match(jsonRegex); let resOutput; let resReliabity; - if (match) { + if (match && match.length > 1) { resOutput = match[2]; resReliabity = parseFloat(match[1]); } else { - new Notice(`⛔ ${this.manifest.name}: output format error`); + new Notice(`⛔ ${this.manifest.name}: output format error (output: ${responseRaw})`); return null; } diff --git a/src/settings.ts b/src/settings.ts index e0ff083..f5525ad 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -172,6 +172,7 @@ export class AutoClassifierSettingTab extends PluginSettingTab { .setValue(commandOption.useRef) .onChange(async (value) => { commandOption.useRef = value; + await this.plugin.saveSettings(); this.display(); }), ); @@ -352,6 +353,7 @@ export class AutoClassifierSettingTab extends PluginSettingTab { .onChange(async (value) => { commandOption.overwrite = value; await this.plugin.saveSettings(); + this.display(); }) ); @@ -397,6 +399,7 @@ export class AutoClassifierSettingTab extends PluginSettingTab { .setValue(commandOption.useCustomCommand) .onChange(async (value) => { commandOption.useCustomCommand = value; + await this.plugin.saveSettings(); this.display(); }), );