Skip to content

Commit

Permalink
save expansion state
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Jan 15, 2024
1 parent 960da87 commit 7c8e911
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/channellist/channellisttree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,23 @@ void ChannelListTree::UseExpansionState(const ExpansionStateRoot &root) {
ExpansionStateRoot ChannelListTree::GetExpansionState() const {
ExpansionStateRoot r;

auto recurse = [this](auto &self, const Gtk::TreeRow &row) -> ExpansionState {
ExpansionState r;

r.IsExpanded = row[m_columns.m_expanded];
for (auto child : row.children()) {
r.Children.Children[static_cast<Snowflake>(child[m_columns.m_id])] = self(self, child);
}

return r;
};

for (auto child : m_model->children()) {
const auto id = static_cast<Snowflake>(child[m_columns.m_id]);
if (static_cast<uint64_t>(id) == 0ULL) continue; // dont save DM header
r.Children[id] = recurse(recurse, child);
}

return r;
}

Expand Down

0 comments on commit 7c8e911

Please sign in to comment.