mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Count all topics as one chat for outer badges.
This commit is contained in:
parent
f9fc65d7de
commit
dfd07a4f4f
5 changed files with 10 additions and 38 deletions
|
@ -897,12 +897,10 @@ Dialogs::UnreadState ForumTopic::unreadStateFor(
|
|||
const auto muted = this->muted();
|
||||
result.messages = count;
|
||||
result.chats = count ? 1 : 0;
|
||||
result.chatsTopic = count ? 1 : 0;
|
||||
result.mentions = unreadMentions().has() ? 1 : 0;
|
||||
result.reactions = unreadReactions().has() ? 1 : 0;
|
||||
result.messagesMuted = muted ? result.messages : 0;
|
||||
result.chatsMuted = muted ? result.chats : 0;
|
||||
result.chatsTopicMuted = muted ? result.chats : 0;
|
||||
result.reactionsMuted = muted ? result.reactions : 0;
|
||||
result.known = known;
|
||||
return result;
|
||||
|
|
|
@ -32,14 +32,10 @@ struct UnreadState {
|
|||
int messagesMuted = 0;
|
||||
int chats = 0;
|
||||
int chatsMuted = 0;
|
||||
int chatsTopic = 0;
|
||||
int chatsTopicMuted = 0;
|
||||
int marks = 0;
|
||||
int marksMuted = 0;
|
||||
int reactions = 0;
|
||||
int reactionsMuted = 0;
|
||||
int forums = 0;
|
||||
int forumsMuted = 0;
|
||||
int mentions = 0;
|
||||
bool known = false;
|
||||
|
||||
|
@ -48,14 +44,10 @@ struct UnreadState {
|
|||
messagesMuted += other.messagesMuted;
|
||||
chats += other.chats;
|
||||
chatsMuted += other.chatsMuted;
|
||||
chatsTopic += other.chatsTopic;
|
||||
chatsTopicMuted += other.chatsTopicMuted;
|
||||
marks += other.marks;
|
||||
marksMuted += other.marksMuted;
|
||||
reactions += other.reactions;
|
||||
reactionsMuted += other.reactionsMuted;
|
||||
forums += other.forums;
|
||||
forumsMuted += other.forumsMuted;
|
||||
mentions += other.mentions;
|
||||
return *this;
|
||||
}
|
||||
|
@ -64,14 +56,10 @@ struct UnreadState {
|
|||
messagesMuted -= other.messagesMuted;
|
||||
chats -= other.chats;
|
||||
chatsMuted -= other.chatsMuted;
|
||||
chatsTopic -= other.chatsTopic;
|
||||
chatsTopicMuted -= other.chatsTopicMuted;
|
||||
marks -= other.marks;
|
||||
marksMuted -= other.marksMuted;
|
||||
reactions -= other.reactions;
|
||||
reactionsMuted -= other.reactionsMuted;
|
||||
forums -= other.forums;
|
||||
forumsMuted -= other.forumsMuted;
|
||||
mentions -= other.mentions;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -85,12 +85,9 @@ using UpdateFlag = Data::HistoryUpdate::Flag;
|
|||
|
||||
[[nodiscard]] Dialogs::UnreadState AdjustedForumUnreadState(
|
||||
Dialogs::UnreadState state) {
|
||||
if (state.chatsTopic) {
|
||||
state.forums = 1;
|
||||
if (state.chatsTopic == state.chatsTopicMuted) {
|
||||
state.forumsMuted = 1;
|
||||
}
|
||||
}
|
||||
const auto allMuted = (state.chats == state.chatsMuted);
|
||||
state.chatsMuted = (state.chats && allMuted) ? 1 : 0;
|
||||
state.chats = state.chats ? 1 : 0;
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -2229,7 +2226,7 @@ Dialogs::BadgesState History::chatListBadgesState() const {
|
|||
if (const auto forum = peer->forum()) {
|
||||
return adjustBadgesStateByFolder(
|
||||
Dialogs::BadgesForUnread(
|
||||
AdjustedForumUnreadState(forum->topicsList()->unreadState()),
|
||||
forum->topicsList()->unreadState(),
|
||||
Dialogs::CountInBadge::Chats,
|
||||
Dialogs::IncludeInBadge::UnmutedOrAll));
|
||||
}
|
||||
|
@ -3103,7 +3100,8 @@ void History::forumChanged(Data::Forum *old) {
|
|||
forum->topicsList()->unreadStateChanges(
|
||||
) | rpl::filter([=] {
|
||||
return (_flags & Flag::IsForum) && inChatList();
|
||||
}) | rpl::map(AdjustedForumUnreadState
|
||||
}) | rpl::map(
|
||||
AdjustedForumUnreadState
|
||||
) | rpl::start_with_next([=](const Dialogs::UnreadState &old) {
|
||||
notifyUnreadStateChange(old);
|
||||
}, forum->lifetime());
|
||||
|
|
|
@ -237,14 +237,8 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
|||
) | rpl::start_with_next([=](
|
||||
const Dialogs::UnreadState &state,
|
||||
bool includeMuted) {
|
||||
const auto chats = state.chatsTopic
|
||||
? (state.chats - state.chatsTopic + state.forums)
|
||||
: state.chats;
|
||||
const auto chatsMuted = state.chatsTopicMuted
|
||||
? (state.chatsMuted
|
||||
- state.chatsTopicMuted
|
||||
+ state.forumsMuted)
|
||||
: state.chatsMuted;
|
||||
const auto chats = state.chats;
|
||||
const auto chatsMuted = state.chatsMuted;
|
||||
const auto muted = (chatsMuted + state.marksMuted);
|
||||
const auto count = (chats + state.marks)
|
||||
- (includeMuted ? 0 : muted);
|
||||
|
|
|
@ -286,14 +286,8 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
|
|||
) | rpl::start_with_next([=](
|
||||
const Dialogs::UnreadState &state,
|
||||
bool includeMuted) {
|
||||
const auto chats = state.chatsTopic
|
||||
? (state.chats - state.chatsTopic + state.forums)
|
||||
: state.chats;
|
||||
const auto chatsMuted = state.chatsTopicMuted
|
||||
? (state.chatsMuted
|
||||
- state.chatsTopicMuted
|
||||
+ state.forumsMuted)
|
||||
: state.chatsMuted;
|
||||
const auto chats = state.chats;
|
||||
const auto chatsMuted = state.chatsMuted;
|
||||
const auto muted = (chatsMuted + state.marksMuted);
|
||||
const auto count = (chats + state.marks)
|
||||
- (includeMuted ? 0 : muted);
|
||||
|
|
Loading…
Add table
Reference in a new issue