From 9745c58144549c8b205f35054880e8ba17e2c39f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Aug 2020 14:20:54 +0200 Subject: [PATCH] use readPath in ImageTile --- .../session/room/timeline/tiles/ImageTile.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/domain/session/room/timeline/tiles/ImageTile.js b/src/domain/session/room/timeline/tiles/ImageTile.js index bb9fb5d4..61746097 100644 --- a/src/domain/session/room/timeline/tiles/ImageTile.js +++ b/src/domain/session/room/timeline/tiles/ImageTile.js @@ -15,6 +15,7 @@ limitations under the License. */ import {MessageTile} from "./MessageTile.js"; +import {readPath, Type} from "../../../../../utils/validate.js"; const MAX_HEIGHT = 300; const MAX_WIDTH = 400; @@ -26,19 +27,21 @@ export class ImageTile extends MessageTile { } get thumbnailUrl() { - const mxcUrl = this._getContent().url; - if (mxcUrl) { + try { + const mxcUrl = readPath(this._getContent(), ["url"], Type.String); return this._room.mxcUrlThumbnail(mxcUrl, this.thumbnailWidth, this.thumbnailHeight, "scale"); + } catch (err) { + return null; } - return null; } get url() { - const mxcUrl = this._getContent().url; - if (mxcUrl) { + try { + const mxcUrl = readPath(this._getContent(), ["url"], Type.String); return this._room.mxcUrl(mxcUrl); + } catch (err) { + return null; } - return null; } _scaleFactor() {