fix: add context menu to individual attachments if > 1 attached (#348)

This commit is contained in:
3nt3
2021-10-31 22:25:33 +01:00
committed by GitHub
parent aa13e9d96f
commit b09ccd90ba
3 changed files with 71 additions and 19 deletions

View File

@@ -2,6 +2,7 @@ import { Attachment as AttachmentI } from "revolt-api/types/Autumn";
import styles from "./Attachment.module.scss";
import classNames from "classnames";
import { attachContextMenu } from "preact-context-menu";
import { useContext, useState } from "preact/hooks";
import { useIntermediate } from "../../../../context/intermediate/Intermediate";
@@ -9,9 +10,9 @@ import { AppContext } from "../../../../context/revoltjs/RevoltClient";
import AttachmentActions from "./AttachmentActions";
import { SizedGrid } from "./Grid";
import ImageFile from "./ImageFile";
import Spoiler from "./Spoiler";
import TextFile from "./TextFile";
import ImageFile from "./ImageFile";
interface Props {
attachment: AttachmentI;
@@ -37,11 +38,18 @@ export default function Attachment({ attachment, hasContent }: Props) {
<SizedGrid
width={metadata.width}
height={metadata.height}
onContextMenu={attachContextMenu("Menu", {
attachment: attachment,
})}
className={classNames({
[styles.margin]: hasContent,
spoiler,
})}>
<ImageFile attachment={attachment} width={metadata.width} height={metadata.height} />
<ImageFile
attachment={attachment}
width={metadata.width}
height={metadata.height}
/>
{spoiler && <Spoiler set={setSpoiler} />}
</SizedGrid>
);