Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
inbox: Use newly supported paging keys
Erik Kundt committed 2 years ago
commit 2778e69733b1c5635229b42891c2178d5b1ab690
parent a5315982cd4d0e81190c869112cd0e7d61194c55
1 file changed +23 -24
modified bin/commands/inbox/flux/select/ui.rs
@@ -226,36 +226,35 @@ impl Widget<InboxState, Action> for Notifications {
        match key {
            Key::Up | Key::Char('k') => {
                self.table.prev();
-

-
                let selected = self
-
                    .table
-
                    .selected()
-
                    .and_then(|selected| self.props.notifications.get(selected));
-

-
                // TODO: propagate error
-
                if let Some(notif) = selected {
-
                    let _ = self.action_tx.send(Action::Select {
-
                        item: notif.clone(),
-
                    });
-
                }
            }
            Key::Down | Key::Char('j') => {
                self.table.next(self.props.notifications.len());
-

-
                let selected = self
-
                    .table
-
                    .selected()
-
                    .and_then(|selected| self.props.notifications.get(selected));
-

-
                // TODO: propagate error
-
                if let Some(notif) = selected {
-
                    let _ = self.action_tx.send(Action::Select {
-
                        item: notif.clone(),
-
                    });
-
                }
+
            }
+
            Key::PageUp => {
+
                self.table.prev_page(self.props.page_size);
+
            }
+
            Key::PageDown => {
+
                self.table
+
                    .next_page(self.props.notifications.len(), self.props.page_size);
+
            }
+
            Key::Home => {
+
                self.table.begin();
+
            }
+
            Key::End => {
+
                self.table.end(self.props.notifications.len());
            }
            _ => {}
        }
+
        self.table
+
            .selected()
+
            .and_then(|selected| self.props.notifications.get(selected))
+
            .and_then(|notif| {
+
                self.action_tx
+
                    .send(Action::Select {
+
                        item: notif.clone(),
+
                    })
+
                    .ok()
+
            });
    }
}