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

Propagate room join errors to the UI #1007

Merged
merged 3 commits into from
Jun 2, 2017

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Jun 2, 2017

Dispatch so we can set the state in RoomViewStore. Show the error
when the room join fails (unsure if it's better to do this from
the component or the store). Remove unused joinError from roomview.

Dispatch so we can set the state in RoomViewStore. Show the error
when the room join fails (unsure if it's better to do this from
the component or the store). Remove unused joinError from roomview.
}

_joinedRoom(payload) {
if (payload.room_id === this._state.roomId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Evil! We must not update state conditionally but instead trust the payload!

}

_joinRoomError(payload) {
if (payload.room_id === this._state.roomId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See above

As apparently doing it confitionally is bad
@lukebarnard1 lukebarnard1 assigned dbkr and unassigned lukebarnard1 Jun 2, 2017
@dbkr
Copy link
Member Author

dbkr commented Jun 2, 2017

done!

@dbkr dbkr assigned lukebarnard1 and unassigned dbkr Jun 2, 2017
MatrixClientPeg.get().joinRoom(this._state.roomId, payload.opts).done(() => {
dis.dispatch({
action: 'joined_room',
room_id: this._state.roomId,
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't used anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't, is it? Since we need to update joining to false.

Copy link
Contributor

Choose a reason for hiding this comment

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

But we don't need the room_id to do that

joinError: err,
dis.dispatch({
action: 'join_room_error',
room_id: this._state.roomId,
Copy link
Contributor

Choose a reason for hiding this comment

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

See above

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed that nothing reads this error, but if it's there then it should probably be kept up to date. We could remove the join error though (unless we need it in RoomView by moving the Modal there)

Copy link
Contributor

@lukebarnard1 lukebarnard1 Jun 2, 2017

Choose a reason for hiding this comment

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

I was referring to the room_id

});
const msg = err.message ? err.message : JSON.stringify(err);
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels quite wrong to create modals in the store. I would at least move this to _onRoomViewStoreUpdate of RoomView, but I am surprised that we weren't already doing this somewhere else...

Copy link
Member Author

Choose a reason for hiding this comment

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

We were doing it in RoomView but it was removed - I wasn't sure whether the intention was to have the thing doing the joining display these errors or the view that caused the join: if the former, you'd get dialogs pop up even if you navigated away from the room view, if the latter, you could get multiple dialogs if multiple things were listening to the dispatch.

Copy link
Contributor

Choose a reason for hiding this comment

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

IRL we decided that the value added by moving the location of the dialog creation is probably quite low.

The store should probably not be doing API calls and it should probably be dumb in that it should just accept state changes via dispatches that it trusts fully but that have originated elsewhere.

@dbkr dbkr merged commit ec0ad93 into new-guest-access Jun 2, 2017
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