Fix wrong assertions that all media events have a mimetype (#8946)

t3chguy/dedup-icons-17oct
Michael Telatynski 2022-06-30 14:35:40 +01:00 committed by GitHub
parent 7a80ea4bbe
commit bb859d5886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -380,7 +380,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
if (content.info?.w && content.info?.h) { if (content.info?.w && content.info?.h) {
infoWidth = content.info.w; infoWidth = content.info.w;
infoHeight = content.info.h; infoHeight = content.info.h;
infoSvg = content.info.mimetype.startsWith("image/svg"); infoSvg = content.info.mimetype === "image/svg+xml";
} else { } else {
// Whilst the image loads, display nothing. We also don't display a blurhash image // Whilst the image loads, display nothing. We also don't display a blurhash image
// because we don't really know what size of image we'll end up with. // because we don't really know what size of image we'll end up with.

View File

@ -16,7 +16,7 @@
import { arrayHasDiff } from "./arrays"; import { arrayHasDiff } from "./arrays";
export function mayBeAnimated(mimeType: string): boolean { export function mayBeAnimated(mimeType?: string): boolean {
// AVIF animation support at the time of writing is only available in Chrome hence not having `blobIsAnimated` check // AVIF animation support at the time of writing is only available in Chrome hence not having `blobIsAnimated` check
return ["image/gif", "image/webp", "image/png", "image/apng", "image/avif"].includes(mimeType); return ["image/gif", "image/webp", "image/png", "image/apng", "image/avif"].includes(mimeType);
} }
@ -34,7 +34,7 @@ function arrayBufferReadStr(arr: ArrayBuffer, start: number, len: number): strin
return String.fromCharCode.apply(null, arrayBufferRead(arr, start, len)); return String.fromCharCode.apply(null, arrayBufferRead(arr, start, len));
} }
export async function blobIsAnimated(mimeType: string, blob: Blob): Promise<boolean> { export async function blobIsAnimated(mimeType: string | undefined, blob: Blob): Promise<boolean> {
switch (mimeType) { switch (mimeType) {
case "image/webp": { case "image/webp": {
// Only extended file format WEBP images support animation, so grab the expected data range and verify header. // Only extended file format WEBP images support animation, so grab the expected data range and verify header.