Skip to content

Commit

Permalink
chore: simplify createPopup and createTab functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 committed Nov 28, 2023
1 parent a8aa500 commit c50daa8
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,27 @@ const utils = {
const { top, left } = await getWindowPosition(windowWidth, windowHeight);

return new Promise((resolve, reject) => {
const createPopup = (options: browser.Windows.CreateCreateDataType) => {
return browser.windows.create(options);
};

const createTab = (options: browser.Tabs.CreateCreatePropertiesType) => {
return browser.tabs.create(options);
const createPopup = () => {
const popupOptions: browser.Windows.CreateCreateDataType = {
url: url,
type: "popup",
width: windowWidth,
height: windowHeight,
top: top,
left: left,
};
return browser.windows.create(popupOptions);
};

const optionsPopup: browser.Windows.CreateCreateDataType = {
url: url,
type: "popup",
width: windowWidth,
height: windowHeight,
top: top,
left: left,
};
const createTab = () => {
const tabOptions: browser.Tabs.CreateCreatePropertiesType = {
url: url,
};

const optionsTab: browser.Tabs.CreateCreatePropertiesType = {
url: url,
return browser.tabs.create(tabOptions);
};

const createPromise = browser.windows
? createPopup(optionsPopup)
: createTab(optionsTab);
const createPromise = browser.windows ? createPopup() : createTab();

return createPromise.then(async (windowOrTab) => {
let tabId: number | undefined;
Expand Down

0 comments on commit c50daa8

Please sign in to comment.