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

Method Update

internal/tui/app.go:109–274  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

107}
108
109func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
110 switch msg := msg.(type) {
111 case tea.WindowSizeMsg:
112 a.width = msg.Width
113 a.height = msg.Height
114 a.ready = true
115 if a.width > 0 {
116 a.authInput.Width = a.width - 6
117 }
118 contentH := a.height - 4 // tab bar + status bar
119 if contentH < 1 {
120 contentH = 1
121 }
122 contentW := a.width
123 a.dashboard.SetSize(contentW, contentH)
124 a.config.SetSize(contentW, contentH)
125 a.auth.SetSize(contentW, contentH)
126 a.keys.SetSize(contentW, contentH)
127 a.oauth.SetSize(contentW, contentH)
128 a.logs.SetSize(contentW, contentH)
129 return a, nil
130
131 case authConnectMsg:
132 a.authConnecting = false
133 if msg.err != nil {
134 a.authError = fmt.Sprintf(T("auth_gate_connect_fail"), msg.err.Error())
135 return a, nil
136 }
137 a.authError = ""
138 a.authenticated = true
139 a.logsEnabled = a.standalone || isLogsEnabledFromConfig(msg.cfg)
140 a.refreshTabs()
141 a.initialized = [6]bool{}
142 a.initialized[tabDashboard] = true
143 cmds := []tea.Cmd{a.dashboard.Init()}
144 if a.logsEnabled {
145 a.initialized[tabLogs] = true
146 cmds = append(cmds, a.logs.Init())
147 }
148 return a, tea.Batch(cmds...)
149
150 case configUpdateMsg:
151 var cmdLogs tea.Cmd
152 if !a.standalone && msg.err == nil && msg.path == "logging-to-file" {
153 logsEnabledConfig, okConfig := msg.value.(bool)
154 if okConfig {
155 logsEnabledBefore := a.logsEnabled
156 a.logsEnabled = logsEnabledConfig
157 if logsEnabledBefore != a.logsEnabled {
158 a.refreshTabs()
159 }
160 if !a.logsEnabled {
161 a.initialized[tabLogs] = false
162 }
163 if !logsEnabledBefore && a.logsEnabled {
164 a.initialized[tabLogs] = true
165 cmdLogs = a.logs.Init()
166 }

Callers 6

upsertAuthRecordMethod · 0.45
broadcastToAllTabsMethod · 0.45
upsertAuthRecordMethod · 0.45
PatchAuthFileStatusMethod · 0.45
PatchAuthFileFieldsMethod · 0.45

Calls 12

refreshTabsMethod · 0.95
setAuthInputPromptMethod · 0.95
connectWithPasswordMethod · 0.95
broadcastToAllTabsMethod · 0.95
initTabIfNeededMethod · 0.95
TFunction · 0.85
isLogsEnabledFromConfigFunction · 0.85
ToggleLocaleFunction · 0.85
SetSizeMethod · 0.45
ErrorMethod · 0.45
InitMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected