From 6fbbb98f9fb0dc56df19c2db7d5689ed2c8cc864 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Tue, 2 Oct 2018 19:34:57 -0500 Subject: [PATCH] Fix Promise.defer warnings in WebPlatform.js (#7409) Signed-off-by: Aaron Raimist --- src/vector/platform/WebPlatform.js | 50 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index a3ea12e866d..1cd440207e9 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -68,11 +68,11 @@ export default class WebPlatform extends VectorBasePlatform { // annoyingly, the latest spec says this returns a // promise, but this is only supported in Chrome 46 // and Firefox 47, so adapt the callback API. - const defer = Promise.defer(); - global.Notification.requestPermission((result) => { - defer.resolve(result); - }); - return defer.promise; + return new Promise(function(resolve, reject) { + global.Notification.requestPermission((result) => { + resolve(result); + }); + }) } displayNotification(title: string, msg: string, avatarUrl: string, room: Object) { @@ -103,31 +103,31 @@ export default class WebPlatform extends VectorBasePlatform { } _getVersion(): Promise { - const deferred = Promise.defer(); - // 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 // actually be the version we'd get on a reload (particularly in the // presence of intermediate caching proxies), but still: we're trying // to tell the user that there is a new version. - request( - { - method: "GET", - url: "version", - qs: { cachebuster: Date.now() }, - }, - (err, response, body) => { - if (err || response.status < 200 || response.status >= 300) { - if (err === null) err = { status: response.status }; - deferred.reject(err); - return; - } - - const ver = body.trim(); - deferred.resolve(ver); - }, - ); - return deferred.promise; + + return new Promise(function(resolve, reject) { + request( + { + method: "GET", + url: "version", + qs: { cachebuster: Date.now() }, + }, + (err, response, body) => { + if (err || response.status < 200 || response.status >= 300) { + if (err === null) err = { status: response.status }; + reject(err); + return; + } + + const ver = body.trim(); + resolve(ver); + }, + ); + }) } getAppVersion(): Promise {