refactor email viewer app
This commit is contained in:
21
maildir_gtd/actions/archive.py
Normal file
21
maildir_gtd/actions/archive.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from textual.widgets import Static
|
||||
import subprocess
|
||||
|
||||
from maildir_gtd.actions.next import action_next
|
||||
def action_archive(app) -> None:
|
||||
"""Archive the current email message."""
|
||||
app.show_status(f"Archiving message {app.current_message_id}...")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["himalaya", "message", "move", "Archives", str(app.current_message_id)],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
if result.returncode == 0:
|
||||
app.query_one("#main_content", Static).update(f"Message {app.current_message_id} archived.")
|
||||
app.show_status(f"Message {app.current_message_id} archived.")
|
||||
action_next(app) # Automatically show the next message
|
||||
else:
|
||||
app.query_one("#main_content", Static).update(f"Failed to archive 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