settings.ts (hoppscotch-2.2.1) | : | settings.ts (hoppscotch-3.0.0) | ||
---|---|---|---|---|
import { pluck, distinctUntilChanged } from "rxjs/operators" | import { pluck, distinctUntilChanged } from "rxjs/operators" | |||
import has from "lodash/has" | import { has } from "lodash-es" | |||
import { Observable } from "rxjs" | import { Observable } from "rxjs" | |||
import { Ref } from "@nuxtjs/composition-api" | ||||
import DispatchingStore, { defineDispatchers } from "./DispatchingStore" | import DispatchingStore, { defineDispatchers } from "./DispatchingStore" | |||
import type { KeysMatching } from "~/types/ts-utils" | import type { KeysMatching } from "~/types/ts-utils" | |||
import { useStream } from "~/helpers/utils/composables" | ||||
export const HoppBgColors = ["system", "light", "dark", "black"] as const | export const HoppBgColors = ["system", "light", "dark", "black"] as const | |||
export type HoppBgColor = typeof HoppBgColors[number] | export type HoppBgColor = typeof HoppBgColors[number] | |||
export const HoppAccentColors = [ | export const HoppAccentColors = [ | |||
"green", | "green", | |||
"teal", | "teal", | |||
"blue", | "blue", | |||
"indigo", | "indigo", | |||
skipping to change at line 64 | skipping to change at line 63 | |||
COLUMN_LAYOUT: boolean | COLUMN_LAYOUT: boolean | |||
} | } | |||
export const defaultSettings: SettingsType = { | export const defaultSettings: SettingsType = { | |||
syncCollections: true, | syncCollections: true, | |||
syncHistory: true, | syncHistory: true, | |||
syncEnvironments: true, | syncEnvironments: true, | |||
PROXY_ENABLED: false, | PROXY_ENABLED: false, | |||
PROXY_URL: "https://proxy.hoppscotch.io/", | PROXY_URL: "https://proxy.hoppscotch.io/", | |||
EXTENSIONS_ENABLED: true, | EXTENSIONS_ENABLED: false, | |||
URL_EXCLUDES: { | URL_EXCLUDES: { | |||
auth: true, | auth: true, | |||
httpUser: true, | httpUser: true, | |||
httpPassword: true, | httpPassword: true, | |||
bearerToken: true, | bearerToken: true, | |||
oauth2Token: true, | oauth2Token: true, | |||
}, | }, | |||
THEME_COLOR: "indigo", | THEME_COLOR: "indigo", | |||
BG_COLOR: "system", | BG_COLOR: "system", | |||
TELEMETRY_ENABLED: true, | TELEMETRY_ENABLED: true, | |||
EXPAND_NAVIGATION: true, | EXPAND_NAVIGATION: true, | |||
SIDEBAR: true, | SIDEBAR: true, | |||
SIDEBAR_ON_LEFT: false, | SIDEBAR_ON_LEFT: true, | |||
ZEN_MODE: false, | ZEN_MODE: false, | |||
FONT_SIZE: "small", | FONT_SIZE: "small", | |||
COLUMN_LAYOUT: true, | COLUMN_LAYOUT: true, | |||
} | } | |||
const validKeys = Object.keys(defaultSettings) | const validKeys = Object.keys(defaultSettings) | |||
const dispatchers = defineDispatchers({ | const dispatchers = defineDispatchers({ | |||
bulkApplySettings( | bulkApplySettings( | |||
_currentState: SettingsType, | _currentState: SettingsType, | |||
skipping to change at line 167 | skipping to change at line 166 | |||
value: SettingsType[K] | value: SettingsType[K] | |||
) { | ) { | |||
settingsStore.dispatch({ | settingsStore.dispatch({ | |||
dispatcher: "applySetting", | dispatcher: "applySetting", | |||
payload: { | payload: { | |||
settingKey, | settingKey, | |||
value, | value, | |||
}, | }, | |||
}) | }) | |||
} | } | |||
export function useSetting<K extends keyof SettingsType>( | ||||
settingKey: K | ||||
): Ref<SettingsType[K]> { | ||||
return useStream( | ||||
settingsStore.subject$.pipe(pluck(settingKey), distinctUntilChanged()), | ||||
settingsStore.value[settingKey], | ||||
(value: SettingsType[K]) => { | ||||
settingsStore.dispatch({ | ||||
dispatcher: "applySetting", | ||||
payload: { | ||||
settingKey, | ||||
value, | ||||
}, | ||||
}) | ||||
} | ||||
) | ||||
} | ||||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 4 lines changed or added |