mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update API scheme, add view link box.
This commit is contained in:
parent
819cd4a099
commit
50c07bfc98
11 changed files with 699 additions and 350 deletions
|
@ -181,6 +181,8 @@ PRIVATE
|
||||||
boxes/peers/edit_participants_box.h
|
boxes/peers/edit_participants_box.h
|
||||||
boxes/peers/edit_peer_info_box.cpp
|
boxes/peers/edit_peer_info_box.cpp
|
||||||
boxes/peers/edit_peer_info_box.h
|
boxes/peers/edit_peer_info_box.h
|
||||||
|
boxes/peers/edit_peer_invite_link.cpp
|
||||||
|
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_type_box.cpp
|
boxes/peers/edit_peer_type_box.cpp
|
||||||
|
|
|
@ -1185,6 +1185,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_group_invite_add" = "Create a New Link";
|
"lng_group_invite_add" = "Create a New Link";
|
||||||
"lng_group_invite_add_about" = "You can generate invite links that will expire after they've been used.";
|
"lng_group_invite_add_about" = "You can generate invite links that will expire after they've been used.";
|
||||||
"lng_group_invite_expires_at" = "This link expires {when}.";
|
"lng_group_invite_expires_at" = "This link expires {when}.";
|
||||||
|
"lng_group_invite_expired_already" = "This link has expired.";
|
||||||
"lng_group_invite_created_by" = "Link created by";
|
"lng_group_invite_created_by" = "Link created by";
|
||||||
"lng_group_invite_context_copy" = "Copy";
|
"lng_group_invite_context_copy" = "Copy";
|
||||||
"lng_group_invite_context_share" = "Share";
|
"lng_group_invite_context_share" = "Share";
|
||||||
|
|
|
@ -455,6 +455,7 @@ sendMessageGamePlayAction#dd6a8f48 = SendMessageAction;
|
||||||
sendMessageRecordRoundAction#88f27fbc = SendMessageAction;
|
sendMessageRecordRoundAction#88f27fbc = SendMessageAction;
|
||||||
sendMessageUploadRoundAction#243e1c66 progress:int = SendMessageAction;
|
sendMessageUploadRoundAction#243e1c66 progress:int = SendMessageAction;
|
||||||
speakingInGroupCallAction#d92c2285 = SendMessageAction;
|
speakingInGroupCallAction#d92c2285 = SendMessageAction;
|
||||||
|
sendMessageHistoryImportAction#dbda9246 progress:int = SendMessageAction;
|
||||||
|
|
||||||
contacts.found#b3134d9d my_results:Vector<Peer> results:Vector<Peer> chats:Vector<Chat> users:Vector<User> = contacts.Found;
|
contacts.found#b3134d9d my_results:Vector<Peer> results:Vector<Peer> chats:Vector<Chat> users:Vector<User> = contacts.Found;
|
||||||
|
|
||||||
|
@ -535,7 +536,7 @@ auth.passwordRecovery#137948a5 email_pattern:string = auth.PasswordRecovery;
|
||||||
|
|
||||||
receivedNotifyMessage#a384b779 id:int flags:int = ReceivedNotifyMessage;
|
receivedNotifyMessage#a384b779 id:int flags:int = ReceivedNotifyMessage;
|
||||||
|
|
||||||
chatInviteExported#6e24fc9d flags:# revoked:flags.0?true permanent:flags.5?true expired:flags.6?true link:string admin_id:int date:int start_date:flags.4?int expire_date:flags.1?int usage_limit:flags.2?int usage:flags.3?int = ExportedChatInvite;
|
chatInviteExported#6e24fc9d flags:# revoked:flags.0?true permanent:flags.5?true link:string admin_id:int date:int start_date:flags.4?int expire_date:flags.1?int usage_limit:flags.2?int usage:flags.3?int = ExportedChatInvite;
|
||||||
|
|
||||||
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
|
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
|
||||||
chatInvite#dfc2f58e flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:Photo participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
chatInvite#dfc2f58e flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:Photo participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
||||||
|
@ -1463,7 +1464,7 @@ messages.getReplies#24b581ba peer:InputPeer msg_id:int offset_id:int offset_date
|
||||||
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
||||||
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
||||||
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
||||||
messages.getExportedChatInvites#6d9cae03 flags:# revoked:flags.3?true peer:InputPeer admin_id:flags.0?InputUser offset_link:flags.2?string limit:int = messages.ExportedChatInvites;
|
messages.getExportedChatInvites#6a72ac6c flags:# revoked:flags.3?true peer:InputPeer admin_id:flags.0?InputUser offset_date:flags.2?int offset_link:flags.2?string limit:int = messages.ExportedChatInvites;
|
||||||
messages.editExportedChatInvite#2e4ffbe flags:# revoked:flags.2?true peer:InputPeer link:string expire_date:flags.0?int usage_limit:flags.1?int = messages.ExportedChatInvite;
|
messages.editExportedChatInvite#2e4ffbe flags:# revoked:flags.2?true peer:InputPeer link:string expire_date:flags.0?int usage_limit:flags.1?int = messages.ExportedChatInvite;
|
||||||
messages.deleteRevokedExportedChatInvites#52041463 peer:InputPeer = Bool;
|
messages.deleteRevokedExportedChatInvites#52041463 peer:InputPeer = Bool;
|
||||||
messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;
|
messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;
|
||||||
|
|
|
@ -41,6 +41,27 @@ void RemovePermanent(PeerInviteLinks &links) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
JoinedByLinkSlice ParseJoinedByLinkSlice(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const MTPmessages_ChatInviteImporters &slice) {
|
||||||
|
auto result = JoinedByLinkSlice();
|
||||||
|
slice.match([&](const MTPDmessages_chatInviteImporters &data) {
|
||||||
|
auto &owner = peer->session().data();
|
||||||
|
owner.processUsers(data.vusers());
|
||||||
|
result.count = data.vcount().v;
|
||||||
|
result.users.reserve(data.vimporters().v.size());
|
||||||
|
for (const auto importer : data.vimporters().v) {
|
||||||
|
importer.match([&](const MTPDchatInviteImporter &data) {
|
||||||
|
result.users.push_back({
|
||||||
|
.user = owner.user(data.vuser_id().v),
|
||||||
|
.date = data.vdate().v,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
InviteLinks::InviteLinks(not_null<ApiWrap*> api) : _api(api) {
|
InviteLinks::InviteLinks(not_null<ApiWrap*> api) : _api(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +349,7 @@ void InviteLinks::requestLinks(not_null<PeerData*> peer) {
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
peer->input,
|
peer->input,
|
||||||
MTPInputUser(), // admin_id
|
MTPInputUser(), // admin_id
|
||||||
|
MTPint(), // offset_date
|
||||||
MTPstring(), // offset_link
|
MTPstring(), // offset_link
|
||||||
MTP_int(kFirstPage)
|
MTP_int(kFirstPage)
|
||||||
)).done([=](const MTPmessages_ExportedChatInvites &result) {
|
)).done([=](const MTPmessages_ExportedChatInvites &result) {
|
||||||
|
@ -362,9 +384,18 @@ void InviteLinks::requestLinks(not_null<PeerData*> peer) {
|
||||||
_firstSliceRequests.emplace(peer, requestId);
|
_firstSliceRequests.emplace(peer, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
JoinedByLinkSlice InviteLinks::lookupJoinedFirstSlice(LinkKey key) const {
|
std::optional<JoinedByLinkSlice> InviteLinks::lookupJoinedFirstSlice(
|
||||||
|
LinkKey key) const {
|
||||||
const auto i = _firstJoined.find(key);
|
const auto i = _firstJoined.find(key);
|
||||||
return (i != end(_firstJoined)) ? i->second : JoinedByLinkSlice();
|
return (i != end(_firstJoined))
|
||||||
|
? std::make_optional(i->second)
|
||||||
|
: std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<JoinedByLinkSlice> InviteLinks::joinedFirstSliceLoaded(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const QString &link) const {
|
||||||
|
return lookupJoinedFirstSlice({ peer, link });
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<JoinedByLinkSlice> InviteLinks::joinedFirstSliceValue(
|
rpl::producer<JoinedByLinkSlice> InviteLinks::joinedFirstSliceValue(
|
||||||
|
@ -372,7 +403,7 @@ rpl::producer<JoinedByLinkSlice> InviteLinks::joinedFirstSliceValue(
|
||||||
const QString &link,
|
const QString &link,
|
||||||
int fullCount) {
|
int fullCount) {
|
||||||
const auto key = LinkKey{ peer, link };
|
const auto key = LinkKey{ peer, link };
|
||||||
auto current = lookupJoinedFirstSlice(key);
|
auto current = lookupJoinedFirstSlice(key).value_or(JoinedByLinkSlice());
|
||||||
if (current.count == fullCount
|
if (current.count == fullCount
|
||||||
&& (!fullCount || !current.users.empty())) {
|
&& (!fullCount || !current.users.empty())) {
|
||||||
return rpl::single(current);
|
return rpl::single(current);
|
||||||
|
@ -390,7 +421,7 @@ rpl::producer<JoinedByLinkSlice> InviteLinks::joinedFirstSliceValue(
|
||||||
) | rpl::filter(
|
) | rpl::filter(
|
||||||
_1 == key
|
_1 == key
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return lookupJoinedFirstSlice(key);
|
return lookupJoinedFirstSlice(key).value_or(JoinedByLinkSlice());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +453,7 @@ void InviteLinks::requestJoinedFirstSlice(LinkKey key) {
|
||||||
MTP_int(kJoinedFirstPage)
|
MTP_int(kJoinedFirstPage)
|
||||||
)).done([=](const MTPmessages_ChatInviteImporters &result) {
|
)).done([=](const MTPmessages_ChatInviteImporters &result) {
|
||||||
_firstJoinedRequests.remove(key);
|
_firstJoinedRequests.remove(key);
|
||||||
_firstJoined[key] = parseSlice(key.peer, result);
|
_firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result);
|
||||||
_joinedFirstSliceLoaded.fire_copy(key);
|
_joinedFirstSliceLoaded.fire_copy(key);
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
_firstJoinedRequests.remove(key);
|
_firstJoinedRequests.remove(key);
|
||||||
|
@ -537,27 +568,6 @@ auto InviteLinks::parseSlice(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
JoinedByLinkSlice InviteLinks::parseSlice(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
const MTPmessages_ChatInviteImporters &slice) const {
|
|
||||||
auto result = JoinedByLinkSlice();
|
|
||||||
slice.match([&](const MTPDmessages_chatInviteImporters &data) {
|
|
||||||
auto &owner = peer->session().data();
|
|
||||||
owner.processUsers(data.vusers());
|
|
||||||
result.count = data.vcount().v;
|
|
||||||
result.users.reserve(data.vimporters().v.size());
|
|
||||||
for (const auto importer : data.vimporters().v) {
|
|
||||||
importer.match([&](const MTPDchatInviteImporter &data) {
|
|
||||||
result.users.push_back({
|
|
||||||
.user = owner.user(data.vuser_id().v),
|
|
||||||
.date = data.vdate().v,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto InviteLinks::parse(
|
auto InviteLinks::parse(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const MTPExportedChatInvite &invite) const -> Link {
|
const MTPExportedChatInvite &invite) const -> Link {
|
||||||
|
@ -578,7 +588,8 @@ auto InviteLinks::parse(
|
||||||
|
|
||||||
void InviteLinks::requestMoreLinks(
|
void InviteLinks::requestMoreLinks(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QString &last,
|
TimeId lastDate,
|
||||||
|
const QString &lastLink,
|
||||||
bool revoked,
|
bool revoked,
|
||||||
Fn<void(Links)> done) {
|
Fn<void(Links)> done) {
|
||||||
using Flag = MTPmessages_GetExportedChatInvites::Flag;
|
using Flag = MTPmessages_GetExportedChatInvites::Flag;
|
||||||
|
@ -587,7 +598,8 @@ void InviteLinks::requestMoreLinks(
|
||||||
| (revoked ? Flag::f_revoked : Flag(0))),
|
| (revoked ? Flag::f_revoked : Flag(0))),
|
||||||
peer->input,
|
peer->input,
|
||||||
MTPInputUser(), // admin_id,
|
MTPInputUser(), // admin_id,
|
||||||
MTP_string(last),
|
MTP_int(lastDate),
|
||||||
|
MTP_string(lastLink),
|
||||||
MTP_int(kPerPage)
|
MTP_int(kPerPage)
|
||||||
)).done([=](const MTPmessages_ExportedChatInvites &result) {
|
)).done([=](const MTPmessages_ExportedChatInvites &result) {
|
||||||
auto slice = parseSlice(peer, result);
|
auto slice = parseSlice(peer, result);
|
||||||
|
|
|
@ -44,6 +44,10 @@ struct InviteLinkUpdate {
|
||||||
std::optional<InviteLink> now;
|
std::optional<InviteLink> now;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const MTPmessages_ChatInviteImporters &slice);
|
||||||
|
|
||||||
class InviteLinks final {
|
class InviteLinks final {
|
||||||
public:
|
public:
|
||||||
explicit InviteLinks(not_null<ApiWrap*> api);
|
explicit InviteLinks(not_null<ApiWrap*> api);
|
||||||
|
@ -90,6 +94,9 @@ public:
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QString &link,
|
const QString &link,
|
||||||
int fullCount);
|
int fullCount);
|
||||||
|
[[nodiscard]] std::optional<JoinedByLinkSlice> joinedFirstSliceLoaded(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const QString &link) const;
|
||||||
[[nodiscard]] rpl::producer<Update> updates(
|
[[nodiscard]] rpl::producer<Update> updates(
|
||||||
not_null<PeerData*> peer) const;
|
not_null<PeerData*> peer) const;
|
||||||
[[nodiscard]] rpl::producer<> allRevokedDestroyed(
|
[[nodiscard]] rpl::producer<> allRevokedDestroyed(
|
||||||
|
@ -97,7 +104,8 @@ public:
|
||||||
|
|
||||||
void requestMoreLinks(
|
void requestMoreLinks(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QString &last,
|
TimeId lastDate,
|
||||||
|
const QString &lastLink,
|
||||||
bool revoked,
|
bool revoked,
|
||||||
Fn<void(Links)> done);
|
Fn<void(Links)> done);
|
||||||
|
|
||||||
|
@ -122,9 +130,6 @@ private:
|
||||||
[[nodiscard]] Link parse(
|
[[nodiscard]] Link parse(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const MTPExportedChatInvite &invite) const;
|
const MTPExportedChatInvite &invite) const;
|
||||||
[[nodiscard]] JoinedByLinkSlice parseSlice(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
const MTPmessages_ChatInviteImporters &slice) const;
|
|
||||||
[[nodiscard]] Link *lookupPermanent(not_null<PeerData*> peer);
|
[[nodiscard]] Link *lookupPermanent(not_null<PeerData*> peer);
|
||||||
[[nodiscard]] Link *lookupPermanent(Links &links);
|
[[nodiscard]] Link *lookupPermanent(Links &links);
|
||||||
[[nodiscard]] const Link *lookupPermanent(const Links &links) const;
|
[[nodiscard]] const Link *lookupPermanent(const Links &links) const;
|
||||||
|
@ -152,7 +157,7 @@ private:
|
||||||
int usageLimit = 0);
|
int usageLimit = 0);
|
||||||
|
|
||||||
void requestJoinedFirstSlice(LinkKey key);
|
void requestJoinedFirstSlice(LinkKey key);
|
||||||
[[nodiscard]] JoinedByLinkSlice lookupJoinedFirstSlice(
|
[[nodiscard]] std::optional<JoinedByLinkSlice> lookupJoinedFirstSlice(
|
||||||
LinkKey key) const;
|
LinkKey key) const;
|
||||||
|
|
||||||
const not_null<ApiWrap*> _api;
|
const not_null<ApiWrap*> _api;
|
||||||
|
|
590
Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp
Normal file
590
Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp
Normal file
|
@ -0,0 +1,590 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "boxes/peers/edit_peer_invite_link.h"
|
||||||
|
|
||||||
|
#include "data/data_peer.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_histories.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "api/api_invite_links.h"
|
||||||
|
#include "base/unixtime.h"
|
||||||
|
#include "apiwrap.h"
|
||||||
|
#include "ui/controls/invite_link_buttons.h"
|
||||||
|
#include "ui/controls/invite_link_label.h"
|
||||||
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
#include "ui/wrap/padding_wrap.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "ui/abstract_button.h"
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "boxes/share_box.h"
|
||||||
|
#include "history/view/history_view_group_call_tracker.h" // GenerateUs...
|
||||||
|
#include "history/history_message.h" // GetErrorTextForSending.
|
||||||
|
#include "history/history.h"
|
||||||
|
#include "boxes/confirm_box.h"
|
||||||
|
#include "boxes/peer_list_box.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "facades.h" // Ui::showPerProfile.
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
#include "settings/settings_common.h"
|
||||||
|
#include "mtproto/sender.h"
|
||||||
|
#include "styles/style_info.h"
|
||||||
|
|
||||||
|
#include <QtGui/QGuiApplication>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kFirstPage = 20;
|
||||||
|
constexpr auto kPerPage = 100;
|
||||||
|
|
||||||
|
using LinkData = Api::InviteLink;
|
||||||
|
|
||||||
|
class Controller final : public PeerListController {
|
||||||
|
public:
|
||||||
|
Controller(not_null<PeerData*> peer, const LinkData &data);
|
||||||
|
|
||||||
|
void prepare() override;
|
||||||
|
void loadMoreRows() override;
|
||||||
|
void rowClicked(not_null<PeerListRow*> row) override;
|
||||||
|
Main::Session &session() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void appendSlice(const Api::JoinedByLinkSlice &slice);
|
||||||
|
[[nodiscard]] object_ptr<Ui::RpWidget> prepareHeader();
|
||||||
|
|
||||||
|
const not_null<PeerData*> _peer;
|
||||||
|
LinkData _data;
|
||||||
|
|
||||||
|
mtpRequestId _requestId = 0;
|
||||||
|
std::optional<Api::JoinedByLinkUser> _lastUser;
|
||||||
|
bool _allLoaded = false;
|
||||||
|
|
||||||
|
MTP::Sender _api;
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class SingleRowController final : public PeerListController {
|
||||||
|
public:
|
||||||
|
SingleRowController(not_null<PeerData*> peer, TimeId date);
|
||||||
|
|
||||||
|
void prepare() override;
|
||||||
|
void loadMoreRows() override;
|
||||||
|
void rowClicked(not_null<PeerListRow*> row) override;
|
||||||
|
Main::Session &session() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const not_null<PeerData*> _peer;
|
||||||
|
TimeId _date = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void AddHeaderBlock(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const LinkData &data,
|
||||||
|
TimeId now) {
|
||||||
|
const auto link = data.link;
|
||||||
|
const auto weak = Ui::MakeWeak(container);
|
||||||
|
const auto copyLink = crl::guard(weak, [=] {
|
||||||
|
CopyInviteLink(link);
|
||||||
|
});
|
||||||
|
const auto shareLink = crl::guard(weak, [=] {
|
||||||
|
ShareInviteLinkBox(peer, link);
|
||||||
|
});
|
||||||
|
const auto revokeLink = crl::guard(weak, [=] {
|
||||||
|
RevokeLink(peer, link);
|
||||||
|
});
|
||||||
|
|
||||||
|
const auto createMenu = [=] {
|
||||||
|
auto result = base::make_unique_q<Ui::PopupMenu>(container);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_copy(tr::now),
|
||||||
|
copyLink);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_share(tr::now),
|
||||||
|
shareLink);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_revoke(tr::now),
|
||||||
|
revokeLink);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto prefix = qstr("https://");
|
||||||
|
const auto label = container->lifetime().make_state<Ui::InviteLinkLabel>(
|
||||||
|
container,
|
||||||
|
rpl::single(link.startsWith(prefix)
|
||||||
|
? link.mid(prefix.size())
|
||||||
|
: link),
|
||||||
|
createMenu);
|
||||||
|
container->add(
|
||||||
|
label->take(),
|
||||||
|
st::inviteLinkFieldPadding);
|
||||||
|
|
||||||
|
label->clicks(
|
||||||
|
) | rpl::start_with_next(copyLink, label->lifetime());
|
||||||
|
|
||||||
|
if ((data.expireDate <= 0 || now < data.expireDate)
|
||||||
|
&& (data.usageLimit <= 0 || data.usage < data.usageLimit)) {
|
||||||
|
AddCopyShareLinkButtons(
|
||||||
|
container,
|
||||||
|
copyLink,
|
||||||
|
shareLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddHeader(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const LinkData &data) {
|
||||||
|
using namespace Settings;
|
||||||
|
|
||||||
|
if (!data.revoked && !data.permanent) {
|
||||||
|
const auto now = base::unixtime::now();
|
||||||
|
AddHeaderBlock(container, peer, data, now);
|
||||||
|
AddSkip(container, st::inviteLinkJoinedRowPadding.bottom() * 2);
|
||||||
|
if (data.expireDate > 0) {
|
||||||
|
AddDividerText(
|
||||||
|
container,
|
||||||
|
(data.expireDate > now
|
||||||
|
? tr::lng_group_invite_expires_at(
|
||||||
|
lt_when,
|
||||||
|
rpl::single(langDateTime(
|
||||||
|
base::unixtime::parse(data.expireDate))))
|
||||||
|
: tr::lng_group_invite_expired_already()));
|
||||||
|
} else {
|
||||||
|
AddDivider(container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddSkip(container);
|
||||||
|
AddSubsectionTitle(
|
||||||
|
container,
|
||||||
|
tr::lng_group_invite_created_by());
|
||||||
|
|
||||||
|
const auto delegate = container->lifetime().make_state<
|
||||||
|
PeerListContentDelegateSimple
|
||||||
|
>();
|
||||||
|
const auto controller = container->lifetime().make_state<
|
||||||
|
SingleRowController
|
||||||
|
>(data.admin, data.date);
|
||||||
|
const auto content = container->add(object_ptr<PeerListContent>(
|
||||||
|
container,
|
||||||
|
controller));
|
||||||
|
delegate->setContent(content);
|
||||||
|
controller->setDelegate(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller::Controller(not_null<PeerData*> peer, const LinkData &data)
|
||||||
|
: _peer(peer)
|
||||||
|
, _data(data)
|
||||||
|
, _api(&_peer->session().api().instance()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
object_ptr<Ui::RpWidget> Controller::prepareHeader() {
|
||||||
|
using namespace Settings;
|
||||||
|
|
||||||
|
auto result = object_ptr<Ui::VerticalLayout>((QWidget*)nullptr);
|
||||||
|
const auto container = result.data();
|
||||||
|
AddHeader(container, _peer, _data);
|
||||||
|
AddDivider(container);
|
||||||
|
AddSkip(container);
|
||||||
|
AddSubsectionTitle(
|
||||||
|
container,
|
||||||
|
(_data.usage
|
||||||
|
? tr::lng_group_invite_joined(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(float64(_data.usage)))
|
||||||
|
: tr::lng_group_invite_no_joined()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::prepare() {
|
||||||
|
delegate()->peerListSetAboveWidget(prepareHeader());
|
||||||
|
_allLoaded = (_data.usage == 0);
|
||||||
|
const auto &inviteLinks = _peer->session().api().inviteLinks();
|
||||||
|
const auto slice = inviteLinks.joinedFirstSliceLoaded(_peer, _data.link);
|
||||||
|
if (slice) {
|
||||||
|
appendSlice(*slice);
|
||||||
|
}
|
||||||
|
loadMoreRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::loadMoreRows() {
|
||||||
|
if (_requestId || _allLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_requestId = _api.request(MTPmessages_GetChatInviteImporters(
|
||||||
|
_peer->input,
|
||||||
|
MTP_string(_data.link),
|
||||||
|
MTP_int(_lastUser ? _lastUser->date : 0),
|
||||||
|
_lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(),
|
||||||
|
MTP_int(_lastUser ? kPerPage : kFirstPage)
|
||||||
|
)).done([=](const MTPmessages_ChatInviteImporters &result) {
|
||||||
|
_requestId = 0;
|
||||||
|
auto slice = Api::ParseJoinedByLinkSlice(_peer, result);
|
||||||
|
_allLoaded = slice.users.empty();
|
||||||
|
appendSlice(slice);
|
||||||
|
}).fail([=](const RPCError &error) {
|
||||||
|
_requestId = 0;
|
||||||
|
_allLoaded = true;
|
||||||
|
}).send();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) {
|
||||||
|
for (const auto &user : slice.users) {
|
||||||
|
_lastUser = user;
|
||||||
|
delegate()->peerListAppendRow(
|
||||||
|
std::make_unique<PeerListRow>(user.user));
|
||||||
|
}
|
||||||
|
delegate()->peerListRefreshRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::rowClicked(not_null<PeerListRow*> row) {
|
||||||
|
Ui::showPeerProfile(row->peer());
|
||||||
|
}
|
||||||
|
|
||||||
|
Main::Session &Controller::session() const {
|
||||||
|
return _peer->session();
|
||||||
|
}
|
||||||
|
|
||||||
|
SingleRowController::SingleRowController(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
TimeId date)
|
||||||
|
: _peer(peer)
|
||||||
|
, _date(date) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleRowController::prepare() {
|
||||||
|
auto row = std::make_unique<PeerListRow>(_peer);
|
||||||
|
row->setCustomStatus(langDateTime(base::unixtime::parse(_date)));
|
||||||
|
delegate()->peerListAppendRow(std::move(row));
|
||||||
|
delegate()->peerListRefreshRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleRowController::loadMoreRows() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleRowController::rowClicked(not_null<PeerListRow*> row) {
|
||||||
|
Ui::showPeerProfile(row->peer());
|
||||||
|
}
|
||||||
|
|
||||||
|
Main::Session &SingleRowController::session() const {
|
||||||
|
return _peer->session();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void AddPermanentLinkBlock(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<PeerData*> peer) {
|
||||||
|
const auto computePermanentLink = [=] {
|
||||||
|
const auto &links = peer->session().api().inviteLinks().links(
|
||||||
|
peer).links;
|
||||||
|
const auto link = links.empty() ? nullptr : &links.front();
|
||||||
|
return (link && link->permanent && !link->revoked) ? link : nullptr;
|
||||||
|
};
|
||||||
|
auto value = peer->session().changes().peerFlagsValue(
|
||||||
|
peer,
|
||||||
|
Data::PeerUpdate::Flag::InviteLinks
|
||||||
|
) | rpl::map([=] {
|
||||||
|
const auto link = computePermanentLink();
|
||||||
|
return link
|
||||||
|
? std::make_tuple(link->link, link->usage)
|
||||||
|
: std::make_tuple(QString(), 0);
|
||||||
|
}) | rpl::distinct_until_changed(
|
||||||
|
) | rpl::start_spawning(container->lifetime());
|
||||||
|
|
||||||
|
const auto weak = Ui::MakeWeak(container);
|
||||||
|
const auto copyLink = crl::guard(weak, [=] {
|
||||||
|
if (const auto link = computePermanentLink()) {
|
||||||
|
CopyInviteLink(link->link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const auto shareLink = crl::guard(weak, [=] {
|
||||||
|
if (const auto link = computePermanentLink()) {
|
||||||
|
ShareInviteLinkBox(peer, link->link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const auto revokeLink = crl::guard(weak, [=] {
|
||||||
|
const auto box = std::make_shared<QPointer<ConfirmBox>>();
|
||||||
|
const auto done = crl::guard(weak, [=] {
|
||||||
|
const auto close = [=](auto&&) {
|
||||||
|
if (*box) {
|
||||||
|
(*box)->closeBox();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
peer->session().api().inviteLinks().revokePermanent(peer, close);
|
||||||
|
});
|
||||||
|
*box = Ui::show(
|
||||||
|
Box<ConfirmBox>(tr::lng_group_invite_about_new(tr::now), done),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto link = rpl::duplicate(
|
||||||
|
value
|
||||||
|
) | rpl::map([=](QString link, int usage) {
|
||||||
|
const auto prefix = qstr("https://");
|
||||||
|
return link.startsWith(prefix) ? link.mid(prefix.size()) : link;
|
||||||
|
});
|
||||||
|
const auto createMenu = [=] {
|
||||||
|
auto result = base::make_unique_q<Ui::PopupMenu>(container);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_copy(tr::now),
|
||||||
|
copyLink);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_share(tr::now),
|
||||||
|
shareLink);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_revoke(tr::now),
|
||||||
|
revokeLink);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
const auto label = container->lifetime().make_state<Ui::InviteLinkLabel>(
|
||||||
|
container,
|
||||||
|
std::move(link),
|
||||||
|
createMenu);
|
||||||
|
container->add(
|
||||||
|
label->take(),
|
||||||
|
st::inviteLinkFieldPadding);
|
||||||
|
|
||||||
|
label->clicks(
|
||||||
|
) | rpl::start_with_next(copyLink, label->lifetime());
|
||||||
|
|
||||||
|
AddCopyShareLinkButtons(
|
||||||
|
container,
|
||||||
|
copyLink,
|
||||||
|
shareLink);
|
||||||
|
|
||||||
|
struct JoinedState {
|
||||||
|
QImage cachedUserpics;
|
||||||
|
std::vector<HistoryView::UserpicInRow> list;
|
||||||
|
int count = 0;
|
||||||
|
bool allUserpicsLoaded = false;
|
||||||
|
rpl::variable<Ui::JoinedCountContent> content;
|
||||||
|
rpl::lifetime lifetime;
|
||||||
|
};
|
||||||
|
const auto state = container->lifetime().make_state<JoinedState>();
|
||||||
|
const auto push = [=] {
|
||||||
|
HistoryView::GenerateUserpicsInRow(
|
||||||
|
state->cachedUserpics,
|
||||||
|
state->list,
|
||||||
|
st::inviteLinkUserpics,
|
||||||
|
0);
|
||||||
|
state->allUserpicsLoaded = ranges::all_of(
|
||||||
|
state->list,
|
||||||
|
[](const HistoryView::UserpicInRow &element) {
|
||||||
|
return !element.peer->hasUserpic() || element.view->image();
|
||||||
|
});
|
||||||
|
state->content = Ui::JoinedCountContent{
|
||||||
|
.count = state->count,
|
||||||
|
.userpics = state->cachedUserpics
|
||||||
|
};
|
||||||
|
};
|
||||||
|
std::move(
|
||||||
|
value
|
||||||
|
) | rpl::map([=](QString link, int usage) {
|
||||||
|
return peer->session().api().inviteLinks().joinedFirstSliceValue(
|
||||||
|
peer,
|
||||||
|
link,
|
||||||
|
usage);
|
||||||
|
}) | rpl::flatten_latest(
|
||||||
|
) | rpl::start_with_next([=](const Api::JoinedByLinkSlice &slice) {
|
||||||
|
auto list = std::vector<HistoryView::UserpicInRow>();
|
||||||
|
list.reserve(slice.users.size());
|
||||||
|
for (const auto &item : slice.users) {
|
||||||
|
const auto i = ranges::find(
|
||||||
|
state->list,
|
||||||
|
item.user,
|
||||||
|
&HistoryView::UserpicInRow::peer);
|
||||||
|
if (i != end(state->list)) {
|
||||||
|
list.push_back(std::move(*i));
|
||||||
|
} else {
|
||||||
|
list.push_back({ item.user });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state->count = slice.count;
|
||||||
|
state->list = std::move(list);
|
||||||
|
push();
|
||||||
|
}, state->lifetime);
|
||||||
|
|
||||||
|
peer->session().downloaderTaskFinished(
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return !state->allUserpicsLoaded;
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
auto pushing = false;
|
||||||
|
state->allUserpicsLoaded = true;
|
||||||
|
for (const auto &element : state->list) {
|
||||||
|
if (!element.peer->hasUserpic()) {
|
||||||
|
continue;
|
||||||
|
} else if (element.peer->userpicUniqueKey(element.view)
|
||||||
|
!= element.uniqueKey) {
|
||||||
|
pushing = true;
|
||||||
|
} else if (!element.view->image()) {
|
||||||
|
state->allUserpicsLoaded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pushing) {
|
||||||
|
push();
|
||||||
|
}
|
||||||
|
}, state->lifetime);
|
||||||
|
|
||||||
|
Ui::AddJoinedCountButton(
|
||||||
|
container,
|
||||||
|
state->content.value(),
|
||||||
|
st::inviteLinkJoinedRowPadding
|
||||||
|
)->setClickedCallback([=] {
|
||||||
|
});
|
||||||
|
|
||||||
|
container->add(object_ptr<Ui::SlideWrap<Ui::FixedHeightWidget>>(
|
||||||
|
container,
|
||||||
|
object_ptr<Ui::FixedHeightWidget>(
|
||||||
|
container,
|
||||||
|
st::inviteLinkJoinedRowPadding.bottom()))
|
||||||
|
)->setDuration(0)->toggleOn(state->content.value(
|
||||||
|
) | rpl::map([=](const Ui::JoinedCountContent &content) {
|
||||||
|
return (content.count <= 0);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyInviteLink(const QString &link) {
|
||||||
|
QGuiApplication::clipboard()->setText(link);
|
||||||
|
Ui::Toast::Show(tr::lng_group_invite_copied(tr::now));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link) {
|
||||||
|
const auto session = &peer->session();
|
||||||
|
const auto sending = std::make_shared<bool>();
|
||||||
|
const auto box = std::make_shared<QPointer<ShareBox>>();
|
||||||
|
|
||||||
|
auto copyCallback = [=] {
|
||||||
|
QGuiApplication::clipboard()->setText(link);
|
||||||
|
Ui::Toast::Show(tr::lng_group_invite_copied(tr::now));
|
||||||
|
};
|
||||||
|
auto submitCallback = [=](
|
||||||
|
std::vector<not_null<PeerData*>> &&result,
|
||||||
|
TextWithTags &&comment,
|
||||||
|
Api::SendOptions options) {
|
||||||
|
if (*sending || result.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto error = [&] {
|
||||||
|
for (const auto peer : result) {
|
||||||
|
const auto error = GetErrorTextForSending(
|
||||||
|
peer,
|
||||||
|
{},
|
||||||
|
comment);
|
||||||
|
if (!error.isEmpty()) {
|
||||||
|
return std::make_pair(error, peer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::make_pair(QString(), result.front());
|
||||||
|
}();
|
||||||
|
if (!error.first.isEmpty()) {
|
||||||
|
auto text = TextWithEntities();
|
||||||
|
if (result.size() > 1) {
|
||||||
|
text.append(
|
||||||
|
Ui::Text::Bold(error.second->name)
|
||||||
|
).append("\n\n");
|
||||||
|
}
|
||||||
|
text.append(error.first);
|
||||||
|
Ui::show(
|
||||||
|
Box<InformBox>(text),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*sending = true;
|
||||||
|
if (!comment.text.isEmpty()) {
|
||||||
|
comment.text = link + "\n" + comment.text;
|
||||||
|
const auto add = link.size() + 1;
|
||||||
|
for (auto &tag : comment.tags) {
|
||||||
|
tag.offset += add;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const auto owner = &peer->owner();
|
||||||
|
auto &api = peer->session().api();
|
||||||
|
auto &histories = owner->histories();
|
||||||
|
const auto requestType = Data::Histories::RequestType::Send;
|
||||||
|
for (const auto peer : result) {
|
||||||
|
const auto history = owner->history(peer);
|
||||||
|
auto message = ApiWrap::MessageToSend(history);
|
||||||
|
message.textWithTags = comment;
|
||||||
|
message.action.options = options;
|
||||||
|
message.action.clearDraft = false;
|
||||||
|
api.sendMessage(std::move(message));
|
||||||
|
}
|
||||||
|
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
||||||
|
if (*box) {
|
||||||
|
(*box)->closeBox();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
auto filterCallback = [](PeerData *peer) {
|
||||||
|
return peer->canWrite();
|
||||||
|
};
|
||||||
|
*box = Ui::show(
|
||||||
|
Box<ShareBox>(
|
||||||
|
App::wnd()->sessionController(),
|
||||||
|
std::move(copyCallback),
|
||||||
|
std::move(submitCallback),
|
||||||
|
std::move(filterCallback)),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RevokeLink(not_null<PeerData*> peer, const QString &link) {
|
||||||
|
const auto box = std::make_shared<QPointer<ConfirmBox>>();
|
||||||
|
const auto revoke = [=] {
|
||||||
|
const auto done = [=](const LinkData &data) {
|
||||||
|
if (*box) {
|
||||||
|
(*box)->closeBox();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
peer->session().api().inviteLinks().revoke(peer, link, done);
|
||||||
|
};
|
||||||
|
*box = Ui::show(
|
||||||
|
Box<ConfirmBox>(
|
||||||
|
tr::lng_group_invite_revoke_about(tr::now),
|
||||||
|
revoke),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowInviteLinkBox(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const Api::InviteLink &link) {
|
||||||
|
auto initBox = [=](not_null<Ui::BoxContent*> box) {
|
||||||
|
box->setTitle((link.permanent && !link.revoked)
|
||||||
|
? tr::lng_manage_peer_link_permanent()
|
||||||
|
: tr::lng_manage_peer_link_invite());
|
||||||
|
peer->session().api().inviteLinks().updates(
|
||||||
|
peer
|
||||||
|
) | rpl::start_with_next([=](const Api::InviteLinkUpdate &update) {
|
||||||
|
if (update.was == link.link
|
||||||
|
&& (!update.now || (!link.revoked && update.now->revoked))) {
|
||||||
|
box->closeBox();
|
||||||
|
}
|
||||||
|
}, box->lifetime());
|
||||||
|
box->addButton(tr::lng_about_done(), [=] { box->closeBox(); });
|
||||||
|
};
|
||||||
|
if (link.usage > 0) {
|
||||||
|
Ui::show(
|
||||||
|
Box<PeerListBox>(
|
||||||
|
std::make_unique<Controller>(peer, link),
|
||||||
|
std::move(initBox)),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
} else {
|
||||||
|
Ui::show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
initBox(box);
|
||||||
|
const auto container = box->verticalLayout();
|
||||||
|
AddHeader(container, peer, link);
|
||||||
|
}), Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
|
}
|
32
Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.h
Normal file
32
Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui/layers/generic_box.h"
|
||||||
|
|
||||||
|
class PeerData;
|
||||||
|
|
||||||
|
namespace Api {
|
||||||
|
struct InviteLink;
|
||||||
|
} // namespace Api
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class VerticalLayout;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
void AddPermanentLinkBlock(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
void CopyInviteLink(const QString &link);
|
||||||
|
void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link);
|
||||||
|
void RevokeLink(not_null<PeerData*> peer, const QString &link);
|
||||||
|
|
||||||
|
void ShowInviteLinkBox(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const Api::InviteLink &link);
|
|
@ -7,49 +7,27 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/peers/edit_peer_invite_links.h"
|
#include "boxes/peers/edit_peer_invite_links.h"
|
||||||
|
|
||||||
#include "data/data_changes.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_user.h"
|
|
||||||
#include "data/data_drafts.h"
|
|
||||||
#include "data/data_session.h"
|
|
||||||
#include "data/data_histories.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "api/api_invite_links.h"
|
#include "api/api_invite_links.h"
|
||||||
#include "ui/boxes/edit_invite_link.h"
|
#include "ui/boxes/edit_invite_link.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
|
||||||
#include "ui/abstract_button.h"
|
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
|
||||||
#include "ui/widgets/input_fields.h"
|
|
||||||
#include "ui/controls/invite_link_label.h"
|
|
||||||
#include "ui/controls/invite_link_buttons.h"
|
|
||||||
#include "ui/text/text_utilities.h"
|
|
||||||
#include "ui/toast/toast.h"
|
|
||||||
#include "history/view/history_view_group_call_tracker.h" // GenerateUs...
|
|
||||||
#include "history/history_message.h" // GetErrorTextForSending.
|
|
||||||
#include "history/history.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "boxes/peer_list_box.h"
|
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
|
#include "boxes/peers/edit_peer_invite_link.h"
|
||||||
#include "settings/settings_common.h" // AddDivider.
|
#include "settings/settings_common.h" // AddDivider.
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "boxes/share_box.h"
|
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "window/window_session_controller.h"
|
|
||||||
#include "api/api_common.h"
|
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_layers.h" // st::boxDividerLabel
|
#include "styles/style_layers.h" // st::boxDividerLabel
|
||||||
#include "styles/style_settings.h" // st::settingsDividerLabelPadding
|
#include "styles/style_settings.h" // st::settingsDividerLabelPadding
|
||||||
|
|
||||||
#include <xxhash.h>
|
#include <xxhash.h>
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kPreloadPages = 2;
|
constexpr auto kPreloadPages = 2;
|
||||||
|
@ -189,95 +167,15 @@ private:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyLink(const QString &link) {
|
|
||||||
QGuiApplication::clipboard()->setText(link);
|
|
||||||
Ui::Toast::Show(tr::lng_group_invite_copied(tr::now));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareLinkBox(not_null<PeerData*> peer, const QString &link) {
|
|
||||||
const auto session = &peer->session();
|
|
||||||
const auto sending = std::make_shared<bool>();
|
|
||||||
const auto box = std::make_shared<QPointer<ShareBox>>();
|
|
||||||
|
|
||||||
auto copyCallback = [=] {
|
|
||||||
QGuiApplication::clipboard()->setText(link);
|
|
||||||
Ui::Toast::Show(tr::lng_group_invite_copied(tr::now));
|
|
||||||
};
|
|
||||||
auto submitCallback = [=](
|
|
||||||
std::vector<not_null<PeerData*>> &&result,
|
|
||||||
TextWithTags &&comment,
|
|
||||||
Api::SendOptions options) {
|
|
||||||
if (*sending || result.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto error = [&] {
|
|
||||||
for (const auto peer : result) {
|
|
||||||
const auto error = GetErrorTextForSending(
|
|
||||||
peer,
|
|
||||||
{},
|
|
||||||
comment);
|
|
||||||
if (!error.isEmpty()) {
|
|
||||||
return std::make_pair(error, peer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::make_pair(QString(), result.front());
|
|
||||||
}();
|
|
||||||
if (!error.first.isEmpty()) {
|
|
||||||
auto text = TextWithEntities();
|
|
||||||
if (result.size() > 1) {
|
|
||||||
text.append(
|
|
||||||
Ui::Text::Bold(error.second->name)
|
|
||||||
).append("\n\n");
|
|
||||||
}
|
|
||||||
text.append(error.first);
|
|
||||||
Ui::show(
|
|
||||||
Box<InformBox>(text),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
*sending = true;
|
|
||||||
if (!comment.text.isEmpty()) {
|
|
||||||
comment.text = link + "\n" + comment.text;
|
|
||||||
const auto add = link.size() + 1;
|
|
||||||
for (auto &tag : comment.tags) {
|
|
||||||
tag.offset += add;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const auto owner = &peer->owner();
|
|
||||||
auto &api = peer->session().api();
|
|
||||||
auto &histories = owner->histories();
|
|
||||||
const auto requestType = Data::Histories::RequestType::Send;
|
|
||||||
for (const auto peer : result) {
|
|
||||||
const auto history = owner->history(peer);
|
|
||||||
auto message = ApiWrap::MessageToSend(history);
|
|
||||||
message.textWithTags = comment;
|
|
||||||
message.action.options = options;
|
|
||||||
message.action.clearDraft = false;
|
|
||||||
api.sendMessage(std::move(message));
|
|
||||||
}
|
|
||||||
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
|
||||||
if (*box) {
|
|
||||||
(*box)->closeBox();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
auto filterCallback = [](PeerData *peer) {
|
|
||||||
return peer->canWrite();
|
|
||||||
};
|
|
||||||
*box = Ui::show(Box<ShareBox>(
|
|
||||||
App::wnd()->sessionController(),
|
|
||||||
std::move(copyCallback),
|
|
||||||
std::move(submitCallback),
|
|
||||||
std::move(filterCallback)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditLink(not_null<PeerData*> peer, const InviteLinkData &data) {
|
void EditLink(not_null<PeerData*> peer, const InviteLinkData &data) {
|
||||||
const auto creating = data.link.isEmpty();
|
const auto creating = data.link.isEmpty();
|
||||||
const auto box = std::make_shared<QPointer<Ui::GenericBox>>();
|
const auto box = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||||
using Fields = Ui::InviteLinkFields;
|
using Fields = Ui::InviteLinkFields;
|
||||||
const auto done = [=](Fields result) {
|
const auto done = [=](Fields result) {
|
||||||
const auto finish = [=](Api::InviteLink finished) {
|
const auto finish = [=](Api::InviteLink finished) {
|
||||||
|
if (creating) {
|
||||||
|
ShowInviteLinkBox(peer, finished);
|
||||||
|
}
|
||||||
if (*box) {
|
if (*box) {
|
||||||
(*box)->closeBox();
|
(*box)->closeBox();
|
||||||
}
|
}
|
||||||
|
@ -511,6 +409,7 @@ private:
|
||||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||||
|
|
||||||
QString _offsetLink;
|
QString _offsetLink;
|
||||||
|
TimeId _offsetDate = 0;
|
||||||
bool _requesting = false;
|
bool _requesting = false;
|
||||||
bool _allLoaded = false;
|
bool _allLoaded = false;
|
||||||
|
|
||||||
|
@ -590,6 +489,7 @@ void Controller::loadMoreRows() {
|
||||||
};
|
};
|
||||||
_peer->session().api().inviteLinks().requestMoreLinks(
|
_peer->session().api().inviteLinks().requestMoreLinks(
|
||||||
_peer,
|
_peer,
|
||||||
|
_offsetDate,
|
||||||
_offsetLink,
|
_offsetLink,
|
||||||
_revoked,
|
_revoked,
|
||||||
crl::guard(this, done));
|
crl::guard(this, done));
|
||||||
|
@ -602,6 +502,7 @@ void Controller::appendSlice(const InviteLinksSlice &slice) {
|
||||||
appendRow(link, now);
|
appendRow(link, now);
|
||||||
}
|
}
|
||||||
_offsetLink = link.link;
|
_offsetLink = link.link;
|
||||||
|
_offsetDate = link.date;
|
||||||
}
|
}
|
||||||
if (slice.links.size() >= slice.count) {
|
if (slice.links.size() >= slice.count) {
|
||||||
_allLoaded = true;
|
_allLoaded = true;
|
||||||
|
@ -610,7 +511,7 @@ void Controller::appendSlice(const InviteLinksSlice &slice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::rowClicked(not_null<PeerListRow*> row) {
|
void Controller::rowClicked(not_null<PeerListRow*> row) {
|
||||||
// #TODO links show
|
ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::rowActionClicked(not_null<PeerListRow*> row) {
|
void Controller::rowActionClicked(not_null<PeerListRow*> row) {
|
||||||
|
@ -647,32 +548,16 @@ base::unique_qptr<Ui::PopupMenu> Controller::createRowContextMenu(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
result->addAction(tr::lng_group_invite_context_copy(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_copy(tr::now), [=] {
|
||||||
CopyLink(link);
|
CopyInviteLink(link);
|
||||||
});
|
});
|
||||||
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
|
||||||
ShareLinkBox(_peer, link);
|
ShareInviteLinkBox(_peer, link);
|
||||||
});
|
});
|
||||||
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
|
||||||
EditLink(_peer, data);
|
EditLink(_peer, data);
|
||||||
});
|
});
|
||||||
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
|
||||||
const auto box = std::make_shared<QPointer<ConfirmBox>>();
|
RevokeLink(_peer, link);
|
||||||
const auto revoke = crl::guard(this, [=] {
|
|
||||||
const auto done = crl::guard(this, [=](InviteLinkData data) {
|
|
||||||
if (*box) {
|
|
||||||
(*box)->closeBox();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_peer->session().api().inviteLinks().revoke(
|
|
||||||
_peer,
|
|
||||||
link,
|
|
||||||
done);
|
|
||||||
});
|
|
||||||
*box = Ui::show(
|
|
||||||
Box<ConfirmBox>(
|
|
||||||
tr::lng_group_invite_revoke_about(tr::now),
|
|
||||||
revoke),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -800,178 +685,6 @@ void Controller::rowPaintIcon(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void AddPermanentLinkBlock(
|
|
||||||
not_null<Ui::VerticalLayout*> container,
|
|
||||||
not_null<PeerData*> peer) {
|
|
||||||
const auto computePermanentLink = [=] {
|
|
||||||
const auto &links = peer->session().api().inviteLinks().links(
|
|
||||||
peer).links;
|
|
||||||
const auto link = links.empty() ? nullptr : &links.front();
|
|
||||||
return (link && link->permanent && !link->revoked) ? link : nullptr;
|
|
||||||
};
|
|
||||||
auto value = peer->session().changes().peerFlagsValue(
|
|
||||||
peer,
|
|
||||||
Data::PeerUpdate::Flag::InviteLinks
|
|
||||||
) | rpl::map([=] {
|
|
||||||
const auto link = computePermanentLink();
|
|
||||||
return link
|
|
||||||
? std::make_tuple(link->link, link->usage)
|
|
||||||
: std::make_tuple(QString(), 0);
|
|
||||||
}) | rpl::distinct_until_changed(
|
|
||||||
) | rpl::start_spawning(container->lifetime());
|
|
||||||
|
|
||||||
const auto weak = Ui::MakeWeak(container);
|
|
||||||
const auto copyLink = crl::guard(weak, [=] {
|
|
||||||
if (const auto link = computePermanentLink()) {
|
|
||||||
CopyLink(link->link);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const auto shareLink = crl::guard(weak, [=] {
|
|
||||||
if (const auto link = computePermanentLink()) {
|
|
||||||
ShareLinkBox(peer, link->link);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const auto revokeLink = crl::guard(weak, [=] {
|
|
||||||
const auto box = std::make_shared<QPointer<ConfirmBox>>();
|
|
||||||
const auto done = crl::guard(weak, [=] {
|
|
||||||
const auto close = [=](auto&&) {
|
|
||||||
if (*box) {
|
|
||||||
(*box)->closeBox();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
peer->session().api().inviteLinks().revokePermanent(peer, close);
|
|
||||||
});
|
|
||||||
*box = Ui::show(
|
|
||||||
Box<ConfirmBox>(tr::lng_group_invite_about_new(tr::now), done),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto link = rpl::duplicate(
|
|
||||||
value
|
|
||||||
) | rpl::map([=](QString link, int usage) {
|
|
||||||
const auto prefix = qstr("https://");
|
|
||||||
return link.startsWith(prefix) ? link.mid(prefix.size()) : link;
|
|
||||||
});
|
|
||||||
const auto createMenu = [=] {
|
|
||||||
auto result = base::make_unique_q<Ui::PopupMenu>(container);
|
|
||||||
result->addAction(
|
|
||||||
tr::lng_group_invite_context_copy(tr::now),
|
|
||||||
copyLink);
|
|
||||||
result->addAction(
|
|
||||||
tr::lng_group_invite_context_share(tr::now),
|
|
||||||
shareLink);
|
|
||||||
result->addAction(
|
|
||||||
tr::lng_group_invite_context_revoke(tr::now),
|
|
||||||
revokeLink);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
const auto label = container->lifetime().make_state<Ui::InviteLinkLabel>(
|
|
||||||
container,
|
|
||||||
std::move(link),
|
|
||||||
createMenu);
|
|
||||||
container->add(
|
|
||||||
label->take(),
|
|
||||||
st::inviteLinkFieldPadding);
|
|
||||||
|
|
||||||
label->clicks(
|
|
||||||
) | rpl::start_with_next(copyLink, label->lifetime());
|
|
||||||
|
|
||||||
AddCopyShareLinkButtons(
|
|
||||||
container,
|
|
||||||
copyLink,
|
|
||||||
shareLink);
|
|
||||||
|
|
||||||
struct JoinedState {
|
|
||||||
QImage cachedUserpics;
|
|
||||||
std::vector<HistoryView::UserpicInRow> list;
|
|
||||||
int count = 0;
|
|
||||||
bool allUserpicsLoaded = false;
|
|
||||||
rpl::variable<Ui::JoinedCountContent> content;
|
|
||||||
rpl::lifetime lifetime;
|
|
||||||
};
|
|
||||||
const auto state = container->lifetime().make_state<JoinedState>();
|
|
||||||
const auto push = [=] {
|
|
||||||
HistoryView::GenerateUserpicsInRow(
|
|
||||||
state->cachedUserpics,
|
|
||||||
state->list,
|
|
||||||
st::inviteLinkUserpics,
|
|
||||||
0);
|
|
||||||
state->allUserpicsLoaded = ranges::all_of(
|
|
||||||
state->list,
|
|
||||||
[](const HistoryView::UserpicInRow &element) {
|
|
||||||
return !element.peer->hasUserpic() || element.view->image();
|
|
||||||
});
|
|
||||||
state->content = Ui::JoinedCountContent{
|
|
||||||
.count = state->count,
|
|
||||||
.userpics = state->cachedUserpics
|
|
||||||
};
|
|
||||||
};
|
|
||||||
std::move(
|
|
||||||
value
|
|
||||||
) | rpl::map([=](QString link, int usage) {
|
|
||||||
return peer->session().api().inviteLinks().joinedFirstSliceValue(
|
|
||||||
peer,
|
|
||||||
link,
|
|
||||||
usage);
|
|
||||||
}) | rpl::flatten_latest(
|
|
||||||
) | rpl::start_with_next([=](const Api::JoinedByLinkSlice &slice) {
|
|
||||||
auto list = std::vector<HistoryView::UserpicInRow>();
|
|
||||||
list.reserve(slice.users.size());
|
|
||||||
for (const auto &item : slice.users) {
|
|
||||||
const auto i = ranges::find(
|
|
||||||
state->list,
|
|
||||||
item.user,
|
|
||||||
&HistoryView::UserpicInRow::peer);
|
|
||||||
if (i != end(state->list)) {
|
|
||||||
list.push_back(std::move(*i));
|
|
||||||
} else {
|
|
||||||
list.push_back({ item.user });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state->count = slice.count;
|
|
||||||
state->list = std::move(list);
|
|
||||||
push();
|
|
||||||
}, state->lifetime);
|
|
||||||
|
|
||||||
peer->session().downloaderTaskFinished(
|
|
||||||
) | rpl::filter([=] {
|
|
||||||
return !state->allUserpicsLoaded;
|
|
||||||
}) | rpl::start_with_next([=] {
|
|
||||||
auto pushing = false;
|
|
||||||
state->allUserpicsLoaded = true;
|
|
||||||
for (const auto &element : state->list) {
|
|
||||||
if (!element.peer->hasUserpic()) {
|
|
||||||
continue;
|
|
||||||
} else if (element.peer->userpicUniqueKey(element.view)
|
|
||||||
!= element.uniqueKey) {
|
|
||||||
pushing = true;
|
|
||||||
} else if (!element.view->image()) {
|
|
||||||
state->allUserpicsLoaded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pushing) {
|
|
||||||
push();
|
|
||||||
}
|
|
||||||
}, state->lifetime);
|
|
||||||
|
|
||||||
Ui::AddJoinedCountButton(
|
|
||||||
container,
|
|
||||||
state->content.value(),
|
|
||||||
st::inviteLinkJoinedRowPadding
|
|
||||||
)->setClickedCallback([=] {
|
|
||||||
});
|
|
||||||
|
|
||||||
container->add(object_ptr<Ui::SlideWrap<Ui::FixedHeightWidget>>(
|
|
||||||
container,
|
|
||||||
object_ptr<Ui::FixedHeightWidget>(
|
|
||||||
container,
|
|
||||||
st::inviteLinkJoinedRowPadding.bottom()))
|
|
||||||
)->setDuration(0)->toggleOn(state->content.value(
|
|
||||||
) | rpl::map([=](const Ui::JoinedCountContent &content) {
|
|
||||||
return (content.count <= 0);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<Ui::RpWidget*> AddLinksList(
|
not_null<Ui::RpWidget*> AddLinksList(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
@ -995,11 +708,14 @@ not_null<Ui::RpWidget*> AddLinksList(
|
||||||
void ManageInviteLinksBox(
|
void ManageInviteLinksBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer) {
|
||||||
|
using namespace Settings;
|
||||||
|
|
||||||
box->setTitle(tr::lng_group_invite_title());
|
box->setTitle(tr::lng_group_invite_title());
|
||||||
|
|
||||||
const auto container = box->verticalLayout();
|
const auto container = box->verticalLayout();
|
||||||
|
AddSubsectionTitle(container, tr::lng_create_permanent_link_title());
|
||||||
AddPermanentLinkBlock(container, peer);
|
AddPermanentLinkBlock(container, peer);
|
||||||
Settings::AddDivider(container);
|
AddDivider(container);
|
||||||
|
|
||||||
const auto add = AddCreateLinkButton(container);
|
const auto add = AddCreateLinkButton(container);
|
||||||
add->setClickedCallback([=] {
|
add->setClickedCallback([=] {
|
||||||
|
@ -1015,7 +731,8 @@ void ManageInviteLinksBox(
|
||||||
container,
|
container,
|
||||||
tr::lng_group_invite_add_about(),
|
tr::lng_group_invite_add_about(),
|
||||||
st::boxDividerLabel),
|
st::boxDividerLabel),
|
||||||
st::settingsDividerLabelPadding)));
|
st::settingsDividerLabelPadding)),
|
||||||
|
style::margins(0, st::inviteLinkCreateSkip, 0, 0));
|
||||||
const auto divider = container->add(object_ptr<Ui::SlideWrap<>>(
|
const auto divider = container->add(object_ptr<Ui::SlideWrap<>>(
|
||||||
container,
|
container,
|
||||||
object_ptr<Ui::BoxContentDivider>(container)));
|
object_ptr<Ui::BoxContentDivider>(container)));
|
||||||
|
|
|
@ -11,14 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
class PeerData;
|
class PeerData;
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class VerticalLayout;
|
|
||||||
} // namespace Ui
|
|
||||||
|
|
||||||
void AddPermanentLinkBlock(
|
|
||||||
not_null<Ui::VerticalLayout*> container,
|
|
||||||
not_null<PeerData*> peer);
|
|
||||||
|
|
||||||
void ManageInviteLinksBox(
|
void ManageInviteLinksBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer);
|
not_null<PeerData*> peer);
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/peers/edit_participants_box.h"
|
#include "boxes/peers/edit_participants_box.h"
|
||||||
#include "boxes/peers/edit_peer_info_box.h" // CreateButton.
|
#include "boxes/peers/edit_peer_info_box.h" // CreateButton.
|
||||||
|
#include "boxes/peers/edit_peer_invite_link.h"
|
||||||
#include "boxes/peers/edit_peer_invite_links.h"
|
#include "boxes/peers/edit_peer_invite_links.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -541,13 +542,8 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkBlock() {
|
||||||
|
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
container->add(
|
|
||||||
object_ptr<Ui::FlatLabel>(
|
|
||||||
container,
|
|
||||||
tr::lng_create_permanent_link_title(),
|
|
||||||
st::settingsSubsectionTitle),
|
|
||||||
st::settingsSubsectionTitlePadding);
|
|
||||||
|
|
||||||
|
AddSubsectionTitle(container, tr::lng_create_permanent_link_title());
|
||||||
AddPermanentLinkBlock(container, _peer);
|
AddPermanentLinkBlock(container, _peer);
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|
|
@ -105,6 +105,7 @@ bool SendActionPainter::updateNeedsAnimating(
|
||||||
_speaking.emplace_or_assign(
|
_speaking.emplace_or_assign(
|
||||||
user,
|
user,
|
||||||
now + kStatusShowClientsideSpeaking);
|
now + kStatusShowClientsideSpeaking);
|
||||||
|
}, [&](const MTPDsendMessageHistoryImportAction &) {
|
||||||
}, [&](const MTPDsendMessageCancelAction &) {
|
}, [&](const MTPDsendMessageCancelAction &) {
|
||||||
Unexpected("CancelAction here.");
|
Unexpected("CancelAction here.");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue