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

RoomView: Handle joining federated rooms #270

Merged
merged 2 commits into from
Apr 13, 2016

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Apr 13, 2016

This hopefully fixes an issue where joining a federated room via the directory
would get stuck at a spinner of doom, due to us not recognising the room in
question when it came down the /sync. We now catch the room id in the response
from the /join, and use it to match up the room in onRoom.

props.roomAlias, props.roomId, and state.room.roomId were somewhat confusing,
so I've tried to rationalise them:

  • props.roomAlias (named thus to stop you assuming it's a room id) is the
    thing that the parent component uses to identify the room of interest, and
    can be either an ID or an alias (ie, it replaces props.roomId and
    props.roomAlias)
  • Everything that needs a room ID now has to get it from state.room.roomId.

Also remove the apparently redundant onRoomName handler. (The room name is displayed by the RoomHeader, which listens to room state changes itself)

This hopefully fixes an issue where joining a federated room via the directory
would get stuck at a spinner of doom, due to us not recognising the room in
question when it came down the /sync. We now catch the room id in the response
from the /join, and use it to match up the room in onRoom.

props.roomAlias, props.roomId, and state.room.roomId were somewhat confusing,
so I've tried to rationalise them:

 * props.roomAlias (named thus to stop you assuming it's a room id) is the
   thing that the parent component uses to identify the room of interest, and
   can be either an ID or an alias (ie, it replaces props.roomId and
   props.roomAlias)

 * Everything that needs a room ID now has to get it from state.room.roomId.
@@ -1052,8 +1055,7 @@ module.exports = React.createClass({
page_element = (
<RoomView
ref="roomView"
roomId={this.state.currentRoom}
roomAlias={this.state.currentRoomAlias}
roomAlias={this.state.currentRoom || this.state.currentRoomAlias}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this setting the room alias prop to a room ID? Wouldn't currentRoom always be present if currentRoomAlias is?

Edit: oh, looking at the doc for RoomView this is an alias or ID.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup; see also the PR description.

As for whether currentRoomAlias is ever present without currentRoom: ¯_(ツ)_/¯. The logic in MatrixChat is opaque to me, and I was rather hoping to avoid poking at it with some minimal changes; hence this defensiveness.

@dbkr
Copy link
Member

dbkr commented Apr 13, 2016

I'm not super keen on something called roomAlias either being an alias or an ID, although that might mean thinking up a better name for it. roomAddress perhaps (ie. address = any string that can be used to get an identifier)?

// peekable. Currently there is a big mess, where at least four
// different components (RoomView, MatrixChat, RoomDirectory,
// SlashCommands) have logic for turning aliases into rooms, and each
// of them do it differently and have different edge cases.
Copy link
Member

Choose a reason for hiding this comment

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

Presumably this is safe because we never actually instantiate RoomView with an alias yet? That said I'd probably rather avoid merging things in where the interface is there but not functional yet as it could trip people up easily. Would it make more sense to make RoomView support both aliases and IDs and then eliminate the duplicate alias lookups once that's in place?

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed via PM: this is really just making the existing situation more explicit.

We do instantiate RoomView with an alias (for instance when you type an alias into the directory); but previously in that case the alias would have been stuffed into props.roomId, causing all manner of breakage. In an ideal world, we'd make this better, (and yes, I'm leaning towards RoomView being in charge of resolving aliases to rooms) but I'm hoping to avoid fixing all of the alias->room flows right now.

@dbkr
Copy link
Member

dbkr commented Apr 13, 2016

In general I like the idea of RoomView being able to take an alias and do the lookup itself (this is something I was hoping to be able to do) and the rest looks fine.

@richvdh
Copy link
Member Author

richvdh commented Apr 13, 2016

@dbkr: ptal?

@richvdh richvdh assigned dbkr and unassigned richvdh Apr 13, 2016
@dbkr
Copy link
Member

dbkr commented Apr 13, 2016

That should confuse me less :) lgtm

@dbkr dbkr assigned richvdh and unassigned dbkr Apr 13, 2016
@richvdh richvdh merged commit 85277a2 into develop Apr 13, 2016
@richvdh richvdh deleted the rav/issue_1314_federated_rooms branch April 13, 2016 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants