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
Rip out bluebird of a bunch of places, lots to go :(
This commit is contained in:
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
import TestClient from '../TestClient';
|
import TestClient from '../TestClient';
|
||||||
import testUtils from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import logger from '../../src/logger';
|
import logger from '../../src/logger';
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import 'source-map-support/register';
|
|||||||
import '../olm-loader';
|
import '../olm-loader';
|
||||||
|
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
import Promise from 'bluebird';
|
|
||||||
const utils = require("../../lib/utils");
|
const utils = require("../../lib/utils");
|
||||||
const testUtils = require("../test-utils");
|
const testUtils = require("../test-utils");
|
||||||
const TestClient = require('../TestClient').default;
|
const TestClient = require('../TestClient').default;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ const sdk = require("../..");
|
|||||||
const HttpBackend = require("matrix-mock-request");
|
const HttpBackend = require("matrix-mock-request");
|
||||||
const utils = require("../test-utils");
|
const utils = require("../test-utils");
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
describe("MatrixClient events", function() {
|
describe("MatrixClient events", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
const baseUrl = "http://localhost.or.something";
|
||||||
let client;
|
let client;
|
||||||
@@ -162,7 +160,7 @@ describe("MatrixClient events", function() {
|
|||||||
});
|
});
|
||||||
client.startClient();
|
client.startClient();
|
||||||
|
|
||||||
httpBackend.flushAllExpected().done(function() {
|
httpBackend.flushAllExpected().then(function() {
|
||||||
expect(fired).toBe(true, "User.presence didn't fire.");
|
expect(fired).toBe(true, "User.presence didn't fire.");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import Promise from 'bluebird';
|
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
const HttpBackend = require("matrix-mock-request");
|
const HttpBackend = require("matrix-mock-request");
|
||||||
const utils = require("../test-utils");
|
const utils = require("../test-utils");
|
||||||
@@ -356,7 +355,7 @@ describe("MatrixClient event timelines", function() {
|
|||||||
.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(resolve, reject);
|
}).then(resolve, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ const MatrixClient = sdk.MatrixClient;
|
|||||||
const HttpBackend = require("matrix-mock-request");
|
const HttpBackend = require("matrix-mock-request");
|
||||||
const utils = require("../test-utils");
|
const utils = require("../test-utils");
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
describe("MatrixClient opts", function() {
|
describe("MatrixClient opts", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
const baseUrl = "http://localhost.or.something";
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -86,7 +84,7 @@ describe("MatrixClient opts", function() {
|
|||||||
httpBackend.when("PUT", "/txn1").respond(200, {
|
httpBackend.when("PUT", "/txn1").respond(200, {
|
||||||
event_id: eventId,
|
event_id: eventId,
|
||||||
});
|
});
|
||||||
client.sendTextMessage("!foo:bar", "a body", "txn1").done(function(res) {
|
client.sendTextMessage("!foo:bar", "a body", "txn1").then(function(res) {
|
||||||
expect(res.event_id).toEqual(eventId);
|
expect(res.event_id).toEqual(eventId);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -139,7 +137,7 @@ describe("MatrixClient opts", function() {
|
|||||||
errcode: "M_SOMETHING",
|
errcode: "M_SOMETHING",
|
||||||
error: "Ruh roh",
|
error: "Ruh roh",
|
||||||
});
|
});
|
||||||
client.sendTextMessage("!foo:bar", "a body", "txn1").done(function(res) {
|
client.sendTextMessage("!foo:bar", "a body", "txn1").then(function(res) {
|
||||||
expect(false).toBe(true, "sendTextMessage resolved but shouldn't");
|
expect(false).toBe(true, "sendTextMessage resolved but shouldn't");
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
expect(err.errcode).toEqual("M_SOMETHING");
|
expect(err.errcode).toEqual("M_SOMETHING");
|
||||||
@@ -157,16 +155,16 @@ describe("MatrixClient opts", function() {
|
|||||||
});
|
});
|
||||||
let sentA = false;
|
let sentA = false;
|
||||||
let sentB = false;
|
let sentB = false;
|
||||||
client.sendTextMessage("!foo:bar", "a body", "txn1").done(function(res) {
|
client.sendTextMessage("!foo:bar", "a body", "txn1").then(function(res) {
|
||||||
sentA = true;
|
sentA = true;
|
||||||
expect(sentB).toBe(true);
|
expect(sentB).toBe(true);
|
||||||
});
|
});
|
||||||
client.sendTextMessage("!foo:bar", "b body", "txn2").done(function(res) {
|
client.sendTextMessage("!foo:bar", "b body", "txn2").then(function(res) {
|
||||||
sentB = true;
|
sentB = true;
|
||||||
expect(sentA).toBe(false);
|
expect(sentA).toBe(false);
|
||||||
});
|
});
|
||||||
httpBackend.flush("/txn2", 1).done(function() {
|
httpBackend.flush("/txn2", 1).then(function() {
|
||||||
httpBackend.flush("/txn1", 1).done(function() {
|
httpBackend.flush("/txn1", 1).then(function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -176,7 +174,7 @@ describe("MatrixClient opts", function() {
|
|||||||
httpBackend.when("PUT", "/txn1").respond(200, {
|
httpBackend.when("PUT", "/txn1").respond(200, {
|
||||||
event_id: "foo",
|
event_id: "foo",
|
||||||
});
|
});
|
||||||
client.sendTextMessage("!foo:bar", "a body", "txn1").done(function(res) {
|
client.sendTextMessage("!foo:bar", "a body", "txn1").then(function(res) {
|
||||||
expect(res.event_id).toEqual("foo");
|
expect(res.event_id).toEqual("foo");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
const HttpBackend = require("matrix-mock-request");
|
const HttpBackend = require("matrix-mock-request");
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ const EventStatus = sdk.EventStatus;
|
|||||||
const HttpBackend = require("matrix-mock-request");
|
const HttpBackend = require("matrix-mock-request");
|
||||||
const utils = require("../test-utils");
|
const utils = require("../test-utils");
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
describe("MatrixClient room timelines", function() {
|
describe("MatrixClient room timelines", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
const baseUrl = "http://localhost.or.something";
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -151,7 +149,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
expect(member.userId).toEqual(userId);
|
expect(member.userId).toEqual(userId);
|
||||||
expect(member.name).toEqual(userName);
|
expect(member.name).toEqual(userName);
|
||||||
|
|
||||||
httpBackend.flush("/sync", 1).done(function() {
|
httpBackend.flush("/sync", 1).then(function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -177,10 +175,10 @@ describe("MatrixClient room timelines", function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
client.sendTextMessage(roomId, "I am a fish", "txn1").done(
|
client.sendTextMessage(roomId, "I am a fish", "txn1").then(
|
||||||
function() {
|
function() {
|
||||||
expect(room.timeline[1].getId()).toEqual(eventId);
|
expect(room.timeline[1].getId()).toEqual(eventId);
|
||||||
httpBackend.flush("/sync", 1).done(function() {
|
httpBackend.flush("/sync", 1).then(function() {
|
||||||
expect(room.timeline[1].getId()).toEqual(eventId);
|
expect(room.timeline[1].getId()).toEqual(eventId);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -210,10 +208,10 @@ describe("MatrixClient room timelines", function() {
|
|||||||
}
|
}
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
const promise = client.sendTextMessage(roomId, "I am a fish", "txn1");
|
const promise = client.sendTextMessage(roomId, "I am a fish", "txn1");
|
||||||
httpBackend.flush("/sync", 1).done(function() {
|
httpBackend.flush("/sync", 1).then(function() {
|
||||||
expect(room.timeline.length).toEqual(2);
|
expect(room.timeline.length).toEqual(2);
|
||||||
httpBackend.flush("/txn1", 1);
|
httpBackend.flush("/txn1", 1);
|
||||||
promise.done(function() {
|
promise.then(function() {
|
||||||
expect(room.timeline.length).toEqual(2);
|
expect(room.timeline.length).toEqual(2);
|
||||||
expect(room.timeline[1].getId()).toEqual(eventId);
|
expect(room.timeline[1].getId()).toEqual(eventId);
|
||||||
done();
|
done();
|
||||||
@@ -248,7 +246,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
expect(room.timeline.length).toEqual(1);
|
expect(room.timeline.length).toEqual(1);
|
||||||
|
|
||||||
client.scrollback(room).done(function() {
|
client.scrollback(room).then(function() {
|
||||||
expect(room.timeline.length).toEqual(1);
|
expect(room.timeline.length).toEqual(1);
|
||||||
expect(room.oldState.paginationToken).toBe(null);
|
expect(room.oldState.paginationToken).toBe(null);
|
||||||
|
|
||||||
@@ -312,7 +310,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
// sync response
|
// sync response
|
||||||
expect(room.timeline.length).toEqual(1);
|
expect(room.timeline.length).toEqual(1);
|
||||||
|
|
||||||
client.scrollback(room).done(function() {
|
client.scrollback(room).then(function() {
|
||||||
expect(room.timeline.length).toEqual(5);
|
expect(room.timeline.length).toEqual(5);
|
||||||
const joinMsg = room.timeline[0];
|
const joinMsg = room.timeline[0];
|
||||||
expect(joinMsg.sender.name).toEqual("Old Alice");
|
expect(joinMsg.sender.name).toEqual("Old Alice");
|
||||||
@@ -350,7 +348,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
expect(room.timeline.length).toEqual(1);
|
expect(room.timeline.length).toEqual(1);
|
||||||
|
|
||||||
client.scrollback(room).done(function() {
|
client.scrollback(room).then(function() {
|
||||||
expect(room.timeline.length).toEqual(3);
|
expect(room.timeline.length).toEqual(3);
|
||||||
expect(room.timeline[0].event).toEqual(sbEvents[1]);
|
expect(room.timeline[0].event).toEqual(sbEvents[1]);
|
||||||
expect(room.timeline[1].event).toEqual(sbEvents[0]);
|
expect(room.timeline[1].event).toEqual(sbEvents[0]);
|
||||||
@@ -381,11 +379,11 @@ describe("MatrixClient room timelines", function() {
|
|||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
expect(room.oldState.paginationToken).toBeTruthy();
|
expect(room.oldState.paginationToken).toBeTruthy();
|
||||||
|
|
||||||
client.scrollback(room, 1).done(function() {
|
client.scrollback(room, 1).then(function() {
|
||||||
expect(room.oldState.paginationToken).toEqual(sbEndTok);
|
expect(room.oldState.paginationToken).toEqual(sbEndTok);
|
||||||
});
|
});
|
||||||
|
|
||||||
httpBackend.flush("/messages", 1).done(function() {
|
httpBackend.flush("/messages", 1).then(function() {
|
||||||
// still have a sync to flush
|
// still have a sync to flush
|
||||||
httpBackend.flush("/sync", 1).then(() => {
|
httpBackend.flush("/sync", 1).then(() => {
|
||||||
done();
|
done();
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ const utils = require("../test-utils");
|
|||||||
const MatrixEvent = sdk.MatrixEvent;
|
const MatrixEvent = sdk.MatrixEvent;
|
||||||
const EventTimeline = sdk.EventTimeline;
|
const EventTimeline = sdk.EventTimeline;
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
describe("MatrixClient syncing", function() {
|
describe("MatrixClient syncing", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
const baseUrl = "http://localhost.or.something";
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -51,7 +49,7 @@ describe("MatrixClient syncing", function() {
|
|||||||
|
|
||||||
client.startClient();
|
client.startClient();
|
||||||
|
|
||||||
httpBackend.flushAllExpected().done(function() {
|
httpBackend.flushAllExpected().then(function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -65,7 +63,7 @@ describe("MatrixClient syncing", function() {
|
|||||||
|
|
||||||
client.startClient();
|
client.startClient();
|
||||||
|
|
||||||
httpBackend.flushAllExpected().done(function() {
|
httpBackend.flushAllExpected().then(function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const anotherjson = require('another-json');
|
const anotherjson = require('another-json');
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
const utils = require('../../lib/utils');
|
const utils = require('../../lib/utils');
|
||||||
const testUtils = require('../test-utils');
|
const testUtils = require('../test-utils');
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ limitations under the License.
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import Promise from 'bluebird';
|
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
|
|
||||||
const AutoDiscovery = sdk.AutoDiscovery;
|
const AutoDiscovery = sdk.AutoDiscovery;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import '../../../olm-loader';
|
import '../../../olm-loader';
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
import sdk from '../../../..';
|
import sdk from '../../../..';
|
||||||
import algorithms from '../../../../lib/crypto/algorithms';
|
import algorithms from '../../../../lib/crypto/algorithms';
|
||||||
import MemoryCryptoStore from '../../../../lib/crypto/store/memory-crypto-store.js';
|
import MemoryCryptoStore from '../../../../lib/crypto/store/memory-crypto-store.js';
|
||||||
@@ -136,11 +134,11 @@ describe("MegolmDecryption", function() {
|
|||||||
const deviceInfo = {};
|
const deviceInfo = {};
|
||||||
mockCrypto.getStoredDevice.mockReturnValue(deviceInfo);
|
mockCrypto.getStoredDevice.mockReturnValue(deviceInfo);
|
||||||
|
|
||||||
mockOlmLib.ensureOlmSessionsForDevices.mockReturnValue(
|
mockOlmLib.ensureOlmSessionsForDevices.mockResolvedValue({
|
||||||
Promise.resolve({'@alice:foo': {'alidevice': {
|
'@alice:foo': {'alidevice': {
|
||||||
sessionId: 'alisession',
|
sessionId: 'alisession',
|
||||||
}}}),
|
}},
|
||||||
);
|
});
|
||||||
|
|
||||||
const awaitEncryptForDevice = new Promise((res, rej) => {
|
const awaitEncryptForDevice = new Promise((res, rej) => {
|
||||||
mockOlmLib.encryptMessageForDevice.mockImplementation(() => {
|
mockOlmLib.encryptMessageForDevice.mockImplementation(() => {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ limitations under the License.
|
|||||||
|
|
||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
import sdk from '../../..';
|
import sdk from '../../..';
|
||||||
import algorithms from '../../../lib/crypto/algorithms';
|
import algorithms from '../../../lib/crypto/algorithms';
|
||||||
import WebStorageSessionStore from '../../../lib/store/session/webstorage';
|
import WebStorageSessionStore from '../../../lib/store/session/webstorage';
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
import sdk from '../..';
|
import sdk from '../..';
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
const MatrixEvent = sdk.MatrixEvent;
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
import logger from '../../src/logger';
|
import logger from '../../src/logger';
|
||||||
|
|
||||||
describe("MatrixEvent", () => {
|
describe("MatrixEvent", () => {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ limitations under the License.
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import Promise from 'bluebird';
|
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
|
|
||||||
const InteractiveAuth = sdk.InteractiveAuth;
|
const InteractiveAuth = sdk.InteractiveAuth;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
/* eslint new-cap: "off" */
|
/* eslint new-cap: "off" */
|
||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import Promise from 'bluebird';
|
|
||||||
import {defer} from '../../src/utils';
|
import {defer} from '../../src/utils';
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
const MatrixScheduler = sdk.MatrixScheduler;
|
const MatrixScheduler = sdk.MatrixScheduler;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import Promise from 'bluebird';
|
|
||||||
const sdk = require("../..");
|
const sdk = require("../..");
|
||||||
const EventTimeline = sdk.EventTimeline;
|
const EventTimeline = sdk.EventTimeline;
|
||||||
const TimelineWindow = sdk.TimelineWindow;
|
const TimelineWindow = sdk.TimelineWindow;
|
||||||
|
|||||||
@@ -1036,7 +1036,7 @@ MegolmDecryption.prototype.shareKeysWithDevice = function(keyRequest) {
|
|||||||
// TODO: retries
|
// TODO: retries
|
||||||
return this._baseApis.sendToDevice("m.room.encrypted", contentMap);
|
return this._baseApis.sendToDevice("m.room.encrypted", contentMap);
|
||||||
});
|
});
|
||||||
}).done();
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
MegolmDecryption.prototype._buildKeyForwardingMessage = async function(
|
MegolmDecryption.prototype._buildKeyForwardingMessage = async function(
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
import SyncAccumulator from "../sync-accumulator";
|
import SyncAccumulator from "../sync-accumulator";
|
||||||
import utils from "../utils";
|
import utils from "../utils";
|
||||||
import * as IndexedDBHelpers from "../indexeddb-helpers";
|
import * as IndexedDBHelpers from "../indexeddb-helpers";
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
|
|
||||||
/* eslint-disable babel/no-invalid-this */
|
/* eslint-disable babel/no-invalid-this */
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
import {MemoryStore} from "./memory";
|
import {MemoryStore} from "./memory";
|
||||||
import utils from "../utils";
|
import utils from "../utils";
|
||||||
import {EventEmitter} from 'events';
|
import {EventEmitter} from 'events';
|
||||||
|
|||||||
Reference in New Issue
Block a user