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

View File

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

View File

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

View File

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

View File

@ -757,11 +757,15 @@ bool PeerData::isFake() const {
}
bool PeerData::isMegagroup() const {
return isChannel() ? asChannel()->isMegagroup() : false;
return isChannel() && asChannel()->isMegagroup();
}
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 {

View File

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

View File

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