Persist current world history
All checks were successful
build-windows-exe / build (push) Successful in 1m50s

This commit is contained in:
messypy
2026-07-28 00:51:15 +09:00
parent 8e704980c1
commit 70bafabee9
3 changed files with 40 additions and 6 deletions

View File

@@ -228,12 +228,14 @@ func historyVisitSource() []historyVisitRecord {
})
}
if label, since, ok := currentWorldVisitInfo(); ok && strings.TrimSpace(label) != "" && !since.IsZero() {
records = append(records, historyVisitRecord{
Key: historyVisitKey(label, since, time.Time{}, "", "", true),
WorldLabel: label,
Start: since,
Current: true,
})
if !hasOpenHistoryVisit(records, label, since) {
records = append(records, historyVisitRecord{
Key: historyVisitKey(label, since, time.Time{}, "", "", true),
WorldLabel: label,
Start: since,
Current: true,
})
}
}
sort.SliceStable(records, func(i, j int) bool {
ti := records[i].End
@@ -252,6 +254,22 @@ func historyVisitSource() []historyVisitRecord {
return records
}
func hasOpenHistoryVisit(records []historyVisitRecord, label string, since time.Time) bool {
label = strings.TrimSpace(label)
for _, record := range records {
if !record.End.IsZero() || record.Start.IsZero() {
continue
}
if !record.Start.Equal(since) {
continue
}
if strings.EqualFold(strings.TrimSpace(record.WorldLabel), label) {
return true
}
}
return false
}
func historyVisitKey(label string, start, end time.Time, worldID, instanceID string, current bool) string {
key := strings.TrimSpace(label)
if worldID != "" {