Fix: Review fixes and add schema for editor-preferences

This commit is contained in:
ramki-bruno
2025-02-22 14:56:26 +05:30
parent 884fa77bac
commit 3dc84f46e5
3 changed files with 7 additions and 2 deletions

View File

@@ -14,13 +14,14 @@ const codemirrorKeymaps = [
const EditorKeymapSettings = ({ close }) => {
const dispatch = useDispatch();
const preferences = useSelector((state) => state.app.preferences);
const keymap = useMemo(() => get(preferences, 'editor.keymap', 'sublime'), [preferences]);
const editorPreferences = preferences.editor || {};
const keymap = editorPreferences.keymap || 'sublime';
const handleKeymapChange = (e) => {
dispatch(
savePreferences({
...preferences,
editor: { keymap: e.target.value }
editor: { ...editorPreferences, keymap: e.target.value }
})
).catch(console.error);
};

View File

@@ -97,6 +97,7 @@ export const {
updateSystemProxyEnvVariables
} = appSlice.actions;
// TODO: Need a equivalent method which allows setting preferences for individual sub-section
export const savePreferences = (preferences) => (dispatch, getState) => {
return new Promise((resolve, reject) => {
const { ipcRenderer } = window;

View File

@@ -58,6 +58,9 @@ const preferencesSchema = Yup.object().shape({
codeFont: Yup.string().nullable(),
codeFontSize: Yup.number().min(1).max(32).nullable()
}),
editor: Yup.object().shape({
keymap: Yup.string().oneOf(['sublime', 'vim', 'emacs']).nullable(),
}),
proxy: Yup.object({
mode: Yup.string().oneOf(['off', 'on', 'system']),
protocol: Yup.string().oneOf(['http', 'https', 'socks4', 'socks5']),