mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-18 10:12:02 +03:00
Fix Promise.defer warnings in WebPlatform.js (#7409)
Signed-off-by: Aaron Raimist <aaron@raim.ist>
This commit is contained in:
parent
54c46df0dc
commit
401c85ad5b
1 changed files with 24 additions and 24 deletions
|
@ -68,11 +68,11 @@ 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 = Promise.defer();
|
return new Promise(function(resolve, reject) {
|
||||||
global.Notification.requestPermission((result) => {
|
global.Notification.requestPermission((result) => {
|
||||||
defer.resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
return defer.promise;
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
displayNotification(title: string, msg: string, avatarUrl: string, room: Object) {
|
displayNotification(title: string, msg: string, avatarUrl: string, room: Object) {
|
||||||
|
@ -103,31 +103,31 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getVersion(): Promise<string> {
|
_getVersion(): Promise<string> {
|
||||||
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
|
||||||
// actually be the version we'd get on a reload (particularly in the
|
// actually be the version we'd get on a reload (particularly in the
|
||||||
// presence of intermediate caching proxies), but still: we're trying
|
// presence of intermediate caching proxies), but still: we're trying
|
||||||
// to tell the user that there is a new version.
|
// 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();
|
return new Promise(function(resolve, reject) {
|
||||||
deferred.resolve(ver);
|
request(
|
||||||
},
|
{
|
||||||
);
|
method: "GET",
|
||||||
return deferred.promise;
|
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<string> {
|
getAppVersion(): Promise<string> {
|
||||||
|
|
Loading…
Reference in a new issue