From 900a05366e2175ea1c7e48faf6f5059be4644198 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 7 Apr 2020 15:22:38 -0600 Subject: [PATCH] Fix share dialog correctly componentDidMount fires too late for this dialog, so we need to set ourselves up in the constructor. Fixes https://github.com/vector-im/riot-web/issues/13068 --- src/components/views/dialogs/ShareDialog.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/views/dialogs/ShareDialog.js b/src/components/views/dialogs/ShareDialog.js index cf4735f608..1bc9decd39 100644 --- a/src/components/views/dialogs/ShareDialog.js +++ b/src/components/views/dialogs/ShareDialog.js @@ -70,9 +70,16 @@ export default class ShareDialog extends React.Component { this.onCopyClick = this.onCopyClick.bind(this); this.onLinkSpecificEventCheckboxClick = this.onLinkSpecificEventCheckboxClick.bind(this); + let permalinkCreator: RoomPermalinkCreator = null; + if (props.target instanceof Room) { + permalinkCreator = new RoomPermalinkCreator(props.target); + permalinkCreator.load(); + } + this.state = { // MatrixEvent defaults to share linkSpecificEvent linkSpecificEvent: this.props.target instanceof MatrixEvent, + permalinkCreator, }; this._link = createRef(); @@ -121,14 +128,6 @@ export default class ShareDialog extends React.Component { }); } - componentDidMount() { - if (this.props.target instanceof Room) { - const permalinkCreator = new RoomPermalinkCreator(this.props.target); - permalinkCreator.load(); - this.setState({permalinkCreator}); - } - } - componentWillUnmount() { // if the Copied tooltip is open then get rid of it, there are ways to close the modal which wouldn't close // the tooltip otherwise, such as pressing Escape or clicking X really quickly