aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/popup-proxy.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 7405b552..f1618c9f 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -132,24 +132,26 @@ class PopupProxy {
}
this._frameOffsetPromise = this._getFrameOffset();
+
+ const handleOffset = (offset) => {
+ this._frameOffset = offset !== null ? offset : [0, 0];
+ this._frameOffsetUpdatedAt = Date.now();
+ this._frameOffsetPromise = null;
+ };
+
+ const handleError = (e) => {
+ console.error(e);
+ this._frameOffsetPromise = null;
+ };
+
if (firstRun) {
try {
- const offset = await this._frameOffsetPromise;
- this._frameOffset = offset !== null ? offset : [0, 0];
- this._frameOffsetUpdatedAt = Date.now();
+ handleOffset(await this._frameOffsetPromise);
} catch (e) {
- console.error(e);
+ handleError(e);
}
- this._frameOffsetPromise = null;
} else {
- this._frameOffsetPromise.then((offset) => {
- this._frameOffset = offset !== null ? offset : [0, 0];
- this._frameOffsetUpdatedAt = Date.now();
- this._frameOffsetPromise = null;
- }, (e) => {
- console.error(e);
- this._frameOffsetPromise = null;
- });
+ this._frameOffsetPromise.then(handleOffset, handleError);
}
}