Converted ttl and mute boxes to confirm boxes.

This commit is contained in:
23rd 2022-04-15 12:55:16 +03:00
parent 0427f90649
commit 07a022bfb6
2 changed files with 27 additions and 16 deletions

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "ui/boxes/choose_time.h"
#include "ui/boxes/confirm_box.h"
#include "ui/boxes/time_picker_box.h"
#include "ui/effects/animation_value.h"
#include "ui/layers/generic_box.h"
@ -153,11 +154,14 @@ void MuteBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
? tr::lng_mute_menu_unmute()
: tr::lng_mute_menu_mute();
}) | rpl::flatten_latest();
const auto confirm = box->addButton(std::move(confirmText), [=] {
peer->owner().notifySettings().update(peer, state->lastSeconds);
box->getDelegate()->hideLayer();
Ui::ConfirmBox(box, {
.confirmed = [=] {
peer->owner().notifySettings().update(peer, state->lastSeconds);
box->getDelegate()->hideLayer();
},
.confirmText = std::move(confirmText),
.cancelText = tr::lng_cancel(),
});
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}
void PickMuteBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
@ -190,18 +194,20 @@ void PickMuteBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
const auto pickerCallback = TimePickerBox(box, seconds, phrases, 0);
box->addButton(tr::lng_mute_menu_mute(), [=] {
const auto muteFor = pickerCallback();
peer->owner().notifySettings().update(peer, muteFor);
peer->session().settings().addMutePeriod(muteFor);
peer->session().saveSettings();
box->closeBox();
Ui::ConfirmBox(box, {
.confirmed = [=] {
const auto muteFor = pickerCallback();
peer->owner().notifySettings().update(peer, muteFor);
peer->session().settings().addMutePeriod(muteFor);
peer->session().saveSettings();
box->closeBox();
},
.confirmText = tr::lng_mute_menu_mute(),
.cancelText = tr::lng_cancel(),
});
box->setTitle(tr::lng_mute_box_title());
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
const auto top = box->addTopButton(st::infoTopBarMenu);
top->setClickedCallback([=] {
if (state->menu) {

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "menu/menu_ttl.h"
#include "lang/lang_keys.h"
#include "ui/boxes/confirm_box.h"
#include "ui/boxes/time_picker_box.h"
#include "ui/layers/generic_box.h"
#include "ui/text/format_values.h"
@ -186,17 +187,21 @@ void TTLBox(not_null<Ui::GenericBox*> box, Args args) {
const auto pickerTtl = TimePickerBox(box, ttls, phrases, args.startTtl);
box->addButton(tr::lng_settings_save(), [=] {
args.callback(pickerTtl());
box->getDelegate()->hideLayer();
Ui::ConfirmBox(box, {
.confirmed = [=] {
args.callback(pickerTtl());
box->getDelegate()->hideLayer();
},
.confirmText = tr::lng_settings_save(),
.cancelText = tr::lng_cancel(),
});
box->setTitle(tr::lng_manage_messages_ttl_title());
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
if (args.startTtl) {
box->addLeftButton(tr::lng_manage_messages_ttl_disable(), [=] {
args.callback(0);
box->getDelegate()->hideLayer();
});
}
}