Skip to content

Commit

Permalink
chore: add group switch message
Browse files Browse the repository at this point in the history
  • Loading branch information
sylingd committed Jul 4, 2024
1 parent d890ddf commit e408093
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/pages/popup/rule/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ import React from 'react';
import Api from '@/share/pages/api';
import useMarkCommon from '@/share/hooks/use-mark-common';
import { t } from '@/share/core/utils';
import { Toast } from '@/share/pages/toast';

const toggleGroup = async (name: string, target: boolean) => {
const rules = flatten(Object.values(await Api.getAllRules()));
const toUpdate = rules.filter((x) => x.group === name);
return Promise.all(
toUpdate.map((x) => {
x.enable = target;
return Api.saveRule(x);
}),
);
try {
await Promise.all(
toUpdate.map((x) => {
x.enable = target;
return Api.saveRule(x);
}),
);
Toast().success(t('switch_success'));
} catch (e) {
console.error(e);
Toast().error(e.message);
}
};

const Group = () => {
Expand Down

0 comments on commit e408093

Please sign in to comment.