From 63129072ba818037525c9370be0f7bdcb938c6f9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 13 Apr 2020 13:35:36 +0400 Subject: [PATCH] Mark voice/video message as read on mention click. Fixes #5623. --- .../SourceFiles/history/history_widget.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index c11995f288..367dadc515 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2913,7 +2913,26 @@ void HistoryWidget::historyDownClicked() { } void HistoryWidget::showNextUnreadMention() { - showHistory(_peer->id, _history->getMinLoadedUnreadMention()); + const auto msgId = _history->getMinLoadedUnreadMention(); + const auto already = (_showAtMsgId == msgId); + + // Mark mention voice/video message as read. + // See https://github.com/telegramdesktop/tdesktop/issues/5623 + if (msgId && already) { + const auto item = _history->owner().message( + _history->channelId(), + msgId); + if (const auto media = item ? item->media() : nullptr) { + if (const auto document = media->document()) { + if (!media->webpage() + && (document->isVoiceMessage() + || document->isVideoMessage())) { + document->owner().markMediaRead(document); + } + } + } + } + showHistory(_peer->id, msgId); } void HistoryWidget::saveEditMsg() {