Skip to content

Commit

Permalink
feat: Add dialog when delete network
Browse files Browse the repository at this point in the history
  • Loading branch information
originalix committed Oct 9, 2024
1 parent 356cfc2 commit 44e7da8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/kit-bg/src/services/ServiceCustomRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ServiceCustomRpc extends ServiceBase {
await this.backgroundApi.simpleDb.customNetwork.deleteCustomNetwork(params);
setTimeout(() => {
appEventBus.emit(EAppEventBusNames.AddedCustomNetwork, undefined);
}, 500);
}, 300);
}

@backgroundMethod()
Expand Down
30 changes: 23 additions & 7 deletions packages/kit/src/views/Setting/pages/CustomNetwork/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useIntl } from 'react-intl';

import {
Alert,
Dialog,
Form,
IconButton,
Input,
Expand Down Expand Up @@ -182,15 +183,30 @@ function AddCustomNetwork() {
if (!routeNetworkId) {
return;
}
await backgroundApiProxy.serviceCustomRpc.deleteCustomNetwork({
networkId: routeNetworkId,
});
Toast.success({
title: intl.formatMessage({
id: ETranslations.explore_removed_success,
Dialog.show({
title: 'Remove this network?',
description:
'You will have to add it back to access your assets on this network.',
showCancelButton: true,
onConfirmText: intl.formatMessage({
id: ETranslations.global_remove,
}),
confirmButtonProps: {
variant: 'destructive',
},
onConfirm: async ({ close }) => {
await backgroundApiProxy.serviceCustomRpc.deleteCustomNetwork({
networkId: routeNetworkId,
});
Toast.success({
title: intl.formatMessage({
id: ETranslations.explore_removed_success,
}),
});
navigation.pop();
await close();
},
});
navigation.pop();
}, [routeNetworkId, intl, navigation]);

const headerRight = useCallback(() => {
Expand Down

0 comments on commit 44e7da8

Please sign in to comment.