Change how viewing a room alias works to make way for jumping into a room once you've logged in.
This commit is contained in:
parent
bc2eca16f9
commit
6348c2cf99
1 changed files with 39 additions and 36 deletions
|
@ -217,30 +217,45 @@ module.exports = {
|
||||||
var self = this;
|
var self = this;
|
||||||
cli.on('syncComplete', function() {
|
cli.on('syncComplete', function() {
|
||||||
self.sdkReady = true;
|
self.sdkReady = true;
|
||||||
if (!self.state.currentRoom) {
|
|
||||||
var firstRoom = null;
|
var defer = q.defer();
|
||||||
if (cli.getRooms() && cli.getRooms().length) {
|
if (self.starting_room_alias) {
|
||||||
firstRoom = RoomListSorter.mostRecentActivityFirst(
|
MatrixClientPeg.get().getRoomIdForAlias(self.starting_room_alias).done(function(result) {
|
||||||
cli.getRooms()
|
self.setState({currentRoom: result.room_id});
|
||||||
)[0].roomId;
|
defer.resolve();
|
||||||
self.setState({ready: true, currentRoom: firstRoom, page_type: self.PageTypes.RoomView});
|
}, function(error) {
|
||||||
} else {
|
defer.resolve();
|
||||||
self.setState({ready: true, page_type: self.PageTypes.RoomDirectory});
|
});
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.setState({ready: true, currentRoom: self.state.currentRoom});
|
defer.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we notifyNewScreen now because now the room will actually be displayed,
|
defer.promise.done(function() {
|
||||||
// and (mostly) now we can get the correct alias.
|
if (!self.state.currentRoom) {
|
||||||
var presentedId = self.state.currentRoom;
|
var firstRoom = null;
|
||||||
var room = MatrixClientPeg.get().getRoom(self.state.currentRoom);
|
if (cli.getRooms() && cli.getRooms().length) {
|
||||||
if (room) {
|
firstRoom = RoomListSorter.mostRecentActivityFirst(
|
||||||
var theAlias = MatrixTools.getCanonicalAliasForRoom(room);
|
cli.getRooms()
|
||||||
if (theAlias) presentedId = theAlias;
|
)[0].roomId;
|
||||||
}
|
self.setState({ready: true, currentRoom: firstRoom, page_type: self.PageTypes.RoomView});
|
||||||
self.notifyNewScreen('room/'+presentedId);
|
} else {
|
||||||
dis.dispatch({action: 'focus_composer'});
|
self.setState({ready: true, page_type: self.PageTypes.RoomDirectory});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.setState({ready: true, page_type: self.PageTypes.RoomView});
|
||||||
|
}
|
||||||
|
|
||||||
|
// we notifyNewScreen now because now the room will actually be displayed,
|
||||||
|
// and (mostly) now we can get the correct alias.
|
||||||
|
var presentedId = self.state.currentRoom;
|
||||||
|
var room = MatrixClientPeg.get().getRoom(self.state.currentRoom);
|
||||||
|
if (room) {
|
||||||
|
var theAlias = MatrixTools.getCanonicalAliasForRoom(room);
|
||||||
|
if (theAlias) presentedId = theAlias;
|
||||||
|
}
|
||||||
|
self.notifyNewScreen('room/'+presentedId);
|
||||||
|
dis.dispatch({action: 'focus_composer'});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
cli.on('Call.incoming', function(call) {
|
cli.on('Call.incoming', function(call) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
|
@ -296,26 +311,14 @@ module.exports = {
|
||||||
});
|
});
|
||||||
} else if (screen.indexOf('room/') == 0) {
|
} else if (screen.indexOf('room/') == 0) {
|
||||||
var roomString = screen.split('/')[1];
|
var roomString = screen.split('/')[1];
|
||||||
var defer = q.defer();
|
|
||||||
if (roomString[0] == '#') {
|
if (roomString[0] == '#') {
|
||||||
var self = this;
|
this.starting_room_alias = roomString;
|
||||||
MatrixClientPeg.get().getRoomIdForAlias(roomString).done(function(result) {
|
|
||||||
if (self.sdkReady) self.setState({ready: true});
|
|
||||||
defer.resolve(result.room_id);
|
|
||||||
}, function() {
|
|
||||||
if (self.sdkReady) self.setState({ready: true});
|
|
||||||
defer.resolve(null);
|
|
||||||
});
|
|
||||||
this.setState({ready: false});
|
|
||||||
} else {
|
} else {
|
||||||
defer.resolve(roomString);
|
|
||||||
}
|
|
||||||
defer.promise.done(function(roomId) {
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room',
|
action: 'view_room',
|
||||||
room_id: roomId
|
room_id: roomString
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue