diff --git a/src/ContentMessages.js b/src/ContentMessages.js index a9d02b1825..93013cfd6c 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -52,7 +52,7 @@ const MAX_HEIGHT = 600; * and a thumbnail key. */ function createThumbnail(element, inputWidth, inputHeight, mimeType) { - const deferred = q.defer(); + const deferred = Promise.defer(); var targetWidth = inputWidth; var targetHeight = inputHeight; @@ -95,7 +95,7 @@ function createThumbnail(element, inputWidth, inputHeight, mimeType) { * @return {Promise} A promise that resolves with the html image element. */ function loadImageElement(imageFile) { - const deferred = q.defer(); + const deferred = Promise.defer(); // Load the file into an html element const img = document.createElement("img"); @@ -154,7 +154,7 @@ function infoForImageFile(matrixClient, roomId, imageFile) { * @return {Promise} A promise that resolves with the video image element. */ function loadVideoElement(videoFile) { - const deferred = q.defer(); + const deferred = Promise.defer(); // Load the file into an html element const video = document.createElement("video"); @@ -210,7 +210,7 @@ function infoForVideoFile(matrixClient, roomId, videoFile) { * is read. */ function readFileAsArrayBuffer(file) { - const deferred = q.defer(); + const deferred = Promise.defer(); const reader = new FileReader(); reader.onload = function(e) { deferred.resolve(e.target.result); @@ -288,7 +288,7 @@ class ContentMessages { content.info.mimetype = file.type; } - const def = q.defer(); + const def = Promise.defer(); if (file.type.indexOf('image/') == 0) { content.msgtype = 'm.image'; infoForImageFile(matrixClient, roomId, file).then(imageInfo=>{ diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 3c7da9496e..eb2156e780 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -236,7 +236,7 @@ function _restoreFromLocalStorage() { function _handleRestoreFailure(e) { console.log("Unable to restore session", e); - const def = q.defer(); + const def = Promise.defer(); const SessionRestoreErrorDialog = sdk.getComponent('views.dialogs.SessionRestoreErrorDialog'); diff --git a/src/RoomNotifs.js b/src/RoomNotifs.js index eddf516b20..5cc078dc59 100644 --- a/src/RoomNotifs.js +++ b/src/RoomNotifs.js @@ -87,7 +87,7 @@ function setRoomNotifsStateMuted(roomId) { ], })); - return q.all(promises); + return Promise.all(promises); } function setRoomNotifsStateUnmuted(roomId, newState) { @@ -126,7 +126,7 @@ function setRoomNotifsStateUnmuted(roomId, newState) { promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); } - return q.all(promises); + return Promise.all(promises); } function findOverrideMuteRule(roomId) { diff --git a/src/ScalarAuthClient.js b/src/ScalarAuthClient.js index 0275dcd1f7..b1d17b93a9 100644 --- a/src/ScalarAuthClient.js +++ b/src/ScalarAuthClient.js @@ -53,7 +53,7 @@ class ScalarAuthClient { } exchangeForScalarToken(openid_token_object) { - var defer = q.defer(); + var defer = Promise.defer(); var scalar_rest_url = SdkConfig.get().integrations_rest_url; request({ diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index b4fd469441..b90cb53435 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -224,7 +224,7 @@ module.exports = React.createClass({ // Used by _viewRoom before getting state from sync this.firstSyncComplete = false; - this.firstSyncPromise = q.defer(); + this.firstSyncPromise = Promise.defer(); if (this.props.config.sync_timeline_limit) { MatrixClientPeg.opts.initialSyncLimit = this.props.config.sync_timeline_limit; @@ -1039,7 +1039,7 @@ module.exports = React.createClass({ // since we're about to start the client and therefore about // to do the first sync this.firstSyncComplete = false; - this.firstSyncPromise = q.defer(); + this.firstSyncPromise = Promise.defer(); const cli = MatrixClientPeg.get(); // Allow the JS SDK to reap timeline events. This reduces the amount of diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 3558e0c278..3cc0b40686 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -316,7 +316,7 @@ module.exports = React.createClass({ _refreshFromServer: function() { const self = this; - q.all([ + Promise.all([ UserSettingsStore.loadProfileInfo(), UserSettingsStore.loadThreePids(), ]).done(function(resps) { self.setState({ diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index f8ebaefec8..d3a208a785 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -498,7 +498,7 @@ module.exports = React.createClass({ } // wait a bit to let the user finish typing - return q.delay(500).then(() => { + return Promise.delay(500).then(() => { if (cancelled) return null; return MatrixClientPeg.get().lookupThreePid(medium, address); }).then((res) => { diff --git a/src/components/views/room_settings/AliasSettings.js b/src/components/views/room_settings/AliasSettings.js index 0fb099422c..ba0663153e 100644 --- a/src/components/views/room_settings/AliasSettings.js +++ b/src/components/views/room_settings/AliasSettings.js @@ -104,7 +104,7 @@ module.exports = React.createClass({ } if (oldCanonicalAlias !== this.state.canonicalAlias) { console.log("AliasSettings: Updating canonical alias"); - promises = [q.all(promises).then( + promises = [Promise.all(promises).then( MatrixClientPeg.get().sendStateEvent( this.props.roomId, "m.room.canonical_alias", { alias: this.state.canonicalAlias diff --git a/src/components/views/rooms/Autocomplete.js b/src/components/views/rooms/Autocomplete.js index 10c9d405ac..1ea2eada7c 100644 --- a/src/components/views/rooms/Autocomplete.js +++ b/src/components/views/rooms/Autocomplete.js @@ -73,7 +73,7 @@ export default class Autocomplete extends React.Component { autocompleteDelay = 0; } - const deferred = Q.defer(); + const deferred = Promise.defer(); this.debounceCompletionsRequest = setTimeout(() => { this.processQuery(query, selection).then(() => { deferred.resolve(); @@ -176,7 +176,7 @@ export default class Autocomplete extends React.Component { } forceComplete() { - const done = Q.defer(); + const done = Promise.defer(); this.setState({ forceComplete: true, hide: false, diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 270b2a54d5..addd1f2e7f 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -184,7 +184,7 @@ module.exports = React.createClass({ }, save: function() { - var stateWasSetDefer = q.defer(); + var stateWasSetDefer = Promise.defer(); // the caller may have JUST called setState on stuff, so we need to re-render before saving // else we won't use the latest values of things. // We can be a bit cheeky here and set a loading flag, and listen for the callback on that @@ -282,7 +282,7 @@ module.exports = React.createClass({ // color scheme var p; p = this.saveColor(); - if (!q.isFulfilled(p)) { + if (!Promise.isFulfilled(p)) { promises.push(p); } @@ -294,7 +294,7 @@ module.exports = React.createClass({ // encryption p = this.saveEnableEncryption(); - if (!q.isFulfilled(p)) { + if (!Promise.isFulfilled(p)) { promises.push(p); } diff --git a/src/components/views/settings/ChangePassword.js b/src/components/views/settings/ChangePassword.js index 9d91c007b1..14ec9806b4 100644 --- a/src/components/views/settings/ChangePassword.js +++ b/src/components/views/settings/ChangePassword.js @@ -161,7 +161,7 @@ module.exports = React.createClass({ }, _optionallySetEmail: function() { - const deferred = q.defer(); + const deferred = Promise.defer(); // Ask for an email otherwise the user has no way to reset their password const SetEmailDialog = sdk.getComponent("dialogs.SetEmailDialog"); Modal.createDialog(SetEmailDialog, { diff --git a/src/languageHandler.js b/src/languageHandler.js index 7af4f7b200..e956d4f8bd 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -231,7 +231,7 @@ export function getCurrentLanguage() { } function getLangsJson() { - const deferred = q.defer(); + const deferred = Promise.defer(); request( { method: "GET", url: i18nFolder + 'languages.json' }, @@ -247,7 +247,7 @@ function getLangsJson() { } function getLanguage(langPath) { - const deferred = q.defer(); + const deferred = Promise.defer(); let response_return = {}; request( diff --git a/src/utils/DecryptFile.js b/src/utils/DecryptFile.js index 8054805409..04496e4204 100644 --- a/src/utils/DecryptFile.js +++ b/src/utils/DecryptFile.js @@ -28,7 +28,7 @@ import Promise from 'bluebird'; * @return {Promise} A promise that resolves with the data:// URI. */ export function readBlobAsDataUri(file) { - var deferred = q.defer(); + var deferred = Promise.defer(); var reader = new FileReader(); reader.onload = function(e) { deferred.resolve(e.target.result); diff --git a/src/utils/MultiInviter.js b/src/utils/MultiInviter.js index ecb5bd67f2..c26cc6b52e 100644 --- a/src/utils/MultiInviter.js +++ b/src/utils/MultiInviter.js @@ -55,7 +55,7 @@ export default class MultiInviter { this.errorTexts[addr] = 'Unrecognised address'; } } - this.deferred = q.defer(); + this.deferred = Promise.defer(); this._inviteMore(0); return this.deferred.promise; diff --git a/test/components/structures/ScrollPanel-test.js b/test/components/structures/ScrollPanel-test.js index 670633c6fd..e7d3d7b0e6 100644 --- a/test/components/structures/ScrollPanel-test.js +++ b/test/components/structures/ScrollPanel-test.js @@ -74,7 +74,7 @@ var Tester = React.createClass({ /* returns a promise which will resolve when the fill happens */ awaitFill: function(dir) { console.log("ScrollPanel Tester: awaiting " + dir + " fill"); - var defer = q.defer(); + var defer = Promise.defer(); this._fillDefers[dir] = defer; return defer.promise; }, @@ -94,7 +94,7 @@ var Tester = React.createClass({ /* returns a promise which will resolve when a scroll event happens */ awaitScroll: function() { console.log("Awaiting scroll"); - this._scrollDefer = q.defer(); + this._scrollDefer = Promise.defer(); return this._scrollDefer.promise; }, diff --git a/test/components/structures/TimelinePanel-test.js b/test/components/structures/TimelinePanel-test.js index 56bde195ee..98ec65b8e8 100644 --- a/test/components/structures/TimelinePanel-test.js +++ b/test/components/structures/TimelinePanel-test.js @@ -147,18 +147,18 @@ describe('TimelinePanel', function() { if(!panel.state.forwardPaginating) return Promise.resolve(); else - return q.delay(0).then(awaitPaginationCompletion); + return Promise.delay(0).then(awaitPaginationCompletion); }; // helper function which will return a promise which resolves when // the TimelinePanel fires a scroll event var awaitScroll = function() { - scrollDefer = q.defer(); + scrollDefer = Promise.defer(); return scrollDefer.promise; }; // let the first round of pagination finish off - q.delay(5).then(() => { + Promise.delay(5).then(() => { expect(panel.state.canBackPaginate).toBe(false); expect(scryEventTiles(panel).length).toEqual(N_EVENTS); @@ -279,7 +279,7 @@ describe('TimelinePanel', function() { // helper function which will return a promise which resolves when // the TimelinePanel fires a scroll event var awaitScroll = function() { - scrollDefer = q.defer(); + scrollDefer = Promise.defer(); return scrollDefer.promise.then(() => { console.log("got scroll event; scrollTop now " + diff --git a/test/components/views/dialogs/InteractiveAuthDialog-test.js b/test/components/views/dialogs/InteractiveAuthDialog-test.js index 969396865e..f606793132 100644 --- a/test/components/views/dialogs/InteractiveAuthDialog-test.js +++ b/test/components/views/dialogs/InteractiveAuthDialog-test.js @@ -110,7 +110,7 @@ describe('InteractiveAuthDialog', function () { ); // let the request complete - return q.delay(1); + return Promise.delay(1); }).then(() => { expect(onFinished.callCount).toEqual(1); expect(onFinished.calledWithExactly(true, {a:1})).toBe(true); diff --git a/test/components/views/rooms/MessageComposerInput-test.js b/test/components/views/rooms/MessageComposerInput-test.js index 2edc1c9432..fe379afcff 100644 --- a/test/components/views/rooms/MessageComposerInput-test.js +++ b/test/components/views/rooms/MessageComposerInput-test.js @@ -47,7 +47,7 @@ describe('MessageComposerInput', () => { // warnings // (please can we make the components not setState() after // they are unmounted?) - Q.delay(10).done(() => { + Promise.delay(10).done(() => { if (parentDiv) { ReactDOM.unmountComponentAtNode(parentDiv); parentDiv.remove();