Clean project layout and fix release workflow
Some checks failed
build-windows-exe / build (push) Failing after 1m13s
Some checks failed
build-windows-exe / build (push) Failing after 1m13s
This commit is contained in:
@@ -19,6 +19,7 @@ type RuntimeState struct {
|
||||
LastOCRText string
|
||||
LastTranslate string
|
||||
CurrentWorld string
|
||||
CurrentWorldSince string
|
||||
}
|
||||
|
||||
var runtimeState = &RuntimeState{}
|
||||
@@ -84,6 +85,29 @@ func SetCurrentWorld(v string) {
|
||||
_ = persistRuntimeState()
|
||||
}
|
||||
|
||||
func SetCurrentWorldVisit(world string, since time.Time) {
|
||||
runtimeState.mu.Lock()
|
||||
runtimeState.CurrentWorld = world
|
||||
if since.IsZero() {
|
||||
runtimeState.CurrentWorldSince = ""
|
||||
} else {
|
||||
runtimeState.CurrentWorldSince = since.Format(time.RFC3339)
|
||||
}
|
||||
runtimeState.mu.Unlock()
|
||||
_ = persistRuntimeState()
|
||||
}
|
||||
|
||||
func SetCurrentWorldSince(v time.Time) {
|
||||
runtimeState.mu.Lock()
|
||||
if v.IsZero() {
|
||||
runtimeState.CurrentWorldSince = ""
|
||||
} else {
|
||||
runtimeState.CurrentWorldSince = v.Format(time.RFC3339)
|
||||
}
|
||||
runtimeState.mu.Unlock()
|
||||
_ = persistRuntimeState()
|
||||
}
|
||||
|
||||
func SnapshotRuntime() RuntimeState {
|
||||
runtimeState.mu.RLock()
|
||||
defer runtimeState.mu.RUnlock()
|
||||
@@ -111,6 +135,7 @@ func persistRuntimeState() error {
|
||||
"ocr": s.LastOCRText,
|
||||
"translate": s.LastTranslate,
|
||||
"world": s.CurrentWorld,
|
||||
"world_since": s.CurrentWorldSince,
|
||||
"updated_at": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user