Commit dcf87368 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents b209c999 a1767ffe
...@@ -930,7 +930,9 @@ ...@@ -930,7 +930,9 @@
} }
}, },
"backbone.vdomview": { "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, "dev": true,
"requires": { "requires": {
"backbone": "1.3.3" "backbone": "1.3.3"
......
...@@ -383,7 +383,13 @@ ...@@ -383,7 +383,13 @@
_converse.log('Error while fetching bookmarks', Strophe.LogLevel.WARN); _converse.log('Error while fetching bookmarks', Strophe.LogLevel.WARN);
_converse.log(iq.outerHTML, Strophe.LogLevel.DEBUG); _converse.log(iq.outerHTML, Strophe.LogLevel.DEBUG);
if (!_.isNil(deferred)) { 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 @@ ...@@ -457,9 +463,12 @@
insertIntoControlBox () { insertIntoControlBox () {
const controlboxview = _converse.chatboxviews.get('controlbox'); const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview)) { if (!_.isUndefined(controlboxview) &&
const chatrooms_el = controlboxview.el.querySelector('#chatrooms'); !document.body.contains(this.el)) {
chatrooms_el.insertAdjacentElement('afterbegin', this.el); const container = controlboxview.el.querySelector('#chatrooms');
if (!_.isNull(container)) {
container.insertBefore(this.el, container.firstChild);
}
} }
}, },
...@@ -533,11 +542,7 @@ ...@@ -533,11 +542,7 @@
if (!_converse.allow_bookmarks) { if (!_converse.allow_bookmarks) {
return; return;
} }
if (_.isUndefined(_converse.bookmarksview)) { initBookmarks();
initBookmarks();
} else {
_converse.bookmarksview.render();
}
}; };
_converse.on('reconnected', afterReconnection); _converse.on('reconnected', afterReconnection);
} }
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
}, },
getRoomsListElementName () { 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')})); const bookmark = _.head(_converse.bookmarksview.model.where({'jid': this.model.get('jid')}));
return bookmark.get('name'); return bookmark.get('name');
} else { } else {
...@@ -160,8 +160,7 @@ ...@@ -160,8 +160,7 @@
}, },
render () { render () {
this.el.innerHTML = this.el.innerHTML = tpl_rooms_list({
tpl_rooms_list({
'toggle_state': this.list_model.get('toggle-state'), 'toggle_state': this.list_model.get('toggle-state'),
'desc_rooms': __('Click to toggle the rooms list'), 'desc_rooms': __('Click to toggle the rooms list'),
'label_rooms': __('Open Rooms') 'label_rooms': __('Open Rooms')
...@@ -202,33 +201,6 @@ ...@@ -202,33 +201,6 @@
} }
}, },
renderRoomsListElement (item) {
if (item.get('type') !== 'chatroom') {
return;
}
this.removeRoomsListElement(item);
let name, bookmark;
if (item.get('bookmarked')) {
bookmark = _.head(_converse.bookmarksview.model.where({'jid': item.get('jid')}));
name = bookmark.get('name');
} else {
name = item.get('name');
}
const div = document.createElement('div');
div.innerHTML = tpl_rooms_list_item(_.extend(item.toJSON(), {
'allow_bookmarks': _converse.allow_bookmarks,
'info_leave_room': __('Leave this room'),
'info_remove_bookmark': __('Unbookmark this room'),
'info_add_bookmark': __('Bookmark this room'),
'info_title': __('Show more information on this room'),
'name': name,
'open_title': __('Click to open this room')
}));
this.el.querySelector('.open-rooms-list').appendChild(div.firstChild);
this.show();
},
showOrHide (item) { showOrHide (item) {
if (!this.model.models.length) { if (!this.model.models.length) {
u.hideElement(this.el); u.hideElement(this.el);
...@@ -240,17 +212,6 @@ ...@@ -240,17 +212,6 @@
removeBookmark: _converse.removeBookmarkViaEvent, removeBookmark: _converse.removeBookmarkViaEvent,
addBookmark: _converse.addBookmarkViaEvent, addBookmark: _converse.addBookmarkViaEvent,
removeRoomsListElement (item) {
const list_el = this.el.querySelector('.open-rooms-list');
const el = _.head(sizzle(`.available-chatroom[data-room-jid="${item.get('jid')}"]`, list_el));
if (el) {
list_el.removeChild(el);
}
if (list_el.childElementCount === 0) {
this.hide();
}
},
toggleRoomsList (ev) { toggleRoomsList (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
const el = ev.target; const el = ev.target;
...@@ -289,14 +250,7 @@ ...@@ -289,14 +250,7 @@
} }
}); });
const afterReconnection = function () { _converse.api.listen.on('reconnected', initRoomsListView);
if (_.isUndefined(_converse.rooms_list_view)) {
initRoomsListView();
} else {
_converse.rooms_list_view.render();
}
};
_converse.api.listen.on('reconnected', afterReconnection);
} }
}); });
})); }));
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