missed one of the context menus

This commit is contained in:
Michael Peters 2021-12-30 21:06:32 -06:00
parent e8ca0d0ed4
commit ca7c683526

View File

@ -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<ImageOverlayProps> = (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 (
<ImageContextMenu
@ -35,12 +34,7 @@ const ImageOverlay: FC<ImageOverlayProps> = (props: ImageOverlayProps) => {
resourceName={resourceName} resourceBuff={resource.data} isPreview={false}
/>
);
}, [ resource, relativeToPos, resourceName ]);
const onContextMenu = useCallback((event: MouseEvent<HTMLImageElement>) => {
setRelativeToPos({ x: event.clientX, y: event.clientY });
toggleContextMenu();
}, [ toggleContextMenu ]);
}, [ resource, resourceName ]);
const sizeText = useMemo(() => resource ? ElementsUtil.humanSize(resource.data.length) : 'Loading Size...', [ resource ]);