Add error handler and improve coverage
This commit is contained in:
+13
@@ -87,6 +87,17 @@ export default class OllamaPlugin extends Plugin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Notify all open ChatView instances when settings change
|
||||
public notifyChatViews(): void {
|
||||
const leaves = this.app.workspace.getLeavesOfType('ollama-chat-view');
|
||||
leaves.forEach((leaf) => {
|
||||
const view = leaf.view as ChatView;
|
||||
if (view && view.onSettingsChange) {
|
||||
view.onSettingsChange(this.settings);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class OllamaSettingTab extends PluginSettingTab {
|
||||
@@ -115,6 +126,7 @@ class OllamaSettingTab extends PluginSettingTab {
|
||||
Logger.debug('URL changed to: ' + value, 'settings');
|
||||
this.plugin.settings.ollamaUrl = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.notifyChatViews();
|
||||
} else {
|
||||
Logger.warn('Invalid URL format: ' + urlValidation.error, 'settings');
|
||||
new Notice(urlValidation.error || 'Invalid Ollama URL format.');
|
||||
@@ -132,6 +144,7 @@ class OllamaSettingTab extends PluginSettingTab {
|
||||
Logger.debug('Model changed to: ' + value, 'settings');
|
||||
this.plugin.settings.model = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.notifyChatViews();
|
||||
} else {
|
||||
Logger.warn('Invalid model name format: ' + modelValidation.error, 'settings');
|
||||
new Notice(modelValidation.error || 'Invalid model name format.');
|
||||
|
||||
Reference in New Issue
Block a user