Skip to content

Commit

Permalink
fix: send correct message on plugin execution using content script
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtsukino committed Nov 7, 2024
1 parent 3989505 commit 1e6b796
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/pages/RunPluginApproval/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
getPluginMetadataByHash,
} from '../../entries/Background/db';
import { runPlugin } from '../../utils/rpc';
import { openSidePanel } from '../../entries/utils';
import { SidePanelActionTypes } from '../../entries/SidePanel/types';

export function RunPluginApproval(): ReactElement {
const [params] = useSearchParams();
Expand All @@ -32,14 +34,18 @@ export function RunPluginApproval(): ReactElement {
const onAccept = useCallback(async () => {
if (!hash) return;
try {
const tab = await browser.tabs.create({
active: true,
});

await browser.storage.local.set({ plugin_hash: hash });

// @ts-ignore
if (chrome.sidePanel) await chrome.sidePanel.open({ tabId: tab.id });
await openSidePanel();

browser.runtime.sendMessage({
type: SidePanelActionTypes.execute_plugin_request,
data: {
pluginHash: hash,
},
});

await runPlugin(hash, 'start');

browser.runtime.sendMessage({
type: BackgroundActiontype.run_plugin_response,
Expand Down

0 comments on commit 1e6b796

Please sign in to comment.