Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
inbox: Adjust to updated render props
Erik Kundt committed 2 years ago
commit fb5d4cf724af6dc45ead0f6c2030df8e74f27557
parent fe4d48282e43e725309da0d513620d6afdeb395e
1 file changed +11 -27
modified bin/commands/inbox/select/ui.rs
@@ -256,10 +256,10 @@ impl<'a: 'static> Widget for BrowsePage<'a> {
        self.shortcuts.update(state);
    }

-
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
+
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<&dyn Any>) {
        let props = props
-
            .and_then(BrowsePageProps::from_boxed_any)
-
            .unwrap_or(self.props.clone());
+
            .and_then(|props| props.downcast_ref::<BrowsePageProps>())
+
            .unwrap_or(&self.props);

        let page_size = area.height.saturating_sub(6) as usize;

@@ -273,33 +273,21 @@ impl<'a: 'static> Widget for BrowsePage<'a> {
            self.notifications.render(
                frame,
                table_area,
-
                Some(
-
                    ContainerProps::default()
-
                        .hide_footer(props.show_search)
-
                        .to_boxed(),
-
                ),
+
                Some(&ContainerProps::default().hide_footer(props.show_search)),
            );
            self.search.render(frame, search_area, None);
        } else {
            self.notifications.render(
                frame,
                content_area,
-
                Some(
-
                    ContainerProps::default()
-
                        .hide_footer(props.show_search)
-
                        .to_boxed(),
-
                ),
+
                Some(&ContainerProps::default().hide_footer(props.show_search)),
            );
        }

        self.shortcuts.render(
            frame,
            shortcuts_area,
-
            Some(
-
                ShortcutsProps::default()
-
                    .shortcuts(&props.shortcuts)
-
                    .to_boxed(),
-
            ),
+
            Some(&ShortcutsProps::default().shortcuts(&props.shortcuts)),
        );

        if page_size != props.page_size {
@@ -380,7 +368,7 @@ impl Widget for Search {
        self.input.update(state);
    }

-
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, _props: Option<Box<dyn Any>>) {
+
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, _props: Option<&dyn Any>) {
        let layout = Layout::horizontal(Constraint::from_mins([0]))
            .horizontal_margin(1)
            .split(area);
@@ -523,10 +511,10 @@ impl<'a: 'static> Widget for HelpPage<'a> {
        self.content.update(state);
    }

-
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
+
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<&dyn Any>) {
        let props = props
-
            .and_then(HelpPageProps::from_boxed_any)
-
            .unwrap_or(self.props.clone());
+
            .and_then(|props| props.downcast_ref::<HelpPageProps>())
+
            .unwrap_or(&self.props);

        let page_size = area.height.saturating_sub(6) as usize;

@@ -537,11 +525,7 @@ impl<'a: 'static> Widget for HelpPage<'a> {
        self.shortcuts.render(
            frame,
            shortcuts_area,
-
            Some(
-
                ShortcutsProps::default()
-
                    .shortcuts(&props.shortcuts)
-
                    .to_boxed(),
-
            ),
+
            Some(&ShortcutsProps::default().shortcuts(&props.shortcuts)),
        );

        if page_size != props.page_size {