Add support for opening usercards by ID (#4934)
Co-authored-by: nerix <nerixdev@outlook.de>
This commit is contained in:
@@ -701,7 +701,18 @@ void UserInfoPopup::setData(const QString &name,
|
||||
const ChannelPtr &contextChannel,
|
||||
const ChannelPtr &openingChannel)
|
||||
{
|
||||
this->userName_ = name;
|
||||
const QStringView idPrefix = u"id:";
|
||||
bool isId = name.startsWith(idPrefix);
|
||||
if (isId)
|
||||
{
|
||||
this->userId_ = name.mid(idPrefix.size());
|
||||
this->userName_ = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
this->userName_ = name;
|
||||
}
|
||||
|
||||
this->channel_ = openingChannel;
|
||||
|
||||
if (!contextChannel->isEmpty())
|
||||
@@ -723,7 +734,11 @@ void UserInfoPopup::setData(const QString &name,
|
||||
|
||||
this->userStateChanged_.invoke();
|
||||
|
||||
this->updateLatestMessages();
|
||||
if (!isId)
|
||||
{
|
||||
this->updateLatestMessages();
|
||||
}
|
||||
// If we're opening by ID, this will be called as soon as we get the information from twitch
|
||||
}
|
||||
|
||||
void UserInfoPopup::updateLatestMessages()
|
||||
@@ -792,6 +807,14 @@ void UserInfoPopup::updateUserData()
|
||||
return;
|
||||
}
|
||||
|
||||
// Correct for when being opened with ID
|
||||
if (this->userName_.isEmpty())
|
||||
{
|
||||
this->userName_ = user.login;
|
||||
// Ensure recent messages are shown
|
||||
this->updateLatestMessages();
|
||||
}
|
||||
|
||||
this->userId_ = user.id;
|
||||
this->avatarUrl_ = user.profileImageUrl;
|
||||
|
||||
@@ -909,8 +932,16 @@ void UserInfoPopup::updateUserData()
|
||||
[] {});
|
||||
};
|
||||
|
||||
getHelix()->getUserByName(this->userName_, onUserFetched,
|
||||
onUserFetchFailed);
|
||||
if (!this->userId_.isEmpty())
|
||||
{
|
||||
getHelix()->getUserById(this->userId_, onUserFetched,
|
||||
onUserFetchFailed);
|
||||
}
|
||||
else
|
||||
{
|
||||
getHelix()->getUserByName(this->userName_, onUserFetched,
|
||||
onUserFetchFailed);
|
||||
}
|
||||
|
||||
this->ui_.block->setEnabled(false);
|
||||
this->ui_.ignoreHighlights->setEnabled(false);
|
||||
|
||||
Reference in New Issue
Block a user