From ca7c6835261770fcdb1c058fab4df79a1a824b0a Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Thu, 30 Dec 2021 21:06:32 -0600 Subject: [PATCH] missed one of the context menus --- .../webapp/elements/overlays/overlay-image.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/client/webapp/elements/overlays/overlay-image.tsx b/src/client/webapp/elements/overlays/overlay-image.tsx index c994d1b..d71d170 100644 --- a/src/client/webapp/elements/overlays/overlay-image.tsx +++ b/src/client/webapp/elements/overlays/overlay-image.tsx @@ -3,11 +3,11 @@ const electronConsole = electronRemote.getGlobal('console') as Console; import Logger from '../../../../logger/logger'; const LOG = Logger.create(__filename, electronConsole); -import React, { FC, useMemo, useState, useRef, MouseEvent, useCallback } from 'react'; +import React, { FC, useMemo, useRef } from 'react'; import CombinedGuild from '../../guild-combined'; -import ElementsUtil from '../require/elements-util'; +import ElementsUtil, { IAlignment } from '../require/elements-util'; import DownloadButton from '../components/button-download'; -import ReactHelper from '../require/react-helper'; +import { useContextClickContextMenu } from '../require/react-helper'; import GuildSubscriptions from '../require/guild-subscriptions'; import ImageContextMenu from '../contexts/context-menu-image'; import Overlay from '../components/overlay'; @@ -26,8 +26,7 @@ const ImageOverlay: FC = (props: ImageOverlayProps) => { const [ imgSrc, resource, resourceError ] = GuildSubscriptions.useSoftImageSrcResourceSubscription(guild, resourceId); - const [ relativeToPos, setRelativeToPos ] = useState<{ x: number, y: number }>({ x: 0, y: 0 }); - const [ contextMenu, toggleContextMenu ] = ReactHelper.useContextMenu((close: () => void) => { + const [ contextMenu, onContextMenu ] = useContextClickContextMenu((alignment: IAlignment, relativeToPos: { x: number, y: number }, close: () => void) => { if (!resource) return null; return ( = (props: ImageOverlayProps) => { resourceName={resourceName} resourceBuff={resource.data} isPreview={false} /> ); - }, [ resource, relativeToPos, resourceName ]); - - const onContextMenu = useCallback((event: MouseEvent) => { - setRelativeToPos({ x: event.clientX, y: event.clientY }); - toggleContextMenu(); - }, [ toggleContextMenu ]); + }, [ resource, resourceName ]); const sizeText = useMemo(() => resource ? ElementsUtil.humanSize(resource.data.length) : 'Loading Size...', [ resource ]);