Made #channel link in /mentions jump to #channel split (#2220)

This commit is contained in:
Paweł
2020-11-28 17:45:20 +01:00
committed by GitHub
parent 1a4d4dca79
commit 49fa9bfd72
4 changed files with 38 additions and 1 deletions
+35
View File
@@ -2043,6 +2043,41 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
SettingsDialogPreference::Accounts);
}
break;
case Link::JumpToChannel: {
// Get all currently open pages
QList<SplitContainer *> openPages;
auto &nb = getApp()->windows->getMainWindow().getNotebook();
for (int i = 0; i < nb.getPageCount(); ++i)
{
openPages.push_back(
static_cast<SplitContainer *>(nb.getPageAt(i)));
}
for (auto *page : openPages)
{
auto splits = page->getSplits();
// Search for channel matching link in page/split container
// TODO(zneix): Consider opening a channel if it's closed (?)
auto it = std::find_if(
splits.begin(), splits.end(), [link](Split *split) {
return split->getChannel()->getName() == link.value;
});
if (it != splits.end())
{
// Select SplitContainer and Split itself where mention message was sent
// TODO(zneix): Try exploring ways of scrolling to a certain message as well
nb.select(page);
Split *split = *it;
page->setSelected(split);
break;
}
}
}
break;
default:;
}