Skip to content

Commit fb4c81b

Browse files
authored
fix: throw error when installilng duplicate pluign (#111)
1 parent 2db735e commit fb4c81b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/entries/Background/rpc.ts

+5
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ async function handleInstallPluginRequest(request: BackgroundAction) {
921921
try {
922922
const hex = Buffer.from(arrayBuffer).toString('hex');
923923
const hash = await addPlugin(hex);
924+
925+
if (!hash) {
926+
throw new Error('Plugin already exist.');
927+
}
928+
924929
await addPluginConfig(hash!, config);
925930
await addPluginMetadata(hash!, {
926931
...metadata,

src/pages/Home/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import {
2020
usePluginConfig,
2121
usePluginHashes,
2222
} from '../../reducers/plugins';
23-
import { PluginConfig } from '../../utils/misc';
24-
import { getPluginConfigByHash } from '../../entries/Background/db';
2523
import { fetchPluginHashes } from '../../utils/rpc';
2624
import DefaultPluginIcon from '../../assets/img/default-plugin-icon.png';
2725

@@ -212,6 +210,8 @@ function PluginIcon({ hash }: { hash: string }) {
212210
onPluginClick();
213211
}, [onPluginClick, config]);
214212

213+
if (!config) return null;
214+
215215
return (
216216
<button
217217
className={classNames(

0 commit comments

Comments
 (0)