Commit 985cf6c2 authored by JC Brand's avatar JC Brand

Use global router to open chat rooms

parent 35db952e
......@@ -355,20 +355,19 @@
});
_converse.api.promises.add(['roomsPanelRendered', 'roomsAutoJoined']);
const MUCRouter = Backbone.Router.extend({
routes: {
'converse?room=:room': 'openRoom'
},
openRoom (room) {
// FIXME: also need to wait for bookmarks
_converse.api.waitUntil('roomsAutoJoined').then(() => {
if (utils.isValidJID(room)) {
_converse.api.rooms.open(room);
}
});
function openRoom (room) {
const promises = [_converse.api.waitUntil('roomsAutoJoined')]
if (!_converse.allow_bookmarks) {
promises.push( _converse.api.waitUntil('bookmarksInitialized'));
}
});
const router = new MUCRouter();
Promise.all(promises).then(() => {
if (utils.isValidJID(room)) {
_converse.api.rooms.open(room);
}
});
}
_converse.router.route('converse/room?jid=:room', openRoom);
function openChatRoom (settings, bring_to_foreground) {
......@@ -2744,8 +2743,6 @@
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.on('chatBoxesFetched', autoJoinRooms);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment