Skip to content

Commit 9546daa

Browse files
committed
clarify announcing & make filtering rooms conditional
1 parent f7cbce3 commit 9546daa

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/app/components/GlobalKeyboardShortcuts.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ export function GlobalKeyboardShortcuts() {
4242
const [hiddenSpaces] = useSetting(settingsAtom, 'hiddenSpaces');
4343
const selectedRoomId = useSelectedRoom();
4444

45-
const filteredRooms = allRooms.filter(
46-
(item) => !hiddenRooms.includes(item) && !hiddenSpaces.includes(item)
47-
);
48-
4945
// Derive the current room ID from the URL so we know which room is active.
5046
const roomMatch =
5147
matchPath(HOME_ROOM_PATH, location.pathname) ??
@@ -89,9 +85,11 @@ export function GlobalKeyboardShortcuts() {
8985
}
9086
const roomName = mx.getRoom(roomId)?.name ?? 'Room';
9187
const roomType = isDirect ? 'Direct Message' : 'Group Room';
92-
announce(
93-
`${roomName}, ${roomType}.${remaining && `${remaining} room${remaining === 1 ? '' : 's'} unread.`}`
94-
);
88+
if (remaining)
89+
announce(
90+
`${roomName}, ${roomType}. ${remaining} room${remaining === 1 ? '' : 's'} unread.`
91+
);
92+
else announce(`${roomName}, ${roomType}`);
9593
},
9694
[mx, mDirects, roomToParents, navigate]
9795
);
@@ -171,6 +169,9 @@ export function GlobalKeyboardShortcuts() {
171169
const handleHideRoomsKeyDown = useCallback(
172170
(evt: KeyboardEvent) => {
173171
if (!isKeyHotkey('alt+shift+h', evt)) return;
172+
const filteredRooms = allRooms.filter(
173+
(item) => !hiddenRooms.includes(item) && !hiddenSpaces.includes(item)
174+
);
174175
evt.preventDefault();
175176
announce(`${isHidingRooms ? 'Disabling' : 'Enabling'} hiding rooms.`);
176177
setIsHidingRooms(!isHidingRooms);
@@ -182,7 +183,15 @@ export function GlobalKeyboardShortcuts() {
182183
)
183184
navigateToRoom(filteredRooms[0]);
184185
},
185-
[setIsHidingRooms, isHidingRooms, navigateToRoom, filteredRooms, selectedRoomId]
186+
[
187+
setIsHidingRooms,
188+
isHidingRooms,
189+
navigateToRoom,
190+
selectedRoomId,
191+
allRooms,
192+
hiddenRooms,
193+
hiddenSpaces,
194+
]
186195
);
187196

188197
useKeyDown(window, handleNextUnreadKeyDown);

0 commit comments

Comments
 (0)