From 58863b01677d2f71015defdf437a442275af38f8 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Tue, 7 Nov 2023 11:09:37 +0200 Subject: Added some quality of life changes like hitting esc would hide the ui and solved a bug where the UI wouldn't showup after calling summarize and other commands --- src/components/OllamaCommandPallete.tsx | 17 +++++++++++++++++ src/components/PromptAI.tsx | 1 + 2 files changed, 18 insertions(+) diff --git a/src/components/OllamaCommandPallete.tsx b/src/components/OllamaCommandPallete.tsx index d48d392..0ee8097 100644 --- a/src/components/OllamaCommandPallete.tsx +++ b/src/components/OllamaCommandPallete.tsx @@ -17,12 +17,15 @@ export function OllamaCommandPallete({ options, theme }: { options: string[], th setIsEnterPressed(true); switch (selection) { case "divide into subtasks": + logseq.hideMainUI() DivideTaskIntoSubTasks() break; case "summarize": + logseq.hideMainUI() summarize() break; case "convert to flash card": + logseq.hideMainUI() convertToFlashCard() break; default: @@ -30,6 +33,20 @@ export function OllamaCommandPallete({ options, theme }: { options: string[], th } } + useEffect(() => { + const handleEsc = (e: any) => { + if (e.key === 'Escape') { + logseq.hideMainUI() + } + }; + + window.addEventListener('keydown', handleEsc); + + return () => { + window.removeEventListener('keydown', handleEsc); + }; + }, []); + if (isEnterPressed && (selection !== 'ask ai' && selection !== 'define' && selection !== 'ask with context')) { return null } diff --git a/src/components/PromptAI.tsx b/src/components/PromptAI.tsx index 0b87917..adae2f9 100644 --- a/src/components/PromptAI.tsx +++ b/src/components/PromptAI.tsx @@ -10,6 +10,7 @@ export const PromptAI = ({ type, theme }: { type: string, theme: string }) => { useEffect(() => { if (hitEnter) { + logseq.hideMainUI() if (type === 'ask ai') { askAI(inputValue) } else if (type === 'define') { -- cgit v1.2.3