Skip to content

Commit

Permalink
chore: alert user when going online
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Jan 2, 2025
1 parent 6516303 commit 120b3a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ui/modal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (m ViewModel) HandleMessage(msg tea.Msg) (*ViewModel, tea.Cmd) {
m.transactionModal.State = msg
m.infoModal.State = msg

// On Fast-Catchup, handle the state as an exception modal

Check warning on line 46 in ui/modal/controller.go

View check run for this annotation

Codecov / codecov/patch

ui/modal/controller.go#L46

Added line #L46 was not covered by tests
if m.State.Status.State == algod.FastCatchupState {
m.Open = true
m.SetType(app.ExceptionModal)
Expand All @@ -63,6 +64,7 @@ func (m ViewModel) HandleMessage(msg tea.Msg) (*ViewModel, tea.Cmd) {
m.title = "Fast Catchup"

} else if m.Type == app.TransactionModal && m.transactionModal.Participation != nil {
// Get the existing account from the state

Check warning on line 67 in ui/modal/controller.go

View check run for this annotation

Codecov / codecov/patch

ui/modal/controller.go#L67

Added line #L67 was not covered by tests
acct, ok := msg.Accounts[m.Address]
// If the previous state is not active
if ok {
Expand All @@ -71,6 +73,7 @@ func (m ViewModel) HandleMessage(msg tea.Msg) (*ViewModel, tea.Cmd) {
acct.Participation.VoteFirstValid == m.transactionModal.Participation.Key.VoteFirstValid {
m.SetActive(true)
m.infoModal.Active = true
m.infoModal.Prefix = "Successfully went online!\n"

Check warning on line 76 in ui/modal/controller.go

View check run for this annotation

Codecov / codecov/patch

ui/modal/controller.go#L76

Added line #L76 was not covered by tests
m.SetType(app.InfoModal)
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions ui/modal/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (

// View renders the current modal's UI based on its type and state, or returns the parent content if the modal is closed.
func (m ViewModel) View() string {
// Clear prefix for infoModal
if !m.infoModal.Active && m.infoModal.Prefix != "" {
m.infoModal.Prefix = ""
}

Check warning on line 14 in ui/modal/view.go

View check run for this annotation

Codecov / codecov/patch

ui/modal/view.go#L13-L14

Added lines #L13 - L14 were not covered by tests
if !m.Open {
return m.Parent
}
Expand Down
8 changes: 7 additions & 1 deletion ui/modals/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ViewModel struct {
Controls string
BorderColor string
Active bool
Prefix string
Participation *api.ParticipationKey
State *algod.StateModel
}
Expand Down Expand Up @@ -92,8 +93,13 @@ func (m ViewModel) View() string {
voteLastValid := style.Purple("Vote Last Valid: ") + utils.IntToStr(m.Participation.Key.VoteLastValid)
voteKeyDilution := style.Purple("Vote Key Dilution: ") + utils.IntToStr(m.Participation.Key.VoteKeyDilution)

prefix := ""
if m.Prefix != "" {
prefix = "\n" + m.Prefix
}

Check warning on line 99 in ui/modals/info/info.go

View check run for this annotation

Codecov / codecov/patch

ui/modals/info/info.go#L98-L99

Added lines #L98 - L99 were not covered by tests

return ansi.Hardwrap(lipgloss.JoinVertical(lipgloss.Left,
"",
prefix,
account,
id,
"",
Expand Down

0 comments on commit 120b3a6

Please sign in to comment.