Skip to content

Commit

Permalink
Attempt to implement toggle (failed)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jan 12, 2024
1 parent ebfb5ac commit 84f9557
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/background/browserAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
*/

import { browserAction } from "@/mv3/api";
import { openSidePanel } from "@/sidebar/sidePanel/messenger/api";
import {
isSidePanelOpen,
openSidePanel,
} from "@/sidebar/sidePanel/messenger/api";
import { getNotifier } from "webext-messenger";

export default async function initBrowserAction(): Promise<void> {
void chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: false });
Expand All @@ -28,6 +32,10 @@ export default async function initBrowserAction(): Promise<void> {
});

browserAction.onClicked.addListener(async (tab) => {
await openSidePanel(tab.id);
if (await isSidePanelOpen()) {
getNotifier("SIDEBAR_CLOSE", { page: "sidebar.html?tabId=" + tab.id })();
} else {
await openSidePanel(tab.id);
}
});
}

0 comments on commit 84f9557

Please sign in to comment.