From: Olaf Wintermann Date: Sat, 5 Sep 2026 12:43:36 +0000 (+0200) Subject: implement go_back/go_forward for the attachments window X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=note.git implement go_back/go_forward for the attachments window --- diff --git a/application/note/src/attachments_window.rs b/application/note/src/attachments_window.rs index 7656010..6b38a29 100644 --- a/application/note/src/attachments_window.rs +++ b/application/note/src/attachments_window.rs @@ -192,14 +192,36 @@ impl AttachmentsWindow { a } + pub fn update_selection(&mut self, selected_index: usize) { + let Some(attachment) = self.attachments.get(selected_index) else { + return; + }; + self.selected_index = Some(selected_index); + self.selection = Some(attachment.attachment.attachment_id); + self.load_content(selected_index); + } #[action] pub fn go_back(&mut self, _event: &ActionEvent) { + let selected_index = match self.selected_index { + Some(index) => index.checked_sub(1), + None => self.attachments.len().checked_sub(1), + }; + if let Some(index) = selected_index { + self.update_selection(index); + } } #[action] pub fn go_forward(&mut self, _event: &ActionEvent) { + let selected_index = match self.selected_index { + Some(index) => index + 1, + None => 0, + }; + if selected_index < self.attachments.len() { + self.update_selection(selected_index); + } } }