2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Strictly match message / media types.

This commit is contained in:
John Preston
2018-12-17 12:16:06 +04:00
parent 6d9f40db30
commit eb7201a55b
13 changed files with 292 additions and 303 deletions

View File

@@ -874,22 +874,20 @@ namespace App {
return false;
}
void updateEditedMessage(const MTPMessage &m) {
auto apply = [](const auto &data) {
auto peerId = peerFromMTP(data.vto_id);
if (data.has_from_id() && peerId == Auth().userPeerId()) {
peerId = peerFromUser(data.vfrom_id);
void updateEditedMessage(const MTPMessage &message) {
message.match([](const MTPDmessageEmpty &) {
}, [](const auto &message) {
auto peerId = peerFromMTP(message.vto_id);
if (message.has_from_id() && peerId == Auth().userPeerId()) {
peerId = peerFromUser(message.vfrom_id);
}
if (auto existing = App::histItemById(peerToChannel(peerId), data.vid.v)) {
existing->applyEdition(data);
const auto existing = App::histItemById(
peerToChannel(peerId),
message.vid.v);
if (existing) {
existing->applyEdition(message);
}
};
if (m.type() == mtpc_message) { // apply message edit
apply(m.c_message());
} else if (m.type() == mtpc_messageService) {
apply(m.c_messageService());
}
});
}
void addSavedGif(DocumentData *doc) {
@@ -932,7 +930,7 @@ namespace App {
}
}
}
const auto msgId = idFromMessage(msg);
const auto msgId = IdFromMessage(msg);
indices.emplace((uint64(uint32(msgId)) << 32) | uint64(i), i);
}
for (const auto [position, index] : indices) {