Load GUI history asynchronously
All checks were successful
build-windows-exe / build (push) Successful in 1m12s

This commit is contained in:
messypy
2026-07-27 23:32:17 +09:00
parent 4df1a5d71a
commit dadc65065c
3 changed files with 158 additions and 14 deletions

View File

@@ -52,6 +52,7 @@ const (
wmCommandGUI = 0x0111
wmSetFont = 0x0030
wmHistoryExportDone = 0x0401
wmHistoryRefreshDone = 0x0402
enChange = 0x0300
enKillFocus = 0x0200
bnClicked = 0x0000
@@ -251,6 +252,8 @@ type guiApp struct {
historyReloadRect winRect
historyExportRect winRect
historyReloadPending bool
historyRefreshRunning bool
historyRefreshResultCh chan historyRefreshResult
historyCacheLoaded bool
historyDetailContentHeightPx int32
settingsExportDirEdit uintptr
@@ -466,7 +469,6 @@ func runNativeGUI(initialTab string) error {
app.historyExportCustom = strings.TrimSpace(guiCfg.HistoryExportCustom)
app.historyReloadPending = true
app.hFont = createAppFont(app.fontSize)
refreshHistoryCache(&app, true)
paneWndProc := syscall.NewCallback(func(hwnd uintptr, message uint32, wParam, lParam uintptr) uintptr {
defer func() {
if r := recover(); r != nil {
@@ -851,17 +853,31 @@ func runNativeGUI(initialTab string) error {
}
case wmTimerGUI:
drainHistoryExportResult(&app)
drainHistoryRefreshResult(&app)
reloadData := app.activeTab == "join" || app.activeTab == "translate"
if app.activeTab == "history" && app.historyReloadPending {
if refreshHistoryCache(&app, true) {
refreshGUI(setWindowText, &app, false)
}
startHistoryRefresh(&app, true)
refreshGUI(setWindowText, &app, false)
refreshSettingsControls(showWindowProc, setWindowPosProc, &app)
return 0
}
refreshGUI(setWindowText, &app, reloadData)
refreshSettingsControls(showWindowProc, setWindowPosProc, &app)
return 0
case wmHistoryRefreshDone:
drainHistoryRefreshResult(&app)
if invalidateRectProc != nil {
if app.leftHwnd != 0 {
invalidateRectProc.Call(app.leftHwnd, 0, 1)
}
if app.rightHwnd != 0 {
invalidateRectProc.Call(app.rightHwnd, 0, 1)
}
if app.hwnd != 0 {
invalidateRectProc.Call(app.hwnd, 0, 1)
}
}
return 0
case wmHistoryExportDone:
drainHistoryExportResult(&app)
if invalidateRectProc != nil {
@@ -984,11 +1000,7 @@ func refreshGUI(setWindowText *syscall.LazyProc, app *guiApp, reloadData bool) {
instanceCount := app.currentUserCount
worldLabel := app.currentWorld
state := readRuntimeSnapshot()
historyDirty := false
historyNeedsRefresh := app.activeTab == "history" && (app.historyReloadPending || !app.historyCacheLoaded)
if historyNeedsRefresh {
historyDirty = refreshHistoryCache(app, false)
}
historyDirty := app.activeTab == "history" && app.historyReloadPending
if reloadData {
if app.activeTab == "translate" {
guiLog("refreshGUI activeTab=translate light refresh")