fix(notifications): Advanced Push Rules mode switch keeps highlight/sound tweaks
RuleModeSwitcher rebuilt a rule's actions from scratch, so changing the mode of e.g. .m.rule.is_user_mention silently dropped its highlight tweak account-wide. Derive the existing highlight/custom-sound tweaks from the rule's current actions and pass them through as NotificationModeOptions. Adds getNotificationModeOptionsFromActions + unit tests. Fixes #19 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -18,6 +18,7 @@ import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
||||
import {
|
||||
getNotificationModeActions,
|
||||
getNotificationModeOptionsFromActions,
|
||||
NotificationMode,
|
||||
useNotificationModeActions,
|
||||
} from '../../../hooks/useNotificationMode';
|
||||
@@ -131,7 +132,13 @@ type RuleModeSwitcherProps = {
|
||||
|
||||
function RuleModeSwitcher({ kind, pushRule }: RuleModeSwitcherProps) {
|
||||
const mx = useMatrixClient();
|
||||
const getModeActions = useNotificationModeActions();
|
||||
// Preserve any `highlight`/custom sound tweak already on the rule — otherwise
|
||||
// switching mode here rebuilds actions from scratch and silently drops them.
|
||||
const options = useMemo(
|
||||
() => getNotificationModeOptionsFromActions(pushRule.actions),
|
||||
[pushRule.actions],
|
||||
);
|
||||
const getModeActions = useNotificationModeActions(options);
|
||||
|
||||
const handleChange = useCallback(
|
||||
async (mode: NotificationMode) => {
|
||||
|
||||
Reference in New Issue
Block a user