Commit 2acc11f7 authored by JC Brand's avatar JC Brand

Fixes #1158. Fall back to bookmark JID if name is not available

parent baf59860
...@@ -59069,7 +59069,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -59069,7 +59069,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.Bookmark = Backbone.Model; _converse.Bookmark = Backbone.Model;
_converse.Bookmarks = Backbone.Collection.extend({ _converse.Bookmarks = Backbone.Collection.extend({
model: _converse.Bookmark, model: _converse.Bookmark,
comparator: 'name', comparator: item => item.get('name').toLowerCase(),
initialize() { initialize() {
this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked)); this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked));
...@@ -59205,9 +59205,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -59205,9 +59205,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const bookmarks = sizzle('items[node="storage:bookmarks"] ' + 'item#current ' + 'storage[xmlns="storage:bookmarks"] ' + 'conference', stanza); const bookmarks = sizzle('items[node="storage:bookmarks"] ' + 'item#current ' + 'storage[xmlns="storage:bookmarks"] ' + 'conference', stanza);
_.forEach(bookmarks, bookmark => { _.forEach(bookmarks, bookmark => {
const jid = bookmark.getAttribute('jid');
this.create({ this.create({
'jid': bookmark.getAttribute('jid'), 'jid': jid,
'name': bookmark.getAttribute('name'), 'name': bookmark.getAttribute('name') || jid,
'autojoin': bookmark.getAttribute('autojoin') === 'true', 'autojoin': bookmark.getAttribute('autojoin') === 'true',
'nick': _.get(bookmark.querySelector('nick'), 'textContent') 'nick': _.get(bookmark.querySelector('nick'), 'textContent')
}); });
...@@ -70141,7 +70142,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } ...@@ -70141,7 +70142,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}).c("x", { }).c("x", {
'xmlns': Strophe.NS.MUC 'xmlns': Strophe.NS.MUC
}).c("history", { }).c("history", {
'maxstanzas': _converse.muc_history_max_stanzas 'maxstanzas': this.get('mam_enabled') ? 0 : _converse.muc_history_max_stanzas
}).up(); }).up();
if (password) { if (password) {
...@@ -78387,7 +78388,7 @@ __e( o.Strophe.getDomainFromJid(o.jid) ) + ...@@ -78387,7 +78388,7 @@ __e( o.Strophe.getDomainFromJid(o.jid) ) +
} ; } ;
__p += '\n </div>\n <p class="chatroom-description">' + __p += '\n </div>\n <p class="chatroom-description">' +
__e( o.description ) + __e( o.description ) +
'<p/>\n</div>\n<div class="chatbox-buttons row no-gutters">\n <a class="chatbox-btn close-chatbox-button fa fa-sign-out" title="' + '<p/>\n</div>\n<div class="chatbox-buttons row no-gutters">\n <a class="chatbox-btn close-chatbox-button fa fa-sign-out-alt" title="' +
__e(o.info_close) + __e(o.info_close) +
'"></a>\n '; '"></a>\n ';
if (o.affiliation == 'owner') { ; if (o.affiliation == 'owner') { ;
...@@ -505,6 +505,10 @@ ...@@ -505,6 +505,10 @@
'autojoin': 'false', 'autojoin': 'false',
'jid': 'first@conference.shakespeare.lit' 'jid': 'first@conference.shakespeare.lit'
}).c('nick').t('JC').up().up() }).c('nick').t('JC').up().up()
.c('conference', {
'autojoin': 'false',
'jid': 'noname@conference.shakespeare.lit'
}).c('nick').t('JC').up().up()
.c('conference', { .c('conference', {
'name': 'Bookmark with a very very long name that will be shortened', 'name': 'Bookmark with a very very long name that will be shortened',
'autojoin': 'false', 'autojoin': 'false',
...@@ -517,27 +521,26 @@ ...@@ -517,27 +521,26 @@
}).c('nick').t('JC').up().up(); }).c('nick').t('JC').up().up();
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
test_utils.waitUntil(function () { test_utils.waitUntil(() => document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length, 300)
return document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length; .then(() => {
}, 300).then(function () { expect(document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(5);
expect(document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(4);
const els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link'); const els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link');
expect(els[0].textContent).toBe("1st Bookmark"); expect(els[0].textContent).toBe("1st Bookmark");
expect(els[1].textContent).toBe("Another room"); expect(els[1].textContent).toBe("Another room");
expect(els[2].textContent).toBe("Bookmark with a very very long name that will be shortened"); expect(els[2].textContent).toBe("Bookmark with a very very long name that will be shortened");
expect(els[3].textContent).toBe("The Play's the Thing"); expect(els[3].textContent).toBe("noname@conference.shakespeare.lit");
expect(els[4].textContent).toBe("The Play's the Thing");
spyOn(window, 'confirm').and.returnValue(true); spyOn(window, 'confirm').and.returnValue(true);
document.querySelector('#chatrooms .bookmarks.rooms-list .room-item:nth-child(2) a:nth-child(2)').click(); document.querySelector('#chatrooms .bookmarks.rooms-list .room-item:nth-child(2) a:nth-child(2)').click();
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
return test_utils.waitUntil(function () { return test_utils.waitUntil(() => document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length === 4, 300)
return document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length === 3;
}, 300)
}).then(() => { }).then(() => {
const els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link'); const els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link');
expect(els[0].textContent).toBe("1st Bookmark"); expect(els[0].textContent).toBe("1st Bookmark");
expect(els[1].textContent).toBe("Bookmark with a very very long name that will be shortened"); expect(els[1].textContent).toBe("Bookmark with a very very long name that will be shortened");
expect(els[2].textContent).toBe("The Play's the Thing"); expect(els[2].textContent).toBe("noname@conference.shakespeare.lit");
expect(els[3].textContent).toBe("The Play's the Thing");
done(); done();
}).catch(_.partial(console.error, _)); }).catch(_.partial(console.error, _));
}); });
......
...@@ -243,7 +243,7 @@ ...@@ -243,7 +243,7 @@
_converse.Bookmarks = Backbone.Collection.extend({ _converse.Bookmarks = Backbone.Collection.extend({
model: _converse.Bookmark, model: _converse.Bookmark,
comparator: 'name', comparator: (item) => item.get('name').toLowerCase(),
initialize () { initialize () {
this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked)); this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked));
...@@ -367,9 +367,10 @@ ...@@ -367,9 +367,10 @@
stanza stanza
) )
_.forEach(bookmarks, (bookmark) => { _.forEach(bookmarks, (bookmark) => {
const jid = bookmark.getAttribute('jid');
this.create({ this.create({
'jid': bookmark.getAttribute('jid'), 'jid': jid,
'name': bookmark.getAttribute('name'), 'name': bookmark.getAttribute('name') || jid,
'autojoin': bookmark.getAttribute('autojoin') === 'true', 'autojoin': bookmark.getAttribute('autojoin') === 'true',
'nick': _.get(bookmark.querySelector('nick'), 'textContent') 'nick': _.get(bookmark.querySelector('nick'), 'textContent')
}); });
......
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