1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-01 13:11:10 +03:00

Add a keyboard shortcut to toggle hidden event visibility when labs are enabled. (#7584)

Notes: The keyboard shortcut is control (or cmd) shift h.
Signed-off-by: Katarzyna Stachura <uwunyaa@outlook.com>
This commit is contained in:
UwUnyaa
2022-01-26 17:50:47 +01:00
committed by GitHub
parent 00912c0b50
commit debf4caade
6 changed files with 82 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ import { fixupColorFonts } from '../../utils/FontManager';
import dis from '../../dispatcher/dispatcher';
import { IMatrixClientCreds } from '../../MatrixClientPeg';
import SettingsStore from "../../settings/SettingsStore";
import { SettingLevel } from "../../settings/SettingLevel";
import ResizeHandle from '../views/elements/ResizeHandle';
import { CollapseDistributor, Resizer } from '../../resizer';
import MatrixClientContext from "../../contexts/MatrixClientContext";
@@ -47,7 +48,7 @@ import { IOOBData, IThreepidInvite } from "../../stores/ThreepidInviteStore";
import Modal from "../../Modal";
import { ICollapseConfig } from "../../resizer/distributors/collapse";
import HostSignupContainer from '../views/host_signup/HostSignupContainer';
import { getKeyBindingsManager, NavigationAction, RoomAction } from '../../KeyBindingsManager';
import { getKeyBindingsManager, NavigationAction, RoomAction, LabsAction } from '../../KeyBindingsManager';
import { IOpts } from "../../createRoom";
import SpacePanel from "../views/spaces/SpacePanel";
import { replaceableComponent } from "../../utils/replaceableComponent";
@@ -537,6 +538,33 @@ class LoggedInView extends React.Component<IProps, IState> {
// if we do not have a handler for it, pass it to the platform which might
handled = PlatformPeg.get().onKeyDown(ev);
}
// Handle labs actions here, as they apply within the same scope
if (!handled) {
const labsAction = getKeyBindingsManager().getLabsAction(ev);
switch (labsAction) {
case LabsAction.ToggleHiddenEventVisibility: {
const hiddenEventVisibility = SettingsStore.getValueAt(
SettingLevel.DEVICE,
'showHiddenEventsInTimeline',
undefined,
false,
);
SettingsStore.setValue(
'showHiddenEventsInTimeline',
undefined,
SettingLevel.DEVICE,
!hiddenEventVisibility,
);
handled = true;
break;
}
default:
// if we do not have a handler for it, pass it to the platform which might
handled = PlatformPeg.get().onKeyDown(ev);
}
}
if (handled) {
ev.stopPropagation();
ev.preventDefault();