ruff formatted
This commit is contained in:
@@ -20,7 +20,7 @@ async def archive_current(app) -> None:
|
||||
process = await asyncio.create_subprocess_shell(
|
||||
f"himalaya message move Archives {app.current_message_id}",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await process.communicate()
|
||||
# app.reload_needed = True
|
||||
|
||||
@@ -2,6 +2,7 @@ import asyncio
|
||||
from textual import work
|
||||
from textual.widgets import ListView
|
||||
|
||||
|
||||
@work(exclusive=False)
|
||||
async def delete_current(app) -> None:
|
||||
app.show_status(f"Deleting message {app.current_message_id}...")
|
||||
@@ -10,7 +11,7 @@ async def delete_current(app) -> None:
|
||||
process = await asyncio.create_subprocess_shell(
|
||||
f"himalaya message delete {app.current_message_id}",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await process.communicate()
|
||||
# app.reload_needed = True
|
||||
@@ -20,6 +21,9 @@ async def delete_current(app) -> None:
|
||||
app.query_one(ListView).index = index
|
||||
# app.action_next() # Automatically show the next message
|
||||
else:
|
||||
app.show_status(f"Failed to delete message {app.current_message_id}. {stderr.decode()}", "error")
|
||||
app.show_status(
|
||||
f"Failed to delete message {app.current_message_id}. {stderr.decode()}",
|
||||
"error",
|
||||
)
|
||||
except Exception as e:
|
||||
app.show_status(f"Error: {e}", "error")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
|
||||
async def action_newest(app) -> None:
|
||||
"""Show the previous email message by finding the next lower ID from the list of envelope IDs."""
|
||||
try:
|
||||
if (app.reload_needed):
|
||||
if app.reload_needed:
|
||||
await app.action_fetch_list()
|
||||
|
||||
ids = sorted((int(envelope['id']) for envelope in app.all_envelopes), reverse=True)
|
||||
ids = sorted(
|
||||
(int(envelope["id"]) for envelope in app.all_envelopes), reverse=True
|
||||
)
|
||||
app.current_message_id = ids[0]
|
||||
app.show_message(app.current_message_id)
|
||||
return
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
async def action_next(app) -> None:
|
||||
"""Show the next email message by finding the next higher ID from the list of envelope IDs."""
|
||||
try:
|
||||
if (app.reload_needed):
|
||||
if app.reload_needed:
|
||||
app.action_fetch_list()
|
||||
ids = sorted(int(envelope['id']) for envelope in app.all_envelopes)
|
||||
ids = sorted(int(envelope["id"]) for envelope in app.all_envelopes)
|
||||
for envelope_id in ids:
|
||||
if envelope_id > int(app.current_message_id):
|
||||
app.show_message(envelope_id)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
def action_oldest(app) -> None:
|
||||
"""Show the previous email message by finding the next lower ID from the list of envelope IDs."""
|
||||
try:
|
||||
if (app.reload_needed):
|
||||
if app.reload_needed:
|
||||
app.action_fetch_list()
|
||||
|
||||
ids = sorted((int(envelope['id']) for envelope in app.all_envelopes))
|
||||
ids = sorted((int(envelope["id"]) for envelope in app.all_envelopes))
|
||||
app.current_message_id = ids[0]
|
||||
app.show_message(app.current_message_id)
|
||||
return
|
||||
|
||||
@@ -3,15 +3,19 @@ from maildir_gtd.screens.OpenMessage import OpenMessageScreen
|
||||
|
||||
def action_open(app) -> None:
|
||||
"""Show the input modal for opening a specific message by ID."""
|
||||
|
||||
def check_id(message_id: str | None) -> bool:
|
||||
try:
|
||||
int(message_id)
|
||||
app.show_message(message_id)
|
||||
if (message_id is not None and message_id > 0):
|
||||
if message_id is not None and message_id > 0:
|
||||
app.show_message(message_id)
|
||||
except ValueError:
|
||||
app.bell()
|
||||
app.show_status("Invalid message ID. Please enter an integer.", severity="error")
|
||||
app.show_status(
|
||||
"Invalid message ID. Please enter an integer.", severity="error"
|
||||
)
|
||||
return True
|
||||
return False
|
||||
|
||||
app.push_screen(OpenMessageScreen(), check_id)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
|
||||
def action_previous(app) -> None:
|
||||
"""Show the previous email message by finding the next lower ID from the list of envelope IDs."""
|
||||
try:
|
||||
if (app.reload_needed):
|
||||
if app.reload_needed:
|
||||
app.action_fetch_list()
|
||||
|
||||
ids = sorted((int(envelope['id']) for envelope in app.all_envelopes), reverse=True)
|
||||
ids = sorted(
|
||||
(int(envelope["id"]) for envelope in app.all_envelopes), reverse=True
|
||||
)
|
||||
for envelope_id in ids:
|
||||
if envelope_id < int(app.current_message_id):
|
||||
app.current_message_id = envelope_id
|
||||
|
||||
@@ -7,6 +7,7 @@ logging.basicConfig(
|
||||
handlers=[TextualHandler()],
|
||||
)
|
||||
|
||||
|
||||
def show_message(app, message_id: int) -> None:
|
||||
"""Fetch and display the email message by ID."""
|
||||
logging.info("Showing message ID: " + str(message_id))
|
||||
|
||||
@@ -11,15 +11,18 @@ def action_create_task(app) -> None:
|
||||
result = await asyncio.create_subprocess_shell(
|
||||
f"task add {task_args}",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await result.communicate()
|
||||
if result.returncode == 0:
|
||||
app.show_status(f"Task created: {stdout.decode()}")
|
||||
else:
|
||||
app.show_status(f"Failed to create task: {stderr.decode()}", severity="error")
|
||||
app.show_status(
|
||||
f"Failed to create task: {stderr.decode()}", severity="error"
|
||||
)
|
||||
except Exception as e:
|
||||
app.show_status(f"Error: {e}", severity="error")
|
||||
return True
|
||||
return False
|
||||
|
||||
app.push_screen(CreateTaskScreen(), check_task)
|
||||
|
||||
Reference in New Issue
Block a user