use readPath in ImageTile
This commit is contained in:
parent
0d3ab21044
commit
9745c58144
1 changed files with 9 additions and 6 deletions
|
@ -15,6 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {MessageTile} from "./MessageTile.js";
|
import {MessageTile} from "./MessageTile.js";
|
||||||
|
import {readPath, Type} from "../../../../../utils/validate.js";
|
||||||
|
|
||||||
const MAX_HEIGHT = 300;
|
const MAX_HEIGHT = 300;
|
||||||
const MAX_WIDTH = 400;
|
const MAX_WIDTH = 400;
|
||||||
|
@ -26,20 +27,22 @@ export class ImageTile extends MessageTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
get thumbnailUrl() {
|
get thumbnailUrl() {
|
||||||
const mxcUrl = this._getContent().url;
|
try {
|
||||||
if (mxcUrl) {
|
const mxcUrl = readPath(this._getContent(), ["url"], Type.String);
|
||||||
return this._room.mxcUrlThumbnail(mxcUrl, this.thumbnailWidth, this.thumbnailHeight, "scale");
|
return this._room.mxcUrlThumbnail(mxcUrl, this.thumbnailWidth, this.thumbnailHeight, "scale");
|
||||||
}
|
} catch (err) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get url() {
|
get url() {
|
||||||
const mxcUrl = this._getContent().url;
|
try {
|
||||||
if (mxcUrl) {
|
const mxcUrl = readPath(this._getContent(), ["url"], Type.String);
|
||||||
return this._room.mxcUrl(mxcUrl);
|
return this._room.mxcUrl(mxcUrl);
|
||||||
}
|
} catch (err) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_scaleFactor() {
|
_scaleFactor() {
|
||||||
const {info} = this._getContent();
|
const {info} = this._getContent();
|
||||||
|
|
Reference in a new issue