You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
nothing works anymore :((
This commit is contained in:
@@ -279,16 +279,17 @@ function sendMessage(client) {
|
|||||||
|
|
||||||
function expectSendMessageRequest(httpBackend) {
|
function expectSendMessageRequest(httpBackend) {
|
||||||
const path = "/send/m.room.encrypted/";
|
const path = "/send/m.room.encrypted/";
|
||||||
const deferred = Promise.defer();
|
const prom = new Promise((resolve) => {
|
||||||
httpBackend.when("PUT", path).respond(200, function(path, content) {
|
httpBackend.when("PUT", path).respond(200, function(path, content) {
|
||||||
deferred.resolve(content);
|
resolve(content);
|
||||||
return {
|
return {
|
||||||
event_id: "asdfgh",
|
event_id: "asdfgh",
|
||||||
};
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// it can take a while to process the key query
|
// it can take a while to process the key query
|
||||||
return httpBackend.flush(path, 1).then(() => deferred.promise);
|
return httpBackend.flush(path, 1).then(() => prom);
|
||||||
}
|
}
|
||||||
|
|
||||||
function aliRecvMessage() {
|
function aliRecvMessage() {
|
||||||
|
|||||||
@@ -83,18 +83,19 @@ function startClient(httpBackend, client) {
|
|||||||
client.startClient();
|
client.startClient();
|
||||||
|
|
||||||
// set up a promise which will resolve once the client is initialised
|
// set up a promise which will resolve once the client is initialised
|
||||||
const deferred = Promise.defer();
|
const prom = new Promise((resolve) => {
|
||||||
client.on("sync", function(state) {
|
client.on("sync", function(state) {
|
||||||
logger.log("sync", state);
|
logger.log("sync", state);
|
||||||
if (state != "SYNCING") {
|
if (state != "SYNCING") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
deferred.resolve();
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
httpBackend.flushAllExpected(),
|
httpBackend.flushAllExpected(),
|
||||||
deferred.promise,
|
prom,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,25 +344,25 @@ describe("MatrixClient event timelines", function() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const deferred = Promise.defer();
|
const prom = new Promise((resolve, reject) => {
|
||||||
client.on("sync", function() {
|
client.on("sync", function() {
|
||||||
client.getEventTimeline(timelineSet, EVENTS[2].event_id,
|
client.getEventTimeline(timelineSet, EVENTS[2].event_id,
|
||||||
).then(function(tl) {
|
).then(function(tl) {
|
||||||
expect(tl.getEvents().length).toEqual(4);
|
expect(tl.getEvents().length).toEqual(4);
|
||||||
expect(tl.getEvents()[0].event).toEqual(EVENTS[1]);
|
expect(tl.getEvents()[0].event).toEqual(EVENTS[1]);
|
||||||
expect(tl.getEvents()[1].event).toEqual(EVENTS[2]);
|
expect(tl.getEvents()[1].event).toEqual(EVENTS[2]);
|
||||||
expect(tl.getEvents()[3].event).toEqual(EVENTS[3]);
|
expect(tl.getEvents()[3].event).toEqual(EVENTS[3]);
|
||||||
expect(tl.getPaginationToken(EventTimeline.BACKWARDS))
|
expect(tl.getPaginationToken(EventTimeline.BACKWARDS))
|
||||||
.toEqual("start_token");
|
.toEqual("start_token");
|
||||||
// expect(tl.getPaginationToken(EventTimeline.FORWARDS))
|
// expect(tl.getPaginationToken(EventTimeline.FORWARDS))
|
||||||
// .toEqual("s_5_4");
|
// .toEqual("s_5_4");
|
||||||
}).done(() => deferred.resolve(),
|
}).done(resolve, reject);
|
||||||
(e) => deferred.reject(e));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
httpBackend.flushAllExpected(),
|
httpBackend.flushAllExpected(),
|
||||||
deferred.promise,
|
prom,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -691,12 +691,12 @@ describe("MatrixClient syncing", function() {
|
|||||||
include_leave: true }});
|
include_leave: true }});
|
||||||
}).respond(200, { filter_id: "another_id" });
|
}).respond(200, { filter_id: "another_id" });
|
||||||
|
|
||||||
const defer = Promise.defer();
|
const prom = new Promise((resolve) => {
|
||||||
|
httpBackend.when("GET", "/sync").check(function(req) {
|
||||||
httpBackend.when("GET", "/sync").check(function(req) {
|
expect(req.queryParams.filter).toEqual("another_id");
|
||||||
expect(req.queryParams.filter).toEqual("another_id");
|
resolve();
|
||||||
defer.resolve();
|
}).respond(200, {});
|
||||||
}).respond(200, {});
|
});
|
||||||
|
|
||||||
client.syncLeftRooms();
|
client.syncLeftRooms();
|
||||||
|
|
||||||
@@ -707,7 +707,7 @@ describe("MatrixClient syncing", function() {
|
|||||||
// flush the syncs
|
// flush the syncs
|
||||||
return httpBackend.flushAllExpected();
|
return httpBackend.flushAllExpected();
|
||||||
}),
|
}),
|
||||||
defer.promise,
|
prom,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3886,26 +3886,26 @@ MatrixClient.prototype.setRoomMutePushRule = function(scope, roomId, mute) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
// Update this.pushRules when the operation completes
|
return new Promise((resolve, reject) => {
|
||||||
const ruleRefreshDeferred = Promise.defer();
|
// Update this.pushRules when the operation completes
|
||||||
deferred.done(function() {
|
deferred.done(function() {
|
||||||
self.getPushRules().done(function(result) {
|
self.getPushRules().done(function(result) {
|
||||||
self.pushRules = result;
|
self.pushRules = result;
|
||||||
ruleRefreshDeferred.resolve();
|
resolve();
|
||||||
|
}, function(err) {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
ruleRefreshDeferred.reject(err);
|
// Update it even if the previous operation fails. This can help the
|
||||||
});
|
// app to recover when push settings has been modifed from another client
|
||||||
}, function(err) {
|
self.getPushRules().done(function(result) {
|
||||||
// Update it even if the previous operation fails. This can help the
|
self.pushRules = result;
|
||||||
// app to recover when push settings has been modifed from another client
|
reject(err);
|
||||||
self.getPushRules().done(function(result) {
|
}, function(err2) {
|
||||||
self.pushRules = result;
|
reject(err);
|
||||||
ruleRefreshDeferred.reject(err);
|
});
|
||||||
}, function(err2) {
|
|
||||||
ruleRefreshDeferred.reject(err);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return ruleRefreshDeferred.promise;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,35 +58,34 @@ export class Backend {
|
|||||||
getOrAddOutgoingRoomKeyRequest(request) {
|
getOrAddOutgoingRoomKeyRequest(request) {
|
||||||
const requestBody = request.requestBody;
|
const requestBody = request.requestBody;
|
||||||
|
|
||||||
const deferred = Promise.defer();
|
return new Promise((resolve, reject) => {
|
||||||
const txn = this._db.transaction("outgoingRoomKeyRequests", "readwrite");
|
const txn = this._db.transaction("outgoingRoomKeyRequests", "readwrite");
|
||||||
txn.onerror = deferred.reject;
|
txn.onerror = reject;
|
||||||
|
|
||||||
// first see if we already have an entry for this request.
|
// first see if we already have an entry for this request.
|
||||||
this._getOutgoingRoomKeyRequest(txn, requestBody, (existing) => {
|
this._getOutgoingRoomKeyRequest(txn, requestBody, (existing) => {
|
||||||
if (existing) {
|
if (existing) {
|
||||||
// this entry matches the request - return it.
|
// this entry matches the request - return it.
|
||||||
|
logger.log(
|
||||||
|
`already have key request outstanding for ` +
|
||||||
|
`${requestBody.room_id} / ${requestBody.session_id}: ` +
|
||||||
|
`not sending another`,
|
||||||
|
);
|
||||||
|
resolve(existing);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we got to the end of the list without finding a match
|
||||||
|
// - add the new request.
|
||||||
logger.log(
|
logger.log(
|
||||||
`already have key request outstanding for ` +
|
`enqueueing key request for ${requestBody.room_id} / ` +
|
||||||
`${requestBody.room_id} / ${requestBody.session_id}: ` +
|
requestBody.session_id,
|
||||||
`not sending another`,
|
|
||||||
);
|
);
|
||||||
deferred.resolve(existing);
|
txn.oncomplete = () => { resolve(request); };
|
||||||
return;
|
const store = txn.objectStore("outgoingRoomKeyRequests");
|
||||||
}
|
store.add(request);
|
||||||
|
});
|
||||||
// we got to the end of the list without finding a match
|
|
||||||
// - add the new request.
|
|
||||||
logger.log(
|
|
||||||
`enqueueing key request for ${requestBody.room_id} / ` +
|
|
||||||
requestBody.session_id,
|
|
||||||
);
|
|
||||||
txn.oncomplete = () => { deferred.resolve(request); };
|
|
||||||
const store = txn.objectStore("outgoingRoomKeyRequests");
|
|
||||||
store.add(request);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,15 +99,14 @@ export class Backend {
|
|||||||
* not found
|
* not found
|
||||||
*/
|
*/
|
||||||
getOutgoingRoomKeyRequest(requestBody) {
|
getOutgoingRoomKeyRequest(requestBody) {
|
||||||
const deferred = Promise.defer();
|
return new Promise((resolve, reject) => {
|
||||||
|
const txn = this._db.transaction("outgoingRoomKeyRequests", "readonly");
|
||||||
|
txn.onerror = reject;
|
||||||
|
|
||||||
const txn = this._db.transaction("outgoingRoomKeyRequests", "readonly");
|
this._getOutgoingRoomKeyRequest(txn, requestBody, (existing) => {
|
||||||
txn.onerror = deferred.reject;
|
resolve(existing);
|
||||||
|
});
|
||||||
this._getOutgoingRoomKeyRequest(txn, requestBody, (existing) => {
|
|
||||||
deferred.resolve(existing);
|
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user