fix(trade): use stream closed and trade_open instead of device clock
Changing the phone time can no longer open a product that the server has closed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,6 +24,19 @@ export function isProductTradeOpen(product: TradeOpenProduct, isBuy: boolean) {
|
||||
return isBuy ? isProductBuyOpen(product) : isProductSellOpen(product)
|
||||
}
|
||||
|
||||
/** ساعت کاری محصول از استریم (trade_open) — نه ساعت دستگاه */
|
||||
export function isProductTradingHoursOpen(
|
||||
product?: { show?: boolean; trade_open?: boolean } | null,
|
||||
) {
|
||||
if (!product) return false
|
||||
if (typeof product.trade_open === 'boolean') return product.trade_open
|
||||
return product.show === true
|
||||
}
|
||||
|
||||
export function productHoursClosedMessage() {
|
||||
return 'این محصول در حال حاضر خارج از ساعت کاری است.'
|
||||
}
|
||||
|
||||
/** تب اولیه با توجه به query و وضعیت باز/بسته خرید و فروش */
|
||||
export function resolveProductTradeIsBuy(product: TradeOpenProduct, routeState?: string | null) {
|
||||
const wantSell = routeState === 'sell'
|
||||
|
||||
+5
-14
@@ -225,20 +225,11 @@ export function isStoreClosedBySchedule(now = new Date()): boolean {
|
||||
return isOutsideTimeWindow(now, start, end)
|
||||
}
|
||||
|
||||
/** باز/بسته بودن فروشگاه فقط از استریم last.closed — نه ساعت دستگاه کاربر */
|
||||
export function isStoreClosed(): boolean {
|
||||
void productTradingHoursVersion.value
|
||||
const { closePriceEnabled } = getStoreTradingHours()
|
||||
|
||||
if (closePriceEnabled) {
|
||||
if (lastPrice.value?.closed === true) {
|
||||
return true
|
||||
}
|
||||
|
||||
return isStoreClosedBySchedule()
|
||||
}
|
||||
|
||||
// وقتی close_price خاموش است، صفر بودن قیمت مرجع به معنی بسته بودن فروشگاه نیست.
|
||||
return isStoreClosedBySchedule()
|
||||
void lastPriceReady.value
|
||||
void lastPrice.value
|
||||
return lastPrice.value?.closed === true
|
||||
}
|
||||
|
||||
export function getStoreClosedMessage(): string {
|
||||
@@ -306,7 +297,7 @@ export function getPriceDisplayState(): PriceDisplayState {
|
||||
return serverStatus
|
||||
}
|
||||
|
||||
if (isOutsideGlobalStoreHours()) {
|
||||
if (p?.closed === true) {
|
||||
if (!shouldShowHomePriceWhenClosed()) return 'closed'
|
||||
return hasShowableHomePrice(p) ? 'open' : 'no_quote'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user