From c6f66e83ee5db735cee8ee763f031215b6b9a612 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 1 Oct 2020 16:53:39 +0300 Subject: [PATCH] Fix restriction label display. Fixes #8680. --- .../view/history_view_compose_controls.cpp | 22 +++++++++++++------ .../view/history_view_compose_controls.h | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp index c033bfe167..f12284d346 100644 --- a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp @@ -732,6 +732,7 @@ void ComposeControls::showStarted() { _tabbedPanel->hideFast(); } _wrap->hide(); + _writeRestricted->hide(); } void ComposeControls::showFinished() { @@ -741,7 +742,7 @@ void ComposeControls::showFinished() { if (_tabbedPanel) { _tabbedPanel->hideFast(); } - _wrap->show(); + updateWrappingVisibility(); } void ComposeControls::showForGrab() { @@ -1078,15 +1079,22 @@ void ComposeControls::initWriteRestriction() { }, _wrap->lifetime()); _writeRestriction.value( - ) | rpl::start_with_next([=](const std::optional &error) { - _writeRestricted->setVisible(error.has_value()); - _wrap->setVisible(!error.has_value()); - if (!error.has_value()) { - _wrap->raise(); - } + ) | rpl::filter([=] { + return _wrap->isHidden() || _writeRestricted->isHidden(); + }) | rpl::start_with_next([=] { + updateWrappingVisibility(); }, _wrap->lifetime()); } +void ComposeControls::updateWrappingVisibility() { + const auto restricted = _writeRestriction.current().has_value(); + _writeRestricted->setVisible(restricted); + _wrap->setVisible(!restricted); + if (!restricted) { + _wrap->raise(); + } +} + void ComposeControls::updateSendButtonType() { using Type = Ui::SendButton::Type; const auto type = [&] { diff --git a/Telegram/SourceFiles/history/view/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/history_view_compose_controls.h index 68f008206b..6b1b2f0a1a 100644 --- a/Telegram/SourceFiles/history/view/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/history_view_compose_controls.h @@ -163,6 +163,7 @@ private: void initWriteRestriction(); void updateSendButtonType(); void updateHeight(); + void updateWrappingVisibility(); void updateControlsVisibility(); void updateControlsGeometry(QSize size); void updateOuterGeometry(QRect rect); @@ -176,7 +177,6 @@ private: void setTextFromEditingMessage(not_null item); - void recordError(); void recordUpdated(quint16 level, int samples); void recordDone(QByteArray result, VoiceWaveform waveform, int samples);