Fix Boken Image & Sticker (#1455)

* fix image without info rendered as broken

* fix enc msg appear as decrypting after deletion
This commit is contained in:
Ajay Bura 2023-10-19 17:41:49 +11:00 committed by GitHub
parent c980fddfa1
commit b92b281050
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 43 deletions

View file

@ -1034,13 +1034,10 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
const content = mEvent.getContent<IImageContent>();
const imgInfo = content?.info;
const mxcUrl = content.file?.url ?? content.url;
if (!imgInfo || typeof imgInfo.mimetype !== 'string' || typeof mxcUrl !== 'string') {
if (mxcUrl) {
return fileRenderer(mEventId, mEvent);
}
if (typeof mxcUrl !== 'string') {
return null;
}
const height = scaleYDimension(imgInfo.w || 400, 400, imgInfo.h || 400);
const height = scaleYDimension(imgInfo?.w || 400, 400, imgInfo?.h || 400);
return (
<Attachment>
@ -1052,7 +1049,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
<ImageContent
body={content.body || 'Image'}
info={imgInfo}
mimeType={imgInfo.mimetype}
mimeType={imgInfo?.mimetype}
url={mxcUrl}
encInfo={content.file}
autoPlay={mediaAutoLoad}
@ -1309,6 +1306,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
>
<EncryptedContent mEvent={mEvent}>
{() => {
if (mEvent.isRedacted()) return <MessageDeletedContent />;
if (mEvent.getType() === MessageEvent.Sticker)
return <StickerContent mEvent={mEvent} autoPlay={mediaAutoLoad} />;
if (mEvent.getType() === MessageEvent.RoomMessage)