From fa773c3024daf6e90f564e4f0ea865c4d66c352a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 9 Jan 2024 20:42:50 +0300 Subject: [PATCH] Fixed incorrect seeking of voice messages with transcribe button. --- .../view/media/history_view_document.cpp | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index 1ea9d6fb9..32763b683 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -1262,18 +1262,22 @@ TextState Document::textState( void Document::updatePressed(QPoint point) { // LayoutMode should be passed here. if (const auto voice = Get()) { - if (voice->seeking()) { - const auto thumbed = Get(); - const auto &st = thumbed ? st::msgFileThumbLayout : st::msgFileLayout; - const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip; - const auto nameright = st.padding.right(); - voice->setSeekingCurrent(std::clamp( - (point.x() - nameleft) - / float64(width() - nameleft - nameright), - 0., - 1.)); - repaint(); + if (!voice->seeking()) { + return; } + const auto thumbed = Get(); + const auto &st = thumbed ? st::msgFileThumbLayout : st::msgFileLayout; + const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip; + const auto nameright = st.padding.right(); + const auto transcribeWidth = voice->transcribe + ? (st::historyTranscribeSkip + voice->transcribe->size().width()) + : 0; + voice->setSeekingCurrent(std::clamp( + (point.x() - nameleft) + / float64(width() - transcribeWidth - nameleft - nameright), + 0., + 1.)); + repaint(); } }