Hover preview tweak
This commit is contained in:
@@ -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 <LoadingIndicator />;
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user