2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Add pinned messages section.

This commit is contained in:
John Preston
2020-10-20 19:29:24 +03:00
parent aefef948cd
commit fc92e3fadd
26 changed files with 1142 additions and 343 deletions

View File

@@ -177,7 +177,6 @@ void History::itemVanished(not_null<HistoryItem*> item) {
&& unreadCount() > 0) {
setUnreadCount(unreadCount() - 1);
}
peer->removePinnedMessage(item->id);
}
void History::setLocalDraft(std::unique_ptr<Data::Draft> &&draft) {
@@ -707,9 +706,6 @@ not_null<HistoryItem*> History::addNewToBack(
item->id,
{ from, till }));
}
if (item->isPinned()) {
item->history()->peer->addPinnedMessage(item->id);
}
}
if (item->from()->id) {
if (auto user = item->from()->asUser()) {
@@ -1007,10 +1003,11 @@ void History::applyServiceChanges(
replyTo->match([&](const MTPDmessageReplyHeader &data) {
const auto id = data.vreply_to_msg_id().v;
if (item) {
item->history()->peer->addPinnedSlice(
session().storage().add(Storage::SharedMediaAddSlice(
peer->id,
Storage::SharedMediaType::Pinned,
{ id },
{ id, ServerMaxMsgId },
std::nullopt);
{ id, ServerMaxMsgId }));
}
});
}
@@ -1164,7 +1161,6 @@ void History::addEdgesToSharedMedia() {
{},
{ from, till }));
}
peer->addPinnedSlice({}, { from, till }, std::nullopt);
}
void History::addOlderSlice(const QVector<MTPMessage> &slice) {
@@ -1328,7 +1324,6 @@ void History::checkAddAllToUnreadMentions() {
void History::addToSharedMedia(
const std::vector<not_null<HistoryItem*>> &items) {
auto pinned = std::vector<MsgId>();
std::vector<MsgId> medias[Storage::kSharedMediaTypeCount];
for (const auto item : items) {
if (const auto types = item->sharedMediaTypes()) {
@@ -1342,12 +1337,6 @@ void History::addToSharedMedia(
}
}
}
if (item->isPinned()) {
if (pinned.empty()) {
pinned.reserve(items.size());
}
pinned.push_back(item->id);
}
}
const auto from = loadedAtTop() ? 0 : minMsgId();
const auto till = loadedAtBottom() ? ServerMaxMsgId : maxMsgId();
@@ -1361,7 +1350,6 @@ void History::addToSharedMedia(
{ from, till }));
}
}
peer->addPinnedSlice(std::move(pinned), { from, till }, std::nullopt);
}
void History::calculateFirstUnreadMessage() {
@@ -3029,7 +3017,6 @@ void History::clear(ClearType type) {
clearSharedMedia();
clearLastKeyboard();
if (const auto channel = peer->asChannel()) {
channel->clearPinnedMessages();
//if (const auto feed = channel->feed()) { // #feed
// // Should be after resetting the _lastMessage.
// feed->historyCleared(this);