~zanneth/Octahedron

edd0011df5d344c2d3658412397be3eb95d2d8ff — Charles Magahern 1 year, 8 months ago 9276c16
Move state restoration logic for the debt requests model inside the block that creates it
1 files changed, 18 insertions(+), 15 deletions(-)

M gtk/src/app_window.rs
M gtk/src/app_window.rs => gtk/src/app_window.rs +18 -15
@@ 485,6 485,24 @@ impl AppWindow {
                Some(model)
            } else if let Some(network) = self.network() {
                let new_model = DebtRequestsModel::new(network).ok();

                if let Some(new_model) = new_model.as_ref() {
                    // restore sort settings
                    let tree_store = new_model.tree_store();
                    if_chain! {
                        if let Some(sort_column) = self.preferences.debt_requests_sort_column();
                        if let Some(sort_type) = self.preferences.debt_requests_sort_type();
                        then {
                            tree_store.set_sort_column_id(gtk::SortColumn::Index(sort_column), sort_type);
                        }
                    }

                    // connect sort signal
                    tree_store.connect_sort_column_changed(clone!(@strong self.self_tx as tx => move |_| {
                        dispatch_msg!(tx, Message::DebtRequestsSortColumnChanged);
                    }));
                }

                self.debt_requests_model = new_model;
                self.debt_requests_model.as_mut()
            } else {


@@ 493,21 511,6 @@ impl AppWindow {
        };

        if let Some(model) = model {
            // restore sort settings
            let tree_store = model.tree_store();
            if_chain! {
                if let Some(sort_column) = self.preferences.debt_requests_sort_column();
                if let Some(sort_type) = self.preferences.debt_requests_sort_type();
                then {
                    tree_store.set_sort_column_id(gtk::SortColumn::Index(sort_column), sort_type);
                }
            }

            // connect sort signal
            tree_store.connect_sort_column_changed(clone!(@strong self.self_tx as tx => move |_| {
                dispatch_msg!(tx, Message::DebtRequestsSortColumnChanged);
            }));

            // set the model on the tree view.
            self.debt_requests_tree_view.set_octahedron_model(model);