fix: refresh lottery results on category switch
This commit is contained in:
@@ -406,15 +406,20 @@ const formatNum = (n: any) => {
|
||||
}
|
||||
|
||||
const fetchLatest = async (showFeedback = false) => {
|
||||
latestDraws.value = []
|
||||
try {
|
||||
const data = await getLatestDrawResult()
|
||||
const data = await getLatestDrawResult(
|
||||
selectedGameCode.value ? { code: selectedGameCode.value } : undefined
|
||||
)
|
||||
const allList = Array.isArray(data) ? data : data ? [data] : []
|
||||
const allGames = gameCategories.value.flatMap((c: any) => c.games || [])
|
||||
const iconMap: Record<string, string> = {}
|
||||
allGames.forEach((g: any) => { if (g.icon) iconMap[g.code] = g.icon })
|
||||
let filtered: any[]
|
||||
const codes = currentGames.value.map((g: any) => g.code)
|
||||
filtered = codes.length ? allList.filter((d: any) => codes.includes(d.code)) : allList
|
||||
filtered = selectedGameCode.value
|
||||
? allList.filter((d: any) => d.code === selectedGameCode.value)
|
||||
: (codes.length ? allList.filter((d: any) => codes.includes(d.code)) : allList)
|
||||
filtered.forEach((d: any) => { d.icon = iconMap[d.code] || '' })
|
||||
latestDraws.value = filtered
|
||||
latestUpdatedAt.value = new Date().toTimeString().slice(0, 5)
|
||||
|
||||
Reference in New Issue
Block a user