Let api.disco.info
use api.sendIQ
(and therefore be promise based)
This commit is contained in:
parent
878b106c7b
commit
9a60b5bb15
26
dist/converse.js
vendored
26
dist/converse.js
vendored
@ -67949,7 +67949,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
'node': 'storage:bookmarks'
|
'node': 'storage:bookmarks'
|
||||||
});
|
});
|
||||||
|
|
||||||
_converse.connection.sendIQ(stanza, _.bind(this.onBookmarksReceived, this, deferred), _.bind(this.onBookmarksReceivedError, this, deferred));
|
_converse.api.sendIQ(stanza).then(iq => this.onBookmarksReceived(deferred, iq)).catch(iq => this.onBookmarksReceivedError(deferred, iq));
|
||||||
},
|
},
|
||||||
|
|
||||||
markRoomAsBookmarked(bookmark) {
|
markRoomAsBookmarked(bookmark) {
|
||||||
@ -71268,7 +71268,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
_converse.LOGOUT = "logout";
|
_converse.LOGOUT = "logout";
|
||||||
_converse.OPENED = 'opened';
|
_converse.OPENED = 'opened';
|
||||||
_converse.PREBIND = "prebind";
|
_converse.PREBIND = "prebind";
|
||||||
_converse.IQ_TIMEOUT = 30000;
|
_converse.IQ_TIMEOUT = 20000;
|
||||||
_converse.CONNECTION_STATUS = {
|
_converse.CONNECTION_STATUS = {
|
||||||
0: 'ERROR',
|
0: 'ERROR',
|
||||||
1: 'CONNECTING',
|
1: 'CONNECTING',
|
||||||
@ -72719,7 +72719,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
},
|
},
|
||||||
|
|
||||||
queryInfo() {
|
queryInfo() {
|
||||||
_converse.api.disco.info(this.get('jid'), null, this.onInfo.bind(this));
|
_converse.api.disco.info(this.get('jid'), null).then(stanza => this.onInfo(stanza)).catch(iq => {
|
||||||
|
this.waitUntilFeaturesDiscovered.resolve();
|
||||||
|
|
||||||
|
_converse.log(iq, Strophe.LogLevel.ERROR);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onDiscoItems(stanza) {
|
onDiscoItems(stanza) {
|
||||||
@ -73086,7 +73090,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'info'(jid, node, callback, errback, timeout) {
|
'info'(jid, node) {
|
||||||
const attrs = {
|
const attrs = {
|
||||||
xmlns: Strophe.NS.DISCO_INFO
|
xmlns: Strophe.NS.DISCO_INFO
|
||||||
};
|
};
|
||||||
@ -73100,8 +73104,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
'to': jid,
|
'to': jid,
|
||||||
'type': 'get'
|
'type': 'get'
|
||||||
}).c('query', attrs);
|
}).c('query', attrs);
|
||||||
|
return _converse.api.sendIQ(info);
|
||||||
_converse.connection.sendIQ(info, callback, errback, timeout);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'items'(jid, node, callback, errback, timeout) {
|
'items'(jid, node, callback, errback, timeout) {
|
||||||
@ -75702,7 +75705,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
} else {
|
} else {
|
||||||
parent_el.insertAdjacentHTML('beforeend', tpl_spinner());
|
parent_el.insertAdjacentHTML('beforeend', tpl_spinner());
|
||||||
|
|
||||||
_converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null, _.partial(insertRoomInfo, parent_el));
|
_converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null).then(stanza => insertRoomInfo(parent_el, stanza)).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77732,9 +77735,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
/* Fetch the room disco info, parse it and then save it.
|
/* Fetch the room disco info, parse it and then save it.
|
||||||
*/
|
*/
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
_converse.api.disco.info(this.get('jid'), null, _.flow(this.parseRoomFeatures.bind(this), resolve), () => {
|
_converse.api.disco.info(this.get('jid'), null).then(stanza => {
|
||||||
|
this.parseRoomFeatures(stanza);
|
||||||
|
resolve();
|
||||||
|
}).catch(err => {
|
||||||
|
_converse.log(err, Strophe.LogLevel.ERROR);
|
||||||
|
|
||||||
reject(new Error("Could not parse the room features"));
|
reject(new Error("Could not parse the room features"));
|
||||||
}, 5000);
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -337,10 +337,9 @@
|
|||||||
'type': 'get',
|
'type': 'get',
|
||||||
}).c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
}).c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
||||||
.c('items', {'node': 'storage:bookmarks'});
|
.c('items', {'node': 'storage:bookmarks'});
|
||||||
_converse.connection.sendIQ(
|
_converse.api.sendIQ(stanza)
|
||||||
stanza,
|
.then((iq) => this.onBookmarksReceived(deferred, iq))
|
||||||
_.bind(this.onBookmarksReceived, this, deferred),
|
.catch((iq) => this.onBookmarksReceivedError(deferred, iq)
|
||||||
_.bind(this.onBookmarksReceivedError, this, deferred)
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@
|
|||||||
_converse.OPENED = 'opened';
|
_converse.OPENED = 'opened';
|
||||||
_converse.PREBIND = "prebind";
|
_converse.PREBIND = "prebind";
|
||||||
|
|
||||||
_converse.IQ_TIMEOUT = 30000;
|
_converse.IQ_TIMEOUT = 20000;
|
||||||
|
|
||||||
_converse.CONNECTION_STATUS = {
|
_converse.CONNECTION_STATUS = {
|
||||||
0: 'ERROR',
|
0: 'ERROR',
|
||||||
|
@ -126,7 +126,12 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
queryInfo () {
|
queryInfo () {
|
||||||
_converse.api.disco.info(this.get('jid'), null, this.onInfo.bind(this));
|
_converse.api.disco.info(this.get('jid'), null)
|
||||||
|
.then((stanza) => this.onInfo(stanza))
|
||||||
|
.catch((iq) => {
|
||||||
|
this.waitUntilFeaturesDiscovered.resolve();
|
||||||
|
_converse.log(iq, Strophe.LogLevel.ERROR);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onDiscoItems (stanza) {
|
onDiscoItems (stanza) {
|
||||||
@ -427,7 +432,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'info' (jid, node, callback, errback, timeout) {
|
'info' (jid, node) {
|
||||||
const attrs = {xmlns: Strophe.NS.DISCO_INFO};
|
const attrs = {xmlns: Strophe.NS.DISCO_INFO};
|
||||||
if (node) {
|
if (node) {
|
||||||
attrs.node = node;
|
attrs.node = node;
|
||||||
@ -437,7 +442,7 @@
|
|||||||
'to':jid,
|
'to':jid,
|
||||||
'type':'get'
|
'type':'get'
|
||||||
}).c('query', attrs);
|
}).c('query', attrs);
|
||||||
_converse.connection.sendIQ(info, callback, errback, timeout);
|
return _converse.api.sendIQ(info);
|
||||||
},
|
},
|
||||||
|
|
||||||
'items' (jid, node, callback, errback, timeout) {
|
'items' (jid, node, callback, errback, timeout) {
|
||||||
|
@ -297,11 +297,9 @@
|
|||||||
parent_el.querySelector('a.room-info').classList.remove('selected');
|
parent_el.querySelector('a.room-info').classList.remove('selected');
|
||||||
} else {
|
} else {
|
||||||
parent_el.insertAdjacentHTML('beforeend', tpl_spinner());
|
parent_el.insertAdjacentHTML('beforeend', tpl_spinner());
|
||||||
_converse.api.disco.info(
|
_converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null)
|
||||||
ev.target.getAttribute('data-room-jid'),
|
.then((stanza) => insertRoomInfo(parent_el, stanza))
|
||||||
null,
|
.catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
|
||||||
_.partial(insertRoomInfo, parent_el)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,13 +326,14 @@
|
|||||||
/* Fetch the room disco info, parse it and then save it.
|
/* Fetch the room disco info, parse it and then save it.
|
||||||
*/
|
*/
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
_converse.api.disco.info(
|
_converse.api.disco.info(this.get('jid'), null)
|
||||||
this.get('jid'),
|
.then((stanza) => {
|
||||||
null,
|
this.parseRoomFeatures(stanza);
|
||||||
_.flow(this.parseRoomFeatures.bind(this), resolve),
|
resolve()
|
||||||
() => { reject(new Error("Could not parse the room features")) },
|
}).catch((err) => {
|
||||||
5000
|
_converse.log(err, Strophe.LogLevel.ERROR);
|
||||||
);
|
reject(new Error("Could not parse the room features"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user