unmuteRoom unconditionally reset the room to Unset when a timed mute expired (in-session timer and boot-time restore alike), silently reverting a mode the user had changed by hand during the window. Mute-timer helpers move to muteTimers.ts; unmuteRoom now reads the live push-rule mode and only resets when it is still Mute, always dropping the persisted timer. Unit-tested. Fixes #21 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
21 lines
875 B
TypeScript
21 lines
875 B
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { RoomNotificationMode } from '../../hooks/useRoomsNotificationPreferences';
|
|
import { shouldResetMuteOnUnmute } from './muteTimers';
|
|
|
|
test('resets to Unset when the room is still Mute at expiry', () => {
|
|
assert.equal(shouldResetMuteOnUnmute(RoomNotificationMode.Mute), true);
|
|
});
|
|
|
|
test('does not reset when the user switched to All messages during the mute window', () => {
|
|
assert.equal(shouldResetMuteOnUnmute(RoomNotificationMode.AllMessages), false);
|
|
});
|
|
|
|
test('does not reset when the user switched to Special messages during the mute window', () => {
|
|
assert.equal(shouldResetMuteOnUnmute(RoomNotificationMode.SpecialMessages), false);
|
|
});
|
|
|
|
test('does not reset when the mode is already Unset', () => {
|
|
assert.equal(shouldResetMuteOnUnmute(RoomNotificationMode.Unset), false);
|
|
});
|