Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for opening usercards by ID #4934

Merged
merged 6 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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)
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/commands/CommandController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,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> [channel]"));
return "";
}

Expand Down
21 changes: 19 additions & 2 deletions src/widgets/dialogs/UserInfoPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,14 @@ void UserInfoPopup::updateUserData()
return;
}

// Correct for when being opened with "id:"
if (this->userName_ != user.login)
{
this->userName_ = user.login;

// Ensure recent messages are shown
this->updateLatestMessages();
Mm2PL marked this conversation as resolved.
Show resolved Hide resolved
}
this->userId_ = user.id;
this->avatarUrl_ = user.profileImageUrl;

Expand Down Expand Up @@ -909,8 +917,17 @@ void UserInfoPopup::updateUserData()
[] {});
};

getHelix()->getUserByName(this->userName_, onUserFetched,
onUserFetchFailed);
const QString idPrefix = "#";
if (this->userName_.startsWith(idPrefix))
{
getHelix()->getUserById(this->userName_.mid(idPrefix.size()),
onUserFetched, onUserFetchFailed);
}
else
{
getHelix()->getUserByName(this->userName_, onUserFetched,
onUserFetchFailed);
}

this->ui_.block->setEnabled(false);
this->ui_.ignoreHighlights->setEnabled(false);
Expand Down
Loading