Skip to content

Commit

Permalink
feat: fix Install Plugin button in extension menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Codetrauma authored Jan 30, 2025
1 parent 846bc1e commit 8733b26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function Menu(props: {
props.setOpen(false);
}}
>
<PluginUploadInfo />
<PluginUploadInfo onPluginInstalled={() => props.setOpen(false)} />
<span>Install Plugin</span>
</MenuRow>
<MenuRow
Expand Down
10 changes: 9 additions & 1 deletion src/components/PluginInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import { ErrorModal } from '../ErrorModal';
import classNames from 'classnames';
import DefaultPluginIcon from '../../assets/img/default-plugin-icon.png';

export default function PluginUploadInfo(): ReactElement {
export default function PluginUploadInfo({
onPluginInstalled,
}: {
onPluginInstalled?: () => void;
}): ReactElement {
const [error, showError] = useState('');
const [pluginBuffer, setPluginBuffer] = useState<ArrayBuffer | any>(null);

Check warning on line 35 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const [pluginContent, setPluginContent] = useState<PluginConfig | null>(null);
Expand All @@ -36,6 +40,7 @@ export default function PluginUploadInfo(): ReactElement {
try {
await addPlugin(Buffer.from(pluginBuffer).toString('hex'));
setPluginContent(null);
onPluginInstalled?.();
} catch (e: any) {

Check warning on line 44 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
showError(e?.message || 'Invalid Plugin');
}
Expand Down Expand Up @@ -72,6 +77,9 @@ export default function PluginUploadInfo(): ReactElement {
className="opacity-0 absolute top-0 right-0 h-full w-full cursor-pointer"
type="file"
onChange={onPluginInfo}
onClick={(e) => {
e.stopPropagation();
}}
/>
{error && <ErrorModal onClose={() => showError('')} message={error} />}
{pluginContent && (
Expand Down

0 comments on commit 8733b26

Please sign in to comment.