Make sure rooms and bookmarks lists are recreated and shown after reconnect
This commit is contained in:
parent
c389b50044
commit
a1767ffecd
4
package-lock.json
generated
4
package-lock.json
generated
@ -930,7 +930,9 @@
|
||||
}
|
||||
},
|
||||
"backbone.vdomview": {
|
||||
"version": "git+https://github.com/jcbrand/backbone.vdomview.git#e685de2ef5a810a87efe886b35c99ce0b3ab8f82",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/backbone.vdomview/-/backbone.vdomview-1.0.0.tgz",
|
||||
"integrity": "sha512-RuuA0acCspsTalZk/AF+AaZySJRa5Z1d6t1Oe8BSb3jDWXusS4ml+IE3QWZZvPnUj3D6QZr8mCxmwV4kNnmlLg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"backbone": "1.3.3"
|
||||
|
@ -383,7 +383,13 @@
|
||||
_converse.log('Error while fetching bookmarks', Strophe.LogLevel.WARN);
|
||||
_converse.log(iq.outerHTML, Strophe.LogLevel.DEBUG);
|
||||
if (!_.isNil(deferred)) {
|
||||
return deferred.reject(new Error("Could not fetch bookmarks"));
|
||||
if (iq.querySelector('error[type="cancel"] item-not-found')) {
|
||||
// Not an exception, the user simply doesn't have
|
||||
// any bookmarks.
|
||||
return deferred.resolve();
|
||||
} else {
|
||||
return deferred.reject(new Error("Could not fetch bookmarks"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -457,9 +463,12 @@
|
||||
|
||||
insertIntoControlBox () {
|
||||
const controlboxview = _converse.chatboxviews.get('controlbox');
|
||||
if (!_.isUndefined(controlboxview)) {
|
||||
const chatrooms_el = controlboxview.el.querySelector('#chatrooms');
|
||||
chatrooms_el.insertAdjacentElement('afterbegin', this.el);
|
||||
if (!_.isUndefined(controlboxview) &&
|
||||
!document.body.contains(this.el)) {
|
||||
const container = controlboxview.el.querySelector('#chatrooms');
|
||||
if (!_.isNull(container)) {
|
||||
container.insertBefore(this.el, container.firstChild);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -533,11 +542,7 @@
|
||||
if (!_converse.allow_bookmarks) {
|
||||
return;
|
||||
}
|
||||
if (_.isUndefined(_converse.bookmarksview)) {
|
||||
initBookmarks();
|
||||
} else {
|
||||
_converse.bookmarksview.render();
|
||||
}
|
||||
initBookmarks();
|
||||
};
|
||||
_converse.on('reconnected', afterReconnection);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@
|
||||
},
|
||||
|
||||
getRoomsListElementName () {
|
||||
if (this.model.get('bookmarked')) {
|
||||
if (this.model.get('bookmarked') && _converse.bookmarksview) {
|
||||
const bookmark = _.head(_converse.bookmarksview.model.where({'jid': this.model.get('jid')}));
|
||||
return bookmark.get('name');
|
||||
} else {
|
||||
@ -160,8 +160,7 @@
|
||||
},
|
||||
|
||||
render () {
|
||||
this.el.innerHTML =
|
||||
tpl_rooms_list({
|
||||
this.el.innerHTML = tpl_rooms_list({
|
||||
'toggle_state': this.list_model.get('toggle-state'),
|
||||
'desc_rooms': __('Click to toggle the rooms list'),
|
||||
'label_rooms': __('Open Rooms')
|
||||
@ -251,14 +250,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
const afterReconnection = function () {
|
||||
if (_.isUndefined(_converse.rooms_list_view)) {
|
||||
initRoomsListView();
|
||||
} else {
|
||||
_converse.rooms_list_view.render();
|
||||
}
|
||||
};
|
||||
_converse.api.listen.on('reconnected', afterReconnection);
|
||||
_converse.api.listen.on('reconnected', initRoomsListView);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user