mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Implement unpin all messages within a thread.
This commit is contained in:
parent
1ac051a812
commit
6d215d3729
6 changed files with 38 additions and 9 deletions
|
@ -1734,7 +1734,7 @@ messages.getOldFeaturedStickers#7ed094a1 offset:int limit:int hash:long = messag
|
|||
messages.getReplies#22ddd30c peer:InputPeer msg_id:int offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages;
|
||||
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
||||
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
||||
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
||||
messages.unpinAllMessages#ee22b9a8 flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory;
|
||||
messages.deleteChat#5bd0ee50 chat_id:long = Bool;
|
||||
messages.deletePhoneCallHistory#f9cbe409 flags:# revoke:flags.0?true = messages.AffectedFoundMessages;
|
||||
messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed;
|
||||
|
|
|
@ -149,6 +149,8 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
|
|||
session->storage().sharedMediaAllRemoved(
|
||||
) | rpl::filter([=](const AllRemoved &update) {
|
||||
return (update.peerId == key.peerId)
|
||||
&& (!update.topicRootId
|
||||
|| update.topicRootId == key.topicRootId)
|
||||
&& update.types.test(key.type);
|
||||
}) | rpl::filter([=] {
|
||||
return builder->removeAll();
|
||||
|
|
|
@ -550,13 +550,25 @@ void History::unpinMessagesFor(MsgId topicRootId) {
|
|||
topic->setHasPinnedMessages(false);
|
||||
});
|
||||
}
|
||||
for (const auto &message : _messages) {
|
||||
if (message->isPinned()) {
|
||||
message->setIsPinned(false);
|
||||
for (const auto &item : _messages) {
|
||||
if (item->isPinned()) {
|
||||
item->setIsPinned(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// #TODO forum pinned
|
||||
session().storage().remove(
|
||||
Storage::SharedMediaRemoveAll(
|
||||
peer->id,
|
||||
topicRootId,
|
||||
Storage::SharedMediaType::Pinned));
|
||||
if (const auto topic = peer->forumTopicFor(topicRootId)) {
|
||||
topic->setHasPinnedMessages(false);
|
||||
}
|
||||
for (const auto &item : _messages) {
|
||||
if (item->isPinned() && item->topicRootId() == topicRootId) {
|
||||
item->setIsPinned(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,11 @@ void SharedMedia::remove(SharedMediaRemoveOne &&query) {
|
|||
}
|
||||
|
||||
void SharedMedia::remove(SharedMediaRemoveAll &&query) {
|
||||
auto peerIt = _lists.lower_bound({ query.peerId, MsgId(0) });
|
||||
while (peerIt != end(_lists) && peerIt->first.peerId == query.peerId) {
|
||||
auto peerIt = _lists.lower_bound({ query.peerId, query.topicRootId });
|
||||
while (peerIt != end(_lists)
|
||||
&& peerIt->first.peerId == query.peerId
|
||||
&& (!query.topicRootId
|
||||
|| peerIt->first.topicRootId == query.topicRootId)) {
|
||||
for (auto index = 0; index != kSharedMediaTypeCount; ++index) {
|
||||
auto type = static_cast<SharedMediaType>(index);
|
||||
if (query.types.test(type)) {
|
||||
|
|
|
@ -124,8 +124,17 @@ struct SharedMediaRemoveAll {
|
|||
: peerId(peerId)
|
||||
, types(types) {
|
||||
}
|
||||
SharedMediaRemoveAll(
|
||||
PeerId peerId,
|
||||
MsgId topicRootId,
|
||||
SharedMediaTypesMask types = SharedMediaTypesMask::All())
|
||||
: peerId(peerId)
|
||||
, topicRootId(topicRootId)
|
||||
, types(types) {
|
||||
}
|
||||
|
||||
PeerId peerId = 0;
|
||||
MsgId topicRootId = 0;
|
||||
SharedMediaTypesMask types;
|
||||
|
||||
};
|
||||
|
|
|
@ -1757,15 +1757,18 @@ void UnpinAllMessages(
|
|||
const auto callback = crl::guard(navigation, [=](Fn<void()> &&close) {
|
||||
close();
|
||||
const auto strong = weak.get();
|
||||
if (!strong || !strong->asHistory()) { // #TODO forum pinned
|
||||
if (!strong) {
|
||||
return;
|
||||
}
|
||||
const auto api = &strong->session().api();
|
||||
const auto sendRequest = [=](auto self) -> void {
|
||||
const auto history = strong->owningHistory();
|
||||
const auto topicRootId = strong->topicRootId();
|
||||
using Flag = MTPmessages_UnpinAllMessages::Flag;
|
||||
api->request(MTPmessages_UnpinAllMessages(
|
||||
history->peer->input
|
||||
MTP_flags(topicRootId ? Flag::f_top_msg_id : Flag()),
|
||||
history->peer->input,
|
||||
MTP_int(topicRootId.bare)
|
||||
)).done([=](const MTPmessages_AffectedHistory &result) {
|
||||
const auto peer = history->peer;
|
||||
const auto offset = api->applyAffectedHistory(peer, result);
|
||||
|
|
Loading…
Add table
Reference in a new issue