move and rename module

This commit is contained in:
Bendt
2025-12-18 14:00:54 -05:00
parent 37be42884f
commit fe65183fb7
33 changed files with 26 additions and 24 deletions

View File

@@ -0,0 +1,39 @@
from textual import work
from src.services.himalaya import client as himalaya_client
@work(exclusive=True)
async def archive_current(app):
"""Archive the current message."""
if not app.current_message_id:
app.show_status("No message selected to archive.", "error")
return
# Store the current message ID and index
current_message_id = app.current_message_id
current_index = app.current_message_index
# Find the next message to display after archiving
next_id, next_idx = app.message_store.find_next_valid_id(current_index)
if next_id is None or next_idx is None:
# If there's no next message, try to find a previous one
next_id, next_idx = app.message_store.find_prev_valid_id(current_index)
# Archive the message using our Himalaya client module
success = await himalaya_client.archive_messages([str(current_message_id)])
if success:
app.show_status(f"Message {current_message_id} archived.", "success")
app.message_store.remove_envelope(current_message_id)
app.refresh_list_view_items()
# Select the next available message if it exists
if next_id is not None and next_idx is not None:
app.current_message_id = next_id
app.current_message_index = next_idx
else:
# If there are no other messages, reset the UI
app.current_message_id = 0
app.show_status("No more messages available.", "warning")
else:
app.show_status(f"Failed to archive message {current_message_id}.", "error")