basic nav status counts
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,6 @@ def action_archive(app) -> None:
|
||||
)
|
||||
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}.")
|
||||
|
||||
@@ -23,13 +23,13 @@ def action_next(app) -> None:
|
||||
import json
|
||||
envelopes = json.loads(result.stdout)
|
||||
ids = sorted(int(envelope['id']) for envelope in envelopes)
|
||||
for envelope_id in ids:
|
||||
if envelope_id > app.current_message_id:
|
||||
app.current_message_id = envelope_id
|
||||
app.show_message(app.current_message_id)
|
||||
app.show_status(f"Showing next message: {app.current_message_id}")
|
||||
for index, envelope_id in enumerate(ids):
|
||||
if envelope_id > int(app.current_message_id):
|
||||
app.show_message(envelope_id)
|
||||
return
|
||||
|
||||
app.show_status("No newer messages found.", severity="warning")
|
||||
app.show_message(envelopes[-1]['id']) # Automatically show the previous message
|
||||
else:
|
||||
app.show_status("Failed to fetch envelope list.", severity="error")
|
||||
except Exception as e:
|
||||
|
||||
@@ -6,7 +6,6 @@ def action_open(app) -> None:
|
||||
def check_id(message_id: str) -> bool:
|
||||
try:
|
||||
int(message_id)
|
||||
app.show_status(f"Opening message {message_id}...")
|
||||
app.current_message_id = message_id
|
||||
app.show_message(app.current_message_id)
|
||||
except ValueError:
|
||||
|
||||
@@ -14,10 +14,9 @@ def action_previous(app) -> None:
|
||||
envelopes = json.loads(result.stdout)
|
||||
ids = sorted((int(envelope['id']) for envelope in envelopes), reverse=True)
|
||||
for envelope_id in ids:
|
||||
if envelope_id < app.current_message_id:
|
||||
if envelope_id < int(app.current_message_id):
|
||||
app.current_message_id = envelope_id
|
||||
app.show_message(app.current_message_id)
|
||||
app.show_status(f"Showing previous message: {app.current_message_id}")
|
||||
return
|
||||
app.show_status("No older messages found.", severity="warning")
|
||||
else:
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from textual.widgets import Static
|
||||
from rich.markdown import Markdown
|
||||
import subprocess
|
||||
|
||||
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(
|
||||
@@ -12,7 +14,6 @@ def show_message(app, message_id: int) -> None:
|
||||
)
|
||||
if result.returncode == 0:
|
||||
# Render the email content as Markdown
|
||||
from rich.markdown import 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)
|
||||
|
||||
Reference in New Issue
Block a user