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

Fixed display photo with modifications as file in attach media preview.

This commit is contained in:
23rd
2022-03-04 18:57:04 +03:00
parent 0e08cffedb
commit f74a75da75
2 changed files with 20 additions and 9 deletions

View File

@@ -27,20 +27,29 @@ void OpenWithPreparedFile(
not_null<Ui::PreparedFile*> file,
int previewWidth,
Fn<void()> &&doneCallback) {
if (file->type != Ui::PreparedFile::Type::Photo) {
return;
}
using ImageInfo = Ui::PreparedFileInformation::Image;
const auto image = std::get_if<ImageInfo>(&file->information->media);
if (!image) {
return;
}
const auto photoType = (file->type == Ui::PreparedFile::Type::Photo);
const auto modifiedFileType = (file->type == Ui::PreparedFile::Type::File)
&& !image->modifications.empty();
if (!photoType && !modifiedFileType) {
return;
}
auto callback = [=, done = std::move(doneCallback)](
const PhotoModifications &mods) {
image->modifications = mods;
Storage::UpdateImageDetails(*file, previewWidth);
{
using namespace Ui;
const auto size = file->preview.size();
file->type = ValidateThumbDimensions(size.width(), size.height())
? PreparedFile::Type::Photo
: PreparedFile::Type::File;
}
done();
};
auto copy = image->data;