mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 06:50:28 +03:00
feat(message): prioritize thumbnail loading with fallback to original image
When viewing messages, thumbnails are loaded first, if loading fails, the original image is loaded as a fallback.
This commit is contained in:
parent
abd713d693
commit
0a659e174c
3 changed files with 38 additions and 6 deletions
|
|
@ -184,13 +184,32 @@ export function RenderMessageContent({
|
|||
}
|
||||
|
||||
if (msgType === MsgType.Image) {
|
||||
const content: IImageContent = getContent();
|
||||
const width = content?.info?.w;
|
||||
const height = content?.info?.h;
|
||||
let thumbnail: {
|
||||
imgWidth: number,
|
||||
imgHeight: number,
|
||||
resizeMethod: string
|
||||
} | undefined;
|
||||
if (width && height) {
|
||||
const scale = (width > height ? width : height) / 800;
|
||||
if (width > 800 || height > 800 && scale > 1) {
|
||||
thumbnail = {
|
||||
imgWidth: width / scale,
|
||||
imgHeight: height / scale,
|
||||
resizeMethod: "scale",
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<MImage
|
||||
content={getContent()}
|
||||
content={content}
|
||||
renderImageContent={(props) => (
|
||||
<ImageContent
|
||||
{...props}
|
||||
{...thumbnail}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue