From 5544ee6408cd4cbefff75fa88ab550ceebfcc4c7 Mon Sep 17 00:00:00 2001 From: Simon Merrick Date: Sun, 6 Dec 2020 23:29:11 +1300 Subject: [PATCH] extract alias handling to separate function --- src/components/views/dialogs/ShareDialog.tsx | 2 +- src/utils/permalinks/Permalinks.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/ShareDialog.tsx b/src/components/views/dialogs/ShareDialog.tsx index 1569977d58..5264031cc6 100644 --- a/src/components/views/dialogs/ShareDialog.tsx +++ b/src/components/views/dialogs/ShareDialog.tsx @@ -146,7 +146,7 @@ export default class ShareDialog extends React.PureComponent { const events = this.props.target.getLiveTimeline().getEvents(); matrixToUrl = this.state.permalinkCreator.forEvent(events[events.length - 1].getId()); } else { - matrixToUrl = this.state.permalinkCreator.forRoom(); + matrixToUrl = this.state.permalinkCreator.forShareableRoom(); } } else if (this.props.target instanceof User || this.props.target instanceof RoomMember) { matrixToUrl = makeUserPermalink(this.props.target.userId); diff --git a/src/utils/permalinks/Permalinks.js b/src/utils/permalinks/Permalinks.js index 2c38a982d3..39c5776852 100644 --- a/src/utils/permalinks/Permalinks.js +++ b/src/utils/permalinks/Permalinks.js @@ -129,7 +129,7 @@ export class RoomPermalinkCreator { return getPermalinkConstructor().forEvent(this._roomId, eventId, this._serverCandidates); } - forRoom() { + forShareableRoom() { if (this._room) { // Prefer to use canonical alias for permalink if possible const alias = this._room.getCanonicalAlias(); @@ -140,6 +140,10 @@ export class RoomPermalinkCreator { return getPermalinkConstructor().forRoom(this._roomId, this._serverCandidates); } + forRoom() { + return getPermalinkConstructor().forRoom(this._roomId, this._serverCandidates); + } + onRoomState(event) { switch (event.getType()) { case "m.room.server_acl":