mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Refresh participants after transfer.
This commit is contained in:
parent
3c11eda611
commit
d23fd3559a
8 changed files with 87 additions and 8 deletions
|
@ -1755,7 +1755,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_admin_log_removed_linked_chat" = "{from} removed the discussion group";
|
"lng_admin_log_removed_linked_chat" = "{from} removed the discussion group";
|
||||||
"lng_admin_log_changed_linked_channel" = "{from} changed the linked channel to «{chat}»";
|
"lng_admin_log_changed_linked_channel" = "{from} changed the linked channel to «{chat}»";
|
||||||
"lng_admin_log_removed_linked_channel" = "{from} removed the linked channel";
|
"lng_admin_log_removed_linked_channel" = "{from} removed the linked channel";
|
||||||
"lng_admin_log_changed_location_chat" = "{from} changed the group location";
|
"lng_admin_log_changed_location_chat" = "{from} changed the group location to {address}";
|
||||||
"lng_admin_log_removed_location_chat" = "{from} removed the group location";
|
"lng_admin_log_removed_location_chat" = "{from} removed the group location";
|
||||||
"lng_admin_log_user_with_username" = "{name} ({mention})";
|
"lng_admin_log_user_with_username" = "{name} ({mention})";
|
||||||
"lng_admin_log_restricted_forever" = "indefinitely";
|
"lng_admin_log_restricted_forever" = "indefinitely";
|
||||||
|
|
|
@ -3572,7 +3572,9 @@ void ApiWrap::parseRecentChannelParticipants(
|
||||||
availableCount,
|
availableCount,
|
||||||
list);
|
list);
|
||||||
}
|
}
|
||||||
callbackList(availableCount, list);
|
if (callbackList) {
|
||||||
|
callbackList(availableCount, list);
|
||||||
|
}
|
||||||
}, std::move(callbackNotModified));
|
}, std::move(callbackNotModified));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ public:
|
||||||
const MTPchannels_ChannelParticipants &result,
|
const MTPchannels_ChannelParticipants &result,
|
||||||
Fn<void(
|
Fn<void(
|
||||||
int availableCount,
|
int availableCount,
|
||||||
const QVector<MTPChannelParticipant> &list)> callbackList,
|
const QVector<MTPChannelParticipant> &list)> callbackList = nullptr,
|
||||||
Fn<void()> callbackNotModified = nullptr);
|
Fn<void()> callbackNotModified = nullptr);
|
||||||
void addChatParticipants(
|
void addChatParticipants(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
|
|
@ -718,6 +718,9 @@ ParticipantsBoxController::ParticipantsBoxController(
|
||||||
if (_role == Role::Profile) {
|
if (_role == Role::Profile) {
|
||||||
setupListChangeViewers();
|
setupListChangeViewers();
|
||||||
}
|
}
|
||||||
|
if (const auto channel = _peer->asChannel()) {
|
||||||
|
subscribeToCreatorChange(channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticipantsBoxController::setupListChangeViewers() {
|
void ParticipantsBoxController::setupListChangeViewers() {
|
||||||
|
@ -1782,6 +1785,54 @@ void ParticipantsBoxController::subscribeToMigration() {
|
||||||
void ParticipantsBoxController::migrate(not_null<ChannelData*> channel) {
|
void ParticipantsBoxController::migrate(not_null<ChannelData*> channel) {
|
||||||
_peer = channel;
|
_peer = channel;
|
||||||
_additional.migrate(channel);
|
_additional.migrate(channel);
|
||||||
|
subscribeToCreatorChange(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticipantsBoxController::subscribeToCreatorChange(
|
||||||
|
not_null<ChannelData*> channel) {
|
||||||
|
const auto isCreator = channel->amCreator();
|
||||||
|
channel->flagsValue(
|
||||||
|
) | rpl::filter([](const ChannelData::Flags::Change &change) {
|
||||||
|
return (change.diff & MTPDchannel::Flag::f_creator);
|
||||||
|
}) | rpl::filter([=] {
|
||||||
|
return (isCreator != channel->amCreator());
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
if (channel->isBroadcast()) {
|
||||||
|
fullListRefresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto weak = base::make_weak(this);
|
||||||
|
const auto api = &channel->session().api();
|
||||||
|
api->request(MTPchannels_GetParticipants(
|
||||||
|
channel->inputChannel,
|
||||||
|
MTP_channelParticipantsRecent(),
|
||||||
|
MTP_int(0),
|
||||||
|
MTP_int(Global::ChatSizeMax()),
|
||||||
|
MTP_int(0)
|
||||||
|
)).done([=](const MTPchannels_ChannelParticipants &result) {
|
||||||
|
channel->mgInfo->creator = channel->amCreator()
|
||||||
|
? channel->session().user().get()
|
||||||
|
: nullptr;
|
||||||
|
channel->mgInfo->lastAdmins.clear();
|
||||||
|
channel->mgInfo->lastRestricted.clear();
|
||||||
|
channel->mgInfo->lastParticipants.clear();
|
||||||
|
api->parseRecentChannelParticipants(channel, result);
|
||||||
|
if (weak) {
|
||||||
|
fullListRefresh();
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticipantsBoxController::fullListRefresh() {
|
||||||
|
_additional = ParticipantsAdditionalData(_peer, _role);
|
||||||
|
|
||||||
|
while (const auto count = delegate()->peerListFullRowsCount()) {
|
||||||
|
delegate()->peerListRemoveRow(
|
||||||
|
delegate()->peerListRowAt(count - 1));
|
||||||
|
}
|
||||||
|
loadMoreRows();
|
||||||
|
delegate()->peerListRefreshRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticipantsBoxSearchController::ParticipantsBoxSearchController(
|
ParticipantsBoxSearchController::ParticipantsBoxSearchController(
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
UserData *applyBanned(const MTPDchannelParticipantBanned &data);
|
UserData *applyBanned(const MTPDchannelParticipantBanned &data);
|
||||||
void fillFromChat(not_null<ChatData*> chat);
|
void fillFromChat(not_null<ChatData*> chat);
|
||||||
void fillFromChannel(not_null<ChannelData*> channel);
|
void fillFromChannel(not_null<ChannelData*> channel);
|
||||||
|
void subscribeToCreatorChange(not_null<ChannelData*> channel);
|
||||||
|
|
||||||
not_null<PeerData*> _peer;
|
not_null<PeerData*> _peer;
|
||||||
Role _role = Role::Members;
|
Role _role = Role::Members;
|
||||||
|
@ -226,6 +227,8 @@ private:
|
||||||
|
|
||||||
void subscribeToMigration();
|
void subscribeToMigration();
|
||||||
void migrate(not_null<ChannelData*> channel);
|
void migrate(not_null<ChannelData*> channel);
|
||||||
|
void subscribeToCreatorChange(not_null<ChannelData*> channel);
|
||||||
|
void fullListRefresh();
|
||||||
|
|
||||||
not_null<Window::SessionNavigation*> _navigation;
|
not_null<Window::SessionNavigation*> _navigation;
|
||||||
not_null<PeerData*> _peer;
|
not_null<PeerData*> _peer;
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "history/admin_log/history_admin_log_inner.h"
|
#include "history/admin_log/history_admin_log_inner.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
|
#include "history/history_location_manager.h"
|
||||||
#include "history/history_service.h"
|
#include "history/history_service.h"
|
||||||
#include "history/history_message.h"
|
#include "history/history_message.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
@ -604,9 +605,25 @@ void GenerateItems(
|
||||||
};
|
};
|
||||||
|
|
||||||
auto createChangeLocation = [&](const MTPDchannelAdminLogEventActionChangeLocation &action) {
|
auto createChangeLocation = [&](const MTPDchannelAdminLogEventActionChangeLocation &action) {
|
||||||
const auto now = (action.vnew_value.type() != mtpc_channelLocationEmpty);
|
action.vnew_value.match([&](const MTPDchannelLocation &data) {
|
||||||
auto text = (now ? lng_admin_log_changed_location_chat : lng_admin_log_removed_location_chat)(lt_from, fromLinkText);
|
const auto address = qs(data.vaddress);
|
||||||
addSimpleServiceMessage(text);
|
const auto link = data.vgeo_point.match([&](const MTPDgeoPoint &data) {
|
||||||
|
return textcmdLink(
|
||||||
|
LocationClickHandler::Url(LocationCoords(data)),
|
||||||
|
address);
|
||||||
|
}, [&](const MTPDgeoPointEmpty &) {
|
||||||
|
return address;
|
||||||
|
});
|
||||||
|
const auto text = lng_admin_log_changed_location_chat(
|
||||||
|
lt_from,
|
||||||
|
fromLinkText,
|
||||||
|
lt_address,
|
||||||
|
link);
|
||||||
|
addSimpleServiceMessage(text);
|
||||||
|
}, [&](const MTPDchannelLocationEmpty &) {
|
||||||
|
const auto text = lng_admin_log_removed_location_chat(lt_from, fromLinkText);
|
||||||
|
addSimpleServiceMessage(text);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
action.match([&](const MTPDchannelAdminLogEventActionChangeTitle &data) {
|
action.match([&](const MTPDchannelAdminLogEventActionChangeTitle &data) {
|
||||||
|
|
|
@ -52,8 +52,12 @@ void LocationClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationClickHandler::setup() {
|
void LocationClickHandler::setup() {
|
||||||
auto latlon = _coords.latAsString() + ',' + _coords.lonAsString();
|
_text = Url(_coords);
|
||||||
_text = qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16");
|
}
|
||||||
|
|
||||||
|
QString LocationClickHandler::Url(const LocationCoords &coords) {
|
||||||
|
const auto latlon = coords.latAsString() + ',' + coords.lonAsString();
|
||||||
|
return qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16");
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationData::LocationData(const LocationCoords &coords)
|
LocationData::LocationData(const LocationCoords &coords)
|
||||||
|
|
|
@ -98,6 +98,8 @@ public:
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString Url(const LocationCoords &coords);
|
||||||
|
|
||||||
void onClick(ClickContext context) const override;
|
void onClick(ClickContext context) const override;
|
||||||
|
|
||||||
QString tooltip() const override {
|
QString tooltip() const override {
|
||||||
|
|
Loading…
Add table
Reference in a new issue