Skip to content

Commit

Permalink
fix: modal state
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Jan 24, 2025
1 parent 53ac04a commit 723c124
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions ui/modal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ func (m *ViewModel) HandleMessage(msg tea.Msg) (*ViewModel, tea.Cmd) {
// It is online, has a participation key but not the one we are looking at AND all the keys are not different
// (AND it's the info modal (this case we are checking on enter) OR we are waiting to register a key, and we made a mistake

// You know it's getting bad when the plugin recommendation is Grazie
// TODO: refactor this beast to have isolated state from the modal controller

// Ahh yes, classic "Set Active to the inverse then only navigate when there is no prefix"
// Ahh yes, classic "Set Active to the inverse then only navigate when there is no prefix and it's not the dilution changing"
// Dilution is likely to match some active keys so we just ignore it. First and last rounds must be unique pairs
// This is the closest thing we have to state, between this and the transaction modal state it works
// Set active ensures the offline modal is changed when a corruption happens
m.SetActive(false)
if m.infoModal.Prefix == "" {
if m.infoModal.Prefix == "" && diff.VoteKeyDilution {
m.infoModal.Prefix = "***WARNING***\nRegistered online but keys do not fully match\nCheck your registered keys carefully against the node keys\n\n"
if diff.VoteFirstValid {
m.infoModal.Prefix = m.infoModal.Prefix + "Mismatched: Vote First Valid\n"
Expand Down
6 changes: 2 additions & 4 deletions ui/modals/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ func (m ViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.HandleMessage(msg)
}
func (m ViewModel) HandleMessage(msg tea.Msg) (ViewModel, tea.Cmd) {
isOffline := !m.OfflineControls
switch msg := msg.(type) {
case app.ModalEvent:
if msg.Type == app.InfoModal {
m.Prefix = msg.Prefix
m.Participation = msg.Key
m.OfflineControls = msg.Active
isOffline = !m.OfflineControls
}
case tea.KeyMsg:
switch msg.String() {
Expand All @@ -59,11 +57,11 @@ func (m ViewModel) HandleMessage(msg tea.Msg) (ViewModel, tea.Cmd) {
}
case "r":
if !m.OfflineControls {
return m, app.EmitCreateShortLink(isOffline, m.Participation, m.State)
return m, app.EmitCreateShortLink(false, m.Participation, m.State)
}
case "o":
if m.OfflineControls {
return m, app.EmitCreateShortLink(isOffline, m.Participation, m.State)
return m, app.EmitCreateShortLink(true, m.Participation, m.State)
}
}
case tea.WindowSizeMsg:
Expand Down

0 comments on commit 723c124

Please sign in to comment.