diff --git a/app/components/HoverPreview/HoverPreview.tsx b/app/components/HoverPreview/HoverPreview.tsx index 3374fdbe8..304f0c38a 100644 --- a/app/components/HoverPreview/HoverPreview.tsx +++ b/app/components/HoverPreview/HoverPreview.tsx @@ -17,7 +17,7 @@ import HoverPreviewDocument from "./HoverPreviewDocument"; import HoverPreviewLink from "./HoverPreviewLink"; import HoverPreviewMention from "./HoverPreviewMention"; -const DELAY_OPEN = 300; +const DELAY_OPEN = 500; const DELAY_CLOSE = 600; type Props = { @@ -126,18 +126,18 @@ function HoverPreviewInternal({ element, onClose }: Props) { useKeyDown("Escape", closePreview); useEventListener("scroll", closePreview, window, { capture: true }); - const stopCloseTimer = () => { + const stopCloseTimer = React.useCallback(() => { if (timerClose.current) { clearTimeout(timerClose.current); timerClose.current = undefined; } - }; + }, []); - const startOpenTimer = () => { + const startOpenTimer = React.useCallback(() => { if (!timerOpen.current) { timerOpen.current = setTimeout(() => setVisible(true), DELAY_OPEN); } - }; + }, []); const startCloseTimer = React.useCallback(() => { stopOpenTimer(); @@ -172,7 +172,7 @@ function HoverPreviewInternal({ element, onClose }: Props) { stopCloseTimer(); }; - }, [element, startCloseTimer, data]); + }, [element, startCloseTimer, data, startOpenTimer, stopCloseTimer]); if (loading) { return ; diff --git a/plugins/iframely/server/iframely.ts b/plugins/iframely/server/iframely.ts index 1c5c0cdea..f7989d973 100644 --- a/plugins/iframely/server/iframely.ts +++ b/plugins/iframely/server/iframely.ts @@ -1,3 +1,4 @@ +import { Day } from "@shared/utils/time"; import env from "@server/env"; import { InternalError } from "@server/errors"; import Logger from "@server/logging/Logger"; @@ -8,7 +9,7 @@ class Iframely { private static apiUrl = `${env.IFRAMELY_URL}/api`; private static apiKey = env.IFRAMELY_API_KEY; private static cacheKeyPrefix = "unfurl"; - private static defaultCacheExpiry = 86400; + private static defaultCacheExpiry = Day; private static cacheKey(url: string) { return `${this.cacheKeyPrefix}-${url}`;