From d482069a81a49e78c8f84200f7e5ce1693910ed0 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 10 Jul 2024 13:40:31 -0400 Subject: [PATCH] fix: Expected server HTML to contain a matching --- webapp/app/_components/add-screenshot-to-input.tsx | 6 +++--- webapp/app/_components/tools.tsx | 1 + webapp/app/settings/_components/status.section.tsx | 6 +++--- webapp/lib/is-in-desktop-app.ts | 11 +++++++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/webapp/app/_components/add-screenshot-to-input.tsx b/webapp/app/_components/add-screenshot-to-input.tsx index 047271f..921fcbb 100644 --- a/webapp/app/_components/add-screenshot-to-input.tsx +++ b/webapp/app/_components/add-screenshot-to-input.tsx @@ -36,8 +36,8 @@ export function AddScreenshotToInput({ addImageAttachments }: Props) { }, [toast, addImageAttachments]); - return ( - isLoading ? : - ); + return (<> + {isLoading ? : } + ); } diff --git a/webapp/app/_components/tools.tsx b/webapp/app/_components/tools.tsx index c4fe8c6..9818579 100644 --- a/webapp/app/_components/tools.tsx +++ b/webapp/app/_components/tools.tsx @@ -1,3 +1,4 @@ +'use client'; import { AddImageAttachments } from '@/lib/image-attachment.type'; import { AddScreenshotToInput } from './add-screenshot-to-input'; import { useIsInDesktopApp } from '@/lib/is-in-desktop-app'; diff --git a/webapp/app/settings/_components/status.section.tsx b/webapp/app/settings/_components/status.section.tsx index 1df4949..d21da03 100644 --- a/webapp/app/settings/_components/status.section.tsx +++ b/webapp/app/settings/_components/status.section.tsx @@ -1,17 +1,17 @@ 'use client'; import { Section } from '@/components/section'; import ServerStatus from './server-status'; -import { useIsInDesktopAppFn } from '@/lib/is-in-desktop-app'; +import { useIsInDesktopApp } from '@/lib/is-in-desktop-app'; import LocalServerSettings from './local-server-settings'; export default function StatusSection() { - const isInDesktopAppFn = useIsInDesktopAppFn(); + const isInDesktopApp = useIsInDesktopApp(); return (
- { isInDesktopAppFn() && } + { isInDesktopApp && }
); } diff --git a/webapp/lib/is-in-desktop-app.ts b/webapp/lib/is-in-desktop-app.ts index e8f3887..f390e7c 100644 --- a/webapp/lib/is-in-desktop-app.ts +++ b/webapp/lib/is-in-desktop-app.ts @@ -1,5 +1,5 @@ 'use client'; -import { useCallback } from 'react'; +import { useCallback, useEffect, useState } from 'react'; export function useIsInDesktopAppFn() { @@ -9,5 +9,12 @@ export function useIsInDesktopAppFn() { } export function useIsInDesktopApp() { - return useIsInDesktopAppFn()(); + const isInDesktopAppFn = useIsInDesktopAppFn(); + const [isInDesktopApp, setIsInDesktopApp] = useState(false); + + useEffect(() => { + setIsInDesktopApp(isInDesktopAppFn()); + }, [isInDesktopAppFn]); + + return isInDesktopApp; } \ No newline at end of file