summaryrefslogtreecommitdiff
path: root/internal/client/ui
diff options
context:
space:
mode:
Diffstat (limited to 'internal/client/ui')
-rw-r--r--internal/client/ui/auth/auth.go4
-rw-r--r--internal/client/ui/core/core.go40
-rw-r--r--internal/client/ui/viminput/viminput.go2
3 files changed, 28 insertions, 18 deletions
diff --git a/internal/client/ui/auth/auth.go b/internal/client/ui/auth/auth.go
index 8e6dffb..47a3f89 100644
--- a/internal/client/ui/auth/auth.go
+++ b/internal/client/ui/auth/auth.go
@@ -378,7 +378,7 @@ func (m *Model) SetSignup(signup bool) tea.Cmd {
m.focusIndex = -1
m.CycleForward()
- privateKey := config.Read().PrivateKeyPath
+ privateKey := config.ReadConfig().PrivateKeyPath
if !m.signup && privateKey != "" {
m.fields[privateKeyField].Input.SetValue(privateKey)
}
@@ -544,7 +544,7 @@ func (m *Model) signin() tea.Cmd {
}
if m.remember {
- _ = config.Use(func(config *config.Config) {
+ _ = config.UseConfig(func(config *config.Config) {
config.PrivateKeyPath = privateKeyFilepath
})
}
diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go
index 5a0f8db..11772fa 100644
--- a/internal/client/ui/core/core.go
+++ b/internal/client/ui/core/core.go
@@ -5,6 +5,8 @@ import (
"fmt"
"log"
"math"
+ "os"
+ "runtime"
"slices"
"time"
@@ -13,6 +15,7 @@ import (
"github.com/charmbracelet/bubbles/timer"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
+ "github.com/kyren223/eko/internal/client/config"
"github.com/kyren223/eko/internal/client/gateway"
"github.com/kyren223/eko/internal/client/ui"
"github.com/kyren223/eko/internal/client/ui/colors"
@@ -294,25 +297,11 @@ func (m *Model) updateConnected(message tea.Msg) tea.Cmd {
combined := msg.Tos + "\n" + msg.PrivacyPolicy
tos := tosscreen.New(combined)
m.tos = &tos
- // var setName tea.Cmd
- // if m.name != "" {
- // setName = gateway.Send(&packet.SetUserData{
- // Data: nil,
- // User: &data.User{
- // Name: m.name,
- // Description: "",
- // IsPublicDM: true,
- // },
- // })
- // m.name = ""
- // }
- //
- // return tea.Batch(m.timer.Stop(), setName)
case *packet.Error:
if m.state == ConnectedAcceptedTos {
if msg.Error == "success" {
- return gateway.Send(&packet.GetNonce{})
+ return tea.Batch(gateway.Send(&packet.GetNonce{}), SendAnalytics())
} else {
log.Println("received error:", msg.Error)
gateway.Disconnect()
@@ -408,6 +397,7 @@ func (m *Model) updateAuthenticated(message tea.Msg) tea.Cmd {
case *packet.Error:
err := "new connection from another location, closing this one"
if err == msg.Error {
+ gateway.Disconnect()
return ui.Transition(ui.NewAuth())
}
@@ -945,3 +935,23 @@ func getSignalNotification(signal snowflake.ID) int {
func (m Model) ViewTos() string {
return "TODO TOS"
}
+
+func SendAnalytics() tea.Cmd {
+ if !config.ReadConfig().AnonymousDeviceAnalytics {
+ return nil // User disabled analytics
+ }
+ assert.Assert(config.ReadConfig().AnonymousDeviceAnalytics, "who is paranoid")
+
+ osName := runtime.GOOS
+ arch := runtime.GOARCH
+ term := os.Getenv("TERM")
+ colorterm := os.Getenv("COLORTERM")
+
+ return gateway.Send(&packet.DeviceAnalytics{
+ DeviceID: config.ReadCache().DeviceID,
+ OS: osName,
+ Arch: arch,
+ Term: term,
+ Colorterm: colorterm,
+ })
+}
diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go
index 6d1f01b..5c4b6b2 100644
--- a/internal/client/ui/viminput/viminput.go
+++ b/internal/client/ui/viminput/viminput.go
@@ -649,7 +649,7 @@ func (m *Model) handleInsertModeKeys(key tea.KeyMsg) {
}
if key.Type == tea.KeyTab || key.Type == tea.KeyShiftTab {
- conf := config.Read()
+ conf := config.ReadConfig()
var runes []rune
if conf.InsertModeTabToSpace {
runes = []rune(strings.Repeat(" ", int(conf.InsertModeSpacesPerTab)))