working good state
This commit is contained in:
@@ -1,23 +1,14 @@
|
||||
from textual.widgets import Static
|
||||
from rich.markdown import Markdown
|
||||
import logging
|
||||
import subprocess
|
||||
from textual.logging import TextualHandler
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
level="NOTSET",
|
||||
handlers=[TextualHandler()],
|
||||
)
|
||||
|
||||
def show_message(app, message_id: int) -> None:
|
||||
"""Fetch and display the email message by ID."""
|
||||
app.current_message_id = message_id
|
||||
app.query_one("#main_content", Static).loading = True
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["himalaya", "message", "read", str(message_id)],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
if result.returncode == 0:
|
||||
# Render the email content as Markdown
|
||||
markdown_content = Markdown(result.stdout, justify=True)
|
||||
app.query_one("#main_content", Static).loading = False
|
||||
app.query_one("#main_content", Static).update(markdown_content)
|
||||
else:
|
||||
app.query_one("#main_content", Static).update(f"Failed to fetch message {message_id}.")
|
||||
except Exception as e:
|
||||
app.query_one("#main_content", Static).update(f"Error: {e}")
|
||||
logging.info("Showing message ID: " + str(message_id))
|
||||
|
||||
Reference in New Issue
Block a user