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

Method Update

internal/tui/auth_tab.go:77–124  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

75}
76
77func (m authTabModel) Update(msg tea.Msg) (authTabModel, tea.Cmd) {
78 switch msg := msg.(type) {
79 case localeChangedMsg:
80 m.viewport.SetContent(m.renderContent())
81 return m, nil
82 case authFilesMsg:
83 if msg.err != nil {
84 m.err = msg.err
85 } else {
86 m.err = nil
87 m.files = msg.files
88 if m.cursor >= len(m.files) {
89 m.cursor = max(0, len(m.files)-1)
90 }
91 m.status = ""
92 }
93 m.viewport.SetContent(m.renderContent())
94 return m, nil
95
96 case authActionMsg:
97 if msg.err != nil {
98 m.status = errorStyle.Render("✗ " + msg.err.Error())
99 } else {
100 m.status = successStyle.Render("✓ " + msg.action)
101 }
102 m.confirm = -1
103 m.viewport.SetContent(m.renderContent())
104 return m, m.fetchFiles
105
106 case tea.KeyMsg:
107 // ---- Editing mode ----
108 if m.editing {
109 return m.handleEditInput(msg)
110 }
111
112 // ---- Delete confirmation mode ----
113 if m.confirm >= 0 {
114 return m.handleConfirmInput(msg)
115 }
116
117 // ---- Normal mode ----
118 return m.handleNormalInput(msg)
119 }
120
121 var cmd tea.Cmd
122 m.viewport, cmd = m.viewport.Update(msg)
123 return m, cmd
124}
125
126// startEdit activates inline editing for a field on the currently selected auth file.
127func (m *authTabModel) startEdit(fieldIdx int) tea.Cmd {

Callers 2

handleEditInputMethod · 0.45
handleNormalInputMethod · 0.45

Calls 6

renderContentMethod · 0.95
handleEditInputMethod · 0.95
handleConfirmInputMethod · 0.95
handleNormalInputMethod · 0.95
maxFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected