mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -153,6 +153,9 @@ ForumTopic::ForumTopic(not_null<Forum*> forum, MsgId rootId)
|
||||||
_sendActionPainter->setTopic(this);
|
_sendActionPainter->setTopic(this);
|
||||||
|
|
||||||
_replies->unreadCountValue(
|
_replies->unreadCountValue(
|
||||||
|
) | rpl::map([=](std::optional<int> value) {
|
||||||
|
return value ? _replies->displayedUnreadCount() : value;
|
||||||
|
}) | rpl::distinct_until_changed(
|
||||||
) | rpl::combine_previous(
|
) | rpl::combine_previous(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return inChatList();
|
return inChatList();
|
||||||
|
@ -620,7 +623,7 @@ not_null<HistoryView::SendActionPainter*> ForumTopic::sendActionPainter() {
|
||||||
|
|
||||||
Dialogs::UnreadState ForumTopic::chatListUnreadState() const {
|
Dialogs::UnreadState ForumTopic::chatListUnreadState() const {
|
||||||
return unreadStateFor(
|
return unreadStateFor(
|
||||||
_replies->unreadCountCurrent(),
|
_replies->displayedUnreadCount(),
|
||||||
_replies->unreadCountKnown());
|
_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(
|
bool RepliesList::isServerSideUnread(
|
||||||
not_null<const HistoryItem*> item) const {
|
not_null<const HistoryItem*> item) const {
|
||||||
const auto till = item->out()
|
const auto till = item->out()
|
||||||
|
@ -847,7 +851,7 @@ void RepliesList::requestUnreadCount() {
|
||||||
const auto session = &_history->session();
|
const auto session = &_history->session();
|
||||||
const auto fullId = FullMsgId(_history->peer->id, _rootId);
|
const auto fullId = FullMsgId(_history->peer->id, _rootId);
|
||||||
const auto apply = [weak, session, fullId](
|
const auto apply = [weak, session, fullId](
|
||||||
int readTill,
|
MsgId readTill,
|
||||||
int unreadCount) {
|
int unreadCount) {
|
||||||
if (const auto strong = weak.get()) {
|
if (const auto strong = weak.get()) {
|
||||||
strong->setInboxReadTill(readTill, unreadCount);
|
strong->setInboxReadTill(readTill, unreadCount);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool unreadCountKnown() const;
|
[[nodiscard]] bool unreadCountKnown() const;
|
||||||
[[nodiscard]] int unreadCountCurrent() const;
|
[[nodiscard]] int unreadCountCurrent() const;
|
||||||
|
[[nodiscard]] int displayedUnreadCount() const;
|
||||||
[[nodiscard]] rpl::producer<std::optional<int>> unreadCountValue() const;
|
[[nodiscard]] rpl::producer<std::optional<int>> unreadCountValue() const;
|
||||||
|
|
||||||
void setInboxReadTill(MsgId readTillId, std::optional<int> unreadCount);
|
void setInboxReadTill(MsgId readTillId, std::optional<int> unreadCount);
|
||||||
|
|
|
@ -1202,9 +1202,7 @@ void RepliesWidget::refreshJoinGroupButton() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const auto channel = _history->peer->asChannel();
|
const auto channel = _history->peer->asChannel();
|
||||||
if (channel->amIn()
|
if (channel->amIn() || channel->canWrite()) {
|
||||||
|| !channel->joinToWrite()
|
|
||||||
|| (channel->amCreator() && channel->canWrite())) {
|
|
||||||
set(nullptr);
|
set(nullptr);
|
||||||
} else {
|
} else {
|
||||||
if (!_joinGroup) {
|
if (!_joinGroup) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_forum.h"
|
#include "data/data_forum.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
|
#include "data/data_replies_list.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "passport/passport_form_controller.h"
|
#include "passport/passport_form_controller.h"
|
||||||
#include "chat_helpers/tabbed_selector.h"
|
#include "chat_helpers/tabbed_selector.h"
|
||||||
|
@ -470,6 +471,18 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
MsgId rootId,
|
MsgId rootId,
|
||||||
MsgId commentId,
|
MsgId commentId,
|
||||||
const SectionShow ¶ms) {
|
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
|
if (_showingRepliesRequestId
|
||||||
&& _showingRepliesHistory == history.get()
|
&& _showingRepliesHistory == history.get()
|
||||||
&& _showingRepliesRootId == rootId) {
|
&& _showingRepliesRootId == rootId) {
|
||||||
|
@ -530,9 +543,14 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deleted || item) {
|
if (deleted || item) {
|
||||||
auto memento = std::make_shared<HistoryView::RepliesMemento>(
|
auto memento = item
|
||||||
item,
|
? std::make_shared<HistoryView::RepliesMemento>(
|
||||||
commentId);
|
item,
|
||||||
|
commentId)
|
||||||
|
: std::make_shared<HistoryView::RepliesMemento>(
|
||||||
|
history,
|
||||||
|
rootId,
|
||||||
|
commentId);
|
||||||
memento->setReadInformation(
|
memento->setReadInformation(
|
||||||
data.vread_inbox_max_id().value_or_empty(),
|
data.vread_inbox_max_id().value_or_empty(),
|
||||||
data.vunread_count().v,
|
data.vunread_count().v,
|
||||||
|
|
Loading…
Add table
Reference in a new issue