refactor email viewer app
This commit is contained in:
23
maildir_gtd/actions/delete.py
Normal file
23
maildir_gtd/actions/delete.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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}")
|
||||
Reference in New Issue
Block a user