Add a confirmation when blocking a user.

This commit is contained in:
John Preston 2019-07-15 15:47:40 +02:00
parent 2351865961
commit ffba901620
6 changed files with 22 additions and 14 deletions

View File

@ -304,7 +304,8 @@ void ContactStatus::setupAddHandler(not_null<UserData*> user) {
void ContactStatus::setupBlockHandler(not_null<UserData*> user) {
_bar.entity()->blockClicks(
) | rpl::start_with_next([=] {
_window->show(Box(Window::PeerMenuBlockUserBox, _window, user));
_window->show(
Box(Window::PeerMenuBlockUserBox, _window, user, true));
}, _bar.lifetime());
}

View File

@ -619,8 +619,11 @@ void ActionsFiller::addBlockAction(not_null<UserData*> user) {
if (user->botInfo) {
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
}
} else {
} else if (user->isBot()) {
user->session().api().blockUser(user);
} else {
window->show(
Box(Window::PeerMenuBlockUserBox, window, user, false));
}
};
AddActionButton(

View File

@ -154,7 +154,6 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
fillSentCodeData(d);
getData()->phone = _sentPhone;
getData()->phoneHash = qba(d.vphone_code_hash());
getData()->phoneIsRegistered = d.is_phone_registered();
const auto next = d.vnext_type();
if (next && next->type() == mtpc_auth_codeTypeCall) {
getData()->callStatus = Widget::Data::CallStatus::Waiting;

View File

@ -59,7 +59,6 @@ public:
QString country;
QString phone;
QByteArray phoneHash;
bool phoneIsRegistered = false;
enum class CallStatus {
Waiting,

View File

@ -348,7 +348,7 @@ void Filler::addBlockUser(not_null<UserData*> user) {
} else if (user->isBot()) {
user->session().api().blockUser(user);
} else {
window->show(Box(PeerMenuBlockUserBox, window, user));
window->show(Box(PeerMenuBlockUserBox, window, user, false));
}
});
@ -710,7 +710,8 @@ void PeerMenuCreatePoll(not_null<PeerData*> peer) {
void PeerMenuBlockUserBox(
not_null<GenericBox*> box,
not_null<Window::Controller*> window,
not_null<UserData*> user) {
not_null<UserData*> user,
bool suggestClearChat) {
using Flag = MTPDpeerSettings::Flag;
const auto settings = user->settings().value_or(Flag(0));
@ -738,13 +739,17 @@ void PeerMenuBlockUserBox(
box->addSkip(st::boxMediumSkip);
}
const auto clear = box->addRow(object_ptr<Ui::Checkbox>(
box,
tr::lng_blocked_list_confirm_clear(tr::now),
true,
st::defaultBoxCheckbox));
const auto clear = suggestClearChat
? box->addRow(object_ptr<Ui::Checkbox>(
box,
tr::lng_blocked_list_confirm_clear(tr::now),
true,
st::defaultBoxCheckbox))
: nullptr;
box->addSkip(st::boxLittleSkip);
if (report || clear) {
box->addSkip(st::boxLittleSkip);
}
box->setTitle(tr::lng_blocked_list_confirm_title(
lt_name,
@ -752,7 +757,7 @@ void PeerMenuBlockUserBox(
box->addButton(tr::lng_blocked_list_confirm_ok(), [=] {
const auto reportChecked = report && report->checked();
const auto clearChecked = clear->checked();
const auto clearChecked = clear && clear->checked();
box->closeBox();

View File

@ -56,7 +56,8 @@ void PeerMenuCreatePoll(not_null<PeerData*> peer);
void PeerMenuBlockUserBox(
not_null<GenericBox*> box,
not_null<Window::Controller*> window,
not_null<UserData*> user);
not_null<UserData*> user,
bool suggestClearChat);
void PeerMenuUnblockUserWithBotRestart(not_null<UserData*> user);
void ToggleHistoryArchived(not_null<History*> history, bool archived);