MCPcopy Create free account
hub / github.com/dailydotdev/apps / useImageViewer

Function useImageViewer

packages/shared/src/hooks/useImageViewer.ts:7–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { getImageOriginRect } from '../components/modals/ImageModal';
6
7export const useImageViewer = () => {
8 const { openModal } = useLazyModal();
9 const { isCompanion } = useRequestProtocol();
10
11 return useCallback(
12 (src: string, alt: string | undefined, originElement: Element) => {
13 if (isCompanion) {
14 window.open(src, '_blank', 'noopener,noreferrer');
15 return;
16 }
17
18 openModal({
19 type: LazyModal.ImageView,
20 props: {
21 src,
22 alt,
23 originRect: getImageOriginRect(originElement),
24 },
25 });
26 },
27 [isCompanion, openModal],
28 );
29};

Callers 2

MarkdownFunction · 0.90
PostImageFunction · 0.90

Calls 4

useLazyModalFunction · 0.90
useRequestProtocolFunction · 0.90
getImageOriginRectFunction · 0.90
openModalFunction · 0.85

Tested by

no test coverage detected