1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-15 14:04:59 -05:00

Fix: Update MUCs list every 30 secs

This commit is contained in:
Sébastien Hut 2015-02-11 17:39:46 +01:00 committed by Sébastien Hut
parent 87e2cb8a27
commit 85e4e06d5a

View File

@ -62,15 +62,19 @@ module.exports = BaseCollection.extend({
if (SERVER_CONFIG.muc) {
if (client.sessionStarted) {
var rooms = [];
client.getDiscoItems(SERVER_CONFIG.muc, '', function (err, res) {
if (!err) {
var rooms = res.discoItems.items;
if (err) return;
rooms = res.discoItems.items;
var roomNum = 0;
if (rooms) {
var roomNum = 0;
rooms.forEach (function (room) {
client.getDiscoInfo(room.jid, '', function (err, res) {
roomNum++;
if (err) return;
var features = res.discoInfo.features;
@ -86,30 +90,25 @@ module.exports = BaseCollection.extend({
app.mucInfos.push(mucInfo);
if (++roomNum == rooms.length)
cb();
}).then(function() {
if (cb && roomNum == rooms.length) cb();
});
});
}
else {
cb();
}
}
if (err)
cb();
}).then(function() {
if (cb && !rooms.length) cb();
});
} else {
app.whenConnected(function () {
self.fetch(function () {});
self.fetch(cb);
});
}
} else {
cb();
return;
}
if (cb) cb();
},
update: function () {
if (SERVER_CONFIG.muc) {