summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend-api-sender.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-09 12:27:56 -0400
committerGitHub <noreply@github.com>2020-05-09 12:27:56 -0400
commit69c783f86114329db175135a136c5567ee3e790f (patch)
treeb204294d77440581d70ceda7a4004205aab5adeb /ext/fg/js/frontend-api-sender.js
parentd6a3825a383e13b34c03c0b36e393da52bf8cf89 (diff)
Frontend/popup proxy message refactoring (#520)
* Use direct message handler functions * Remove unused targetPopupId * Make target a member of FrontendApiSender * Rename frameId to parentFrameId for clarity * Remove _parentFrameId * Rename _parentId to _parentPopupId for clarity
Diffstat (limited to 'ext/fg/js/frontend-api-sender.js')
-rw-r--r--ext/fg/js/frontend-api-sender.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js
index d5084c29..4dcde638 100644
--- a/ext/fg/js/frontend-api-sender.js
+++ b/ext/fg/js/frontend-api-sender.js
@@ -17,7 +17,8 @@
class FrontendApiSender {
- constructor() {
+ constructor(target) {
+ this._target = target;
this._senderId = yomichan.generateId(16);
this._ackTimeout = 3000; // 3 seconds
this._responseTimeout = 10000; // 10 seconds
@@ -27,7 +28,7 @@ class FrontendApiSender {
this._port = null;
}
- invoke(action, params, target) {
+ invoke(action, params) {
if (this._disconnected) {
// attempt to reconnect the next time
this._disconnected = false;
@@ -46,7 +47,7 @@ class FrontendApiSender {
this._callbacks.set(id, info);
info.timer = setTimeout(() => this._onError(id, 'Timeout (ack)'), this._ackTimeout);
- this._port.postMessage({id, action, params, target, senderId: this._senderId});
+ this._port.postMessage({id, action, params, target: this._target, senderId: this._senderId});
});
}