Commit 5f3761dc authored by JC Brand's avatar JC Brand

Only initialize bookmarks and show icon if PEP is supported

which we check by checking if the PEP identity is provided.
https://xmpp.org/extensions/xep-0163.html#support
parent bbe47b46
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
} (this, function (jasmine, $, converse, utils, mock, test_utils) { } (this, function (jasmine, $, converse, utils, mock, test_utils) {
"use strict"; "use strict";
var $iq = converse.env.$iq, var $iq = converse.env.$iq,
Backbone = converse.env.Backbone,
Strophe = converse.env.Strophe, Strophe = converse.env.Strophe,
_ = converse.env._, _ = converse.env._,
u = converse.env.utils; u = converse.env.utils;
...@@ -30,11 +31,15 @@ ...@@ -30,11 +31,15 @@
spyOn(_converse.connection, 'getUniqueId').and.callThrough(); spyOn(_converse.connection, 'getUniqueId').and.callThrough();
test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC'); test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
var jid = 'theplay@conference.shakespeare.lit'; var jid = 'theplay@conference.shakespeare.lit';
var view = _converse.chatboxviews.get(jid); var view = _converse.chatboxviews.get(jid);
spyOn(view, 'renderBookmarkForm').and.callThrough(); spyOn(view, 'renderBookmarkForm').and.callThrough();
spyOn(view, 'closeForm').and.callThrough(); spyOn(view, 'closeForm').and.callThrough();
test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
}, 300).then(function () {
var $bookmark = $(view.el).find('.icon-pushpin'); var $bookmark = $(view.el).find('.icon-pushpin');
$bookmark[0].click(); $bookmark[0].click();
expect(view.renderBookmarkForm).toHaveBeenCalled(); expect(view.renderBookmarkForm).toHaveBeenCalled();
...@@ -129,6 +134,7 @@ ...@@ -129,6 +134,7 @@
// We ignore this IQ stanza... (unless it's an error stanza), so // We ignore this IQ stanza... (unless it's an error stanza), so
// nothing to test for here. // nothing to test for here.
done(); done();
});
})); }));
it("will be automatically opened if 'autojoin' is set on the bookmark", mock.initConverseWithPromises( it("will be automatically opened if 'autojoin' is set on the bookmark", mock.initConverseWithPromises(
...@@ -161,13 +167,18 @@ ...@@ -161,13 +167,18 @@
test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy'); test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
var view = _converse.chatboxviews.get('lounge@localhost'); var view = _converse.chatboxviews.get('lounge@localhost');
var $bookmark_icon = $(view.el.querySelector('.icon-pushpin'));
expect($bookmark_icon.hasClass('button-on')).toBeFalsy(); test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
}, 300).then(function () {
var bookmark_icon = view.el.querySelector('.icon-pushpin');
expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
view.model.set('bookmarked', true); view.model.set('bookmarked', true);
expect($bookmark_icon.hasClass('button-on')).toBeTruthy(); expect(_.includes(bookmark_icon.classList, 'button-on')).toBeTruthy();
view.model.set('bookmarked', false); view.model.set('bookmarked', false);
expect($bookmark_icon.hasClass('button-on')).toBeFalsy(); expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
done(); done();
});
})); }));
it("can be unbookmarked", mock.initConverseWithPromises( it("can be unbookmarked", mock.initConverseWithPromises(
...@@ -175,12 +186,18 @@ ...@@ -175,12 +186,18 @@
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC'); test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
var jid = 'theplay@conference.shakespeare.lit'; var jid = 'theplay@conference.shakespeare.lit';
var view = _converse.chatboxviews.get(jid); var view = _converse.chatboxviews.get(jid);
test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
}, 300).then(function () {
spyOn(view, 'toggleBookmark').and.callThrough(); spyOn(view, 'toggleBookmark').and.callThrough();
spyOn(_converse.bookmarks, 'sendBookmarkStanza').and.callThrough(); spyOn(_converse.bookmarks, 'sendBookmarkStanza').and.callThrough();
view.delegateEvents(); view.delegateEvents();
_converse.bookmarks.create({ _converse.bookmarks.create({
'jid': view.model.get('jid'), 'jid': view.model.get('jid'),
'autojoin': false, 'autojoin': false,
...@@ -230,6 +247,7 @@ ...@@ -230,6 +247,7 @@
"</iq>" "</iq>"
); );
done(); done();
});
})); }));
}); });
...@@ -308,8 +326,12 @@ ...@@ -308,8 +326,12 @@
})); }));
it("can be retrieved from the XMPP server", mock.initConverseWithPromises( it("can be retrieved from the XMPP server", mock.initConverseWithPromises(
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) { ['send'], ['chatBoxesFetched', 'roomsPanelRendered', 'rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.waitUntil(function () {
return _converse.bookmarks;
}, 300).then(function () {
/* Client requests all items /* Client requests all items
* ------------------------- * -------------------------
* *
...@@ -382,6 +404,7 @@ ...@@ -382,6 +404,7 @@
expect(_converse.bookmarks.findWhere({'jid': 'theplay@conference.shakespeare.lit'}).get('autojoin')).toBe(true); expect(_converse.bookmarks.findWhere({'jid': 'theplay@conference.shakespeare.lit'}).get('autojoin')).toBe(true);
expect(_converse.bookmarks.findWhere({'jid': 'another@conference.shakespeare.lit'}).get('autojoin')).toBe(false); expect(_converse.bookmarks.findWhere({'jid': 'another@conference.shakespeare.lit'}).get('autojoin')).toBe(false);
done(); done();
});
})); }));
describe("The rooms panel", function () { describe("The rooms panel", function () {
...@@ -389,6 +412,10 @@ ...@@ -389,6 +412,10 @@
it("shows a list of bookmarks", mock.initConverseWithPromises( it("shows a list of bookmarks", mock.initConverseWithPromises(
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) { ['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
test_utils.waitUntil(function () {
return _converse.bookmarks;
}, 300).then(function () {
test_utils.openControlBox().openRoomsPanel(_converse); test_utils.openControlBox().openRoomsPanel(_converse);
var IQ_id; var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) { expect(_.filter(_converse.connection.send.calls.all(), function (call) {
...@@ -454,11 +481,15 @@ ...@@ -454,11 +481,15 @@
"1st Bookmark  Bookmark with a very very long name that will be shortened  The Play&apos;s the Thing"; "1st Bookmark  Bookmark with a very very long name that will be shortened  The Play&apos;s the Thing";
}, 300) }, 300)
}).then(done); }).then(done);
});
})); }));
it("remembers the toggle state of the bookmarks list", mock.initConverseWithPromises( it("remembers the toggle state of the bookmarks list", mock.initConverseWithPromises(
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) { ['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
test_utils.waitUntil(function () {
return _converse.bookmarks;
}, 300).then(function () {
var IQ_id; var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) { expect(_.filter(_converse.connection.send.calls.all(), function (call) {
var stanza = call.args[0]; var stanza = call.args[0];
...@@ -510,6 +541,7 @@ ...@@ -510,6 +541,7 @@
expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED); expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED);
done(); done();
}); });
});
})); }));
}); });
}); });
...@@ -521,6 +553,9 @@ ...@@ -521,6 +553,9 @@
{ hide_open_bookmarks: true }, { hide_open_bookmarks: true },
function (done, _converse) { function (done, _converse) {
test_utils.waitUntil(function () {
return _converse.bookmarks;
}, 300).then(function () {
test_utils.openControlBox().openRoomsPanel(_converse); test_utils.openControlBox().openRoomsPanel(_converse);
// XXX Create bookmarks view here, otherwise we need to mock stanza // XXX Create bookmarks view here, otherwise we need to mock stanza
// traffic for it to get created. // traffic for it to get created.
...@@ -551,6 +586,7 @@ ...@@ -551,6 +586,7 @@
view.close(); view.close();
expect(u.hasClass('hidden', _converse.bookmarksview.el.querySelector(".available-chatroom"))).toBeFalsy(); expect(u.hasClass('hidden', _converse.bookmarksview.el.querySelector(".available-chatroom"))).toBeFalsy();
done(); done();
});
})); }));
}); });
})); }));
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp') test_utils.waitUntilFeatureSupportConfirmed(_converse, 'localhost', 'vcard-temp')
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
...@@ -1228,7 +1228,7 @@ ...@@ -1228,7 +1228,7 @@
function (done, _converse) { function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza; var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp') test_utils.waitUntilFeatureSupportConfirmed(_converse, 'localhost', 'vcard-temp')
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
...@@ -1842,7 +1842,7 @@ ...@@ -1842,7 +1842,7 @@
function (done, _converse) { function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza; var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp') test_utils.waitUntilFeatureSupportConfirmed(_converse, 'localhost', 'vcard-temp')
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
...@@ -1989,7 +1989,7 @@ ...@@ -1989,7 +1989,7 @@
function (done, _converse) { function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza; var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp') test_utils.waitUntilFeatureSupportConfirmed(_converse, 'localhost', 'vcard-temp')
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
......
...@@ -762,7 +762,6 @@ ...@@ -762,7 +762,6 @@
}); });
var view = _converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'}); var view = _converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'});
spyOn(view, 'generateHeadingHTML').and.callThrough();
var features_stanza = $iq({ var features_stanza = $iq({
from: 'coven@chat.shakespeare.lit', from: 'coven@chat.shakespeare.lit',
'id': IQ_id, 'id': IQ_id,
...@@ -791,10 +790,12 @@ ...@@ -791,10 +790,12 @@
.c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of occupants'}) .c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of occupants'})
.c('value').t(0); .c('value').t(0);
_converse.connection._dataRecv(test_utils.createRequest(features_stanza)); _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
test_utils.waitUntil(function () {
expect(view.generateHeadingHTML).toHaveBeenCalled(); return _.get(view.el.querySelector('.chatroom-description'), 'textContent');
}).then(function () {
expect($(view.el.querySelector('.chatroom-description')).text()).toBe('This is the description'); expect($(view.el.querySelector('.chatroom-description')).text()).toBe('This is the description');
done(); done();
});
})); }));
it("will specially mark messages in which you are mentioned", it("will specially mark messages in which you are mentioned",
...@@ -825,8 +826,7 @@ ...@@ -825,8 +826,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'localhost', 'vcard-temp')
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
...@@ -890,6 +890,11 @@ ...@@ -890,6 +890,11 @@
_converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'}); _converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'});
view = _converse.chatboxviews.get('coven@chat.shakespeare.lit'); view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
}, 300).then(function () {
spyOn(view, 'saveAffiliationAndRole').and.callThrough(); spyOn(view, 'saveAffiliationAndRole').and.callThrough();
// We pretend this is a new room, so no disco info is returned. // We pretend this is a new room, so no disco info is returned.
...@@ -922,9 +927,14 @@ ...@@ -922,9 +927,14 @@
.c('status', {code: '110'}); .c('status', {code: '110'});
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.saveAffiliationAndRole).toHaveBeenCalled(); expect(view.saveAffiliationAndRole).toHaveBeenCalled();
expect($(view.el.querySelector('.configure-chatroom-button')).is(':visible')).toBeTruthy();
expect($(view.el.querySelector('.toggle-chatbox-button')).is(':visible')).toBeTruthy(); expect($(view.el.querySelector('.toggle-chatbox-button')).is(':visible')).toBeTruthy();
expect($(view.el.querySelector('.toggle-bookmark')).is(':visible')).toBeTruthy(); expect($(view.el.querySelector('.toggle-bookmark')).is(':visible')).toBeTruthy();
test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.configure-chatroom-button'));
}, 300).then(function () {
expect($(view.el.querySelector('.configure-chatroom-button')).is(':visible')).toBeTruthy();
view.el.querySelector('.configure-chatroom-button').click(); view.el.querySelector('.configure-chatroom-button').click();
/* Check that an IQ is sent out, asking for the /* Check that an IQ is sent out, asking for the
...@@ -1095,6 +1105,8 @@ ...@@ -1095,6 +1105,8 @@
expect($sent_stanza.find('field[var="muc#roomconfig_allowpm"] value').text()).toBe('moderators'); expect($sent_stanza.find('field[var="muc#roomconfig_allowpm"] value').text()).toBe('moderators');
expect($sent_stanza.find('field[var="muc#roomconfig_presencebroadcast"] value').text()).toBe('moderator'); expect($sent_stanza.find('field[var="muc#roomconfig_presencebroadcast"] value').text()).toBe('moderator');
done(); done();
});
});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
})); }));
...@@ -1973,6 +1985,9 @@ ...@@ -1973,6 +1985,9 @@
var view = _converse.chatboxviews.get('lounge@localhost'), var view = _converse.chatboxviews.get('lounge@localhost'),
trimmed_chatboxes = _converse.minimized_chats; trimmed_chatboxes = _converse.minimized_chats;
test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
}, 300).then(function () {
spyOn(view, 'minimize').and.callThrough(); spyOn(view, 'minimize').and.callThrough();
spyOn(view, 'maximize').and.callThrough(); spyOn(view, 'maximize').and.callThrough();
spyOn(_converse, 'emit'); spyOn(_converse, 'emit');
...@@ -1991,6 +2006,7 @@ ...@@ -1991,6 +2006,7 @@
expect(view.model.get('minimized')).toBeFalsy(); expect(view.model.get('minimized')).toBeFalsy();
expect(_converse.emit.calls.count(), 3); expect(_converse.emit.calls.count(), 3);
done(); done();
});
})); }));
it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", it("can be closed again by clicking a DOM element with class 'close-chatbox-button'",
...@@ -2000,6 +2016,9 @@ ...@@ -2000,6 +2016,9 @@
test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy'); test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
var view = _converse.chatboxviews.get('lounge@localhost'); var view = _converse.chatboxviews.get('lounge@localhost');
test_utils.waitUntil(function () {
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
}, 300).then(function () {
spyOn(view, 'close').and.callThrough(); spyOn(view, 'close').and.callThrough();
spyOn(_converse, 'emit'); spyOn(_converse, 'emit');
spyOn(view, 'leave'); spyOn(view, 'leave');
...@@ -2013,6 +2032,7 @@ ...@@ -2013,6 +2032,7 @@
// See the "leave" method on the ChatRoomView. // See the "leave" method on the ChatRoomView.
// expect(_converse.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object)); // expect(_converse.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
done(); done();
});
})); }));
}); });
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
var entities = _converse.disco_entities; var entities = _converse.disco_entities;
expect(entities.length).toBe(1); expect(entities.length).toBe(2); // We have an extra entity, which is the user's JID
expect(entities.get(_converse.domain).features.length).toBe(5); expect(entities.get(_converse.domain).features.length).toBe(5);
expect(entities.get(_converse.domain).identities.length).toBe(3); expect(entities.get(_converse.domain).identities.length).toBe(3);
expect(entities.get('localhost').features.where({'var': 'jabber:iq:version'}).length).toBe(1); expect(entities.get('localhost').features.where({'var': 'jabber:iq:version'}).length).toBe(1);
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
entities = _converse.disco_entities; entities = _converse.disco_entities;
expect(entities.length).toBe(4); expect(entities.length).toBe(5); // We have an extra entity, which is the user's JID
expect(entities.get(_converse.domain).identities.where({'category': 'conference'}).length).toBe(1); expect(entities.get(_converse.domain).identities.where({'category': 'conference'}).length).toBe(1);
expect(entities.get(_converse.domain).identities.where({'category': 'directory'}).length).toBe(1); expect(entities.get(_converse.domain).identities.where({'category': 'directory'}).length).toBe(1);
done(); done();
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
function (done, _converse) { function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza; var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp') test_utils.waitUntilFeatureSupportConfirmed(_converse, 'localhost', 'vcard-temp')
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
......
...@@ -71,13 +71,18 @@ ...@@ -71,13 +71,18 @@
this.setBookmarkState(); this.setBookmarkState();
}, },
generateHeadingHTML () { renderHeading () {
const { _converse } = this.__super__, const { _converse } = this.__super__,
{ __ } = _converse, { __ } = _converse;
html = this.__super__.generateHeadingHTML.apply(this, arguments);
if (_converse.allow_bookmarks) { if (_converse.allow_bookmarks) {
_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid).then((identity) => {
if (_.isNil(identity)) {
return;
}
const div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = html; div.innerHTML = this.generateHeadingHTML();
const bookmark_button = tpl_chatroom_bookmark_toggle( const bookmark_button = tpl_chatroom_bookmark_toggle(
_.assignIn( _.assignIn(
this.model.toJSON(), this.model.toJSON(),
...@@ -88,9 +93,11 @@ ...@@ -88,9 +93,11 @@
)); ));
const close_button = div.querySelector('.close-chatbox-button'); const close_button = div.querySelector('.close-chatbox-button');
close_button.insertAdjacentHTML('afterend', bookmark_button); close_button.insertAdjacentHTML('afterend', bookmark_button);
return div.innerHTML; this.el.querySelector('.chat-head-chatroom').innerHTML = div.innerHTML;
});
} else {
return this.__super__.renderHeading.apply(this, arguments);
} }
return html;
}, },
checkForReservedNick () { checkForReservedNick () {
...@@ -112,6 +119,9 @@ ...@@ -112,6 +119,9 @@
onBookmarked () { onBookmarked () {
const icon = this.el.querySelector('.icon-pushpin'); const icon = this.el.querySelector('.icon-pushpin');
if (_.isNull(icon)) {
return;
}
if (this.model.get('bookmarked')) { if (this.model.get('bookmarked')) {
icon.classList.add('button-on'); icon.classList.add('button-on');
} else { } else {
...@@ -520,16 +530,25 @@ ...@@ -520,16 +530,25 @@
if (!_converse.allow_bookmarks) { if (!_converse.allow_bookmarks) {
return; return;
} }
// Only initialize bookmarks if the server supports PEP
_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid).then((identity) => {
if (_.isNil(identity)) {
_converse.emit('bookmarksInitialized');
return;
}
_converse.bookmarks = new _converse.Bookmarks(); _converse.bookmarks = new _converse.Bookmarks();
_converse.bookmarks.fetchBookmarks().then(() => { _converse.bookmarks.fetchBookmarks().then(() => {
_converse.bookmarksview = new _converse.BookmarksView( _converse.bookmarksview = new _converse.BookmarksView(
{'model': _converse.bookmarks} {'model': _converse.bookmarks}
); );
}) }).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR))
.then(() => { .then(() => {
_converse.emit('bookmarksInitialized'); _converse.emit('bookmarksInitialized');
}); });
}).catch((e) => {
_converse.log(e, Strophe.LogLevel.ERROR);
_converse.emit('bookmarksInitialized');
});
}; };
Promise.all([ Promise.all([
......
...@@ -1473,6 +1473,7 @@ ...@@ -1473,6 +1473,7 @@
this.connfeedback = new this.ConnectionFeedback(); this.connfeedback = new this.ConnectionFeedback();
this.XMPPStatus = Backbone.Model.extend({ this.XMPPStatus = Backbone.Model.extend({
initialize () { initialize () {
this.set({ this.set({
'status' : this.getStatus() 'status' : this.getStatus()
......
...@@ -326,6 +326,9 @@ ...@@ -326,6 +326,9 @@
); );
} }
const promises = [_converse.api.waitUntil('roomsAutoJoined')] const promises = [_converse.api.waitUntil('roomsAutoJoined')]
if (_converse.allow_bookmarks) {
promises.push( _converse.api.waitUntil('bookmarksInitialized'));
}
Promise.all(promises).then(() => { Promise.all(promises).then(() => {
_converse.api.rooms.open(jid); _converse.api.rooms.open(jid);
}); });
......
...@@ -118,6 +118,14 @@ ...@@ -118,6 +118,14 @@
'debug': false 'debug': false
}, settings || {})); }, settings || {}));
_converse.ChatBoxViews.prototype.trimChat = function () {}; _converse.ChatBoxViews.prototype.trimChat = function () {};
var entity = _converse.api.disco.entities.get(_converse.bare_jid, true);
entity.identities.create({
'category': 'pubsub',
'type': 'pep'
});
entity.waitUntilFeaturesDiscovered.resolve();
window.converse_disable_effects = true; window.converse_disable_effects = true;
return _converse; return _converse;
} }
......
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
} }
utils.waitUntil = waitUntilPromise.default; utils.waitUntil = waitUntilPromise.default;
utils.waitUntilFeatureSupportConfirmed = function (_converse, feature_name) { utils.waitUntilFeatureSupportConfirmed = function (_converse, entity_jid, feature_name) {
var IQ_disco, stanza; var IQ_disco, stanza;
return utils.waitUntil(function () { return utils.waitUntil(function () {
IQ_disco = _.filter(_converse.connection.IQ_stanzas, function (iq) { IQ_disco = _.filter(_converse.connection.IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('query[xmlns="http://jabber.org/protocol/disco#info"]'); return iq.nodeTree.querySelector('query[xmlns="http://jabber.org/protocol/disco#info"]') &&
iq.nodeTree.getAttribute('to') === entity_jid;
}).pop(); }).pop();
return !_.isUndefined(IQ_disco); return !_.isUndefined(IQ_disco);
}, 300).then(function () { }, 300).then(function () {
......
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