fix: 히어로 '지금' 날씨를 지금이 든 3시간 칸으로 — 칸 뒤쪽 절반 시각에 다음 칸(최대 1시간 반 뒤) 예보가 지금으로 보이던 것 (서버가 지금 칸에 지금 시각 예보를 넣기 전인 10/12 의 '가장 가까운 칸' 규칙이 남아 있었음)
This commit is contained in:
1 parent
9c4852959b
commit
d4f937b439
1 file changed
+2
-8
@@ -219,15 +219,9 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
}, [tmr, tmrKind, setPreview])
|
||||
const slots = (tmr ? tomorrowQ.data?.slots : today?.slots) ?? []
|
||||
const slotsLoad = tmr ? loadOf(tomorrowQ) : todayLoad
|
||||
// 그 시각 칸, 비어 있으면(지난 새벽 칸 등) 그 뒤 첫 예보 칸
|
||||
// 지금은 가장 가까운 3시간 칸(17시면 18시 칸). 시간대는 그 시각 칸, 비어 있으면(지난 새벽 칸 등) 그 뒤 첫 예보 칸
|
||||
// 지금은 지금이 든 3시간 칸(17시면 15시 칸. 서버가 그 칸에 지금 시각 예보를 넣어 준다). 시간대는 그 시각 칸, 비어 있으면(지난 새벽 칸 등) 그 뒤 첫 예보 칸
|
||||
const slotOf = (k: TimeKind | 'now') => {
|
||||
if (k === 'now') {
|
||||
const known = slots.filter((x) => x.temp_c != null)
|
||||
const at = t.h + t.mi / 60
|
||||
return known.length ? known.reduce((a, b) => (Math.abs(kst(b.at).h - at) < Math.abs(kst(a.at).h - at) ? b : a)) : undefined
|
||||
}
|
||||
const h = PREVIEW[k].hour
|
||||
const h = k === 'now' ? t.h : PREVIEW[k].hour
|
||||
const s = slots.length ? slotAt(slots, h) : undefined
|
||||
return s?.temp_c != null ? s : (slots.find((x) => kst(x.at).h > h && x.temp_c != null) ?? s)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user