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_link.h
boxes/peers/edit_peer_invite_links.cpp boxes/peers/edit_peer_invite_links.cpp
boxes/peers/edit_peer_invite_links.h 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.cpp
boxes/peers/edit_peer_permissions_box.h boxes/peers/edit_peer_permissions_box.h
boxes/peers/edit_peer_reactions.cpp 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 "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 "lang/lang_keys.h"
#include "ui/layers/generic_box.h" #include "ui/layers/generic_box.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
@ -19,13 +16,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
void EditPeerHistoryVisibilityBox( void EditPeerHistoryVisibilityBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<PeerData*> peer, bool isLegacy,
Fn<void(HistoryVisibility)> savedCallback, Fn<void(HistoryVisibility)> savedCallback,
HistoryVisibility historyVisibilitySavedValue) { HistoryVisibility historyVisibilitySavedValue) {
const auto historyVisibility = std::make_shared< const auto historyVisibility = std::make_shared<
Ui::RadioenumGroup<HistoryVisibility> Ui::RadioenumGroup<HistoryVisibility>
>(historyVisibilitySavedValue); >(historyVisibilitySavedValue);
peer->updateFull();
box->setTitle(tr::lng_manage_history_visibility_title()); box->setTitle(tr::lng_manage_history_visibility_title());
box->addButton(tr::lng_settings_save(), [=] { box->addButton(tr::lng_settings_save(), [=] {
@ -34,18 +30,6 @@ void EditPeerHistoryVisibilityBox(
}); });
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); 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->addSkip(st::editPeerHistoryVisibilityTopSkip);
box->addRow(object_ptr<Ui::Radioenum<HistoryVisibility>>( box->addRow(object_ptr<Ui::Radioenum<HistoryVisibility>>(
box, box,
@ -70,7 +54,7 @@ void EditPeerHistoryVisibilityBox(
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
(peer->isChat() (isLegacy
? tr::lng_manage_history_visibility_hidden_legacy ? tr::lng_manage_history_visibility_hidden_legacy
: tr::lng_manage_history_visibility_hidden_about)(), : tr::lng_manage_history_visibility_hidden_about)(),
st::editPeerPrivacyLabel), st::editPeerPrivacyLabel),

View File

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

View File

@ -837,9 +837,21 @@ void Controller::fillHistoryVisibilityButton() {
_historyVisibilitySavedValue = checked; _historyVisibilitySavedValue = checked;
}); });
const auto buttonCallback = [=] { 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( _navigation->parentController()->show(Box(
EditPeerHistoryVisibilityBox, EditPeerHistoryVisibilityBox,
_peer, _peer->isChat(),
boxCallback, boxCallback,
*_historyVisibilitySavedValue)); *_historyVisibilitySavedValue));
}; };

View File

@ -48,6 +48,9 @@ nice_target_sources(td_ui ${src_loc}
PRIVATE PRIVATE
${style_files} ${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.cpp
calls/group/ui/calls_group_recording_box.h calls/group/ui/calls_group_recording_box.h
calls/group/ui/calls_group_scheduled_labels.cpp calls/group/ui/calls_group_scheduled_labels.cpp