mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add support for opening usercards by ID (#4934)
Co-authored-by: nerix <nerixdev@outlook.de>
This commit is contained in:
parent
5209e47df1
commit
f943f70634
3 changed files with 38 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
|||
- Minor: The account switcher is now styled to match your theme. (#4817)
|
||||
- Minor: Add an invisible resize handle to the bottom of frameless user info popups and reply thread popups. (#4795)
|
||||
- Minor: The installer now checks for the VC Runtime version and shows more info when it's outdated. (#4847)
|
||||
- Minor: The `/usercard` command now accepts user ids. (#4934)
|
||||
- Minor: Add menu actions to reply directly to a message or the original thread root. (#4923)
|
||||
- Minor: The `/reply` command now replies to the latest message of the user. (#4919)
|
||||
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
|
||||
|
|
|
@ -856,7 +856,8 @@ void CommandController::initialize(Settings &, Paths &paths)
|
|||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /usercard <user> [channel]"));
|
||||
makeSystemMessage("Usage: /usercard <username> [channel] or "
|
||||
"/usercard id:<id> [channel]"));
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -701,7 +701,18 @@ void UserInfoPopup::setData(const QString &name,
|
|||
const ChannelPtr &contextChannel,
|
||||
const ChannelPtr &openingChannel)
|
||||
{
|
||||
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();
|
||||
|
||||
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()
|
|||
[] {});
|
||||
};
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue