mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-18 05:07:01 +00:00
Add members link in info for channel admins.
This commit is contained in:
parent
a6df928d45
commit
dbb011fc56
@ -696,7 +696,8 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
|
|||||||
| UpdateFlag::UserIsBlocked
|
| UpdateFlag::UserIsBlocked
|
||||||
| UpdateFlag::AdminsChanged
|
| UpdateFlag::AdminsChanged
|
||||||
| UpdateFlag::MembersChanged
|
| UpdateFlag::MembersChanged
|
||||||
| UpdateFlag::UserOnlineChanged;
|
| UpdateFlag::UserOnlineChanged
|
||||||
|
| UpdateFlag::ChannelAmIn;
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [this](const Notify::PeerUpdate &update) {
|
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [this](const Notify::PeerUpdate &update) {
|
||||||
if (update.peer == _peer) {
|
if (update.peer == _peer) {
|
||||||
if (update.flags & UpdateFlag::ChannelRightsChanged) {
|
if (update.flags & UpdateFlag::ChannelRightsChanged) {
|
||||||
@ -730,7 +731,8 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
|
|||||||
if (update.flags & (UpdateFlag::UserIsBlocked
|
if (update.flags & (UpdateFlag::UserIsBlocked
|
||||||
| UpdateFlag::AdminsChanged
|
| UpdateFlag::AdminsChanged
|
||||||
| UpdateFlag::MembersChanged
|
| UpdateFlag::MembersChanged
|
||||||
| UpdateFlag::UserOnlineChanged)) {
|
| UpdateFlag::UserOnlineChanged
|
||||||
|
| UpdateFlag::ChannelAmIn)) {
|
||||||
handlePeerUpdate();
|
handlePeerUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ infoNotificationsIconPosition: point(20px, 5px);
|
|||||||
infoSharedMediaIconPosition: point(20px, 24px);
|
infoSharedMediaIconPosition: point(20px, 24px);
|
||||||
infoSharedMediaButtonIconPosition: point(20px, 3px);
|
infoSharedMediaButtonIconPosition: point(20px, 3px);
|
||||||
infoIconPosition: point(20px, 15px);
|
infoIconPosition: point(20px, 15px);
|
||||||
|
infoChannelMembersIconPosition: point(20px, 24px);
|
||||||
infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
|
infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
|
||||||
maxHeight: 20px;
|
maxHeight: 20px;
|
||||||
style: TextStyle(defaultTextStyle) {
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
@ -262,7 +262,7 @@ void WrapWidget::createTopBar() {
|
|||||||
}
|
}
|
||||||
if (_controller->section().type() == Section::Type::Profile) {
|
if (_controller->section().type() == Section::Type::Profile) {
|
||||||
addProfileMenuButton();
|
addProfileMenuButton();
|
||||||
addProfileNotificationsButton();
|
// addProfileNotificationsButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
_topBar->move(0, 0);
|
_topBar->move(0, 0);
|
||||||
|
@ -21,6 +21,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||||||
#include "info/profile/info_profile_actions.h"
|
#include "info/profile/info_profile_actions.h"
|
||||||
|
|
||||||
#include <rpl/flatten_latest.h>
|
#include <rpl/flatten_latest.h>
|
||||||
|
#include <rpl/combine.h>
|
||||||
|
#include "data/data_peer_values.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
@ -42,6 +44,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||||||
#include "info/profile/info_profile_text.h"
|
#include "info/profile/info_profile_text.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
|
#include "profile/profile_channel_controllers.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
#include "messenger.h"
|
#include "messenger.h"
|
||||||
@ -557,8 +560,7 @@ void ActionsFiller::addLeaveChannelAction(
|
|||||||
_wrap,
|
_wrap,
|
||||||
Lang::Viewer(lng_profile_leave_channel),
|
Lang::Viewer(lng_profile_leave_channel),
|
||||||
AmInChannelValue(channel),
|
AmInChannelValue(channel),
|
||||||
[channel] { Auth().api().leaveChannel(channel); },
|
[channel] { Auth().api().leaveChannel(channel); });
|
||||||
st::infoBlockButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionsFiller::addJoinChannelAction(
|
void ActionsFiller::addJoinChannelAction(
|
||||||
@ -608,10 +610,10 @@ void ActionsFiller::fillChannelActions(
|
|||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
addJoinChannelAction(channel);
|
addJoinChannelAction(channel);
|
||||||
|
addLeaveChannelAction(channel);
|
||||||
if (!channel->amCreator()) {
|
if (!channel->amCreator()) {
|
||||||
addReportAction();
|
addReportAction();
|
||||||
}
|
}
|
||||||
addLeaveChannelAction(channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
||||||
@ -631,12 +633,13 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
|||||||
fillUserActions(user);
|
fillUserActions(user);
|
||||||
});
|
});
|
||||||
} else if (auto channel = _peer->asChannel()) {
|
} else if (auto channel = _peer->asChannel()) {
|
||||||
if (!channel->isMegagroup()) {
|
if (channel->isMegagroup()) {
|
||||||
|
return { nullptr };
|
||||||
|
}
|
||||||
return wrapResult([=] {
|
return wrapResult([=] {
|
||||||
fillChannelActions(channel);
|
fillChannelActions(channel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return { nullptr };
|
return { nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,5 +661,56 @@ object_ptr<Ui::RpWidget> SetupActions(
|
|||||||
return filler.fill();
|
return filler.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_ptr<Ui::RpWidget> SetupChannelMembers(
|
||||||
|
not_null<Controller*> controller,
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
not_null<PeerData*> peer) {
|
||||||
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
|
auto channel = peer->asChannel();
|
||||||
|
if (!channel || channel->isMegagroup()) {
|
||||||
|
return { nullptr };
|
||||||
|
}
|
||||||
|
|
||||||
|
auto membersShown = rpl::combine(
|
||||||
|
MembersCountValue(channel),
|
||||||
|
Data::PeerFullFlagValue(
|
||||||
|
channel,
|
||||||
|
MTPDchannelFull::Flag::f_can_view_participants),
|
||||||
|
($1 > 0) && $2);
|
||||||
|
auto membersText = MembersCountValue(channel)
|
||||||
|
| rpl::map([](int count) {
|
||||||
|
return lng_chat_status_members(lt_count, count);
|
||||||
|
});
|
||||||
|
auto membersCallback = [controller, channel] {
|
||||||
|
using Controller = ::Profile::ParticipantsBoxController;
|
||||||
|
Controller::Start(
|
||||||
|
controller->window(),
|
||||||
|
channel,
|
||||||
|
Controller::Role::Members);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
parent,
|
||||||
|
object_ptr<Ui::VerticalLayout>(parent));
|
||||||
|
result->toggleOn(std::move(membersShown));
|
||||||
|
|
||||||
|
auto members = result->entity();
|
||||||
|
members->add(object_ptr<BoxContentDivider>(members));
|
||||||
|
members->add(CreateSkipWidget(members));
|
||||||
|
AddActionButton(
|
||||||
|
members,
|
||||||
|
std::move(membersText),
|
||||||
|
rpl::single(true),
|
||||||
|
std::move(membersCallback));
|
||||||
|
object_ptr<FloatingIcon>(
|
||||||
|
members,
|
||||||
|
st::infoIconMembers,
|
||||||
|
st::infoChannelMembersIconPosition);
|
||||||
|
members->add(CreateSkipWidget(members));
|
||||||
|
|
||||||
|
return std::move(result);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Profile
|
} // namespace Profile
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
@ -40,5 +40,10 @@ object_ptr<Ui::RpWidget> SetupActions(
|
|||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<PeerData*> peer);
|
not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
object_ptr<Ui::RpWidget> SetupChannelMembers(
|
||||||
|
not_null<Controller*> controller,
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
not_null<PeerData*> peer);
|
||||||
|
|
||||||
} // namespace Profile
|
} // namespace Profile
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
@ -102,8 +102,10 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
|
|||||||
result->add(std::move(details));
|
result->add(std::move(details));
|
||||||
}
|
}
|
||||||
result->add(setupSharedMedia(result.data()));
|
result->add(setupSharedMedia(result.data()));
|
||||||
|
if (auto members = SetupChannelMembers(_controller, result.data(), _peer)) {
|
||||||
|
result->add(std::move(members));
|
||||||
|
}
|
||||||
result->add(object_ptr<BoxContentDivider>(result));
|
result->add(object_ptr<BoxContentDivider>(result));
|
||||||
|
|
||||||
if (auto actions = SetupActions(_controller, result.data(), _peer)) {
|
if (auto actions = SetupActions(_controller, result.data(), _peer)) {
|
||||||
result->add(std::move(actions));
|
result->add(std::move(actions));
|
||||||
}
|
}
|
||||||
|
@ -183,19 +183,11 @@ rpl::producer<int> MembersCountValue(
|
|||||||
: 0;
|
: 0;
|
||||||
});
|
});
|
||||||
} else if (auto channel = peer->asChannel()) {
|
} else if (auto channel = peer->asChannel()) {
|
||||||
return rpl::combine(
|
return Notify::PeerUpdateValue(
|
||||||
Notify::PeerUpdateValue(
|
|
||||||
channel,
|
channel,
|
||||||
Notify::PeerUpdate::Flag::MembersChanged),
|
Notify::PeerUpdate::Flag::MembersChanged)
|
||||||
Data::PeerFullFlagValue(
|
|
||||||
channel,
|
|
||||||
MTPDchannelFull::Flag::f_can_view_participants))
|
|
||||||
| rpl::map([channel] {
|
| rpl::map([channel] {
|
||||||
auto canViewCount = channel->canViewMembers()
|
return channel->membersCount();
|
||||||
|| !channel->isMegagroup();
|
|
||||||
return canViewCount
|
|
||||||
? qMax(channel->membersCount(), 1)
|
|
||||||
: 0;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Unexpected("User in MembersCountViewer().");
|
Unexpected("User in MembersCountViewer().");
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _infoExpanded = false;
|
bool _infoExpanded = true;
|
||||||
base::optional<QString> _membersSearch;
|
base::optional<QString> _membersSearch;
|
||||||
std::unique_ptr<PeerListState> _membersState;
|
std::unique_ptr<PeerListState> _membersState;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user