added online and trigger
This commit is contained in:
+2
-11
@@ -163,18 +163,9 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
setCachedMainMetal(mainMetalRow?.value)
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
setCachedMainWalletProductIds(parseMainWalletProductIds(mainWalletRow?.value))
|
||||
} catch {
|
||||
storeModeFromSettings = false
|
||||
setBannerEnabledFromSettings(false)
|
||||
setTrackingSystemsEnabledFromSettings(false)
|
||||
setCustomerDirectSmsEnabledFromSettings(false)
|
||||
setConditionalOrderEnabledFromSettings(false)
|
||||
applyAccountingProviderFromRows([])
|
||||
setCachedMainMetal(null)
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
setCachedMainWalletProductIds([])
|
||||
} finally {
|
||||
settingsBootstrapped = true
|
||||
} catch {
|
||||
// Allow retry on next init* call — do not lock flags to false forever.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/** همتراز با CustomerPresenceService::ONLINE_THRESHOLD_SECONDS روی سرور */
|
||||
export const CUSTOMER_ONLINE_THRESHOLD_MS = 2 * 60 * 1000
|
||||
|
||||
export type CustomerPresenceKind = 'online' | 'offline' | 'never'
|
||||
|
||||
export function getCustomerPresenceKind(
|
||||
lastSeenAt: string | Date | null | undefined
|
||||
): CustomerPresenceKind {
|
||||
if (!lastSeenAt) return 'never'
|
||||
const t = lastSeenAt instanceof Date ? lastSeenAt.getTime() : new Date(lastSeenAt).getTime()
|
||||
if (!Number.isFinite(t)) return 'never'
|
||||
if (Date.now() - t < CUSTOMER_ONLINE_THRESHOLD_MS) return 'online'
|
||||
return 'offline'
|
||||
}
|
||||
|
||||
export function isCustomerOnline(lastSeenAt: string | Date | null | undefined): boolean {
|
||||
return getCustomerPresenceKind(lastSeenAt) === 'online'
|
||||
}
|
||||
Reference in New Issue
Block a user