Fix animated stickers extension.

GitOrigin-RevId: 69d65bd19e46fe2eb2dc6ebb4afd6dd64164ffc9
This commit is contained in:
levlam 2019-07-18 19:47:29 +03:00
parent 7081198275
commit e76c98ad74
3 changed files with 18 additions and 17 deletions

View File

@ -25267,7 +25267,7 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m
// There are many ways of handling a gap in a channel: // There are many ways of handling a gap in a channel:
// 1) Delete all known messages in the chat, begin from scratch. It is easy to implement, but suddenly disappearing // 1) Delete all known messages in the chat, begin from scratch. It is easy to implement, but suddenly disappearing
// messages looks awful for the user. // messages looks awful for the user.
// 2) Save all messages loaded in the memory until application restart, but delete all messages from database. // 2) Save all messages loaded in the memory until application restart, but delete all messages from the database.
// Messages left in the memory must be lazily updated using calls to getHistory. It looks much smoothly for the // Messages left in the memory must be lazily updated using calls to getHistory. It looks much smoothly for the
// user, he will need to redownload messages only after client restart. Unsynchronized messages left in the // user, he will need to redownload messages only after client restart. Unsynchronized messages left in the
// memory shouldn't be saved to database, results of getHistory and getMessage must be used to update state of // memory shouldn't be saved to database, results of getHistory and getMessage must be used to update state of

View File

@ -1272,11 +1272,13 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(
return {}; return {};
} }
bool is_animated = document->mime_type_ == "application/x-tgsticker";
int64 document_id = document->id_; int64 document_id = document->id_;
FileId sticker_id = td_->file_manager_->register_remote( FileId sticker_id =
FullRemoteFileLocation(FileType::Sticker, document_id, document->access_hash_, dc_id, td_->file_manager_->register_remote(FullRemoteFileLocation(FileType::Sticker, document_id, document->access_hash_,
document->file_reference_.as_slice().str()), dc_id, document->file_reference_.as_slice().str()),
FileLocationSource::FromServer, DialogId(), document->size_, 0, PSTRING() << document_id << ".webp"); FileLocationSource::FromServer, DialogId(), document->size_, 0,
PSTRING() << document_id << (is_animated ? ".tgs" : ".webp"));
PhotoSize thumbnail; PhotoSize thumbnail;
for (auto &thumb : document->thumbs_) { for (auto &thumb : document->thumbs_) {
@ -1291,8 +1293,7 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(
} }
} }
create_sticker(sticker_id, std::move(thumbnail), dimensions, std::move(sticker), create_sticker(sticker_id, std::move(thumbnail), dimensions, std::move(sticker), is_animated, nullptr);
document->mime_type_ == "application/x-tgsticker", nullptr);
return {document_id, sticker_id}; return {document_id, sticker_id};
} }

View File

@ -1343,16 +1343,16 @@ Result<FileId> FileManager::merge(FileId x_file_id, FileId y_file_id, bool no_sy
return Status::Error("Can't merge files. Different encryption keys"); return Status::Error("Can't merge files. Different encryption keys");
} }
} }
if (trusted_by_source == 0) { // if new is more trusted
// prefer more trusted source
if (remote_name_i == 2) { if (remote_name_i == 2) {
remote_name_i = 0; remote_name_i = trusted_by_source;
} }
if (url_i == 2) { if (url_i == 2) {
url_i = 0; url_i = trusted_by_source;
} }
if (expected_size_i == 2) { if (expected_size_i == 2) {
expected_size_i = 0; expected_size_i = trusted_by_source;
}
} }
int node_i = int node_i =