55 useGetApiV1TalksQuery ,
66} from '@/generated/dreamkast-api.generated'
77import config from '@/config'
8+ import { nowAccurate , startTimeSync } from '@/utils/time'
89import { useEffect , useMemo , useRef , useState } from 'react'
910
1011// onAirTalkはtalk_idまたはidのみを含む可能性がある
@@ -52,11 +53,17 @@ export default function MonitorPage() {
5253 }
5354 } , [ talks ] )
5455
55- // 現在時刻を1秒ごとに更新
56+ // 現在時刻をサーバー時刻基準で1秒ごとに更新
5657 useEffect ( ( ) => {
57- const timer = setInterval ( ( ) => {
58- setCurrentTime ( new Date ( ) )
59- } , 1000 )
58+ startTimeSync ( )
59+
60+ const updateTime = ( ) => {
61+ setCurrentTime ( nowAccurate ( ) . toDate ( ) )
62+ }
63+
64+ updateTime ( )
65+ const timer = setInterval ( updateTime , 1000 )
66+
6067 return ( ) => clearInterval ( timer )
6168 } , [ ] )
6269
@@ -66,7 +73,7 @@ export default function MonitorPage() {
6673 if ( ! isFetching && isSuccess && tracks ) {
6774 // 前回がフェッチ中だった場合、または初回ロード完了時
6875 if ( prevIsFetchingRef . current || isInitialLoadRef . current ) {
69- setLastUpdateTime ( new Date ( ) )
76+ setLastUpdateTime ( nowAccurate ( ) . toDate ( ) )
7077 isInitialLoadRef . current = false
7178 }
7279 }
@@ -194,15 +201,15 @@ export default function MonitorPage() {
194201 ) }
195202 < div className = "grid grid-cols-2 gap-4 mt-4" >
196203 < div >
197- < div className = "text-base text-gray-300 " >
204+ < div className = "text-base text-gray-400 " >
198205 開始時刻
199206 </ div >
200207 < div className = "text-2xl font-semibold" >
201208 { formatDateTime ( talkInfo . startTime ) }
202209 </ div >
203210 </ div >
204211 < div >
205- < div className = "text-base text-gray-300 " >
212+ < div className = "text-base text-gray-400 " >
206213 終了時刻
207214 </ div >
208215 < div className = "text-2xl font-semibold" >
0 commit comments