-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
58 lines (47 loc) · 1.21 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"KAIWorkerViz/beckend"
"KAIWorkerViz/beckend/Data"
"KAIWorkerViz/beckend/httpClient"
"context"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
// App struct
type App struct {
ctx context.Context
client httpClient.Client
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called at application startup
func (a *App) startup(ctx context.Context) {
// Perform your setup here
a.ctx = ctx
a.client = httpClient.NewClient(ctx)
}
// domReady is called after the front-end dom has been loaded
func (a *App) domReady(ctx context.Context) {
// Add your action here
// download json from all sources
// deserialize to struct
// check for duplicates?
// send to frontend
backend.RunFuncAtInterval(3000, func() {
workersInfo, err := a.client.GetJson("https://stablehorde.net/api/v2/workers?type=text")
if err != nil {
panic(err.Error())
runtime.LogDebugf(a.ctx, err.Error())
} else {
runtime.EventsEmit(a.ctx, "update_list", *workersInfo)
}
}, true)
}
func (a *App) GetCurrentWorkers() []Data.WorkerInfo {
wi, err := a.client.GetJson("https://stablehorde.net/api/v2/workers?type=text")
if err != nil {
return nil
}
return *wi
}