Fix viewers list search when used before loading finishes (#3774)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
kornes 2022-05-29 11:06:01 +00:00 committed by GitHub
parent 8b98f0e142
commit 143f4ef2ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 33 deletions

View file

@ -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 <text>`. 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)

View file

@ -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",