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

Commit

Permalink
Merge pull request #2869 from matrix-org/matthew/redacted_tombstones
Browse files Browse the repository at this point in the history
fix NPE for rooms with redacted tombstones
  • Loading branch information
ara4n authored Apr 4, 2019
2 parents a61ab4e + b9eebee commit d45f431
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/views/rooms/MessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,22 @@ export default class MessageComposer extends React.Component {
} else if (this.state.tombstone) {
const replacementRoomId = this.state.tombstone.getContent()['replacement_room'];

const continuesLink = replacementRoomId ? (
<a href={makeRoomPermalink(replacementRoomId)}
className="mx_MessageComposer_roomReplaced_link"
onClick={this._onTombstoneClick}
>
{_t("The conversation continues here.")}
</a>
) : '';

controls.push(<div className="mx_MessageComposer_replaced_wrapper">
<div className="mx_MessageComposer_replaced_valign">
<img className="mx_MessageComposer_roomReplaced_icon" src={require("../../../../res/img/room_replaced.svg")} />
<span className="mx_MessageComposer_roomReplaced_header">
{_t("This room has been replaced and is no longer active.")}
</span><br />
<a href={makeRoomPermalink(replacementRoomId)}
className="mx_MessageComposer_roomReplaced_link"
onClick={this._onTombstoneClick}
>
{_t("The conversation continues here.")}
</a>
{ continuesLink }
</div>
</div>);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/matrix-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ export function makeUserPermalink(userId) {
export function makeRoomPermalink(roomId) {
const permalinkBase = `${baseUrl}/#/${roomId}`;

if (!roomId) {
throw new Error("can't permalink a falsey roomId");
}

// If the roomId isn't actually a room ID, don't try to list the servers.
// Aliases are already routable, and don't need extra information.
if (roomId[0] !== '!') return permalinkBase;
Expand Down

0 comments on commit d45f431

Please sign in to comment.