-
-
Notifications
You must be signed in to change notification settings - Fork 832
Propagate room join errors to the UI #1007
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ limitations under the License. | |
import dis from '../dispatcher'; | ||
import {Store} from 'flux/utils'; | ||
import MatrixClientPeg from '../MatrixClientPeg'; | ||
import sdk from '../index'; | ||
import Modal from '../Modal'; | ||
import { _t } from '../languageHandler'; | ||
|
||
const INITIAL_STATE = { | ||
// Whether we're joining the currently viewed room | ||
|
@@ -76,6 +79,12 @@ class RoomViewStore extends Store { | |
case 'join_room': | ||
this._joinRoom(payload); | ||
break; | ||
case 'joined_room': | ||
this._joinedRoom(payload); | ||
break; | ||
case 'join_room_error': | ||
this._joinRoomError(payload); | ||
break; | ||
case 'on_logged_out': | ||
this.reset(); | ||
break; | ||
|
@@ -128,16 +137,36 @@ class RoomViewStore extends Store { | |
this._setState({ | ||
joining: true, | ||
}); | ||
MatrixClientPeg.get().joinRoom(this._state.roomId, payload.opts).then( | ||
() => { | ||
this._setState({ | ||
joining: false, | ||
MatrixClientPeg.get().joinRoom(this._state.roomId, payload.opts).done(() => { | ||
dis.dispatch({ | ||
action: 'joined_room', | ||
room_id: this._state.roomId, | ||
}); | ||
}, (err) => { | ||
this._setState({ | ||
joining: false, | ||
joinError: err, | ||
dis.dispatch({ | ||
action: 'join_room_error', | ||
room_id: this._state.roomId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was referring to the |
||
err: err, | ||
}); | ||
const msg = err.message ? err.message : JSON.stringify(err); | ||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); | ||
Modal.createDialog(ErrorDialog, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
title: _t("Failed to join room"), | ||
description: msg, | ||
}); | ||
}); | ||
} | ||
|
||
_joinedRoom(payload) { | ||
this._setState({ | ||
joining: false, | ||
}); | ||
} | ||
|
||
_joinRoomError(payload) { | ||
this._setState({ | ||
joining: false, | ||
joinError: payload.err, | ||
}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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