Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Users should always be able to edit their user/non-room widgets #1879

Merged
merged 4 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/views/elements/AppTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ export default class AppTile extends React.Component {
}

_canUserModify() {
// User widgets should always be modifiable by their creator
if (this.props.userWidget && MatrixClientPeg.get().credentials.userId === this.props.creatorUserId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recently been pointed to get the MatrixClient instance over React Contexts, probably worth pointing out here also

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out @t3chguy. Having spoken with @dbkr about this, it appears that passing context to the context-menus is a little complicated. So, for the time being we've chosen to leave this as is (I will bear it in mind in future though). Cheers.

return true;
}
// Check if the current user can modify widgets in the current room
return WidgetUtils.canUserModifyWidgets(this.props.room.roomId);
}

Expand Down Expand Up @@ -698,6 +703,8 @@ AppTile.propTypes = {
// Optional function to be called on widget capability request
// Called with an array of the requested capabilities
onCapabilityRequest: PropTypes.func,
// Is this an instance of a user widget
userWidget: PropTypes.bool,
};

AppTile.defaultProps = {
Expand All @@ -710,4 +717,5 @@ AppTile.defaultProps = {
showPopout: true,
handleMinimisePointerEvents: false,
whitelistCapabilities: [],
userWidget: false,
};
5 changes: 3 additions & 2 deletions src/components/views/rooms/Stickerpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export default class Stickerpicker extends React.Component {
room={this.props.room}
type={stickerpickerWidget.content.type}
fullWidth={true}
userId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
creatorUserId={MatrixClientPeg.get().credentials.userId}
userId={MatrixClientPeg.get().credentials.userId}
creatorUserId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
waitForIframeLoad={true}
show={true}
showMenubar={true}
Expand All @@ -178,6 +178,7 @@ export default class Stickerpicker extends React.Component {
onMinimiseClick={this._onHideStickersClick}
handleMinimisePointerEvents={true}
whitelistCapabilities={['m.sticker']}
userWidget={true}
/>
</div>
</div>
Expand Down