added online and trigger

This commit is contained in:
2026-07-22 18:12:45 +03:30
parent a759cf7251
commit 090dbbe239
21 changed files with 1463 additions and 286 deletions
+2 -11
View File
@@ -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.
}
}
+18
View File
@@ -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'
}