Use global router to open chat rooms
This commit is contained in:
parent
35db952e71
commit
985cf6c294
@ -355,20 +355,19 @@
|
|||||||
});
|
});
|
||||||
_converse.api.promises.add(['roomsPanelRendered', 'roomsAutoJoined']);
|
_converse.api.promises.add(['roomsPanelRendered', 'roomsAutoJoined']);
|
||||||
|
|
||||||
const MUCRouter = Backbone.Router.extend({
|
|
||||||
routes: {
|
function openRoom (room) {
|
||||||
'converse?room=:room': 'openRoom'
|
const promises = [_converse.api.waitUntil('roomsAutoJoined')]
|
||||||
},
|
if (!_converse.allow_bookmarks) {
|
||||||
openRoom (room) {
|
promises.push( _converse.api.waitUntil('bookmarksInitialized'));
|
||||||
// FIXME: also need to wait for bookmarks
|
}
|
||||||
_converse.api.waitUntil('roomsAutoJoined').then(() => {
|
Promise.all(promises).then(() => {
|
||||||
if (utils.isValidJID(room)) {
|
if (utils.isValidJID(room)) {
|
||||||
_converse.api.rooms.open(room);
|
_converse.api.rooms.open(room);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
_converse.router.route('converse/room?jid=:room', openRoom);
|
||||||
const router = new MUCRouter();
|
|
||||||
|
|
||||||
|
|
||||||
function openChatRoom (settings, bring_to_foreground) {
|
function openChatRoom (settings, bring_to_foreground) {
|
||||||
@ -2744,8 +2743,6 @@
|
|||||||
Strophe.LogLevel.ERROR);
|
Strophe.LogLevel.ERROR);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// XXX: Could return Promise for api.rooms.open and then wait
|
|
||||||
// until all promises have resolved before emitting this.
|
|
||||||
_converse.emit('roomsAutoJoined');
|
_converse.emit('roomsAutoJoined');
|
||||||
}
|
}
|
||||||
_converse.on('chatBoxesFetched', autoJoinRooms);
|
_converse.on('chatBoxesFetched', autoJoinRooms);
|
||||||
|
Loading…
Reference in New Issue
Block a user