| 472 | } |
| 473 | |
| 474 | void EditCaptionBox::rebuildPreview() { |
| 475 | const auto gifPaused = [controller = _controller] { |
| 476 | return controller->isGifPausedAtLeastFor( |
| 477 | Window::GifPauseReason::Layer); |
| 478 | }; |
| 479 | |
| 480 | applyChanges(); |
| 481 | |
| 482 | if (_preparedList.files.empty()) { |
| 483 | const auto media = _historyItem->media(); |
| 484 | const auto photo = media->photo(); |
| 485 | const auto document = media->document(); |
| 486 | _isPhoto = (photo != nullptr); |
| 487 | _isVideo = (document != nullptr) && document->isVideoFile(); |
| 488 | if (_isPhoto || _isVideo || document->isAnimation()) { |
| 489 | const auto media = Ui::CreateChild<Ui::ItemSingleMediaPreview>( |
| 490 | this, |
| 491 | st::defaultComposeControls, |
| 492 | gifPaused, |
| 493 | _historyItem, |
| 494 | Ui::AttachControls::Type::EditOnly); |
| 495 | _photoMedia = media->sharedPhotoMedia(); |
| 496 | _content.reset(media); |
| 497 | } else { |
| 498 | _content.reset(Ui::CreateChild<Ui::ItemSingleFilePreview>( |
| 499 | this, |
| 500 | st::defaultComposeControls, |
| 501 | _historyItem, |
| 502 | Ui::AttachControls::Type::EditOnly)); |
| 503 | } |
| 504 | } else { |
| 505 | const auto &file = _preparedList.files.front(); |
| 506 | _isVideo = file.isVideoFile(); |
| 507 | const auto media = Ui::SingleMediaPreview::Create( |
| 508 | this, |
| 509 | st::defaultComposeControls, |
| 510 | gifPaused, |
| 511 | file, |
| 512 | Ui::AttachControls::Type::EditOnly); |
| 513 | _isPhoto = (media && media->isPhoto()); |
| 514 | if (media && !_asFile) { |
| 515 | media->setSendWay(currentSendWay()); |
| 516 | media->setCanShowHighQualityBadge(file.canUseHighQualityPhoto()); |
| 517 | _content.reset(media); |
| 518 | } else { |
| 519 | _content.reset(Ui::CreateChild<Ui::SingleFilePreview>( |
| 520 | this, |
| 521 | st::defaultComposeControls, |
| 522 | file, |
| 523 | Ui::AttachControls::Type::EditOnly)); |
| 524 | } |
| 525 | } |
| 526 | Assert(_content != nullptr); |
| 527 | |
| 528 | rpl::combine( |
| 529 | _content->heightValue(), |
| 530 | _footerHeight.value(), |
| 531 | rpl::single(st::boxPhotoPadding.top()), |
nothing calls this directly
no test coverage detected