Files
luk/maildir_gtd/actions/delete.py
2025-05-01 11:59:28 -04:00

23 lines
832 B
Python

import subprocess
from textual.widgets import Static
from maildir_gtd.actions.next import action_next
def action_delete(app) -> None:
"""Delete the current email message."""
app.show_status(f"Deleting message {app.current_message_id}...")
app.query_one("#main_content", Static).loading = True
try:
result = subprocess.run(
["himalaya", "message", "delete", str(app.current_message_id)],
capture_output=True,
text=True
)
if result.returncode == 0:
app.query_one("#main_content").loading = False
action_next(app) # Automatically show the next message
else:
app.show_status(f"Failed to delete message {app.current_message_id}.", "error")
except Exception as e:
app.show_status(f"Error: {e}", "error")