add status bar indicator for compeltion

This commit is contained in:
celeste 2023-03-13 02:14:13 -07:00
parent 15b9487373
commit 3efdab908c

10
main.ts
View file

@ -59,6 +59,7 @@ export default class LoomPlugin extends Plugin {
editor: Editor;
view: LoomView;
statusBarItem: HTMLElement;
openai: OpenAIApi;
@ -96,6 +97,10 @@ export default class LoomPlugin extends Plugin {
this.setOpenAI();
this.statusBarItem = this.addStatusBarItem();
this.statusBarItem.setText("Completing...");
this.statusBarItem.style.display = "none";
this.addCommand({
id: "loom-complete",
name: "Complete",
@ -752,6 +757,8 @@ export default class LoomPlugin extends Plugin {
if (!file) return;
// TODO add async support to withFile and wftsar, so `complete` can be wrapped
this.statusBarItem.style.display = "inline-flex";
const state = this.state[file.path];
let prompt = this.fullText(state.current, state);
@ -795,6 +802,7 @@ export default class LoomPlugin extends Plugin {
"Unknown OpenAI API error: " + e.response.data.error.message
);
this.statusBarItem.style.display = "none";
return;
}
@ -823,6 +831,8 @@ export default class LoomPlugin extends Plugin {
this.save();
this.view.render();
this.statusBarItem.style.display = "none";
}
fullText(id: string, state: NoteState) {