Moved EditPeerHistoryVisibilityBox to td_ui.

This commit is contained in:
23rd 2022-04-24 15:28:00 +03:00 committed by John Preston
parent 66e6bf8217
commit a994c9f017
5 changed files with 19 additions and 22 deletions

View file

@ -188,8 +188,6 @@ PRIVATE
boxes/peers/edit_peer_invite_link.h
boxes/peers/edit_peer_invite_links.cpp
boxes/peers/edit_peer_invite_links.h
boxes/peers/edit_peer_history_visibility_box.cpp
boxes/peers/edit_peer_history_visibility_box.h
boxes/peers/edit_peer_permissions_box.cpp
boxes/peers/edit_peer_permissions_box.h
boxes/peers/edit_peer_reactions.cpp

View file

@ -7,9 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/peers/edit_peer_history_visibility_box.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_peer.h"
#include "lang/lang_keys.h"
#include "ui/layers/generic_box.h"
#include "ui/widgets/checkbox.h"
@ -19,13 +16,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
void EditPeerHistoryVisibilityBox(
not_null<Ui::GenericBox*> box,
not_null<PeerData*> peer,
bool isLegacy,
Fn<void(HistoryVisibility)> savedCallback,
HistoryVisibility historyVisibilitySavedValue) {
const auto historyVisibility = std::make_shared<
Ui::RadioenumGroup<HistoryVisibility>
>(historyVisibilitySavedValue);
peer->updateFull();
box->setTitle(tr::lng_manage_history_visibility_title());
box->addButton(tr::lng_settings_save(), [=] {
@ -34,18 +30,6 @@ void EditPeerHistoryVisibilityBox(
});
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
const auto canEdit = [&] {
if (const auto chat = peer->asChat()) {
return chat->canEditPreHistoryHidden();
} else if (const auto channel = peer->asChannel()) {
return channel->canEditPreHistoryHidden();
}
Unexpected("User in HistoryVisibilityEdit.");
}();
if (!canEdit) {
return;
}
box->addSkip(st::editPeerHistoryVisibilityTopSkip);
box->addRow(object_ptr<Ui::Radioenum<HistoryVisibility>>(
box,
@ -70,7 +54,7 @@ void EditPeerHistoryVisibilityBox(
box->addRow(
object_ptr<Ui::FlatLabel>(
box,
(peer->isChat()
(isLegacy
? tr::lng_manage_history_visibility_hidden_legacy
: tr::lng_manage_history_visibility_hidden_about)(),
st::editPeerPrivacyLabel),

View file

@ -18,6 +18,6 @@ enum class HistoryVisibility {
void EditPeerHistoryVisibilityBox(
not_null<Ui::GenericBox*> box,
not_null<PeerData*> peer,
bool isLegacy,
Fn<void(HistoryVisibility)> savedCallback,
HistoryVisibility historyVisibilitySavedValue);

View file

@ -837,9 +837,21 @@ void Controller::fillHistoryVisibilityButton() {
_historyVisibilitySavedValue = checked;
});
const auto buttonCallback = [=] {
_peer->updateFull();
const auto canEdit = [&] {
if (const auto chat = _peer->asChat()) {
return chat->canEditPreHistoryHidden();
} else if (const auto channel = _peer->asChannel()) {
return channel->canEditPreHistoryHidden();
}
Unexpected("User in HistoryVisibilityEdit.");
}();
if (!canEdit) {
return;
}
_navigation->parentController()->show(Box(
EditPeerHistoryVisibilityBox,
_peer,
_peer->isChat(),
boxCallback,
*_historyVisibilitySavedValue));
};

View file

@ -48,6 +48,9 @@ nice_target_sources(td_ui ${src_loc}
PRIVATE
${style_files}
boxes/peers/edit_peer_history_visibility_box.cpp
boxes/peers/edit_peer_history_visibility_box.h
calls/group/ui/calls_group_recording_box.cpp
calls/group/ui/calls_group_recording_box.h
calls/group/ui/calls_group_scheduled_labels.cpp