MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / Update

Method Update

internal/tui/dashboard.go:61–98  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

59}
60
61func (m dashboardModel) Update(msg tea.Msg) (dashboardModel, tea.Cmd) {
62 switch msg := msg.(type) {
63 case localeChangedMsg:
64 // Re-render immediately with cached data using new locale
65 m.content = m.renderDashboard(m.lastConfig, m.lastAuthFiles, m.lastAPIKeys)
66 m.viewport.SetContent(m.content)
67 // Also fetch fresh data in background
68 return m, m.fetchData
69
70 case dashboardDataMsg:
71 if msg.err != nil {
72 m.err = msg.err
73 m.content = errorStyle.Render("⚠ Error: " + msg.err.Error())
74 } else {
75 m.err = nil
76 // Cache data for locale switching
77 m.lastConfig = msg.config
78 m.lastAuthFiles = msg.authFiles
79 m.lastAPIKeys = msg.apiKeys
80
81 m.content = m.renderDashboard(msg.config, msg.authFiles, msg.apiKeys)
82 }
83 m.viewport.SetContent(m.content)
84 return m, nil
85
86 case tea.KeyMsg:
87 if msg.String() == "r" {
88 return m, m.fetchData
89 }
90 var cmd tea.Cmd
91 m.viewport, cmd = m.viewport.Update(msg)
92 return m, cmd
93 }
94
95 var cmd tea.Cmd
96 m.viewport, cmd = m.viewport.Update(msg)
97 return m, cmd
98}
99
100func (m *dashboardModel) SetSize(w, h int) {
101 m.width = w

Callers

nothing calls this directly

Calls 3

renderDashboardMethod · 0.95
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected