diff --git a/CHANGELOG.md b/CHANGELOG.md index 66c731ccc..b320fed61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Minor: Added `/requests` command. Usage: `/requests [channel]`. Opens the channel points requests queue for the provided channel or the current channel if no input is provided. (#3746) - Minor: Added ability to execute commands on chat messages using the message context menu. (#3738) - Minor: Added `/copy` command. Usage: `/copy `. Copies provided text to clipboard - can be useful with custom commands. (#3763) +- Bugfix: Fixed viewers list search not working when used before loading finishes. (#3774) - Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646) - Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678) - Bugfix: Fixed certain settings dialogs appearing behind the main window, when `Always on top` was used. (#3679) diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 8f9b7370d..a805b822e 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -990,6 +990,33 @@ void Split::showViewerList() "viewers"}; auto loadingLabel = new QLabel("Loading..."); + searchBar->setPlaceholderText("Search User..."); + + auto performListSearch = [=]() { + auto query = searchBar->text(); + if (query.isEmpty()) + { + resultList->hide(); + chattersList->show(); + return; + } + + auto results = chattersList->findItems(query, Qt::MatchContains); + chattersList->hide(); + resultList->clear(); + for (auto &item : results) + { + if (!item->text().contains("(")) + { + resultList->addItem(formatListItemText(item->text())); + } + } + resultList->show(); + }; + + QObject::connect(searchBar, &QLineEdit::textEdited, this, + performListSearch); + NetworkRequest::twitchRequest("https://tmi.twitch.tv/group/user/" + this->getChannel()->getName() + "/chatters") .caller(this) @@ -1023,54 +1050,31 @@ void Split::showViewerList() chattersList->addItem(new QListWidgetItem()); } + performListSearch(); return Success; }) .execute(); - searchBar->setPlaceholderText("Search User..."); - QObject::connect(searchBar, &QLineEdit::textEdited, this, [=]() { - auto query = searchBar->text(); - if (!query.isEmpty()) - { - auto results = chattersList->findItems(query, Qt::MatchContains); - chattersList->hide(); - resultList->clear(); - for (auto &item : results) - { - if (!item->text().contains("(")) - { - resultList->addItem(formatListItemText(item->text())); - } - } - resultList->show(); - } - else - { - resultList->hide(); - chattersList->show(); - } - }); - QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this, [=]() { viewerDock->setMinimumWidth(300); }); - auto listDoubleClick = [=](QString userName) { + auto listDoubleClick = [this](const QModelIndex &index) { + const auto itemText = index.data().toString(); + // if the list item contains a parentheses it means that // it's a category label so don't show a usercard - if (!userName.contains("(") && !userName.isEmpty()) + if (!itemText.contains("(") && !itemText.isEmpty()) { - this->view_->showUserInfoPopup(userName); + this->view_->showUserInfoPopup(itemText); } }; - QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() { - listDoubleClick(chattersList->currentItem()->text()); - }); + QObject::connect(chattersList, &QListWidget::doubleClicked, this, + listDoubleClick); - QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() { - listDoubleClick(resultList->currentItem()->text()); - }); + QObject::connect(resultList, &QListWidget::doubleClicked, this, + listDoubleClick); HotkeyController::HotkeyMap actions{ {"delete",