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:
2026-08-27 18:47:42 +03:30
co-authored by Cursor
parent 059ba0b565
commit 449fad5ed1
3 changed files with 100 additions and 8 deletions
+23 -2
View File
@@ -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)
}