diff --git a/src/main.js b/src/main.js index 9826dfd..eb01795 100644 --- a/src/main.js +++ b/src/main.js @@ -24,6 +24,7 @@ export async function main(container) { const vm = new RootViewModel({ request: xhrRequest, openLink: url => location.href = url, + setTimeout: (f, time) => window.setTimeout(f, time), platforms: guessApplicablePlatforms(navigator.userAgent, navigator.platform), preferences: new Preferences(window.localStorage), origin: location.origin, diff --git a/src/open/OpenLinkViewModel.js b/src/open/OpenLinkViewModel.js index ee5d17c..2fd4129 100644 --- a/src/open/OpenLinkViewModel.js +++ b/src/open/OpenLinkViewModel.js @@ -45,7 +45,7 @@ export class OpenLinkViewModel extends ViewModel { const matrixUrl = this._link.toMatrixUrl() if (matrixUrl) { this.tryingLink = true; - setTimeout(() => { + this.setTimeout(() => { this.tryingLink = false; this.emitChange(); }, 1000); diff --git a/src/utils/ViewModel.js b/src/utils/ViewModel.js index b9afbc1..274dd6b 100644 --- a/src/utils/ViewModel.js +++ b/src/utils/ViewModel.js @@ -63,6 +63,7 @@ export class ViewModel extends EventEmitter { get request() { return this._options.request; } get origin() { return this._options.origin; } get openLink() { return this._options.openLink; } + get setTimeout() { return this._options.setTimeout; } get platforms() { return this._options.platforms; } get preferences() { return this._options.preferences; } @@ -71,6 +72,7 @@ export class ViewModel extends EventEmitter { request: this.request, origin: this.origin, openLink: this.openLink, + setTimeout: this.setTimeout, platforms: this.platforms, preferences: this.preferences, }, options);