Make the "user info popup" crash less likely (hack v2)
This commit is contained in:
@@ -379,7 +379,12 @@ void UserInfoPopup::updateUserData()
|
|||||||
{
|
{
|
||||||
std::weak_ptr<bool> hack = this->hack_;
|
std::weak_ptr<bool> hack = this->hack_;
|
||||||
|
|
||||||
const auto onUserFetchFailed = [this] {
|
const auto onUserFetchFailed = [this, hack] {
|
||||||
|
if (!hack.lock())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// this can occur when the account doesn't exist.
|
// this can occur when the account doesn't exist.
|
||||||
this->ui_.followerCountLabel->setText(
|
this->ui_.followerCountLabel->setText(
|
||||||
TEXT_FOLLOWERS.arg(TEXT_UNAVAILABLE));
|
TEXT_FOLLOWERS.arg(TEXT_UNAVAILABLE));
|
||||||
@@ -394,6 +399,11 @@ void UserInfoPopup::updateUserData()
|
|||||||
QString(TEXT_UNAVAILABLE));
|
QString(TEXT_UNAVAILABLE));
|
||||||
};
|
};
|
||||||
const auto onUserFetched = [this, hack](const auto &user) {
|
const auto onUserFetched = [this, hack](const auto &user) {
|
||||||
|
if (!hack.lock())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||||
|
|
||||||
this->userId_ = user.id;
|
this->userId_ = user.id;
|
||||||
@@ -404,7 +414,11 @@ void UserInfoPopup::updateUserData()
|
|||||||
this->ui_.viewCountLabel->setText(TEXT_VIEWS.arg(user.viewCount));
|
this->ui_.viewCountLabel->setText(TEXT_VIEWS.arg(user.viewCount));
|
||||||
getKraken()->getUser(
|
getKraken()->getUser(
|
||||||
user.id,
|
user.id,
|
||||||
[this](const auto &user) {
|
[this, hack](const auto &user) {
|
||||||
|
if (!hack.lock())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
this->ui_.createdDateLabel->setText(
|
this->ui_.createdDateLabel->setText(
|
||||||
TEXT_CREATED.arg(user.createdAt.section("T", 0, 0)));
|
TEXT_CREATED.arg(user.createdAt.section("T", 0, 0)));
|
||||||
},
|
},
|
||||||
@@ -415,7 +429,11 @@ void UserInfoPopup::updateUserData()
|
|||||||
|
|
||||||
getHelix()->getUserFollowers(
|
getHelix()->getUserFollowers(
|
||||||
user.id,
|
user.id,
|
||||||
[this](const auto &followers) {
|
[this, hack](const auto &followers) {
|
||||||
|
if (!hack.lock())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
this->ui_.followerCountLabel->setText(
|
this->ui_.followerCountLabel->setText(
|
||||||
TEXT_FOLLOWERS.arg(followers.total));
|
TEXT_FOLLOWERS.arg(followers.total));
|
||||||
},
|
},
|
||||||
@@ -425,14 +443,14 @@ void UserInfoPopup::updateUserData()
|
|||||||
|
|
||||||
// get follow state
|
// get follow state
|
||||||
currentUser->checkFollow(user.id, [this, hack](auto result) {
|
currentUser->checkFollow(user.id, [this, hack](auto result) {
|
||||||
if (hack.lock())
|
if (!hack.lock())
|
||||||
{
|
{
|
||||||
if (result != FollowResult_Failed)
|
return;
|
||||||
{
|
}
|
||||||
this->ui_.follow->setEnabled(true);
|
if (result != FollowResult_Failed)
|
||||||
this->ui_.follow->setChecked(result ==
|
{
|
||||||
FollowResult_Following);
|
this->ui_.follow->setEnabled(true);
|
||||||
}
|
this->ui_.follow->setChecked(result == FollowResult_Following);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user