Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application data refactor #699

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove frameId from Frontend
  • Loading branch information
toasted-nutbread committed Feb 17, 2024
commit 6bd6106eda004b32a9202c7e26b37e5ac896ec52
2 changes: 0 additions & 2 deletions ext/js/app/content-script-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ await Application.main(async (application) => {

const frontend = new Frontend({
application,
tabId,
frameId,
popupFactory,
depth: 0,
parentPopupId: null,
Expand Down
22 changes: 11 additions & 11 deletions ext/js/app/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export class Frontend {
pageType,
popupFactory,
depth,
tabId,
frameId,
parentPopupId,
parentFrameId,
useProxyPopup,
Expand All @@ -57,10 +55,6 @@ export class Frontend {
this._popupFactory = popupFactory;
/** @type {number} */
this._depth = depth;
/** @type {number|undefined} */
this._tabId = tabId;
/** @type {number} */
this._frameId = frameId;
/** @type {?string} */
this._parentPopupId = parentPopupId;
/** @type {?number} */
Expand Down Expand Up @@ -588,8 +582,13 @@ export class Frontend {
return null;
}

const {frameId} = this._application;
if (frameId === null) {
return null;
}

return await this._popupFactory.getOrCreatePopup({
frameId: this._frameId,
frameId,
depth: this._depth,
childrenSupported: this._childrenSupported
});
Expand Down Expand Up @@ -703,11 +702,12 @@ export class Frontend {
};
if (sentence !== null) { detailsState.sentence = sentence; }
if (documentTitle !== null) { detailsState.documentTitle = documentTitle; }
const {tabId, frameId} = this._application;
/** @type {import('display').HistoryContent} */
const detailsContent = {
contentOrigin: {
tabId: this._tabId,
frameId: this._frameId
tabId: tabId !== null ? tabId : void 0,
frameId: frameId !== null ? frameId : void 0
}
};
if (dictionaryEntries !== null) {
Expand Down Expand Up @@ -819,7 +819,7 @@ export class Frontend {
*/
_signalFrontendReady(targetFrameId) {
/** @type {import('application').ApiMessageNoFrameId<'frontendReady'>} */
const message = {action: 'frontendReady', params: {frameId: this._frameId}};
const message = {action: 'frontendReady', params: {frameId: this._application.frameId}};
if (targetFrameId === null) {
this._application.api.broadcastTab(message);
} else {
Expand Down Expand Up @@ -867,7 +867,7 @@ export class Frontend {
}

chrome.runtime.onMessage.addListener(onMessage);
this._application.api.broadcastTab({action: 'frontendRequestReadyBroadcast', params: {frameId: this._frameId}});
this._application.api.broadcastTab({action: 'frontendRequestReadyBroadcast', params: {frameId: this._application.frameId}});
});
}

Expand Down
2 changes: 0 additions & 2 deletions ext/js/pages/settings/popup-preview-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,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,
Expand Down
4 changes: 2 additions & 2 deletions types/ext/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export type ApiSurface = {
};
frontendRequestReadyBroadcast: {
params: {
frameId: number;
frameId: number | null;
};
return: void;
};
Expand All @@ -101,7 +101,7 @@ export type ApiSurface = {
};
frontendReady: {
params: {
frameId: number;
frameId: number | null;
};
return: void;
};
Expand Down
4 changes: 0 additions & 4 deletions types/ext/frontend.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export type ConstructorDetails = {
popupFactory: PopupFactory;
/** The nesting depth value of the popup. */
depth: number;
/** The tab ID of the host tab. */
tabId: number | undefined;
/** The frame ID of the host frame. */
frameId: number;
/** The popup ID of the parent popup if one exists, otherwise null. */
parentPopupId: string | null;
/** The frame ID of the parent popup if one exists, otherwise null. */
Expand Down