Skip to content

Commit

Permalink
refactor(ui): Settings > Indent size (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
flawiddsouza committed Sep 13, 2024
1 parent 5aae3ac commit 9aa7b1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/ui/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,7 @@ export interface OpenApiSpecPathParams {
}
}
}

export interface EditorConfig {
indentSize: number
}
7 changes: 3 additions & 4 deletions packages/ui/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
HandleRequestState,
State,
OpenApiSpecPathParams,
EditorConfig,
} from './global'
import { ActionContext } from 'vuex'
import { version } from '../../electron/package.json'
Expand Down Expand Up @@ -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)
}

0 comments on commit 9aa7b1c

Please sign in to comment.