Fix toggle save and some error handlings

This commit is contained in:
Hyeonseo Nam 2023-05-06 01:37:28 +09:00
parent eed824884a
commit d8aede8a3d
2 changed files with 6 additions and 3 deletions

View file

@ -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;
}

View file

@ -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();
}),
);