Skip to content

Commit e408093

Browse files
committed
chore: add group switch message
1 parent d890ddf commit e408093

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/pages/popup/rule/group.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ import React from 'react';
55
import Api from '@/share/pages/api';
66
import useMarkCommon from '@/share/hooks/use-mark-common';
77
import { t } from '@/share/core/utils';
8+
import { Toast } from '@/share/pages/toast';
89

910
const toggleGroup = async (name: string, target: boolean) => {
1011
const rules = flatten(Object.values(await Api.getAllRules()));
1112
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+
}
1825
};
1926

2027
const Group = () => {

0 commit comments

Comments
 (0)