replace q method calls with bluebird ones
``` find src test -name '*.js' | xargs perl -i -pe 's/q\.(all|defer|reject|delay|try|isFulfilled)\(/Promise.$1(/' ```
This commit is contained in:
parent
b29b4a959b
commit
d5b550f89a
|
@ -53,7 +53,7 @@ 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") {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -594,7 +594,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
|
||||||
});
|
});
|
||||||
|
|
|
@ -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" },
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -103,7 +103,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) {
|
||||||
|
@ -171,7 +171,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);
|
||||||
|
@ -183,7 +183,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(() => {
|
||||||
// we expect a single <Login> component following session load
|
// we expect a single <Login> component following session load
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
@ -197,7 +197,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);
|
||||||
|
@ -209,7 +209,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(() => {
|
||||||
|
@ -232,7 +232,7 @@ describe('loading:', function () {
|
||||||
uriFragment: "#/login",
|
uriFragment: "#/login",
|
||||||
});
|
});
|
||||||
|
|
||||||
return q.delay(100).then(() => {
|
return Promise.delay(100).then(() => {
|
||||||
// we expect a single <Login> component
|
// we expect a single <Login> component
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('structures.login.Login'));
|
matrixChat, sdk.getComponent('structures.login.Login'));
|
||||||
|
@ -339,7 +339,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);
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ describe('loading:', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// give the UI a chance to display
|
// give the UI a chance to display
|
||||||
return q.delay(50);
|
return Promise.delay(50);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows a login view', function() {
|
it('shows a login view', function() {
|
||||||
|
@ -403,7 +403,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);
|
||||||
|
@ -436,7 +436,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);
|
||||||
|
@ -471,7 +471,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);
|
||||||
|
@ -530,7 +530,7 @@ describe('loading:', function () {
|
||||||
|
|
||||||
dis.dispatch({ action: 'start_login' });
|
dis.dispatch({ action: 'start_login' });
|
||||||
|
|
||||||
return q.delay(1);
|
return Promise.delay(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -559,7 +559,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'));
|
||||||
|
@ -574,7 +574,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);
|
||||||
|
|
||||||
|
@ -629,7 +629,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(
|
||||||
|
@ -674,7 +674,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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue