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

This commit is contained in:
JC Brand 2018-09-06 17:25:10 +02:00
parent baf598608a
commit 2acc11f776
3 changed files with 22 additions and 17 deletions

11
dist/converse.js vendored
View File

@ -59069,7 +59069,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.Bookmark = Backbone.Model;
_converse.Bookmarks = Backbone.Collection.extend({
model: _converse.Bookmark,
comparator: 'name',
comparator: item => item.get('name').toLowerCase(),
initialize() {
this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked));
@ -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);
_.forEach(bookmarks, bookmark => {
const jid = bookmark.getAttribute('jid');
this.create({
'jid': bookmark.getAttribute('jid'),
'name': bookmark.getAttribute('name'),
'jid': jid,
'name': bookmark.getAttribute('name') || jid,
'autojoin': bookmark.getAttribute('autojoin') === 'true',
'nick': _.get(bookmark.querySelector('nick'), 'textContent')
});
@ -70141,7 +70142,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}).c("x", {
'xmlns': Strophe.NS.MUC
}).c("history", {
'maxstanzas': _converse.muc_history_max_stanzas
'maxstanzas': this.get('mam_enabled') ? 0 : _converse.muc_history_max_stanzas
}).up();
if (password) {
@ -78387,7 +78388,7 @@ __e( o.Strophe.getDomainFromJid(o.jid) ) +
} ;
__p += '\n </div>\n <p class="chatroom-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) +
'"></a>\n ';
if (o.affiliation == 'owner') { ;

View File

@ -505,6 +505,10 @@
'autojoin': 'false',
'jid': 'first@conference.shakespeare.lit'
}).c('nick').t('JC').up().up()
.c('conference', {
'autojoin': 'false',
'jid': 'noname@conference.shakespeare.lit'
}).c('nick').t('JC').up().up()
.c('conference', {
'name': 'Bookmark with a very very long name that will be shortened',
'autojoin': 'false',
@ -517,27 +521,26 @@
}).c('nick').t('JC').up().up();
_converse.connection._dataRecv(test_utils.createRequest(stanza));
test_utils.waitUntil(function () {
return document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length;
}, 300).then(function () {
expect(document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(4);
test_utils.waitUntil(() => document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length, 300)
.then(() => {
expect(document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(5);
const els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link');
expect(els[0].textContent).toBe("1st Bookmark");
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[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);
document.querySelector('#chatrooms .bookmarks.rooms-list .room-item:nth-child(2) a:nth-child(2)').click();
expect(window.confirm).toHaveBeenCalled();
return test_utils.waitUntil(function () {
return document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length === 3;
}, 300)
return test_utils.waitUntil(() => document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length === 4, 300)
}).then(() => {
const els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link');
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[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();
}).catch(_.partial(console.error, _));
});

View File

@ -243,7 +243,7 @@
_converse.Bookmarks = Backbone.Collection.extend({
model: _converse.Bookmark,
comparator: 'name',
comparator: (item) => item.get('name').toLowerCase(),
initialize () {
this.on('add', _.flow(this.openBookmarkedRoom, this.markRoomAsBookmarked));
@ -367,9 +367,10 @@
stanza
)
_.forEach(bookmarks, (bookmark) => {
const jid = bookmark.getAttribute('jid');
this.create({
'jid': bookmark.getAttribute('jid'),
'name': bookmark.getAttribute('name'),
'jid': jid,
'name': bookmark.getAttribute('name') || jid,
'autojoin': bookmark.getAttribute('autojoin') === 'true',
'nick': _.get(bookmark.querySelector('nick'), 'textContent')
});