mostly working after the refactor
This commit is contained in:
@@ -108,6 +108,7 @@ class EmailViewerApp(App):
|
||||
Binding("1", "focus_1", "Focus Accounts Panel"),
|
||||
Binding("2", "focus_2", "Focus Folders Panel"),
|
||||
Binding("3", "focus_3", "Focus Envelopes Panel"),
|
||||
Binding("4", "focus_4", "Focus Main Content"),
|
||||
Binding("m", "toggle_mode", "Toggle Content Mode"),
|
||||
]
|
||||
|
||||
@@ -353,6 +354,7 @@ class EmailViewerApp(App):
|
||||
def show_message(self, message_id: int, new_index=None) -> None:
|
||||
if new_index:
|
||||
self.current_message_index = new_index
|
||||
self.action_focus_4()
|
||||
self.current_message_id = message_id
|
||||
|
||||
def show_status(self, message: str, severity: str = "information") -> None:
|
||||
@@ -458,11 +460,15 @@ class EmailViewerApp(App):
|
||||
def action_focus_3(self) -> None:
|
||||
self.query_one("#folders_list").focus()
|
||||
|
||||
def action_focus_4(self) -> None:
|
||||
self.query_one("#main_content").focus()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = EmailViewerApp()
|
||||
app.run()
|
||||
|
||||
|
||||
def launch_email_viewer():
|
||||
app = EmailViewerApp()
|
||||
app.run()
|
||||
|
||||
@@ -94,20 +94,7 @@ Markdown {
|
||||
}
|
||||
|
||||
|
||||
#create_task_container {
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
border: heavy $secondary;
|
||||
layout: horizontal;
|
||||
align: center middle;
|
||||
Label {
|
||||
width: auto;
|
||||
}
|
||||
Input {
|
||||
width: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#envelopes_list {
|
||||
ListItem:odd {
|
||||
background: rgb(45, 45, 46);
|
||||
@@ -126,10 +113,12 @@ Markdown {
|
||||
|
||||
|
||||
#open_message_container, #create_task_container {
|
||||
dock: bottom;
|
||||
width: 100%;
|
||||
border: panel $border;
|
||||
dock: right;
|
||||
width: 25%;
|
||||
min-width: 60;
|
||||
padding: 0 1;
|
||||
height: 5;
|
||||
height: 100%;
|
||||
|
||||
Input {
|
||||
width: 1fr;
|
||||
|
||||
@@ -18,7 +18,6 @@ class CreateTaskScreen(ModalScreen):
|
||||
def compose(self):
|
||||
yield Container(
|
||||
Vertical(
|
||||
Label("Create Task", id="create_task_title"),
|
||||
Horizontal(
|
||||
Label("Subject:"),
|
||||
Input(
|
||||
@@ -56,6 +55,8 @@ class CreateTaskScreen(ModalScreen):
|
||||
)
|
||||
|
||||
def on_mount(self):
|
||||
self.query_one("#create_task_container",
|
||||
Container).border_title = "New Task (taskwarrior)"
|
||||
self.styles.align = ("center", "middle")
|
||||
|
||||
@on(Button.Pressed, "#create_btn")
|
||||
@@ -69,7 +70,8 @@ class CreateTaskScreen(ModalScreen):
|
||||
priority = self.query_one("#priority_input").value
|
||||
|
||||
# Process tags (split by commas and trim whitespace)
|
||||
tags = [tag.strip() for tag in tags_input.split(",")] if tags_input else []
|
||||
tags = [tag.strip()
|
||||
for tag in tags_input.split(",")] if tags_input else []
|
||||
|
||||
# Add a tag for the sender, if provided
|
||||
if self.from_addr and "@" in self.from_addr:
|
||||
|
||||
@@ -64,7 +64,7 @@ class ContentContainer(ScrollableContainer):
|
||||
self.header = EnvelopeHeader(id="envelope_header")
|
||||
self.content = Markdown("", id="markdown_content")
|
||||
self.html_content = Static("", id="html_content", markup=False)
|
||||
self.current_mode = "text" # Default to text mode
|
||||
self.current_mode = "html" # Default to text mode
|
||||
self.current_content = None
|
||||
self.current_message_id = None
|
||||
self.content_worker = None
|
||||
@@ -75,6 +75,7 @@ class ContentContainer(ScrollableContainer):
|
||||
|
||||
def on_mount(self):
|
||||
# Hide markdown content initially
|
||||
# self.action_notify("loading message...")
|
||||
self.content.styles.display = "none"
|
||||
self.html_content.styles.display = "block"
|
||||
|
||||
@@ -88,7 +89,7 @@ class ContentContainer(ScrollableContainer):
|
||||
self.current_mode = "html"
|
||||
self.content.styles.display = "none"
|
||||
self.html_content.styles.display = "block"
|
||||
|
||||
# self.action_notify(f"switched to mode {self.current_mode}")
|
||||
# Reload the content if we have a message ID
|
||||
if self.current_message_id:
|
||||
self.display_content(self.current_message_id)
|
||||
@@ -112,6 +113,7 @@ class ContentContainer(ScrollableContainer):
|
||||
|
||||
def display_content(self, message_id: int) -> None:
|
||||
"""Display the content of a message."""
|
||||
# self.action_notify(f"recieved message_id to display {message_id}")
|
||||
if not message_id:
|
||||
return
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ async def archive_message(message_id: int) -> bool:
|
||||
"""
|
||||
try:
|
||||
process = await asyncio.create_subprocess_shell(
|
||||
f"himalaya message archive {message_id}",
|
||||
f"himalaya message move Archives {message_id}",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
@@ -146,7 +146,6 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]:
|
||||
|
||||
Args:
|
||||
message_id: The ID of the message to retrieve
|
||||
format: The desired format of the message content ("html" or "text")
|
||||
|
||||
Returns:
|
||||
Tuple containing:
|
||||
@@ -176,7 +175,7 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]:
|
||||
|
||||
|
||||
def sync_himalaya():
|
||||
"""Synchronize data using Himalaya."""
|
||||
"""This command does not exist. Halucinated by AI."""
|
||||
try:
|
||||
# subprocess.run(["himalaya", "sync"], check=True)
|
||||
print("Himalaya sync completed successfully.")
|
||||
|
||||
@@ -41,7 +41,7 @@ async def fetch_mail_async(
|
||||
None
|
||||
"""
|
||||
from src.utils.mail_utils.maildir import save_mime_to_maildir_async
|
||||
from utils.mail_utils.helpers import truncate_id
|
||||
from src.utils.mail_utils.helpers import truncate_id
|
||||
|
||||
mail_url = "https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$top=100&$orderby=receivedDateTime asc&$select=id,subject,from,toRecipients,ccRecipients,receivedDateTime,isRead"
|
||||
messages = []
|
||||
|
||||
@@ -13,7 +13,7 @@ import aiohttp
|
||||
import re
|
||||
|
||||
from src.utils.calendar_utils import truncate_id
|
||||
from utils.mail_utils.helpers import safe_filename, ensure_directory_exists, format_datetime, format_mime_date
|
||||
from src.utils.mail_utils.helpers import safe_filename, ensure_directory_exists, format_datetime, format_mime_date
|
||||
|
||||
async def save_mime_to_maildir_async(maildir_path, message, attachments_dir, headers, progress, dry_run=False, download_attachments=False):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user