Skip to content

Commit

Permalink
feat: sidepanel now refreshes on subsequent plugin runs if still open
Browse files Browse the repository at this point in the history
  • Loading branch information
Codetrauma committed Feb 27, 2025
1 parent 7631baf commit 6e66ae7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/entries/SidePanel/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ export default function SidePanel(): ReactElement {
setStarted(true);
break;
}
case SidePanelActionTypes.is_panel_open: {
return { isOpen: true };
}
case SidePanelActionTypes.reset_panel: {
setConfig(null);
setHash('');
setHex('');
setStarted(false);
break;
}
}
});
}, []);
Expand Down
2 changes: 2 additions & 0 deletions src/entries/SidePanel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export enum SidePanelActionTypes {
run_p2p_plugin_request = 'sidePanel/run_p2p_plugin_request',
run_p2p_plugin_response = 'sidePanel/run_p2p_plugin_response',
start_p2p_plugin = 'sidePanel/start_p2p_plugin',
is_panel_open = 'sidePanel/is_panel_open',
reset_panel = 'sidePanel/reset_panel',
}
12 changes: 12 additions & 0 deletions src/entries/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ export const openSidePanel = async () => {
const { promise, resolve, reject } = deferredPromise();

try {
const response = await browser.runtime.sendMessage({
type: SidePanelActionTypes.is_panel_open,
});

if (response?.isOpen) {
await browser.runtime.sendMessage({
type: SidePanelActionTypes.reset_panel,
});
resolve();
return promise;
}

const [tab] = await browser.tabs.query({
active: true,
currentWindow: true,
Expand Down

0 comments on commit 6e66ae7

Please sign in to comment.