From 2646da31a1a396b5c9d4c9537a5f04f8a210883c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:32:18 -0400 Subject: check filter model conversions --- src/components/channellist/channellist.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/components') diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 51e8f33..236513e 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -604,9 +604,15 @@ void ChannelList::SetActiveChannel(Snowflake id, bool expand_to) { const auto channel_iter = GetIteratorForRowFromID(id); if (channel_iter) { if (expand_to) { - m_view.expand_to_path(m_filter_model->convert_child_path_to_path(m_model->get_path(channel_iter))); + const auto filter_path = m_filter_model->convert_child_path_to_path(m_model->get_path(channel_iter)); + if (filter_path) { + m_view.expand_to_path(filter_path); + } + } + const auto filter_iter = m_filter_model->convert_child_iter_to_iter(channel_iter); + if (filter_iter) { + m_view.get_selection()->select(filter_iter); } - m_view.get_selection()->select(m_filter_model->convert_child_iter_to_iter(channel_iter)); } else { m_view.get_selection()->unselect_all(); const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id); @@ -614,7 +620,10 @@ void ChannelList::SetActiveChannel(Snowflake id, bool expand_to) { auto parent_iter = GetIteratorForRowFromID(*channel->ParentID); if (!parent_iter) return; m_temporary_thread_row = CreateThreadRow(parent_iter->children(), *channel); - m_view.get_selection()->select(m_filter_model->convert_child_iter_to_iter(m_temporary_thread_row)); + const auto filter_iter = m_filter_model->convert_child_iter_to_iter(m_temporary_thread_row); + if (filter_iter) { + m_view.get_selection()->select(filter_iter); + } } } -- cgit v1.2.3