실시간 UI 갱신: 세션 완료/명령어 변경 시 렌더러 자동 리로드
- bootstrap: notifyRenderer('app:dataChanged') 이벤트 발행
- session-completed: Dashboard 통계 + History 갱신
- command:selected: CMD 페이지 활성 명령어 갱신
- preload: app.onDataChanged 이벤트 리스너 추가
- DashboardPage/CommandsPage/HistoryPage: onDataChanged 구독하여 자동 loadData()
This commit is contained in:
parent
1361b95a4d
commit
ea48168b1e
5 changed files with 39 additions and 3 deletions
|
|
@ -46,7 +46,16 @@ export function CommandsPage(): React.ReactElement {
|
|||
setLoading(false)
|
||||
}, [])
|
||||
|
||||
useEffect(() => { loadData() }, [loadData])
|
||||
useEffect(() => {
|
||||
loadData()
|
||||
const unsub = window.electronAPI.app.onDataChanged((data) => {
|
||||
if (data.type === 'command-changed' && data.activeId) {
|
||||
setActiveId(data.activeId)
|
||||
}
|
||||
loadData()
|
||||
})
|
||||
return unsub
|
||||
}, [loadData])
|
||||
|
||||
const handleActivate = (id: string) => {
|
||||
const newId = activeId === id ? null : id // 토글: 같은 거 누르면 해제
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ export function DashboardPage(): React.ReactElement {
|
|||
useEffect(() => {
|
||||
loadData()
|
||||
const interval = setInterval(loadData, 30000)
|
||||
return () => clearInterval(interval)
|
||||
// 실시간 갱신: 세션 완료/명령어 변경 시 즉시 리로드
|
||||
const unsub = window.electronAPI.app.onDataChanged(() => { loadData() })
|
||||
return () => { clearInterval(interval); unsub() }
|
||||
}, [loadData])
|
||||
|
||||
// 날짜별 그룹핑
|
||||
|
|
|
|||
|
|
@ -54,7 +54,11 @@ export function HistoryPage(): React.ReactElement {
|
|||
setLoading(false)
|
||||
}, [search])
|
||||
|
||||
useEffect(() => { loadData() }, [loadData])
|
||||
useEffect(() => {
|
||||
loadData()
|
||||
const unsub = window.electronAPI.app.onDataChanged(() => { loadData() })
|
||||
return unsub
|
||||
}, [loadData])
|
||||
|
||||
// 날짜별 그룹핑
|
||||
const groupedEntries = useMemo(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue