diff --git a/src/components/common/messaging/attachments/Attachment.tsx b/src/components/common/messaging/attachments/Attachment.tsx index d3a9980e..ca219c56 100644 --- a/src/components/common/messaging/attachments/Attachment.tsx +++ b/src/components/common/messaging/attachments/Attachment.tsx @@ -2,7 +2,6 @@ import { Attachment as AttachmentRJS } from "revolt.js/dist/api/objects"; import styles from "./Attachment.module.scss"; import classNames from "classnames"; -import { Text } from "preact-i18n"; import { useContext, useState } from "preact/hooks"; import { useIntermediate } from "../../../../context/intermediate/Intermediate"; @@ -11,6 +10,7 @@ import { AppContext } from "../../../../context/revoltjs/RevoltClient"; import AttachmentActions from "./AttachmentActions"; import TextFile from "./TextFile"; import { SizedGrid } from "./Grid"; +import Spoiler from "./Spoiler"; interface Props { attachment: AttachmentRJS; @@ -24,7 +24,6 @@ export default function Attachment({ attachment, hasContent }: Props) { const { openScreen } = useIntermediate(); const { filename, metadata } = attachment; const [spoiler, setSpoiler] = useState(filename.startsWith("SPOILER_")); - const [loaded, setLoaded] = useState(false); const url = client.generateFileURL( attachment, @@ -36,7 +35,7 @@ export default function Attachment({ attachment, hasContent }: Props) { case "Image": { return ( + className={classNames({ [styles.margin]: hasContent, spoiler })}> {filename} ev.button === 1 && window.open(url, "_blank") } /> + { spoiler && } ) } + case "Video": { return (
- +
) } - - - - /*return ( -
spoiler && setSpoiler(false)}> - {spoiler && ( -
- - - -
- )} - {filename} metadata.height - ? styles.long - : styles.tall, - )} - style={{ - "--width": metadata.width, - "--height": metadata.height, - "--width-px": metadata.width + "px", - "--height-px": metadata.height + "px", - }} - onClick={() => - openScreen({ id: "image_viewer", attachment }) - } - onMouseDown={(ev) => - ev.button === 1 && window.open(url, "_blank") - } - onLoad={() => setLoaded(true)} - /> -
- ); - }*/ case "Audio": { return (
); } - /*case "Video": { - return ( -
spoiler && setSpoiler(false)}> - {spoiler && ( -
- - - -
- )} -
- -
-
- ); - }*/ + case "Text": { return (
); } + default: { return (
void +} + +export default function Spoiler({ set }: Props) { + return ( + set(false)}> + + + ) +} \ No newline at end of file