refactor(notifications): simplify keywords to add/remove, dropping the per-keyword loudness control

This commit is contained in:
heaven 2026-06-04 01:22:20 +03:00
parent 94bc35092a
commit a3a8655487

View file

@ -12,9 +12,7 @@ import {
getNotificationModeActions, getNotificationModeActions,
NotificationMode, NotificationMode,
NotificationModeOptions, NotificationModeOptions,
useNotificationModeActions,
} from '../../../hooks/useNotificationMode'; } from '../../../hooks/useNotificationMode';
import { NotificationModeSwitcher } from './NotificationModeSwitcher';
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback'; import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
const NOTIFY_MODE_OPS: NotificationModeOptions = { const NOTIFY_MODE_OPS: NotificationModeOptions = {
@ -126,27 +124,6 @@ function KeywordCross({ pushRule }: PushRulesProps) {
); );
} }
function KeywordModeSwitcher({ pushRule }: PushRulesProps) {
const mx = useMatrixClient();
const getModeActions = useNotificationModeActions(NOTIFY_MODE_OPS);
const handleChange = useCallback(
async (mode: NotificationMode) => {
const actions = getModeActions(mode);
await mx.setPushRuleActions(
'global',
PushRuleKind.ContentSpecific,
pushRule.rule_id,
actions
);
},
[mx, getModeActions, pushRule]
);
return <NotificationModeSwitcher pushRule={pushRule} onChange={handleChange} />;
}
export function KeywordMessagesNotifications() { export function KeywordMessagesNotifications() {
const { t } = useTranslation(); const { t } = useTranslation();
const pushRulesEvt = useAccountData(AccountDataEvent.PushRules); const pushRulesEvt = useAccountData(AccountDataEvent.PushRules);
@ -179,7 +156,6 @@ export function KeywordMessagesNotifications() {
</Text> </Text>
} }
before={<KeywordCross pushRule={pushRule} />} before={<KeywordCross pushRule={pushRule} />}
after={<KeywordModeSwitcher pushRule={pushRule} />}
/> />
))} ))}
</SettingsSection> </SettingsSection>