-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.go
68 lines (58 loc) · 1.95 KB
/
startup.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
59
60
61
62
63
64
65
66
67
68
package main
import (
"context"
"strings"
"time"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/names"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
func (a *App) startup(ctx context.Context) {
logger.Info("Calling app.startup")
a.ctx = ctx
nameParts := names.Custom | names.Prefund | names.Regular | names.Baddress
m, err := names.LoadNamesMap(a.dataFile.Chain, nameParts, nil)
a.namesMap[a.dataFile.Chain] = m
if err != nil {
logger.Error("Failed to load names map:", err)
}
}
func (a *App) domReady(ctx context.Context) {
runtime.WindowSetPosition(a.ctx, a.config.WindowState.X, a.config.WindowState.Y)
runtime.WindowShow(ctx)
logger.Info("Calling app.domReady")
chartType, err := a.config.Get("settings", "chartType", "month")
if err != nil {
logger.Error(err)
}
logger.Info("domReady", "chartType", chartType)
exportExcel, err := a.config.Get("settings", "exportExcel", "false")
if err != nil {
logger.Error(err)
}
logger.Info("domReady", "exportExcel", exportExcel)
a.Export(a.dataFile.Address.Hex(), "")
a.updateState()
if file.FileExists("addresses.txt") {
lines := file.AsciiFileToLines("addresses.txt")
m := make([]string, 0, len(lines))
for _, line := range lines {
if strings.HasPrefix(line, "#") {
continue
}
m = append(m, line)
}
runtime.EventsEmit(a.ctx, "monitors", strings.Join(m, "\n"))
}
runtime.EventsEmit(a.ctx, "chartType", chartType)
runtime.EventsEmit(a.ctx, "exportExcel", exportExcel)
runtime.EventsEmit(a.ctx, "progress", "Loading names map...")
time.Sleep(1 * time.Second)
runtime.EventsEmit(a.ctx, "progress", "")
}
func (a *App) shutdown(ctx context.Context) {
a.config.WindowState.Width, a.config.WindowState.Height = runtime.WindowGetSize(ctx)
a.config.WindowState.X, a.config.WindowState.Y = runtime.WindowGetPosition(ctx)
a.config.Save()
}