mostly working after the refactor
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ output_ics/outlook_events_latest.ics
|
|||||||
cache_timestamp.json
|
cache_timestamp.json
|
||||||
sync_timestamp.json
|
sync_timestamp.json
|
||||||
__pycache__
|
__pycache__
|
||||||
|
~/Calendar/corteva
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class EmailViewerApp(App):
|
|||||||
Binding("1", "focus_1", "Focus Accounts Panel"),
|
Binding("1", "focus_1", "Focus Accounts Panel"),
|
||||||
Binding("2", "focus_2", "Focus Folders Panel"),
|
Binding("2", "focus_2", "Focus Folders Panel"),
|
||||||
Binding("3", "focus_3", "Focus Envelopes Panel"),
|
Binding("3", "focus_3", "Focus Envelopes Panel"),
|
||||||
|
Binding("4", "focus_4", "Focus Main Content"),
|
||||||
Binding("m", "toggle_mode", "Toggle Content Mode"),
|
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:
|
def show_message(self, message_id: int, new_index=None) -> None:
|
||||||
if new_index:
|
if new_index:
|
||||||
self.current_message_index = new_index
|
self.current_message_index = new_index
|
||||||
|
self.action_focus_4()
|
||||||
self.current_message_id = message_id
|
self.current_message_id = message_id
|
||||||
|
|
||||||
def show_status(self, message: str, severity: str = "information") -> None:
|
def show_status(self, message: str, severity: str = "information") -> None:
|
||||||
@@ -458,11 +460,15 @@ class EmailViewerApp(App):
|
|||||||
def action_focus_3(self) -> None:
|
def action_focus_3(self) -> None:
|
||||||
self.query_one("#folders_list").focus()
|
self.query_one("#folders_list").focus()
|
||||||
|
|
||||||
|
def action_focus_4(self) -> None:
|
||||||
|
self.query_one("#main_content").focus()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = EmailViewerApp()
|
app = EmailViewerApp()
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
|
|
||||||
def launch_email_viewer():
|
def launch_email_viewer():
|
||||||
app = EmailViewerApp()
|
app = EmailViewerApp()
|
||||||
app.run()
|
app.run()
|
||||||
|
|||||||
@@ -94,19 +94,6 @@ Markdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#create_task_container {
|
|
||||||
width: 50%;
|
|
||||||
height: 50%;
|
|
||||||
border: heavy $secondary;
|
|
||||||
layout: horizontal;
|
|
||||||
align: center middle;
|
|
||||||
Label {
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
Input {
|
|
||||||
width: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#envelopes_list {
|
#envelopes_list {
|
||||||
ListItem:odd {
|
ListItem:odd {
|
||||||
@@ -126,10 +113,12 @@ Markdown {
|
|||||||
|
|
||||||
|
|
||||||
#open_message_container, #create_task_container {
|
#open_message_container, #create_task_container {
|
||||||
dock: bottom;
|
border: panel $border;
|
||||||
width: 100%;
|
dock: right;
|
||||||
|
width: 25%;
|
||||||
|
min-width: 60;
|
||||||
padding: 0 1;
|
padding: 0 1;
|
||||||
height: 5;
|
height: 100%;
|
||||||
|
|
||||||
Input {
|
Input {
|
||||||
width: 1fr;
|
width: 1fr;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class CreateTaskScreen(ModalScreen):
|
|||||||
def compose(self):
|
def compose(self):
|
||||||
yield Container(
|
yield Container(
|
||||||
Vertical(
|
Vertical(
|
||||||
Label("Create Task", id="create_task_title"),
|
|
||||||
Horizontal(
|
Horizontal(
|
||||||
Label("Subject:"),
|
Label("Subject:"),
|
||||||
Input(
|
Input(
|
||||||
@@ -56,6 +55,8 @@ class CreateTaskScreen(ModalScreen):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_mount(self):
|
def on_mount(self):
|
||||||
|
self.query_one("#create_task_container",
|
||||||
|
Container).border_title = "New Task (taskwarrior)"
|
||||||
self.styles.align = ("center", "middle")
|
self.styles.align = ("center", "middle")
|
||||||
|
|
||||||
@on(Button.Pressed, "#create_btn")
|
@on(Button.Pressed, "#create_btn")
|
||||||
@@ -69,7 +70,8 @@ class CreateTaskScreen(ModalScreen):
|
|||||||
priority = self.query_one("#priority_input").value
|
priority = self.query_one("#priority_input").value
|
||||||
|
|
||||||
# Process tags (split by commas and trim whitespace)
|
# 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
|
# Add a tag for the sender, if provided
|
||||||
if self.from_addr and "@" in self.from_addr:
|
if self.from_addr and "@" in self.from_addr:
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ContentContainer(ScrollableContainer):
|
|||||||
self.header = EnvelopeHeader(id="envelope_header")
|
self.header = EnvelopeHeader(id="envelope_header")
|
||||||
self.content = Markdown("", id="markdown_content")
|
self.content = Markdown("", id="markdown_content")
|
||||||
self.html_content = Static("", id="html_content", markup=False)
|
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_content = None
|
||||||
self.current_message_id = None
|
self.current_message_id = None
|
||||||
self.content_worker = None
|
self.content_worker = None
|
||||||
@@ -75,6 +75,7 @@ class ContentContainer(ScrollableContainer):
|
|||||||
|
|
||||||
def on_mount(self):
|
def on_mount(self):
|
||||||
# Hide markdown content initially
|
# Hide markdown content initially
|
||||||
|
# self.action_notify("loading message...")
|
||||||
self.content.styles.display = "none"
|
self.content.styles.display = "none"
|
||||||
self.html_content.styles.display = "block"
|
self.html_content.styles.display = "block"
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ class ContentContainer(ScrollableContainer):
|
|||||||
self.current_mode = "html"
|
self.current_mode = "html"
|
||||||
self.content.styles.display = "none"
|
self.content.styles.display = "none"
|
||||||
self.html_content.styles.display = "block"
|
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
|
# Reload the content if we have a message ID
|
||||||
if self.current_message_id:
|
if self.current_message_id:
|
||||||
self.display_content(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:
|
def display_content(self, message_id: int) -> None:
|
||||||
"""Display the content of a message."""
|
"""Display the content of a message."""
|
||||||
|
# self.action_notify(f"recieved message_id to display {message_id}")
|
||||||
if not message_id:
|
if not message_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ async def archive_message(message_id: int) -> bool:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
process = await asyncio.create_subprocess_shell(
|
process = await asyncio.create_subprocess_shell(
|
||||||
f"himalaya message archive {message_id}",
|
f"himalaya message move Archives {message_id}",
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
)
|
)
|
||||||
@@ -146,7 +146,6 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
message_id: The ID of the message to retrieve
|
message_id: The ID of the message to retrieve
|
||||||
format: The desired format of the message content ("html" or "text")
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tuple containing:
|
Tuple containing:
|
||||||
@@ -176,7 +175,7 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]:
|
|||||||
|
|
||||||
|
|
||||||
def sync_himalaya():
|
def sync_himalaya():
|
||||||
"""Synchronize data using Himalaya."""
|
"""This command does not exist. Halucinated by AI."""
|
||||||
try:
|
try:
|
||||||
# subprocess.run(["himalaya", "sync"], check=True)
|
# subprocess.run(["himalaya", "sync"], check=True)
|
||||||
print("Himalaya sync completed successfully.")
|
print("Himalaya sync completed successfully.")
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ async def fetch_mail_async(
|
|||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
from src.utils.mail_utils.maildir import save_mime_to_maildir_async
|
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"
|
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 = []
|
messages = []
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import aiohttp
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from src.utils.calendar_utils import truncate_id
|
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):
|
async def save_mime_to_maildir_async(maildir_path, message, attachments_dir, headers, progress, dry_run=False, download_attachments=False):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Test script for the refactored code
|
# Test script for the refactored code
|
||||||
|
|
||||||
echo "Testing the refactored code with a dry run (no attachment download)..."
|
echo "Testing the refactored code with a dry run (no attachment download)..."
|
||||||
python fetch_outlook.py --dry-run
|
python3 main.py sync --dry-run
|
||||||
|
|
||||||
echo -e "\nTesting with attachment downloading enabled..."
|
echo -e "\nTesting with attachment downloading enabled..."
|
||||||
python fetch_outlook.py --dry-run --download-attachments
|
python3 main.py sync --dry-run --download-attachments
|
||||||
|
|||||||
Reference in New Issue
Block a user