From 3efdab908ce733dfe9c6ea14d4be8a79e7e43610 Mon Sep 17 00:00:00 2001 From: celeste Date: Mon, 13 Mar 2023 02:14:13 -0700 Subject: [PATCH] add status bar indicator for compeltion --- main.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.ts b/main.ts index 6885959..f17a8c6 100644 --- a/main.ts +++ b/main.ts @@ -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) {