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

Added confirmation for usercard actions #2629

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unversioned

- Minor: Added confirmation when unfollowing/following or unblocking/blocking a user in the usercard (#2629)

## 2.3.0

- Major: Added clip creation support. You can create clips with `/clip` command, `Alt+X` keybind or `Create a clip` option in split header's context menu. This requires a new authentication scope so re-authentication will be required to use it. (#2271, #2377, #2528)
Expand Down
1 change: 1 addition & 0 deletions resources/contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nuuls | https://github.com/nuuls | | Contributor
Chronophylos | https://github.com/Chronophylos | | Contributor
Ckath | https://github.com/Ckath | | Contributor
matijakevic | https://github.com/matijakevic | | Contributor
Auro | https://github.com/mrauro | | Contributor
nforro | https://github.com/nforro | | Contributor
vanolpfan | https://github.com/vanolpfan | | Contributor
23rd | https://github.com/23rd | | Contributor
Expand Down
123 changes: 76 additions & 47 deletions src/widgets/dialogs/UserInfoPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,19 @@ void UserInfoPopup::installEvents()
switch (newState)
{
case Qt::CheckState::Unchecked: {
this->ui_.follow->setEnabled(false);
getHelix()->unfollowUser(currentUser->getUserId(),
this->userId_,
reenableFollowCheckbox, [] {
//
});
auto box = new QMessageBox(
QMessageBox::Information, "Chatterino 2",
"Unfollow user?", QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose);
if (box->exec() == QMessageBox::Yes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a QT guru but I suspect blocking the UI with this call is your cause. Try using QObject::connect to connect to the clicked signal. See here for an example.

QT devs correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to all 4 usages of exec()

{
this->ui_.follow->setEnabled(false);
getHelix()->unfollowUser(currentUser->getUserId(),
this->userId_,
reenableFollowCheckbox, [] {
//
});
}
}
break;

Expand All @@ -441,12 +448,19 @@ void UserInfoPopup::installEvents()
break;

case Qt::CheckState::Checked: {
this->ui_.follow->setEnabled(false);
getHelix()->followUser(currentUser->getUserId(),
this->userId_,
reenableFollowCheckbox, [] {
//
});
auto box = new QMessageBox(
QMessageBox::Information, "Chatterino 2",
"Follow user?", QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose);
if (box->exec() == QMessageBox::Yes)
{
this->ui_.follow->setEnabled(false);
getHelix()->followUser(currentUser->getUserId(),
this->userId_,
reenableFollowCheckbox, [] {
//
});
}
}
break;
}
Expand All @@ -473,23 +487,31 @@ void UserInfoPopup::installEvents()
switch (newState)
{
case Qt::CheckState::Unchecked: {
this->ui_.block->setEnabled(false);

getApp()->accounts->twitch.getCurrent()->unblockUser(
this->userId_,
[this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage(
QString("You successfully unblocked user %1")
.arg(this->userName_)));
reenableBlockCheckbox();
},
[this, reenableBlockCheckbox] {
this->channel_->addMessage(
makeSystemMessage(QString(
"User %1 couldn't be unblocked, an unknown "
"error occurred!")));
reenableBlockCheckbox();
});
auto box = new QMessageBox(
QMessageBox::Information, "Chatterino 2",
"Unblock user?", QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose);
if (box->exec() == QMessageBox::Yes)
{
this->ui_.block->setEnabled(false);

getApp()->accounts->twitch.getCurrent()->unblockUser(
this->userId_,
[this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage(
QString(
"You successfully unblocked user %1")
.arg(this->userName_)));
reenableBlockCheckbox();
},
[this, reenableBlockCheckbox] {
this->channel_->addMessage(makeSystemMessage(
QString("User %1 couldn't be unblocked, an "
"unknown "
"error occurred!")));
reenableBlockCheckbox();
});
}
}
break;

Expand All @@ -499,24 +521,31 @@ void UserInfoPopup::installEvents()
break;

case Qt::CheckState::Checked: {
this->ui_.block->setEnabled(false);

getApp()->accounts->twitch.getCurrent()->blockUser(
this->userId_,
[this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage(
QString("You successfully blocked user %1")
.arg(this->userName_)));
reenableBlockCheckbox();
},
[this, reenableBlockCheckbox] {
this->channel_->addMessage(makeSystemMessage(
QString(
"User %1 couldn't be blocked, an unknown "
"error occurred!")
.arg(this->userName_)));
reenableBlockCheckbox();
});
auto box = new QMessageBox(
QMessageBox::Information, "Chatterino 2", "Block user?",
QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose);
if (box->exec() == QMessageBox::Yes)
{
this->ui_.block->setEnabled(false);

getApp()->accounts->twitch.getCurrent()->blockUser(
this->userId_,
[this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage(
QString("You successfully blocked user %1")
.arg(this->userName_)));
reenableBlockCheckbox();
},
[this, reenableBlockCheckbox] {
this->channel_->addMessage(makeSystemMessage(
QString("User %1 couldn't be blocked, an "
"unknown "
"error occurred!")
.arg(this->userName_)));
reenableBlockCheckbox();
});
}
}
break;
}
Expand Down