fix(price): delay empty-quote UI until settle window
Avoid flashing no-quote too early while waiting for live/SSE price after first empty response. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -426,9 +426,14 @@ function handleLastPayload(payload: unknown) {
|
||||
|
||||
const raw = payload as Price & { settings_patch?: unknown }
|
||||
const last = applyBoardSpecialToLastPayload(raw)
|
||||
const hasQuote = last.price_last != null || last.price != null || last.buy != null
|
||||
const hasDisplayable =
|
||||
Number(last.buy ?? 0) > 0
|
||||
|| Number(last.sell ?? 0) > 0
|
||||
|| Number(last.price_last ?? 0) > 0
|
||||
|| Number(last.price ?? 0) > 0
|
||||
const hasStatus = last.status != null || typeof last.closed === 'boolean'
|
||||
if (!hasQuote && !hasStatus) {
|
||||
|
||||
if (!hasDisplayable && !hasStatus) {
|
||||
if (Array.isArray(raw.settings_patch) && raw.settings_patch.length) {
|
||||
touchStreamActivity()
|
||||
void applySettingsFromStream(raw.settings_patch)
|
||||
@@ -436,6 +441,22 @@ function handleLastPayload(payload: unknown) {
|
||||
return
|
||||
}
|
||||
|
||||
// SSE گاهی last خالی/no_quote میفرستد؛ قیمت معتبر فعلی را پاک نکن
|
||||
if (!hasDisplayable) {
|
||||
if (Array.isArray(raw.settings_patch) && raw.settings_patch.length) {
|
||||
touchStreamActivity()
|
||||
void applySettingsFromStream(raw.settings_patch)
|
||||
}
|
||||
void import('@/utils/price').then(({ getTradeBuyPrice, lastPrice }) => {
|
||||
const keepCurrent =
|
||||
getTradeBuyPrice(lastPrice.value) > 0 && last.status !== 'closed'
|
||||
touchStreamActivity()
|
||||
if (keepCurrent) return
|
||||
void applyLastFromStream(last)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
touchStreamActivity()
|
||||
void applyLastFromStream(last)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user