File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,23 @@ import React from 'react';
5
5
import Api from '@/share/pages/api' ;
6
6
import useMarkCommon from '@/share/hooks/use-mark-common' ;
7
7
import { t } from '@/share/core/utils' ;
8
+ import { Toast } from '@/share/pages/toast' ;
8
9
9
10
const toggleGroup = async ( name : string , target : boolean ) => {
10
11
const rules = flatten ( Object . values ( await Api . getAllRules ( ) ) ) ;
11
12
const toUpdate = rules . filter ( ( x ) => x . group === name ) ;
12
- return Promise . all (
13
- toUpdate . map ( ( x ) => {
14
- x . enable = target ;
15
- return Api . saveRule ( x ) ;
16
- } ) ,
17
- ) ;
13
+ try {
14
+ await Promise . all (
15
+ toUpdate . map ( ( x ) => {
16
+ x . enable = target ;
17
+ return Api . saveRule ( x ) ;
18
+ } ) ,
19
+ ) ;
20
+ Toast ( ) . success ( t ( 'switch_success' ) ) ;
21
+ } catch ( e ) {
22
+ console . error ( e ) ;
23
+ Toast ( ) . error ( e . message ) ;
24
+ }
18
25
} ;
19
26
20
27
const Group = ( ) => {
You can’t perform that action at this time.
0 commit comments