diff options
Diffstat (limited to 'internal/client')
| -rw-r--r-- | internal/client/ui/auth/auth.go | 14 | ||||
| -rw-r--r-- | internal/client/ui/core/core.go | 6 | ||||
| -rw-r--r-- | internal/client/ui/ui.go | 2 |
3 files changed, 19 insertions, 3 deletions
diff --git a/internal/client/ui/auth/auth.go b/internal/client/ui/auth/auth.go index 42ea3e5..3f89298 100644 --- a/internal/client/ui/auth/auth.go +++ b/internal/client/ui/auth/auth.go @@ -80,14 +80,22 @@ ___] | |__] | \| | | \|`) centerStyle = lipgloss.NewStyle().Width(authWidth).AlignHorizontal(0.5) ) +func init() { + // HACK: to avoid a circular dependency, so core can transition to this + // I don't like how go has this issue, I would rather slower compilations + ui.NewAuth = func() tea.Model { + return New() + } +} + type Model struct { - focusIndex int + popup *choicepopup.Model + fields []authfield.Model + focusIndex int remember bool signup bool - - popup *choicepopup.Model } func New() Model { diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 50abbe6..1e2bc6a 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -179,6 +179,12 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd { m.timeout = initialTimeout return tea.Batch(gateway.Connect(m.privKey, connectionTimeout), m.loading.Init()) + case *packet.Error: + err := "new connection from another location, closing this one" + if msg.PktType == packet.PacketError && err == msg.Error { + return ui.Transition(ui.NewAuth()) + } + case *packet.NetworksInfo: if msg.Set { state.State.Networks = msg.Networks diff --git a/internal/client/ui/ui.go b/internal/client/ui/ui.go index 3ee0124..ab8b273 100644 --- a/internal/client/ui/ui.go +++ b/internal/client/ui/ui.go @@ -23,6 +23,8 @@ var Width int var Height int var Program *tea.Program +var NewAuth func() tea.Model + type ModelTransition struct { Model tea.Model } |
