Merge pull request #1193 from matrix-org/luke/fix-create-room-preview

Fix vector-im/riot-web#4526 by pretending to join when creating a room
This commit is contained in:
David Baker 2017-07-06 17:58:30 +01:00 committed by GitHub
commit 282b63d0cf
2 changed files with 16 additions and 0 deletions

View file

@ -79,6 +79,12 @@ function createRoom(opts) {
const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner'); const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner');
let roomId; let roomId;
if (opts.andView) {
// We will possibly have a successful join, indicate as such
dis.dispatch({
action: 'will_join',
});
}
return client.createRoom(createOpts).finally(function() { return client.createRoom(createOpts).finally(function() {
modal.close(); modal.close();
}).then(function(res) { }).then(function(res) {
@ -98,10 +104,16 @@ function createRoom(opts) {
action: 'view_room', action: 'view_room',
room_id: roomId, room_id: roomId,
should_peek: false, should_peek: false,
// Creating a room will have joined us to the room
joined: true,
}); });
} }
return roomId; return roomId;
}, function(err) { }, function(err) {
// We also failed to join the room (this sets joining to false in RoomViewStore)
dis.dispatch({
action: 'join_room_error',
});
console.error("Failed to create room " + roomId + " " + err); console.error("Failed to create room " + roomId + " " + err);
Modal.createDialog(ErrorDialog, { Modal.createDialog(ErrorDialog, {
title: _t("Failure to create room"), title: _t("Failure to create room"),

View file

@ -141,6 +141,10 @@ class RoomViewStore extends Store {
shouldPeek: payload.should_peek === undefined ? true : payload.should_peek, shouldPeek: payload.should_peek === undefined ? true : payload.should_peek,
}; };
if (payload.joined) {
newState.joining = false;
}
// If an event ID wasn't specified, default to the one saved for this room // If an event ID wasn't specified, default to the one saved for this room
// via update_scroll_state. Assume initialEventPixelOffset should be set. // via update_scroll_state. Assume initialEventPixelOffset should be set.
if (!newState.initialEventId) { if (!newState.initialEventId) {