summaryrefslogtreecommitdiff
path: root/ext/fg/js/popup-proxy.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/popup-proxy.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/popup-proxy.js')
-rw-r--r--ext/fg/js/popup-proxy.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 6a84e000..82da839a 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -20,12 +20,11 @@
*/
class PopupProxy {
- constructor(id, depth, parentId, parentFrameId, getFrameOffset=null, setDisabled=null) {
- this._parentId = parentId;
- this._parentFrameId = parentFrameId;
+ constructor(id, depth, parentPopupId, parentFrameId, getFrameOffset=null, setDisabled=null) {
this._id = id;
this._depth = depth;
- this._apiSender = new FrontendApiSender();
+ this._parentPopupId = parentPopupId;
+ this._apiSender = new FrontendApiSender(`popup-factory#${parentFrameId}`);
this._getFrameOffset = getFrameOffset;
this._setDisabled = setDisabled;
@@ -51,7 +50,7 @@ class PopupProxy {
// Public functions
async prepare() {
- const {id} = await this._invoke('getOrCreatePopup', {id: this._id, parentId: this._parentId});
+ const {id} = await this._invoke('getOrCreatePopup', {id: this._id, parentId: this._parentPopupId});
this._id = id;
}
@@ -112,10 +111,7 @@ class PopupProxy {
// Private
_invoke(action, params={}) {
- if (typeof this._parentFrameId !== 'number') {
- return Promise.reject(new Error('Invalid frame'));
- }
- return this._apiSender.invoke(action, params, `popup-factory#${this._parentFrameId}`);
+ return this._apiSender.invoke(action, params);
}
async _updateFrameOffset() {