Skip to content

Commit d82c046

Browse files
committed
chore: cleanup
1 parent 97d9cb1 commit d82c046

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/SettingsContext.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
SettingsStateContextType,
77
SerializedSettingsState,
88
KeyBindings,
9-
KeyCommand,
109
} from './types';
1110
import { defaultKeyBindings, commonKeyBindings } from './keybindings';
1211
import { usePersistToLocalStorage } from './persistence';
@@ -21,15 +20,15 @@ const initialState: SettingsState = {
2120
function serializeSettingsState(state: SettingsState): SerializedSettingsState {
2221
return {
2322
...state,
24-
keybindings: Object.entries(state.keybindings).reduce(
23+
keybindings: Object.entries(state.keybindings).reduce<Record<string, string>>(
2524
(acc, [key, value]) => {
2625
const commonName = Object.entries(commonKeyBindings).find(([_, v]) => v === value)?.[0];
2726
if (commonName) {
2827
acc[key] = commonName;
2928
}
3029
return acc;
3130
},
32-
{} as Record<string, string>,
31+
{},
3332
),
3433
};
3534
}
@@ -39,13 +38,13 @@ function deserializeSettingsState(state: SerializedSettingsState): SettingsState
3938
...state,
4039
keybindings: {
4140
...defaultKeyBindings,
42-
...Object.entries(state.keybindings).reduce((acc, [key, commonName]) => {
41+
...Object.entries(state.keybindings).reduce<KeyBindings>((acc, [key, commonName]) => {
4342
const commonBinding = commonKeyBindings[commonName as keyof typeof commonKeyBindings];
4443
if (commonBinding) {
4544
acc[key as keyof typeof defaultKeyBindings] = commonBinding;
4645
}
4746
return acc;
48-
}, {} as KeyBindings),
47+
}, {}),
4948
},
5049
};
5150
}

lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ export type SettingsStateContextType = {
5555
};
5656

5757
export type SerializedSettingsState = Omit<SettingsState, 'keybindings'> & {
58-
keybindings: Record<string, string | undefined>;
58+
keybindings: Record<string, string>;
5959
};

0 commit comments

Comments
 (0)