fix(price): apply live trading-hours settings without refresh
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,7 @@ export interface AppSetting {
|
||||
export const useSettingsStore = defineStore('settings', () => {
|
||||
const settings = ref<AppSetting[]>([])
|
||||
const loaded = ref(false)
|
||||
const settingsRevision = ref(0)
|
||||
let fetchPromise: Promise<AppSetting[]> | null = null
|
||||
|
||||
function getSettingByKey(key: string) {
|
||||
@@ -42,6 +43,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
}
|
||||
|
||||
const merged = [...settings.value]
|
||||
let changed = false
|
||||
items.forEach((item) => {
|
||||
if (!item?.key) {
|
||||
return
|
||||
@@ -49,13 +51,25 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
|
||||
const index = merged.findIndex((setting) => setting.key === item.key)
|
||||
if (index >= 0) {
|
||||
merged[index] = { ...merged[index], ...item }
|
||||
} else {
|
||||
merged.push(item)
|
||||
const current = merged[index]
|
||||
if (current.value === item.value && current.is_active === item.is_active) {
|
||||
return
|
||||
}
|
||||
merged[index] = { ...current, ...item }
|
||||
changed = true
|
||||
return
|
||||
}
|
||||
|
||||
merged.push(item)
|
||||
changed = true
|
||||
})
|
||||
|
||||
if (!changed) {
|
||||
return
|
||||
}
|
||||
|
||||
settings.value = merged
|
||||
settingsRevision.value += 1
|
||||
}
|
||||
|
||||
async function fetchSettings(force = false) {
|
||||
@@ -89,6 +103,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
return {
|
||||
settings,
|
||||
loaded,
|
||||
settingsRevision,
|
||||
fetchSettings,
|
||||
mergeSettings,
|
||||
getSettingByKey,
|
||||
|
||||
Reference in New Issue
Block a user