Fix crash that could occur if closing the usercard quickly after blocking (#4711)
* Specifically, this adds a caller to the network request, which makes the success or failure callback not fire. This has the unintended consequence of the block list not reloading if the usercard is closed, but it's not a big concern. * Add unrelated `-DUSE_ALTERNATE_LINKER` cmake option From https://github.com/heavyai/heavydb/blob/0517d99b467806f6af7b4c969e351368a667497d/CMakeLists.txt#L87-L103
This commit is contained in:
@@ -650,7 +650,7 @@ void CommandController::initialize(Settings &, Paths &paths)
|
||||
target,
|
||||
[currentUser, channel, target](const HelixUser &targetUser) {
|
||||
getApp()->accounts->twitch.getCurrent()->blockUser(
|
||||
targetUser.id,
|
||||
targetUser.id, nullptr,
|
||||
[channel, target, targetUser] {
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("You successfully blocked user %1")
|
||||
@@ -703,7 +703,7 @@ void CommandController::initialize(Settings &, Paths &paths)
|
||||
target,
|
||||
[currentUser, channel, target](const auto &targetUser) {
|
||||
getApp()->accounts->twitch.getCurrent()->unblockUser(
|
||||
targetUser.id,
|
||||
targetUser.id, nullptr,
|
||||
[channel, target, targetUser] {
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("You successfully unblocked user %1")
|
||||
|
||||
@@ -121,11 +121,12 @@ void TwitchAccount::loadBlocks()
|
||||
});
|
||||
}
|
||||
|
||||
void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess,
|
||||
void TwitchAccount::blockUser(QString userId, const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure)
|
||||
{
|
||||
getHelix()->blockUser(
|
||||
userId,
|
||||
userId, caller,
|
||||
[this, userId, onSuccess] {
|
||||
TwitchUser blockedUser;
|
||||
blockedUser.id = userId;
|
||||
@@ -141,11 +142,12 @@ void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess,
|
||||
std::move(onFailure));
|
||||
}
|
||||
|
||||
void TwitchAccount::unblockUser(QString userId, std::function<void()> onSuccess,
|
||||
void TwitchAccount::unblockUser(QString userId, const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure)
|
||||
{
|
||||
getHelix()->unblockUser(
|
||||
userId,
|
||||
userId, caller,
|
||||
[this, userId, onSuccess] {
|
||||
TwitchUser ignoredUser;
|
||||
ignoredUser.id = userId;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QElapsedTimer>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
@@ -71,9 +72,11 @@ public:
|
||||
bool isAnon() const;
|
||||
|
||||
void loadBlocks();
|
||||
void blockUser(QString userId, std::function<void()> onSuccess,
|
||||
void blockUser(QString userId, const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure);
|
||||
void unblockUser(QString userId, std::function<void()> onSuccess,
|
||||
void unblockUser(QString userId, const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure);
|
||||
|
||||
SharedAccessGuard<const std::set<QString>> accessBlockedUserIds() const;
|
||||
|
||||
@@ -541,7 +541,7 @@ void Helix::loadBlocks(QString userId,
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::blockUser(QString targetUserId,
|
||||
void Helix::blockUser(QString targetUserId, const QObject *caller,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
@@ -549,6 +549,7 @@ void Helix::blockUser(QString targetUserId,
|
||||
urlQuery.addQueryItem("target_user_id", targetUserId);
|
||||
|
||||
this->makePut("users/blocks", urlQuery)
|
||||
.caller(caller)
|
||||
.onSuccess([successCallback](auto /*result*/) -> Outcome {
|
||||
successCallback();
|
||||
return Success;
|
||||
@@ -560,7 +561,7 @@ void Helix::blockUser(QString targetUserId,
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::unblockUser(QString targetUserId,
|
||||
void Helix::unblockUser(QString targetUserId, const QObject *caller,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
@@ -568,6 +569,7 @@ void Helix::unblockUser(QString targetUserId,
|
||||
urlQuery.addQueryItem("target_user_id", targetUserId);
|
||||
|
||||
this->makeDelete("users/blocks", urlQuery)
|
||||
.caller(caller)
|
||||
.onSuccess([successCallback](auto /*result*/) -> Outcome {
|
||||
successCallback();
|
||||
return Success;
|
||||
|
||||
@@ -805,12 +805,12 @@ public:
|
||||
HelixFailureCallback failureCallback) = 0;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#block-user
|
||||
virtual void blockUser(QString targetUserId,
|
||||
virtual void blockUser(QString targetUserId, const QObject *caller,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback) = 0;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#unblock-user
|
||||
virtual void unblockUser(QString targetUserId,
|
||||
virtual void unblockUser(QString targetUserId, const QObject *caller,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback) = 0;
|
||||
|
||||
@@ -1118,11 +1118,12 @@ public:
|
||||
HelixFailureCallback failureCallback) final;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#block-user
|
||||
void blockUser(QString targetUserId, std::function<void()> successCallback,
|
||||
void blockUser(QString targetUserId, const QObject *caller,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback) final;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#unblock-user
|
||||
void unblockUser(QString targetUserId,
|
||||
void unblockUser(QString targetUserId, const QObject *caller,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback) final;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QPointer>
|
||||
|
||||
const QString TEXT_FOLLOWERS("Followers: %1");
|
||||
const QString TEXT_CREATED("Created: %1");
|
||||
@@ -593,7 +594,7 @@ void UserInfoPopup::installEvents()
|
||||
this->ui_.block->setEnabled(false);
|
||||
|
||||
getApp()->accounts->twitch.getCurrent()->unblockUser(
|
||||
this->userId_,
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addMessage(makeSystemMessage(
|
||||
QString("You successfully unblocked user %1")
|
||||
@@ -620,7 +621,7 @@ void UserInfoPopup::installEvents()
|
||||
this->ui_.block->setEnabled(false);
|
||||
|
||||
getApp()->accounts->twitch.getCurrent()->blockUser(
|
||||
this->userId_,
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addMessage(makeSystemMessage(
|
||||
QString("You successfully blocked user %1")
|
||||
|
||||
Reference in New Issue
Block a user