mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactor: always warn about blocking
This commit is contained in:
parent
c0cef9ccd7
commit
0f89162fe9
|
@ -651,8 +651,26 @@ void UserInfoPopup::installEvents()
|
|||
if (newState == Qt::Checked)
|
||||
{
|
||||
this->ui_.block->setEnabled(false);
|
||||
auto blockThisUser = [this, reenableBlockCheckbox,
|
||||
currentUser] {
|
||||
|
||||
bool wasPinned = this->ensurePinned();
|
||||
auto btn = QMessageBox::warning(
|
||||
this, u"Blocking " % this->userName_,
|
||||
u"Blocking %1 can cause unintended side-effects like unfollowing.\n\n"_s
|
||||
"Are you sure you want to block %1?".arg(this->userName_),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel);
|
||||
if (wasPinned)
|
||||
{
|
||||
this->togglePinned();
|
||||
}
|
||||
if (btn != QMessageBox::Yes)
|
||||
{
|
||||
reenableBlockCheckbox();
|
||||
QSignalBlocker blocker(this->ui_.block);
|
||||
this->ui_.block->setCheckState(Qt::Unchecked);
|
||||
return;
|
||||
}
|
||||
|
||||
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
|
@ -668,63 +686,6 @@ void UserInfoPopup::installEvents()
|
|||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
});
|
||||
};
|
||||
getHelix()->getFollowedChannel(
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||
this->userId_, this,
|
||||
[this, blockThisUser,
|
||||
reenableBlockCheckbox](const auto &followStatus) {
|
||||
if (!followStatus)
|
||||
{
|
||||
blockThisUser();
|
||||
return;
|
||||
}
|
||||
bool wasPinned = this->ensurePinned();
|
||||
auto btn = QMessageBox::warning(
|
||||
this, u"Blocking " % this->userName_,
|
||||
u"You're following %1 since %2.\n"_s
|
||||
"Blocking %1 will unfollow them!\n\n"
|
||||
"Are you sure you want to unfollow and block %1?"
|
||||
.arg(this->userName_,
|
||||
followStatus->followedAt.toString()),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel);
|
||||
if (wasPinned)
|
||||
{
|
||||
this->togglePinned();
|
||||
}
|
||||
if (btn != QMessageBox::Yes)
|
||||
{
|
||||
reenableBlockCheckbox();
|
||||
return;
|
||||
}
|
||||
blockThisUser();
|
||||
},
|
||||
[this, blockThisUser,
|
||||
reenableBlockCheckbox](const auto &error) {
|
||||
bool wasPinned = this->ensurePinned();
|
||||
auto btn = QMessageBox::warning(
|
||||
this, u"Blocking " % this->userName_,
|
||||
u"Failed to get following status for %1 (error: %2).\n"_s
|
||||
"Blocking a followed channel will automatically "
|
||||
"unfollow them.\n\n"
|
||||
"Are you sure you want to block %1?".arg(
|
||||
this->userName_, error),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel);
|
||||
if (wasPinned)
|
||||
{
|
||||
this->togglePinned();
|
||||
}
|
||||
if (btn == QMessageBox::Yes)
|
||||
{
|
||||
blockThisUser();
|
||||
}
|
||||
else
|
||||
{
|
||||
reenableBlockCheckbox();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue