You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Impl syncing of left rooms. Factor out getting or creating filters.
This commit is contained in:
@@ -2117,8 +2117,30 @@ MatrixClient.prototype.search = function(opts, callback) {
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.syncLeftRooms = function() {
|
||||
// Guard against multiple calls whilst ongoing and multiple calls post success
|
||||
if (this._syncedLeftRooms) {
|
||||
console.log("Already synced left rooms");
|
||||
return q([]); // don't call syncRooms again if it succeeded.
|
||||
}
|
||||
if (this._syncLeftRoomsPromise) {
|
||||
console.log("Returning ongoing request promise");
|
||||
return this._syncLeftRoomsPromise; // return the ongoing request
|
||||
}
|
||||
console.log("Making sync left rooms request");
|
||||
var self = this;
|
||||
var syncApi = new SyncApi(this);
|
||||
return syncApi.syncLeftRooms();
|
||||
this._syncLeftRoomsPromise = syncApi.syncLeftRooms();
|
||||
|
||||
// cleanup locks
|
||||
this._syncLeftRoomsPromise.then(function(res) {
|
||||
console.log("Marking success of sync left room request");
|
||||
self._syncedLeftRooms = true; // flip the bit on success
|
||||
}).finally(function() {
|
||||
console.log("Cleaning up request state");
|
||||
self._syncLeftRoomsPromise = null; // cleanup ongoing request state
|
||||
});
|
||||
|
||||
return this._syncLeftRoomsPromise;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user