Fix transcribe animation glitch in message view refresh.

This commit is contained in:
John Preston 2022-06-15 15:09:08 +04:00
parent 6553e4492c
commit 1d64a03804
2 changed files with 14 additions and 7 deletions

View file

@ -126,11 +126,15 @@ void TranscribeButton::setOpened(bool opened, Fn<void()> update) {
return;
}
_opened = opened;
_openedAnimation.start(
std::move(update),
_opened ? 0. : 1.,
_opened ? 1. : 0.,
st::fadeWrapDuration);
if (update) {
_openedAnimation.start(
std::move(update),
_opened ? 0. : 1.,
_opened ? 1. : 0.,
st::fadeWrapDuration);
} else {
_openedAnimation.stop();
}
}
ClickHandlerPtr TranscribeButton::link() {

View file

@ -243,7 +243,8 @@ QSize Document::countOptimalSize() {
voice->transcribe = nullptr;
voice->transcribeText = {};
} else {
if (!voice->transcribe) {
const auto creating = !voice->transcribe;
if (creating) {
voice->transcribe = std::make_unique<TranscribeButton>(
_realParent);
}
@ -262,7 +263,9 @@ QSize Document::countOptimalSize() {
: TextWithEntities{
entry.result + (entry.pending ? " [...]" : ""),
};
voice->transcribe->setOpened(!text.empty(), update);
voice->transcribe->setOpened(
!text.empty(),
creating ? Fn<void()>() : update);
if (text.empty()) {
voice->transcribeText = {};
} else {