diff --git a/apps/extension/content/ContentApp.tsx b/apps/extension/content/ContentApp.tsx index d82857e2..217f72ff 100644 --- a/apps/extension/content/ContentApp.tsx +++ b/apps/extension/content/ContentApp.tsx @@ -137,35 +137,40 @@ export default function ContentApp({ shadowRoot.appendChild(portalDiv); setPortalContainer(portalDiv); - const getSpaces = async () => { - const response = await fetch(`${BACKEND_URL}/api/spaces`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - - if (response.status === 401) { - showLoginToast(); - return; - } - - try { - const data = await response.json(); - setSpacesOptions(data.data); - } catch (e) { - console.error( - `Error in supermemory.ai extension: ${e}. Please contact the developer https://x.com/dhravyashah`, - ); - } - }; - - getSpaces(); - return () => { document.removeEventListener("mousemove", () => {}); }; }, []); + const getSpaces = async () => { + const response = await fetch(`${BACKEND_URL}/api/spaces`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + + if (response.status === 401) { + showLoginToast(); + return; + } + + try { + const data = await response.json(); + setSpacesOptions(data.data); + } catch (e) { + console.error( + `Error in supermemory.ai extension: ${e}. Please contact the developer https://x.com/dhravyashah`, + ); + } + }; + + async function handlePopoverChange() { + setIsPopoverOpen(!isPopoverOpen); + if (isPopoverOpen) { + await getSpaces(); + } + } + async function sendUrlToAPI(spaces: string[]) { setLoading(true); @@ -243,7 +248,7 @@ export default function ContentApp({