From bca7f91715b2ac116b1c6cee52cf645d7b9b6ad7 Mon Sep 17 00:00:00 2001 From: BiggerRain <15911122312@163.COM> Date: Fri, 29 Nov 2024 15:13:03 +0800 Subject: [PATCH] fix: clear last height (#29) --- src/components/SearchChat/Search.tsx | 13 ++++++++++--- src/components/SearchChat/index.tsx | 4 +--- src/hooks/useAutoResizeWindow.ts | 2 -- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/SearchChat/Search.tsx b/src/components/SearchChat/Search.tsx index 782346f..4c56d24 100644 --- a/src/components/SearchChat/Search.tsx +++ b/src/components/SearchChat/Search.tsx @@ -27,8 +27,8 @@ function Search({ isTransitioned, isChatMode, input }: SearchProps) { const resizeObserver = new ResizeObserver(async (entries) => { for (let entry of entries) { let newHeight = entry.contentRect.height; - newHeight = newHeight + 90 + (newHeight === 0 ? 0 : 46); console.log("Height updated:", newHeight); + newHeight = newHeight + 90 + (newHeight === 0 ? 0 : 46); await getCurrentWebviewWindow()?.setSize( new LogicalSize(680, newHeight) ); @@ -40,7 +40,7 @@ function Search({ isTransitioned, isChatMode, input }: SearchProps) { return () => { resizeObserver.disconnect(); }; - }, []); + }, [suggests]); const getSuggest = async () => { try { @@ -51,6 +51,13 @@ function Search({ isTransitioned, isChatMode, input }: SearchProps) { console.log("_suggest", input, response); const data = response.data?.hits?.hits || []; setSuggests(data); + // + // const list = []; + // for (let i = 0; i < input.length; i++) { + // list.push({}); + // } + // setSuggests(list); + // setIsSearchComplete(true); } catch (error) { console.error("Failed to fetch user data:", error); @@ -72,7 +79,7 @@ function Search({ isTransitioned, isChatMode, input }: SearchProps) { if (!input) setSuggests([]); }, [input]); - if (isChatMode || suggests.length === 0) return null; + // if (isChatMode || suggests.length === 0) return null; return (
- {isChatMode || !input ? null : ( + {isChatMode ? null : ( { try { // Resize the window to fit content size - - console.log(121212, contentHeight) await getCurrentWebviewWindow()?.setSize( new LogicalSize(680, contentHeight) );