From f699be971e72600f6ed6c3567d91cd6df8c6a7b4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 23 Sep 2020 11:02:41 +0100 Subject: [PATCH] Prepare AppTile to be usable outside of rooms for User Widgets Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/AppTile.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 6aaeab060f..f74f23c09d 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -104,6 +104,7 @@ export default class AppTile extends React.Component { const hasPermissionToLoad = () => { if (this._usingLocalWidget()) return true; + if (!newProps.room) return true; // user widgets always have permissions const currentlyAllowedWidgets = SettingsStore.getValue("allowedWidgets", newProps.room.roomId); return !!currentlyAllowedWidgets[newProps.app.eventId]; }; @@ -419,7 +420,9 @@ export default class AppTile extends React.Component { ActiveWidgetStore.delWidgetMessaging(this.props.app.id); this._setupWidgetMessaging(); - ActiveWidgetStore.setRoomId(this.props.app.id, this.props.room.roomId); + if (this.props.room) { + ActiveWidgetStore.setRoomId(this.props.app.id, this.props.room.roomId); + } this.setState({loading: false}); } @@ -589,7 +592,7 @@ export default class AppTile extends React.Component { const myUser = MatrixClientPeg.get().getUser(myUserId); const vars = Object.assign(targetData, this.props.app.data, { 'matrix_user_id': myUserId, - 'matrix_room_id': this.props.room.roomId, + 'matrix_room_id': this.props.room ? this.props.room.roomId : null, 'matrix_display_name': myUser ? myUser.displayName : myUserId, 'matrix_avatar_url': myUser ? MatrixClientPeg.get().mxcUrlToHttp(myUser.avatarUrl) : '', @@ -754,6 +757,7 @@ export default class AppTile extends React.Component { ); if (!this.state.hasPermissionToLoad) { + // only possible for room widgets, can assert this.props.room here const isEncrypted = MatrixClientPeg.get().isRoomEncrypted(this.props.room.roomId); appTileBody = (