fix: apply initialData appState for zenmode and grid stats and refactor check param for actions (#2871)

* fix: pass default value for grid mode / zen mode so it sets the value from initialData appState

fixes #2870

* change checked from boolean to be a function which recieves appState and returns boolean

* fix

* use clsx

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Aakansha Doshi 2021-01-29 23:38:37 +05:30 committed by GitHub
parent e8685c5236
commit 4624ec2bd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 18 deletions

View file

@ -4,17 +4,16 @@ import { register } from "./register";
export const actionToggleZenMode = register({
name: "zenMode",
perform(elements, appState) {
this.checked = !this.checked;
return {
appState: {
...appState,
zenModeEnabled: this.checked,
zenModeEnabled: !this.checked!(appState),
},
commitToHistory: false,
};
},
checked: false,
checked: (appState) => appState.zenModeEnabled,
contextItemLabel: "buttons.zenMode",
// Wrong event code
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE,
keyTest: (event) =>
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.Z,
});