adding UV

This commit is contained in:
Tim Bendt
2025-05-08 12:02:24 -06:00
parent 7e42644224
commit eba883a465
10 changed files with 856 additions and 126 deletions

View File

@@ -380,8 +380,12 @@ class EmailViewerApp(App):
return
modifier = 1
idx = self.current_message_index
if self.all_envelopes[idx + modifier] is None or self.all_envelopes[idx + modifier].get("type") == "header":
idx = idx + modifier
try:
if self.all_envelopes[idx + modifier] is None or self.all_envelopes[idx + modifier].get("type") == "header":
idx = idx + modifier
except IndexError:
# If we reach the end of the list, wrap around to the beginning
idx = 0
self.show_message(self.all_envelopes[idx + modifier].get("id"), idx + modifier)
self.fetch_envelopes() if self.reload_needed else None
@@ -390,26 +394,39 @@ class EmailViewerApp(App):
return
modifier = -1
idx = self.current_message_index
if self.all_envelopes[idx + modifier] is None or self.all_envelopes[idx + modifier].get("type") == "header":
idx = idx + modifier
try:
if self.all_envelopes[idx + modifier] is None or self.all_envelopes[idx + modifier].get("type") == "header":
idx = idx + modifier
except IndexError:
# If we reach the beginning of the list, wrap around to the end
idx = len(self.all_envelopes) - 1
self.show_message(self.all_envelopes[idx + modifier].get("id"), idx + modifier)
self.fetch_envelopes() if self.reload_needed else None
async def action_delete(self) -> None:
self.all_envelopes.remove(self.all_envelopes[self.current_message_index])
self.message_body_cache.pop(self.current_message_id, None)
self.total_messages = len(self.all_envelopes)
delete_current(self)
self.query_one("#envelopes_list").pop(self.current_message_index)
self.all_envelopes = list(filter(lambda x: int(x.get("id", "0")) != self.current_message_id, self.all_envelopes))
self.message_metadata.pop(self.current_message_id, None)
self.message_body_cache.pop(self.current_message_id, None)
self.total_messages = len(self.message_metadata)
delete_current(self)
newmsg = self.all_envelopes[self.current_message_index]
if newmsg.get('type') == "header":
newmsg = self.all_envelopes[self.current_message_index + 1]
return
self.show_message(newmsg['id'])
async def action_archive(self) -> None:
self.all_envelopes.remove(self.all_envelopes[self.current_message_index])
self.query_one("#envelopes_list").pop(self.current_message_index)
self.all_envelopes = list(filter(lambda x: int(x.get("id", "0")) != self.current_message_id, self.all_envelopes))
self.message_metadata.pop(self.current_message_id, None)
self.message_body_cache.pop(self.current_message_id, None)
self.total_messages = len(self.all_envelopes)
self.total_messages = len(self.message_metadata)
worker = archive_current(self)
await worker.wait()
newmsg = self.all_envelopes[self.current_message_index]
if newmsg.get('type') == "header":
newmsg = self.current_message_index = self.current_message_index + 1
newmsg = self.all_envelopes[self.current_message_index + 1]
return
self.show_message(newmsg['id'])