Adapt UI for gigagroups.

This commit is contained in:
John Preston 2021-02-12 19:07:41 +04:00
parent 56b15b26bb
commit 8188ab3033
7 changed files with 52 additions and 21 deletions

View File

@ -328,7 +328,7 @@ private:
object_ptr<Ui::RpWidget> createStickersEdit(); object_ptr<Ui::RpWidget> createStickersEdit();
bool canEditInformation() const; bool canEditInformation() const;
void refreshHistoryVisibility(anim::type animated = anim::type::normal); void refreshHistoryVisibility();
void showEditPeerTypeBox( void showEditPeerTypeBox(
std::optional<rpl::producer<QString>> error = {}); std::optional<rpl::producer<QString>> error = {});
void showEditLinkedChatBox(); void showEditLinkedChatBox();
@ -631,7 +631,7 @@ bool Controller::canEditInformation() const {
return false; return false;
} }
void Controller::refreshHistoryVisibility(anim::type animated) { void Controller::refreshHistoryVisibility() {
if (!_controls.historyVisibilityWrap) { if (!_controls.historyVisibilityWrap) {
return; return;
} }
@ -639,7 +639,7 @@ void Controller::refreshHistoryVisibility(anim::type animated) {
(_privacySavedValue != Privacy::HasUsername (_privacySavedValue != Privacy::HasUsername
&& !_channelHasLocationOriginalValue && !_channelHasLocationOriginalValue
&& (!_linkedChatSavedValue || !*_linkedChatSavedValue)), && (!_linkedChatSavedValue || !*_linkedChatSavedValue)),
animated); anim::type::instant);
} }
void Controller::showEditPeerTypeBox( void Controller::showEditPeerTypeBox(
@ -880,7 +880,7 @@ void Controller::fillHistoryVisibilityButton() {
updateHistoryVisibility->fire_copy(*_historyVisibilitySavedValue); updateHistoryVisibility->fire_copy(*_historyVisibilitySavedValue);
refreshHistoryVisibility(anim::type::instant); refreshHistoryVisibility();
} }
void Controller::fillSetMessagesTTLButton() { void Controller::fillSetMessagesTTLButton() {
@ -965,7 +965,7 @@ void Controller::fillManageSection() {
}(); }();
const auto canViewKicked = [&] { const auto canViewKicked = [&] {
return isChannel return isChannel
? (!channel->isMegagroup()) ? (channel->isBroadcast() || channel->isGigagroup())
: false; : false;
}(); }();
const auto hasRecentActions = [&] { const auto hasRecentActions = [&] {
@ -1015,7 +1015,7 @@ void Controller::fillManageSection() {
} }
if (canEditPreHistoryHidden if (canEditPreHistoryHidden
|| canEditSignatures || canEditSignatures
|| canEditInviteLinks //|| canEditInviteLinks
|| canViewOrEditLinkedChat || canViewOrEditLinkedChat
|| canEditUsername || canEditUsername
|| canSetMessagesTTL) { || canSetMessagesTTL) {
@ -1038,7 +1038,10 @@ void Controller::fillManageSection() {
[=] { ShowEditPermissions(_navigation, _peer); }, [=] { ShowEditPermissions(_navigation, _peer); },
st::infoIconPermissions); st::infoIconPermissions);
} }
if (canEditInviteLinks) { if (canEditInviteLinks
&& (canEditUsername
|| !_peer->isChannel()
|| !_peer->asChannel()->hasUsername())) {
auto count = Info::Profile::MigratedOrMeValue( auto count = Info::Profile::MigratedOrMeValue(
_peer _peer
) | rpl::map([=](not_null<PeerData*> peer) { ) | rpl::map([=](not_null<PeerData*> peer) {
@ -1053,8 +1056,13 @@ void Controller::fillManageSection() {
}) | rpl::flatten_latest( }) | rpl::flatten_latest(
) | rpl::start_spawning(_controls.buttonsLayout->lifetime()); ) | rpl::start_spawning(_controls.buttonsLayout->lifetime());
const auto wrap = _controls.buttonsLayout->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
_controls.buttonsLayout,
object_ptr<Ui::VerticalLayout>(
_controls.buttonsLayout)));
AddButtonWithCount( AddButtonWithCount(
_controls.buttonsLayout, wrap->entity(),
tr::lng_manage_peer_invite_links(), tr::lng_manage_peer_invite_links(),
rpl::duplicate(count) | ToPositiveNumberString(), rpl::duplicate(count) | ToPositiveNumberString(),
[=] { Ui::show( [=] { Ui::show(
@ -1062,6 +1070,16 @@ void Controller::fillManageSection() {
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}, },
st::infoIconInviteLinks); st::infoIconInviteLinks);
if (_privacySavedValue) {
_privacyTypeUpdates.events_starting_with_copy(
*_privacySavedValue
) | rpl::start_with_next([=](Privacy flag) {
wrap->toggle(
flag != Privacy::HasUsername,
anim::type::instant);
}, wrap->lifetime());
}
} }
if (canViewAdmins) { if (canViewAdmins) {
AddButtonWithCount( AddButtonWithCount(

View File

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/continuous_sliders.h" #include "ui/widgets/continuous_sliders.h"
#include "ui/widgets/box_content_divider.h" #include "ui/widgets/box_content_divider.h"
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "info/profile/info_profile_icon.h" #include "info/profile/info_profile_icon.h"
#include "info/profile/info_profile_values.h" #include "info/profile/info_profile_values.h"
@ -34,7 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace { namespace {
constexpr auto kSlowmodeValues = 7; constexpr auto kSlowmodeValues = 7;
constexpr auto kSuggestGigagroupThreshold = 199000; constexpr auto kSuggestGigagroupThreshold = 1; AssertIsDebug(199000);
int SlowmodeDelayByIndex(int index) { int SlowmodeDelayByIndex(int index) {
Expects(index >= 0 && index < kSlowmodeValues); Expects(index >= 0 && index < kSlowmodeValues);
@ -551,7 +552,7 @@ void EditPeerPermissionsBox::addSuggestGigagroup(
channel->inputChannel channel->inputChannel
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result); channel->session().api().applyUpdates(result);
Ui::hideLayer(); Ui::hideSettingsAndLayer();
}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
*converting = false; *converting = false;
}).send(); }).send();
@ -565,13 +566,9 @@ void EditPeerPermissionsBox::addSuggestGigagroup(
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
tr::lng_gigagroup_warning(), tr::lng_gigagroup_warning(
st::defaultFlatLabel), ) | Ui::Text::ToRichLangValue(),
style::margins( st::infoAboutGigagroup));
st::boxRowPadding.left(),
st::boxLittleSkip,
st::boxRowPadding.right(),
st::boxLittleSkip));
box->addButton(tr::lng_gigagroup_convert_sure(), convertSure); box->addButton(tr::lng_gigagroup_convert_sure(), convertSure);
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
})); }));
@ -583,11 +580,13 @@ void EditPeerPermissionsBox::addSuggestGigagroup(
getDelegate()->show(Box([=](not_null<Ui::GenericBox*> box) { getDelegate()->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_gigagroup_convert_title()); box->setTitle(tr::lng_gigagroup_convert_title());
const auto addFeature = [&](rpl::producer<QString> text) { const auto addFeature = [&](rpl::producer<QString> text) {
using namespace rpl::mappers;
const auto prefix = QString::fromUtf8("\xE2\x80\xA2 ");
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
std::move(text), std::move(text) | rpl::map(prefix + _1),
st::defaultFlatLabel), st::infoAboutGigagroup),
style::margins( style::margins(
st::boxRowPadding.left(), st::boxRowPadding.left(),
st::boxLittleSkip, st::boxLittleSkip,

View File

@ -454,6 +454,7 @@ bool ChannelData::canEditInformation() const {
bool ChannelData::canEditPermissions() const { bool ChannelData::canEditPermissions() const {
return isMegagroup() return isMegagroup()
&& !isGigagroup()
&& ((adminRights() & AdminRight::f_ban_users) || amCreator()); && ((adminRights() & AdminRight::f_ban_users) || amCreator());
} }

View File

@ -96,6 +96,7 @@ public:
| MTPDchannel::Flag::f_scam | MTPDchannel::Flag::f_scam
| MTPDchannel::Flag::f_fake | MTPDchannel::Flag::f_fake
| MTPDchannel::Flag::f_megagroup | MTPDchannel::Flag::f_megagroup
| MTPDchannel::Flag::f_gigagroup
| MTPDchannel::Flag::f_restricted | MTPDchannel::Flag::f_restricted
| MTPDchannel::Flag::f_signatures | MTPDchannel::Flag::f_signatures
| MTPDchannel::Flag::f_username | MTPDchannel::Flag::f_username
@ -233,6 +234,9 @@ public:
[[nodiscard]] bool isBroadcast() const { [[nodiscard]] bool isBroadcast() const {
return flags() & MTPDchannel::Flag::f_broadcast; return flags() & MTPDchannel::Flag::f_broadcast;
} }
[[nodiscard]] bool isGigagroup() const {
return flags() & MTPDchannel::Flag::f_gigagroup;
}
[[nodiscard]] bool hasUsername() const { [[nodiscard]] bool hasUsername() const {
return flags() & MTPDchannel::Flag::f_username; return flags() & MTPDchannel::Flag::f_username;
} }

View File

@ -757,11 +757,15 @@ bool PeerData::isFake() const {
} }
bool PeerData::isMegagroup() const { bool PeerData::isMegagroup() const {
return isChannel() ? asChannel()->isMegagroup() : false; return isChannel() && asChannel()->isMegagroup();
} }
bool PeerData::isBroadcast() const { bool PeerData::isBroadcast() const {
return isChannel() ? asChannel()->isBroadcast() : false; return isChannel() && asChannel()->isBroadcast();
}
bool PeerData::isGigagroup() const {
return isChannel() && asChannel()->isGigagroup();
} }
bool PeerData::isRepliesChat() const { bool PeerData::isRepliesChat() const {

View File

@ -156,6 +156,7 @@ public:
[[nodiscard]] bool isFake() const; [[nodiscard]] bool isFake() const;
[[nodiscard]] bool isMegagroup() const; [[nodiscard]] bool isMegagroup() const;
[[nodiscard]] bool isBroadcast() const; [[nodiscard]] bool isBroadcast() const;
[[nodiscard]] bool isGigagroup() const;
[[nodiscard]] bool isRepliesChat() const; [[nodiscard]] bool isRepliesChat() const;
[[nodiscard]] bool sharedMediaInfo() const { [[nodiscard]] bool sharedMediaInfo() const {
return isSelf() || isRepliesChat(); return isSelf() || isRepliesChat();

View File

@ -937,3 +937,7 @@ inviteLinkRevokedIcon: icon {{ "info/edit/links_revoked", mediaviewFileExtFg }};
inviteLinkThreeDotsSkip: 12px; inviteLinkThreeDotsSkip: 12px;
inviteLinkRevokedTitlePadding: margins(22px, 16px, 10px, 4px); inviteLinkRevokedTitlePadding: margins(22px, 16px, 10px, 4px);
inviteLinkLimitMargin: margins(22px, 8px, 22px, 8px); inviteLinkLimitMargin: margins(22px, 8px, 22px, 8px);
infoAboutGigagroup: FlatLabel(defaultFlatLabel) {
minWidth: 274px;
}