some concurrency additions (#2698)
This commit is contained in:
@@ -101,14 +101,17 @@ void TwitchAccount::loadBlocks()
|
||||
getHelix()->loadBlocks(
|
||||
getApp()->accounts->twitch.getCurrent()->userId_,
|
||||
[this](std::vector<HelixBlock> blocks) {
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
this->ignores_.clear();
|
||||
auto ignores = this->ignores_.access();
|
||||
auto userIds = this->ignoresUserIds_.access();
|
||||
ignores->clear();
|
||||
userIds->clear();
|
||||
|
||||
for (const HelixBlock &block : blocks)
|
||||
{
|
||||
TwitchUser blockedUser;
|
||||
blockedUser.fromHelixBlock(block);
|
||||
this->ignores_.insert(blockedUser);
|
||||
ignores->insert(blockedUser);
|
||||
userIds->insert(blockedUser.id);
|
||||
}
|
||||
},
|
||||
[] {
|
||||
@@ -125,9 +128,11 @@ void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess,
|
||||
TwitchUser blockedUser;
|
||||
blockedUser.id = userId;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
auto ignores = this->ignores_.access();
|
||||
auto userIds = this->ignoresUserIds_.access();
|
||||
|
||||
this->ignores_.insert(blockedUser);
|
||||
ignores->insert(blockedUser);
|
||||
userIds->insert(blockedUser.id);
|
||||
}
|
||||
onSuccess();
|
||||
},
|
||||
@@ -143,9 +148,11 @@ void TwitchAccount::unblockUser(QString userId, std::function<void()> onSuccess,
|
||||
TwitchUser ignoredUser;
|
||||
ignoredUser.id = userId;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
auto ignores = this->ignores_.access();
|
||||
auto userIds = this->ignoresUserIds_.access();
|
||||
|
||||
this->ignores_.erase(ignoredUser);
|
||||
ignores->erase(ignoredUser);
|
||||
userIds->erase(ignoredUser.id);
|
||||
}
|
||||
onSuccess();
|
||||
},
|
||||
@@ -169,11 +176,14 @@ void TwitchAccount::checkFollow(const QString targetUserID,
|
||||
[] {});
|
||||
}
|
||||
|
||||
std::set<TwitchUser> TwitchAccount::getBlocks() const
|
||||
AccessGuard<const std::set<TwitchUser>> TwitchAccount::accessBlocks() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
return this->ignores_.accessConst();
|
||||
}
|
||||
|
||||
return this->ignores_;
|
||||
AccessGuard<const std::set<QString>> TwitchAccount::accessBlockedUserIds() const
|
||||
{
|
||||
return this->ignoresUserIds_.accessConst();
|
||||
}
|
||||
|
||||
void TwitchAccount::loadEmotes()
|
||||
|
||||
Reference in New Issue
Block a user