mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-21 00:23:56 +08:00
Fixed restoring pinned community dialogs on launch.
This commit is contained in:
@@ -1269,6 +1269,12 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||
} else if (!result->isLoaded()) {
|
||||
result->setLoadedStatus(PeerData::LoadedStatus::Normal);
|
||||
}
|
||||
if (!_pinnedCommunitiesNotLoaded.empty()) {
|
||||
if (const auto channel = result->asChannel()
|
||||
; channel && channel->isCommunity()) {
|
||||
checkPinnedCommunityLoaded(channel);
|
||||
}
|
||||
}
|
||||
if (flags) {
|
||||
session().changes().peerUpdated(result, flags);
|
||||
}
|
||||
@@ -2694,8 +2700,12 @@ void Session::applyDialog(
|
||||
const auto channelId = ChannelId(data.vcommunity_id().v);
|
||||
const auto channel = channelLoaded(channelId);
|
||||
if (!channel || !channel->isCommunity()) {
|
||||
if (data.is_pinned()) {
|
||||
_pinnedCommunitiesNotLoaded.emplace(channelId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
_pinnedCommunitiesNotLoaded.remove(channelId);
|
||||
const auto history = this->history(channel);
|
||||
notifySettings().apply(
|
||||
peerFromChannel(channelId),
|
||||
@@ -2704,6 +2714,13 @@ void Session::applyDialog(
|
||||
setPinnedFromEntryList(history, data.is_pinned());
|
||||
}
|
||||
|
||||
void Session::checkPinnedCommunityLoaded(not_null<ChannelData*> channel) {
|
||||
if (!_pinnedCommunitiesNotLoaded.remove(peerToChannel(channel->id))) {
|
||||
return;
|
||||
}
|
||||
session().api().reloadPinnedDialogs();
|
||||
}
|
||||
|
||||
bool Session::pinnedCanPin(not_null<Dialogs::Entry*> entry) const {
|
||||
if ([[maybe_unused]] const auto sublist = entry->asSublist()) {
|
||||
if (sublist->parentChat()) {
|
||||
@@ -2831,6 +2848,9 @@ const std::vector<Dialogs::Key> &Session::pinnedChatsOrder(
|
||||
}
|
||||
|
||||
void Session::clearPinnedChats(Data::Folder *folder) {
|
||||
if (!folder) {
|
||||
_pinnedCommunitiesNotLoaded.clear();
|
||||
}
|
||||
chatsList(folder)->pinned()->clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user