diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 003316997..2d0b7f92d 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -595,6 +595,10 @@ bool InnerWidget::elementHideReply(not_null view) { return true; } +bool InnerWidget::elementShownUnread(not_null view) { + return view->data()->unread(); +} + void InnerWidget::saveState(not_null memento) { memento->setFilter(std::move(_filter)); memento->setAdmins(std::move(_admins)); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h index bb35ce57b..bf8f97f86 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h @@ -114,6 +114,8 @@ public: bool elementIsGifPaused() override; bool elementHideReply( not_null view) override; + bool elementShownUnread( + not_null view) override; ~InnerWidget(); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index bc9e2a5c3..2fbd09a11 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -3411,6 +3411,9 @@ not_null HistoryInner::ElementDelegate() { bool elementHideReply(not_null view) override { return false; } + bool elementShownUnread(not_null view) override { + return view->data()->unread(); + } }; static Result result; diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 05ecfb17d..f8768d2c3 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -116,6 +116,11 @@ bool SimpleElementDelegate::elementHideReply(not_null view) { return false; } +bool SimpleElementDelegate::elementShownUnread( + not_null view) { + return view->data()->unread(); +} + TextSelection UnshiftItemSelection( TextSelection selection, uint16 byLength) { diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 5d598512c..654eea2f0 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -65,6 +65,7 @@ public: Fn hiddenCallback) = 0; virtual bool elementIsGifPaused() = 0; virtual bool elementHideReply(not_null view) = 0; + virtual bool elementShownUnread(not_null view) = 0; }; @@ -96,6 +97,7 @@ public: Fn hiddenCallback) override; bool elementIsGifPaused() override; bool elementHideReply(not_null view) override; + bool elementShownUnread(not_null view) override; private: const not_null _controller; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 9f413fdb3..e97eb03ed 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -1279,6 +1279,10 @@ bool ListWidget::elementHideReply(not_null view) { return _delegate->listElementHideReply(view); } +bool ListWidget::elementShownUnread(not_null view) { + return _delegate->listElementShownUnread(view); +} + void ListWidget::saveState(not_null memento) { memento->setAroundPosition(_aroundPosition); auto state = countScrollState(); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index 2c1ccb015..b758470a3 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -84,6 +84,7 @@ public: virtual void listContentRefreshed() = 0; virtual ClickHandlerPtr listDateLink(not_null view) = 0; virtual bool listElementHideReply(not_null view) = 0; + virtual bool listElementShownUnread(not_null view) = 0; virtual bool listIsGoodForAroundPosition( not_null view) = 0; @@ -229,6 +230,7 @@ public: Fn hiddenCallback) override; bool elementIsGifPaused() override; bool elementHideReply(not_null view) override; + bool elementShownUnread(not_null view) override; ~ListWidget(); diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 1104d8639..a0f4ca5f1 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1774,7 +1774,7 @@ void Message::drawInfo( if (outbg) { auto icon = [&] { if (item->id > 0) { - if (item->unread()) { + if (delegate()->elementShownUnread(this)) { return &(invertedsprites ? st::historySentInvertedIcon : (selected ? st::historySentSelectedIcon : st::historySentIcon)); } return &(invertedsprites ? st::historyReceivedInvertedIcon : (selected ? st::historyReceivedSelectedIcon : st::historyReceivedIcon)); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index f87f7073d..1fdb27598 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -211,6 +211,13 @@ RepliesWidget::RepliesWidget( } }, lifetime()); + _history->session().changes().historyUpdates( + _history, + Data::HistoryUpdate::Flag::OutboxRead + ) | rpl::start_with_next([=] { + _inner->update(); + }, lifetime()); + setupScrollDownButton(); setupComposeControls(); } @@ -252,6 +259,7 @@ void RepliesWidget::setupRoot() { if (_readRequestPending) { sendReadTillRequest(); } + _inner->update(); } updatePinnedVisibility(); refreshRootView(); @@ -1580,6 +1588,17 @@ bool RepliesWidget::listElementHideReply(not_null view) { return (view->data()->replyToId() == _rootId); } +bool RepliesWidget::listElementShownUnread(not_null view) { + if (!_root) { + return false; + } + const auto item = view->data(); + const auto till = item->out() + ? _root->computeRepliesOutboxReadTillFull() + : _root->computeRepliesInboxReadTillFull(); + return (item->id > till); +} + bool RepliesWidget::listIsGoodForAroundPosition( not_null view) { return IsServerMsgId(view->data()->id); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index 0e75cd9a1..91c5253cd 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -123,6 +123,7 @@ public: void listContentRefreshed() override; ClickHandlerPtr listDateLink(not_null view) override; bool listElementHideReply(not_null view) override; + bool listElementShownUnread(not_null view) override; bool listIsGoodForAroundPosition(not_null view) override; protected: diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 5fee974c9..8a5f341ac 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -1150,6 +1150,10 @@ bool ScheduledWidget::listElementHideReply(not_null view) { return false; } +bool ScheduledWidget::listElementShownUnread(not_null view) { + return true; +} + bool ScheduledWidget::listIsGoodForAroundPosition( not_null view) { return true; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h index 8eb7f6342..c64a57f1f 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h @@ -111,6 +111,7 @@ public: void listContentRefreshed() override; ClickHandlerPtr listDateLink(not_null view) override; bool listElementHideReply(not_null view) override; + bool listElementShownUnread(not_null view) override; bool listIsGoodForAroundPosition(not_null view) override; protected: