mirror of
https://github.com/ivabus/pop
synced 2024-11-10 02:25:19 +03:00
fix: escape attachments
This commit is contained in:
parent
daa31dc744
commit
d6f2498dbd
|
@ -9,6 +9,7 @@ type KeyMap struct {
|
|||
Send key.Binding
|
||||
Attach key.Binding
|
||||
Unattach key.Binding
|
||||
Back key.Binding
|
||||
Quit key.Binding
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,11 @@ func DefaultKeybinds() KeyMap {
|
|||
key.WithHelp("x", "remove"),
|
||||
key.WithDisabled(),
|
||||
),
|
||||
Back: key.NewBinding(
|
||||
key.WithKeys("esc"),
|
||||
key.WithHelp("esc", "back"),
|
||||
key.WithDisabled(),
|
||||
),
|
||||
Quit: key.NewBinding(
|
||||
key.WithKeys("ctrl+c"),
|
||||
key.WithHelp("ctrl+c", "quit"),
|
||||
|
@ -64,4 +70,5 @@ func (m *Model) updateKeymap() {
|
|||
canSend := m.From.Value() != "" && m.To.Value() != "" && m.Subject.Value() != "" && m.Body.Value() != ""
|
||||
m.keymap.Send.SetEnabled(canSend && m.state != editingBody && m.state != pickingFile)
|
||||
m.keymap.Unattach.SetEnabled(m.state == editingAttachments && len(m.Attachments.Items()) > 0)
|
||||
m.keymap.Back.SetEnabled(m.state == pickingFile)
|
||||
}
|
||||
|
|
8
model.go
8
model.go
|
@ -127,7 +127,6 @@ func NewModel() Model {
|
|||
func (m Model) Init() tea.Cmd {
|
||||
return tea.Batch(
|
||||
m.From.Cursor.BlinkCmd(),
|
||||
m.filepicker.Init(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -174,6 +173,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
m.focusActiveInput()
|
||||
|
||||
case key.Matches(msg, m.keymap.Back):
|
||||
m.state = editingAttachments
|
||||
m.updateKeymap()
|
||||
return m, nil
|
||||
case key.Matches(msg, m.keymap.Send):
|
||||
m.state = sendingEmail
|
||||
return m, tea.Batch(
|
||||
|
@ -182,6 +185,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
)
|
||||
case key.Matches(msg, m.keymap.Attach):
|
||||
m.state = pickingFile
|
||||
return m, m.filepicker.Init()
|
||||
case key.Matches(msg, m.keymap.Unattach):
|
||||
m.Attachments.RemoveItem(m.Attachments.Index())
|
||||
m.Attachments.SetHeight(max(len(m.Attachments.Items()), 1) + 2)
|
||||
|
@ -276,7 +280,7 @@ func (m Model) View() string {
|
|||
|
||||
switch m.state {
|
||||
case pickingFile:
|
||||
return "\n" + activeLabelStyle.Render("Attachments") +
|
||||
return "\n" + activeLabelStyle.Render("Attachments") + " " + commentStyle.Render(m.filepicker.CurrentDirectory) +
|
||||
"\n\n" + m.filepicker.View()
|
||||
case sendingEmail:
|
||||
return "\n " + m.loadingSpinner.View() + "Sending email"
|
||||
|
|
Loading…
Reference in a new issue