mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
Merge branch 'master' of https://gitlab.insrt.uk/revolt/revite
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { Attachment, EmbedImage } from "revolt.js/dist/api/objects";
|
||||
import {
|
||||
Attachment,
|
||||
AttachmentMetadata,
|
||||
EmbedImage,
|
||||
} from "revolt.js/dist/api/objects";
|
||||
|
||||
import styles from "./ImageViewer.module.scss";
|
||||
import { useContext, useEffect } from "preact/hooks";
|
||||
@@ -15,6 +19,8 @@ interface Props {
|
||||
attachment?: Attachment;
|
||||
}
|
||||
|
||||
type ImageMetadata = AttachmentMetadata & { type: "Image" };
|
||||
|
||||
export function ImageViewer({ attachment, embed, onClose }: Props) {
|
||||
// ! FIXME: temp code
|
||||
// ! add proxy function to client
|
||||
@@ -22,7 +28,10 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
|
||||
return "https://jan.revolt.chat/proxy?url=" + encodeURIComponent(url);
|
||||
}
|
||||
|
||||
if (attachment?.metadata.type !== "Image") {
|
||||
if (attachment && attachment.metadata.type !== "Image") {
|
||||
console.warn(
|
||||
`Attempted to use a non valid attatchment type in the image viewer: ${attachment.metadata.type}`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,8 +44,10 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
|
||||
<>
|
||||
<img
|
||||
src={client.generateFileURL(attachment)}
|
||||
width={attachment.metadata.width}
|
||||
height={attachment.metadata.height}
|
||||
width={(attachment.metadata as ImageMetadata).width}
|
||||
height={
|
||||
(attachment.metadata as ImageMetadata).height
|
||||
}
|
||||
/>
|
||||
<AttachmentActions attachment={attachment} />
|
||||
</>
|
||||
@@ -45,8 +56,8 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
|
||||
<>
|
||||
<img
|
||||
src={proxyImage(embed.url)}
|
||||
width={attachment.metadata.width}
|
||||
height={attachment.metadata.height}
|
||||
width={embed.width}
|
||||
height={embed.height}
|
||||
/>
|
||||
<EmbedMediaActions embed={embed} />
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user