From 9aa7b1cb68691ecde5a880bb3612b1b19db1adb0 Mon Sep 17 00:00:00 2001 From: Flawid DSouza Date: Fri, 13 Sep 2024 10:57:23 +0530 Subject: [PATCH] refactor(ui): Settings > Indent size (#240) --- packages/ui/src/global.d.ts | 4 ++++ packages/ui/src/helpers.ts | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/global.d.ts b/packages/ui/src/global.d.ts index 86b7e56f..c66555d6 100644 --- a/packages/ui/src/global.d.ts +++ b/packages/ui/src/global.d.ts @@ -243,3 +243,7 @@ export interface OpenApiSpecPathParams { } } } + +export interface EditorConfig { + indentSize: number +} diff --git a/packages/ui/src/helpers.ts b/packages/ui/src/helpers.ts index 1174be24..efa1e8ec 100644 --- a/packages/ui/src/helpers.ts +++ b/packages/ui/src/helpers.ts @@ -19,6 +19,7 @@ import { HandleRequestState, State, OpenApiSpecPathParams, + EditorConfig, } from './global' import { ActionContext } from 'vuex' import { version } from '../../electron/package.json' @@ -1752,14 +1753,12 @@ export function covertPostmanAuthToRestfoxAuth(request: any) { return authentication } -export function getEditorConfig(): { - indentSize: number - } { +export function getEditorConfig(): EditorConfig { return { indentSize: parseInt(localStorage.getItem(constants.LOCAL_STORAGE_KEY.INDENT_SIZE) || constants.EDITOR_CONFIG.indent_size.toString(), 10) } } -export function jsonStringify(data: any, space = getEditorConfig().indentSize): any { +export function jsonStringify(data: any, space: number = getEditorConfig().indentSize): any { return JSON.stringify(data, null, space) }