wallet fix 2
This commit is contained in:
@@ -16,6 +16,11 @@ let settingsBootstrapped = false
|
||||
/** reactive — برای فیلتر منوی «بنرها» در پیکربندی */
|
||||
export const bannerEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — نمایش UI تهحsاب در حسابداری و ... */
|
||||
export const tahesabEnabledSetting = ref(false)
|
||||
|
||||
let tahesabEnabledFromSettings: boolean | null = null
|
||||
|
||||
function isSwitchOn(value: string | undefined | null): boolean {
|
||||
const v = (value ?? '').trim().toLowerCase()
|
||||
return v === 'true' || v === '1' || v === 'yes'
|
||||
@@ -29,6 +34,11 @@ export function setBannerEnabledFromSettings(value: boolean): void {
|
||||
bannerEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setTahesabEnabledFromSettings(value: boolean): void {
|
||||
tahesabEnabledFromSettings = value
|
||||
tahesabEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function applyBannerEnabledFromRows(rows: Array<{ key?: string; value?: string | null }>) {
|
||||
const row = rows.find((item) => item.key === 'banner_enabled')
|
||||
setBannerEnabledFromSettings(row ? isSwitchOn(row.value) : false)
|
||||
@@ -45,7 +55,9 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
const isStoreRow = list.find((item) => item.key === 'is_store')
|
||||
const mainWalletRow = list.find((item) => item.key === 'main_wallet_products')
|
||||
const mainMetalRow = list.find((item) => item.key === 'main_metal')
|
||||
const tahesabRow = list.find((item) => item.key === 'send_to_tahesab')
|
||||
storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false
|
||||
setTahesabEnabledFromSettings(tahesabRow ? isSwitchOn(tahesabRow.value) : false)
|
||||
applyBannerEnabledFromRows(list)
|
||||
setCachedMainMetal(mainMetalRow?.value)
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
@@ -53,6 +65,7 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
} catch {
|
||||
storeModeFromSettings = false
|
||||
setBannerEnabledFromSettings(false)
|
||||
setTahesabEnabledFromSettings(false)
|
||||
setCachedMainMetal(null)
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
setCachedMainWalletProductIds([])
|
||||
@@ -77,3 +90,15 @@ export async function initWalletSettingsFromApi(): Promise<void> {
|
||||
export function isStoreApp(): boolean {
|
||||
return storeModeFromSettings === true
|
||||
}
|
||||
|
||||
export function isTahesabEnabled(): boolean {
|
||||
return tahesabEnabledFromSettings === true
|
||||
}
|
||||
|
||||
export async function initTahesabSettingFromApi(): Promise<boolean> {
|
||||
if (tahesabEnabledFromSettings !== null) return tahesabEnabledFromSettings === true
|
||||
|
||||
await bootstrapSettingsFromApi()
|
||||
|
||||
return tahesabEnabledFromSettings === true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user