From 7e9f7e2616973418cc50f7706bd8f644cb9d5559 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 18 Feb 2024 07:58:59 -0500 Subject: Application data refactor (#699) * Pass tabId and frameId to Application * Remove casts * Remove redundant frameInformationGet calls * Expose tabId and frameId * Remove unsed * Simplify * Update FrameAncestryHandler to not need a direct frameId * Remove frameId from FrameOffsetForwarder * Remove frameId from PopupFactory * Remove frameId from Frontend * Remove frameId from PopupPreviewFrame * Fix PopupFactory and Frontend constructor * Remove frameId from Display * Remove frameId from SearchDisplayController * Restore if check --- ext/js/pages/settings/popup-preview-frame-main.js | 12 ++---------- ext/js/pages/settings/popup-preview-frame.js | 10 +--------- 2 files changed, 3 insertions(+), 19 deletions(-) (limited to 'ext/js/pages/settings') diff --git a/ext/js/pages/settings/popup-preview-frame-main.js b/ext/js/pages/settings/popup-preview-frame-main.js index cffbf01b..c6c694cd 100644 --- a/ext/js/pages/settings/popup-preview-frame-main.js +++ b/ext/js/pages/settings/popup-preview-frame-main.js @@ -22,21 +22,13 @@ import {HotkeyHandler} from '../../input/hotkey-handler.js'; import {PopupPreviewFrame} from './popup-preview-frame.js'; await Application.main(async (application) => { - const {tabId, frameId} = await application.api.frameInformationGet(); - if (typeof tabId === 'undefined') { - throw new Error('Failed to get tabId'); - } - if (typeof frameId === 'undefined') { - throw new Error('Failed to get frameId'); - } - const hotkeyHandler = new HotkeyHandler(); hotkeyHandler.prepare(application.crossFrame); - const popupFactory = new PopupFactory(application, frameId); + const popupFactory = new PopupFactory(application); popupFactory.prepare(); - const preview = new PopupPreviewFrame(application, tabId, frameId, popupFactory, hotkeyHandler); + const preview = new PopupPreviewFrame(application, popupFactory, hotkeyHandler); await preview.prepare(); document.documentElement.dataset.loaded = 'true'; diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index 1ad4859b..2898eaa2 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -24,18 +24,12 @@ import {TextSourceRange} from '../../dom/text-source-range.js'; export class PopupPreviewFrame { /** * @param {import('../../application.js').Application} application - * @param {number} tabId - * @param {number} frameId * @param {import('../../app/popup-factory.js').PopupFactory} popupFactory * @param {import('../../input/hotkey-handler.js').HotkeyHandler} hotkeyHandler */ - constructor(application, tabId, frameId, popupFactory, hotkeyHandler) { + constructor(application, popupFactory, hotkeyHandler) { /** @type {import('../../application.js').Application} */ this._application = application; - /** @type {number} */ - this._tabId = tabId; - /** @type {number} */ - this._frameId = frameId; /** @type {import('../../app/popup-factory.js').PopupFactory} */ this._popupFactory = popupFactory; /** @type {import('../../input/hotkey-handler.js').HotkeyHandler} */ @@ -94,8 +88,6 @@ export class PopupPreviewFrame { // Overwrite frontend this._frontend = new Frontend({ application: this._application, - tabId: this._tabId, - frameId: this._frameId, popupFactory: this._popupFactory, depth: 0, parentPopupId: null, -- cgit v1.2.3