Files
luk/maildir_gtd/actions/delete.py
2025-04-30 13:11:00 -04:00

24 lines
987 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", Static).loading = False
app.query_one("#main_content", Static).update(f"Message {app.current_message_id} deleted.")
action_next(app) # Automatically show the next message
else:
app.query_one("#main_content", Static).update(f"Failed to delete message {app.current_message_id}.")
except Exception as e:
app.query_one("#main_content", Static).update(f"Error: {e}")