Merge pull request #4565 from vector-im/rav/bluebird
Switch riot-web to bluebird
This commit is contained in:
commit
348ec52b14
13 changed files with 64 additions and 62 deletions
|
@ -54,6 +54,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "^6.5.0",
|
"babel-polyfill": "^6.5.0",
|
||||||
"babel-runtime": "^6.11.6",
|
"babel-runtime": "^6.11.6",
|
||||||
|
"bluebird": "^3.5.0",
|
||||||
"browser-request": "^0.3.3",
|
"browser-request": "^0.3.3",
|
||||||
"classnames": "^2.1.2",
|
"classnames": "^2.1.2",
|
||||||
"draft-js": "^0.8.1",
|
"draft-js": "^0.8.1",
|
||||||
|
@ -69,7 +70,6 @@
|
||||||
"matrix-react-sdk": "0.9.7",
|
"matrix-react-sdk": "0.9.7",
|
||||||
"modernizr": "^3.1.0",
|
"modernizr": "^3.1.0",
|
||||||
"pako": "^1.0.5",
|
"pako": "^1.0.5",
|
||||||
"q": "^1.4.1",
|
|
||||||
"react": "^15.4.0",
|
"react": "^15.4.0",
|
||||||
"react-dnd": "^2.1.4",
|
"react-dnd": "^2.1.4",
|
||||||
"react-dnd-html5-backend": "^2.1.2",
|
"react-dnd-html5-backend": "^2.1.2",
|
||||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var q = require("q");
|
import Promise from 'bluebird';
|
||||||
var Matrix = require("matrix-js-sdk");
|
var Matrix = require("matrix-js-sdk");
|
||||||
var Room = Matrix.Room;
|
var Room = Matrix.Room;
|
||||||
var CallHandler = require('matrix-react-sdk/lib/CallHandler');
|
var CallHandler = require('matrix-react-sdk/lib/CallHandler');
|
||||||
|
@ -53,11 +53,11 @@ ConferenceCall.prototype._joinConferenceUser = function() {
|
||||||
// Make sure the conference user is in the group chat room
|
// Make sure the conference user is in the group chat room
|
||||||
var groupRoom = this.client.getRoom(this.groupRoomId);
|
var groupRoom = this.client.getRoom(this.groupRoomId);
|
||||||
if (!groupRoom) {
|
if (!groupRoom) {
|
||||||
return q.reject("Bad group room ID");
|
return Promise.reject("Bad group room ID");
|
||||||
}
|
}
|
||||||
var member = groupRoom.getMember(this.confUserId);
|
var member = groupRoom.getMember(this.confUserId);
|
||||||
if (member && member.membership === "join") {
|
if (member && member.membership === "join") {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
return this.client.invite(this.groupRoomId, this.confUserId);
|
return this.client.invite(this.groupRoomId, this.confUserId);
|
||||||
};
|
};
|
||||||
|
@ -75,7 +75,7 @@ ConferenceCall.prototype._getConferenceUserRoom = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (confRoom) {
|
if (confRoom) {
|
||||||
return q(confRoom);
|
return Promise.resolve(confRoom);
|
||||||
}
|
}
|
||||||
return this.client.createRoom({
|
return this.client.createRoom({
|
||||||
preset: "private_chat",
|
preset: "private_chat",
|
||||||
|
|
|
@ -28,7 +28,7 @@ var linkify = require('linkifyjs');
|
||||||
var linkifyString = require('linkifyjs/string');
|
var linkifyString = require('linkifyjs/string');
|
||||||
var linkifyMatrix = require('matrix-react-sdk/lib/linkify-matrix');
|
var linkifyMatrix = require('matrix-react-sdk/lib/linkify-matrix');
|
||||||
var sanitizeHtml = require('sanitize-html');
|
var sanitizeHtml = require('sanitize-html');
|
||||||
var q = require('q');
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getMoreRooms: function() {
|
getMoreRooms: function() {
|
||||||
if (!MatrixClientPeg.get()) return q();
|
if (!MatrixClientPeg.get()) return Promise.resolve();
|
||||||
|
|
||||||
const my_filter_string = this.state.filterString;
|
const my_filter_string = this.state.filterString;
|
||||||
const my_server = this.state.roomServer;
|
const my_server = this.state.roomServer;
|
||||||
|
@ -266,7 +266,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onFillRequest: function(backwards) {
|
onFillRequest: function(backwards) {
|
||||||
if (backwards || !this.nextBatch) return q(false);
|
if (backwards || !this.nextBatch) return Promise.resolve(false);
|
||||||
|
|
||||||
return this.getMoreRooms();
|
return this.getMoreRooms();
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import q from 'q';
|
import Promise from 'bluebird';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import sdk from 'matrix-react-sdk';
|
import sdk from 'matrix-react-sdk';
|
||||||
|
@ -61,7 +61,7 @@ module.exports = React.createClass({
|
||||||
const roomId = this.props.room.roomId;
|
const roomId = this.props.room.roomId;
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
if (!cli.isGuest()) {
|
if (!cli.isGuest()) {
|
||||||
q.delay(500).then(function() {
|
Promise.delay(500).then(function() {
|
||||||
if (tagNameOff !== null && tagNameOff !== undefined) {
|
if (tagNameOff !== null && tagNameOff !== undefined) {
|
||||||
cli.deleteRoomTag(roomId, tagNameOff).finally(function() {
|
cli.deleteRoomTag(roomId, tagNameOff).finally(function() {
|
||||||
// Close the context menu
|
// Close the context menu
|
||||||
|
@ -212,7 +212,7 @@ module.exports = React.createClass({
|
||||||
RoomNotifs.setRoomNotifsState(this.props.room.roomId, newState).done(() => {
|
RoomNotifs.setRoomNotifsState(this.props.room.roomId, newState).done(() => {
|
||||||
// delay slightly so that the user can see their state change
|
// delay slightly so that the user can see their state change
|
||||||
// before closing the menu
|
// before closing the menu
|
||||||
return q.delay(500).then(() => {
|
return Promise.delay(500).then(() => {
|
||||||
if (this._unmounted) return;
|
if (this._unmounted) return;
|
||||||
// Close the context menu
|
// Close the context menu
|
||||||
if (this.props.onFinished) {
|
if (this.props.onFinished) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
'use strict';
|
'use strict';
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
import { _t, _tJsx } from 'matrix-react-sdk/lib/languageHandler';
|
import { _t, _tJsx } from 'matrix-react-sdk/lib/languageHandler';
|
||||||
var q = require("q");
|
import Promise from 'bluebird';
|
||||||
var sdk = require('matrix-react-sdk');
|
var sdk = require('matrix-react-sdk');
|
||||||
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
var UserSettingsStore = require('matrix-react-sdk/lib/UserSettingsStore');
|
var UserSettingsStore = require('matrix-react-sdk/lib/UserSettingsStore');
|
||||||
|
@ -236,7 +236,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q.all(deferreds).done(function() {
|
Promise.all(deferreds).done(function() {
|
||||||
self._refreshFromServer();
|
self._refreshFromServer();
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
@ -306,7 +306,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q.all(deferreds).done(function(resps) {
|
Promise.all(deferreds).done(function(resps) {
|
||||||
self._refreshFromServer();
|
self._refreshFromServer();
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
@ -361,7 +361,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then, add the new ones
|
// Then, add the new ones
|
||||||
q.all(removeDeferreds).done(function(resps) {
|
Promise.all(removeDeferreds).done(function(resps) {
|
||||||
var deferreds = [];
|
var deferreds = [];
|
||||||
|
|
||||||
var pushRuleVectorStateKind = self.state.vectorContentRules.vectorState;
|
var pushRuleVectorStateKind = self.state.vectorContentRules.vectorState;
|
||||||
|
@ -399,7 +399,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q.all(deferreds).done(function(resps) {
|
Promise.all(deferreds).done(function(resps) {
|
||||||
self._refreshFromServer();
|
self._refreshFromServer();
|
||||||
}, onError);
|
}, onError);
|
||||||
}, onError);
|
}, onError);
|
||||||
|
@ -431,7 +431,9 @@ module.exports = React.createClass({
|
||||||
'global', kind, LEGACY_RULES[rule.rule_id], portLegacyActions(rule.actions)
|
'global', kind, LEGACY_RULES[rule.rule_id], portLegacyActions(rule.actions)
|
||||||
).then( function() {
|
).then( function() {
|
||||||
return cli.deletePushRule('global', kind, rule.rule_id);
|
return cli.deletePushRule('global', kind, rule.rule_id);
|
||||||
})
|
}).catch( (e) => {
|
||||||
|
console.warn(`Error when porting legacy rule: ${e}`);
|
||||||
|
});
|
||||||
}(kind, rule));
|
}(kind, rule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +442,7 @@ module.exports = React.createClass({
|
||||||
if (needsUpdate.length > 0) {
|
if (needsUpdate.length > 0) {
|
||||||
// If some of the rules need to be ported then wait for the porting
|
// If some of the rules need to be ported then wait for the porting
|
||||||
// to happen and then fetch the rules again.
|
// to happen and then fetch the rules again.
|
||||||
return q.allSettled(needsUpdate).then( function() {
|
return Promise.all(needsUpdate).then( function() {
|
||||||
return cli.getPushRules();
|
return cli.getPushRules();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -594,7 +596,7 @@ module.exports = React.createClass({
|
||||||
self.setState({pushers: resp.pushers});
|
self.setState({pushers: resp.pushers});
|
||||||
});
|
});
|
||||||
|
|
||||||
q.all([pushRulesPromise, pushersPromise]).then(function() {
|
Promise.all([pushRulesPromise, pushersPromise]).then(function() {
|
||||||
self.setState({
|
self.setState({
|
||||||
phase: self.phases.DISPLAY
|
phase: self.phases.DISPLAY
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,7 +65,7 @@ var sdk = require("matrix-react-sdk");
|
||||||
const PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
|
const PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
|
||||||
sdk.loadSkin(require('../component-index'));
|
sdk.loadSkin(require('../component-index'));
|
||||||
var VectorConferenceHandler = require('../VectorConferenceHandler');
|
var VectorConferenceHandler = require('../VectorConferenceHandler');
|
||||||
var q = require('q');
|
import Promise from 'bluebird';
|
||||||
var request = require('browser-request');
|
var request = require('browser-request');
|
||||||
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
|
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
|
||||||
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
|
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
|
||||||
|
@ -188,7 +188,7 @@ var makeRegistrationUrl = function(params) {
|
||||||
window.addEventListener('hashchange', onHashChange);
|
window.addEventListener('hashchange', onHashChange);
|
||||||
|
|
||||||
function getConfig() {
|
function getConfig() {
|
||||||
let deferred = q.defer();
|
let deferred = Promise.defer();
|
||||||
|
|
||||||
request(
|
request(
|
||||||
{ method: "GET", url: "config.json" },
|
{ method: "GET", url: "config.json" },
|
||||||
|
|
|
@ -20,7 +20,7 @@ limitations under the License.
|
||||||
import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
|
import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
|
||||||
import dis from 'matrix-react-sdk/lib/dispatcher';
|
import dis from 'matrix-react-sdk/lib/dispatcher';
|
||||||
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
||||||
import q from 'q';
|
import Promise from 'bluebird';
|
||||||
import {remote, ipcRenderer} from 'electron';
|
import {remote, ipcRenderer} from 'electron';
|
||||||
import rageshake from '../rageshake';
|
import rageshake from '../rageshake';
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppVersion(): Promise<string> {
|
getAppVersion(): Promise<string> {
|
||||||
return q(remote.app.getVersion());
|
return Promise.resolve(remote.app.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
startUpdateCheck() {
|
startUpdateCheck() {
|
||||||
|
@ -201,7 +201,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
isElectron(): boolean { return true; }
|
isElectron(): boolean { return true; }
|
||||||
|
|
||||||
requestNotificationPermission(): Promise<string> {
|
requestNotificationPermission(): Promise<string> {
|
||||||
return q('granted');
|
return Promise.resolve('granted');
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
|
||||||
import request from 'browser-request';
|
import request from 'browser-request';
|
||||||
import dis from 'matrix-react-sdk/lib/dispatcher.js';
|
import dis from 'matrix-react-sdk/lib/dispatcher.js';
|
||||||
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
||||||
import q from 'q';
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import UAParser from 'ua-parser-js';
|
import UAParser from 'ua-parser-js';
|
||||||
|
@ -68,7 +68,7 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||||
// annoyingly, the latest spec says this returns a
|
// annoyingly, the latest spec says this returns a
|
||||||
// promise, but this is only supported in Chrome 46
|
// promise, but this is only supported in Chrome 46
|
||||||
// and Firefox 47, so adapt the callback API.
|
// and Firefox 47, so adapt the callback API.
|
||||||
const defer = q.defer();
|
const defer = Promise.defer();
|
||||||
global.Notification.requestPermission((result) => {
|
global.Notification.requestPermission((result) => {
|
||||||
defer.resolve(result);
|
defer.resolve(result);
|
||||||
});
|
});
|
||||||
|
@ -103,7 +103,7 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getVersion(): Promise<string> {
|
_getVersion(): Promise<string> {
|
||||||
const deferred = q.defer();
|
const deferred = Promise.defer();
|
||||||
|
|
||||||
// We add a cachebuster to the request to make sure that we know about
|
// We add a cachebuster to the request to make sure that we know about
|
||||||
// the most recent version on the origin server. That might not
|
// the most recent version on the origin server. That might not
|
||||||
|
@ -132,7 +132,7 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||||
|
|
||||||
getAppVersion(): Promise<string> {
|
getAppVersion(): Promise<string> {
|
||||||
if (this.runningVersion !== null) {
|
if (this.runningVersion !== null) {
|
||||||
return q(this.runningVersion);
|
return Promise.resolve(this.runningVersion);
|
||||||
}
|
}
|
||||||
return this._getVersion();
|
return this._getVersion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import q from "q";
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
// This module contains all the code needed to log the console, persist it to
|
// This module contains all the code needed to log the console, persist it to
|
||||||
// disk and submit bug reports. Rationale is as follows:
|
// disk and submit bug reports. Rationale is as follows:
|
||||||
|
@ -116,7 +116,7 @@ class IndexedDBLogStore {
|
||||||
*/
|
*/
|
||||||
connect() {
|
connect() {
|
||||||
let req = this.indexedDB.open("logs");
|
let req = this.indexedDB.open("logs");
|
||||||
return q.Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
req.onsuccess = (event) => {
|
req.onsuccess = (event) => {
|
||||||
this.db = event.target.result;
|
this.db = event.target.result;
|
||||||
// Periodically flush logs to local storage / indexeddb
|
// Periodically flush logs to local storage / indexeddb
|
||||||
|
@ -193,7 +193,7 @@ class IndexedDBLogStore {
|
||||||
}
|
}
|
||||||
// there is no flush promise or there was but it has finished, so do
|
// there is no flush promise or there was but it has finished, so do
|
||||||
// a brand new one, destroying the chain which may have been built up.
|
// a brand new one, destroying the chain which may have been built up.
|
||||||
this.flushPromise = q.Promise((resolve, reject) => {
|
this.flushPromise = new Promise((resolve, reject) => {
|
||||||
if (!this.db) {
|
if (!this.db) {
|
||||||
// not connected yet or user rejected access for us to r/w to
|
// not connected yet or user rejected access for us to r/w to
|
||||||
// the db.
|
// the db.
|
||||||
|
@ -277,7 +277,7 @@ class IndexedDBLogStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteLogs(id) {
|
function deleteLogs(id) {
|
||||||
return q.Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const txn = db.transaction(
|
const txn = db.transaction(
|
||||||
["logs", "logslastmod"], "readwrite"
|
["logs", "logslastmod"], "readwrite"
|
||||||
);
|
);
|
||||||
|
@ -375,7 +375,7 @@ class IndexedDBLogStore {
|
||||||
*/
|
*/
|
||||||
function selectQuery(store, keyRange, resultMapper) {
|
function selectQuery(store, keyRange, resultMapper) {
|
||||||
const query = store.openCursor(keyRange);
|
const query = store.openCursor(keyRange);
|
||||||
return q.Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let results = [];
|
let results = [];
|
||||||
query.onerror = (event) => {
|
query.onerror = (event) => {
|
||||||
reject(new Error("Query failed: " + event.target.errorCode));
|
reject(new Error("Query failed: " + event.target.errorCode));
|
||||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import pako from 'pako';
|
import pako from 'pako';
|
||||||
import q from "q";
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
|
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
|
||||||
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
|
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
|
||||||
|
@ -100,7 +100,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _submitReport(endpoint, body, progressCallback) {
|
function _submitReport(endpoint, body, progressCallback) {
|
||||||
const deferred = q.defer();
|
const deferred = Promise.defer();
|
||||||
|
|
||||||
const req = new XMLHttpRequest();
|
const req = new XMLHttpRequest();
|
||||||
req.open("POST", endpoint);
|
req.open("POST", endpoint);
|
||||||
|
|
|
@ -33,7 +33,7 @@ var React = require('react');
|
||||||
var ReactDOM = require('react-dom');
|
var ReactDOM = require('react-dom');
|
||||||
var ReactTestUtils = require('react-addons-test-utils');
|
var ReactTestUtils = require('react-addons-test-utils');
|
||||||
var expect = require('expect');
|
var expect = require('expect');
|
||||||
var q = require('q');
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
var test_utils = require('../test-utils');
|
var test_utils = require('../test-utils');
|
||||||
var MockHttpBackend = require('matrix-mock-request');
|
var MockHttpBackend = require('matrix-mock-request');
|
||||||
|
@ -106,7 +106,7 @@ describe('joining a room', function () {
|
||||||
.respond(200, {});
|
.respond(200, {});
|
||||||
function awaitSync(attempts) {
|
function awaitSync(attempts) {
|
||||||
if (syncDone) {
|
if (syncDone) {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
if (!attempts) {
|
if (!attempts) {
|
||||||
throw new Error("Gave up waiting for /sync")
|
throw new Error("Gave up waiting for /sync")
|
||||||
|
@ -118,7 +118,7 @@ describe('joining a room', function () {
|
||||||
// wait for the directory requests
|
// wait for the directory requests
|
||||||
httpBackend.when('POST', '/publicRooms').respond(200, {chunk: []});
|
httpBackend.when('POST', '/publicRooms').respond(200, {chunk: []});
|
||||||
httpBackend.when('GET', '/thirdparty/protocols').respond(200, {});
|
httpBackend.when('GET', '/thirdparty/protocols').respond(200, {});
|
||||||
return q.all([
|
return Promise.all([
|
||||||
httpBackend.flush('/thirdparty/protocols'),
|
httpBackend.flush('/thirdparty/protocols'),
|
||||||
httpBackend.flush('/publicRooms'),
|
httpBackend.flush('/publicRooms'),
|
||||||
]);
|
]);
|
||||||
|
@ -139,14 +139,14 @@ describe('joining a room', function () {
|
||||||
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
||||||
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
||||||
|
|
||||||
return q.all([
|
return Promise.all([
|
||||||
httpBackend.flush('/directory/room/'+encodeURIComponent(ROOM_ALIAS), 1, 200),
|
httpBackend.flush('/directory/room/'+encodeURIComponent(ROOM_ALIAS), 1, 200),
|
||||||
httpBackend.flush('/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync", 1, 200),
|
httpBackend.flush('/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync", 1, 200),
|
||||||
]);
|
]);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
|
|
||||||
return q.delay(1);
|
return Promise.delay(1);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// we should now have a roomview, with a preview bar
|
// we should now have a roomview, with a preview bar
|
||||||
roomView = ReactTestUtils.findRenderedComponentWithType(
|
roomView = ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
@ -164,14 +164,14 @@ describe('joining a room', function () {
|
||||||
.respond(200, {room_id: ROOM_ID});
|
.respond(200, {room_id: ROOM_ID});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// wait for the join request to be made
|
// wait for the join request to be made
|
||||||
return q.delay(1);
|
return Promise.delay(1);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// and again, because the state update has to go to the store and
|
// and again, because the state update has to go to the store and
|
||||||
// then one dispatch within the store, then to the view
|
// then one dispatch within the store, then to the view
|
||||||
// XXX: This is *super flaky*: a better way would be to declare
|
// XXX: This is *super flaky*: a better way would be to declare
|
||||||
// that we expect a certain state transition to happen, then wait
|
// that we expect a certain state transition to happen, then wait
|
||||||
// for that transition to occur.
|
// for that transition to occur.
|
||||||
return q.delay(1);
|
return Promise.delay(1);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// the roomview should now be loading
|
// the roomview should now be loading
|
||||||
expect(roomView.state.room).toBe(null);
|
expect(roomView.state.room).toBe(null);
|
||||||
|
@ -186,7 +186,7 @@ describe('joining a room', function () {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
|
|
||||||
return q.delay(1);
|
return Promise.delay(1);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// We've joined, expect this to false
|
// We've joined, expect this to false
|
||||||
expect(roomView.state.joining).toBe(false);
|
expect(roomView.state.joining).toBe(false);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import ReactTestUtils from 'react-addons-test-utils';
|
import ReactTestUtils from 'react-addons-test-utils';
|
||||||
import expect from 'expect';
|
import expect from 'expect';
|
||||||
import q from 'q';
|
import Promise from 'bluebird';
|
||||||
import MatrixReactTestUtils from 'matrix-react-test-utils';
|
import MatrixReactTestUtils from 'matrix-react-test-utils';
|
||||||
|
|
||||||
import jssdk from 'matrix-js-sdk';
|
import jssdk from 'matrix-js-sdk';
|
||||||
|
@ -104,7 +104,7 @@ describe('loading:', function () {
|
||||||
toString: function() { return this.search + this.hash; },
|
toString: function() { return this.search + this.hash; },
|
||||||
};
|
};
|
||||||
|
|
||||||
let tokenLoginCompleteDefer = q.defer();
|
let tokenLoginCompleteDefer = Promise.defer();
|
||||||
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
|
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
|
||||||
|
|
||||||
function onNewScreen(screen) {
|
function onNewScreen(screen) {
|
||||||
|
@ -140,7 +140,7 @@ describe('loading:', function () {
|
||||||
realQueryParams={params}
|
realQueryParams={params}
|
||||||
startingFragmentQueryParams={fragParts.params}
|
startingFragmentQueryParams={fragParts.params}
|
||||||
enableGuest={true}
|
enableGuest={true}
|
||||||
onTokenLoginCompleted={tokenLoginCompleteDefer.resolve}
|
onTokenLoginCompleted={() => tokenLoginCompleteDefer.resolve()}
|
||||||
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
|
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
|
||||||
makeRegistrationUrl={() => {throw new Error('Not implemented');}}
|
makeRegistrationUrl={() => {throw new Error('Not implemented');}}
|
||||||
/>, parentDiv
|
/>, parentDiv
|
||||||
|
@ -172,7 +172,7 @@ describe('loading:', function () {
|
||||||
it('gives a login panel by default', function (done) {
|
it('gives a login panel by default', function (done) {
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
q.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -195,7 +195,7 @@ describe('loading:', function () {
|
||||||
uriFragment: "#/room/!room:id",
|
uriFragment: "#/room/!room:id",
|
||||||
});
|
});
|
||||||
|
|
||||||
q.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -207,7 +207,7 @@ describe('loading:', function () {
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// Wait for another trip around the event loop for the UI to update
|
// Wait for another trip around the event loop for the UI to update
|
||||||
return q.delay(10);
|
return Promise.delay(10);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return completeLogin(matrixChat);
|
return completeLogin(matrixChat);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
@ -337,7 +337,7 @@ describe('loading:', function () {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return q.delay(1).then(() => {
|
return Promise.delay(1).then(() => {
|
||||||
// we expect a loading spinner while we log into the RTS
|
// we expect a loading spinner while we log into the RTS
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ describe('loading:', function () {
|
||||||
it('shows a home page by default', function (done) {
|
it('shows a home page by default', function (done) {
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
q.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -434,7 +434,7 @@ describe('loading:', function () {
|
||||||
|
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
q.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -469,7 +469,7 @@ describe('loading:', function () {
|
||||||
loadApp({
|
loadApp({
|
||||||
uriFragment: "#/room/!room:id"
|
uriFragment: "#/room/!room:id"
|
||||||
});
|
});
|
||||||
q.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -557,7 +557,7 @@ describe('loading:', function () {
|
||||||
|
|
||||||
ReactTestUtils.Simulate.click(returnToApp);
|
ReactTestUtils.Simulate.click(returnToApp);
|
||||||
|
|
||||||
return q.delay(1).then(() => {
|
return Promise.delay(1).then(() => {
|
||||||
// we should be straight back into the home page
|
// we should be straight back into the home page
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('structures.HomePage'));
|
matrixChat, sdk.getComponent('structures.HomePage'));
|
||||||
|
@ -572,7 +572,7 @@ describe('loading:', function () {
|
||||||
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
|
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
|
||||||
});
|
});
|
||||||
|
|
||||||
q.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// we expect a spinner while we're logging in
|
// we expect a spinner while we're logging in
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ describe('loading:', function () {
|
||||||
|
|
||||||
return httpBackend.flush().then(() => {
|
return httpBackend.flush().then(() => {
|
||||||
// Wait for another trip around the event loop for the UI to update
|
// Wait for another trip around the event loop for the UI to update
|
||||||
return q.delay(1);
|
return Promise.delay(1);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
@ -671,7 +671,7 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
|
||||||
}
|
}
|
||||||
// loading can take quite a long time, because we delete the
|
// loading can take quite a long time, because we delete the
|
||||||
// indexedDB store.
|
// indexedDB store.
|
||||||
return q.delay(5).then(() => {
|
return Promise.delay(5).then(() => {
|
||||||
return awaitSyncingSpinner(matrixChat, retryLimit, retryCount + 1);
|
return awaitSyncingSpinner(matrixChat, retryLimit, retryCount + 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
|
||||||
|
|
||||||
// state looks good, check the rendered output
|
// state looks good, check the rendered output
|
||||||
assertAtSyncingSpinner(matrixChat);
|
assertAtSyncingSpinner(matrixChat);
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertAtSyncingSpinner(matrixChat) {
|
function assertAtSyncingSpinner(matrixChat) {
|
||||||
|
@ -708,7 +708,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
|
||||||
throw new Error("MatrixChat still not ready after " +
|
throw new Error("MatrixChat still not ready after " +
|
||||||
retryCount + " tries");
|
retryCount + " tries");
|
||||||
}
|
}
|
||||||
return q.delay(0).then(() => {
|
return Promise.delay(0).then(() => {
|
||||||
return awaitRoomView(matrixChat, retryLimit, retryCount + 1);
|
return awaitRoomView(matrixChat, retryLimit, retryCount + 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -718,7 +718,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
|
||||||
// state looks good, check the rendered output
|
// state looks good, check the rendered output
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('structures.RoomView'));
|
matrixChat, sdk.getComponent('structures.RoomView'));
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function awaitLoginComponent(matrixChat, attempts) {
|
function awaitLoginComponent(matrixChat, attempts) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var q = require('q');
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform common actions before each test case, e.g. printing the test case
|
* Perform common actions before each test case, e.g. printing the test case
|
||||||
|
@ -28,7 +28,7 @@ export function browserSupportsWebRTC() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteIndexedDB(dbName) {
|
export function deleteIndexedDB(dbName) {
|
||||||
return new q.Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!window.indexedDB) {
|
if (!window.indexedDB) {
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue