mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Ignore unread counts in non-opened topics.
This commit is contained in:
parent
7aea54ad8f
commit
3a967bbbfe
5 changed files with 32 additions and 8 deletions
Telegram/SourceFiles
|
@ -153,6 +153,9 @@ ForumTopic::ForumTopic(not_null<Forum*> forum, MsgId rootId)
|
|||
_sendActionPainter->setTopic(this);
|
||||
|
||||
_replies->unreadCountValue(
|
||||
) | rpl::map([=](std::optional<int> value) {
|
||||
return value ? _replies->displayedUnreadCount() : value;
|
||||
}) | rpl::distinct_until_changed(
|
||||
) | rpl::combine_previous(
|
||||
) | rpl::filter([=] {
|
||||
return inChatList();
|
||||
|
@ -620,7 +623,7 @@ not_null<HistoryView::SendActionPainter*> ForumTopic::sendActionPainter() {
|
|||
|
||||
Dialogs::UnreadState ForumTopic::chatListUnreadState() const {
|
||||
return unreadStateFor(
|
||||
_replies->unreadCountCurrent(),
|
||||
_replies->displayedUnreadCount(),
|
||||
_replies->unreadCountKnown());
|
||||
}
|
||||
|
||||
|
|
|
@ -765,6 +765,10 @@ void RepliesList::setUnreadCount(std::optional<int> count) {
|
|||
}
|
||||
}
|
||||
|
||||
int RepliesList::displayedUnreadCount() const {
|
||||
return (_inboxReadTillId > 1) ? unreadCountCurrent() : 0;
|
||||
}
|
||||
|
||||
bool RepliesList::isServerSideUnread(
|
||||
not_null<const HistoryItem*> item) const {
|
||||
const auto till = item->out()
|
||||
|
@ -847,7 +851,7 @@ void RepliesList::requestUnreadCount() {
|
|||
const auto session = &_history->session();
|
||||
const auto fullId = FullMsgId(_history->peer->id, _rootId);
|
||||
const auto apply = [weak, session, fullId](
|
||||
int readTill,
|
||||
MsgId readTill,
|
||||
int unreadCount) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->setInboxReadTill(readTill, unreadCount);
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool unreadCountKnown() const;
|
||||
[[nodiscard]] int unreadCountCurrent() const;
|
||||
[[nodiscard]] int displayedUnreadCount() const;
|
||||
[[nodiscard]] rpl::producer<std::optional<int>> unreadCountValue() const;
|
||||
|
||||
void setInboxReadTill(MsgId readTillId, std::optional<int> unreadCount);
|
||||
|
|
|
@ -1202,9 +1202,7 @@ void RepliesWidget::refreshJoinGroupButton() {
|
|||
}
|
||||
};
|
||||
const auto channel = _history->peer->asChannel();
|
||||
if (channel->amIn()
|
||||
|| !channel->joinToWrite()
|
||||
|| (channel->amCreator() && channel->canWrite())) {
|
||||
if (channel->amIn() || channel->canWrite()) {
|
||||
set(nullptr);
|
||||
} else {
|
||||
if (!_joinGroup) {
|
||||
|
|
|
@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_forum.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_replies_list.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
|
@ -470,6 +471,18 @@ void SessionNavigation::showRepliesForMessage(
|
|||
MsgId rootId,
|
||||
MsgId commentId,
|
||||
const SectionShow ¶ms) {
|
||||
if (const auto topic = history->peer->forumTopicFor(rootId)) {
|
||||
auto replies = topic->replies();
|
||||
if (replies->unreadCountKnown()) {
|
||||
auto memento = std::make_shared<HistoryView::RepliesMemento>(
|
||||
history,
|
||||
rootId,
|
||||
commentId);
|
||||
memento->setReplies(std::move(replies));
|
||||
showSection(std::move(memento), params);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_showingRepliesRequestId
|
||||
&& _showingRepliesHistory == history.get()
|
||||
&& _showingRepliesRootId == rootId) {
|
||||
|
@ -530,9 +543,14 @@ void SessionNavigation::showRepliesForMessage(
|
|||
}
|
||||
}
|
||||
if (deleted || item) {
|
||||
auto memento = std::make_shared<HistoryView::RepliesMemento>(
|
||||
item,
|
||||
commentId);
|
||||
auto memento = item
|
||||
? std::make_shared<HistoryView::RepliesMemento>(
|
||||
item,
|
||||
commentId)
|
||||
: std::make_shared<HistoryView::RepliesMemento>(
|
||||
history,
|
||||
rootId,
|
||||
commentId);
|
||||
memento->setReadInformation(
|
||||
data.vread_inbox_max_id().value_or_empty(),
|
||||
data.vunread_count().v,
|
||||
|
|
Loading…
Add table
Reference in a new issue