Persist current world history
All checks were successful
build-windows-exe / build (push) Successful in 1m50s
All checks were successful
build-windows-exe / build (push) Successful in 1m50s
This commit is contained in:
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user