mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Show messages count in forum.
This commit is contained in:
parent
8ee28f6665
commit
d0d2a4f488
5 changed files with 27 additions and 10 deletions
|
@ -3556,6 +3556,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_forum_create_topic" = "Create topic";
|
||||
"lng_forum_discard_sure" = "Are you sure you want to discard this topic?";
|
||||
"lng_forum_view_as_messages" = "View as Messages";
|
||||
"lng_forum_no_messages" = "No messages";
|
||||
"lng_forum_messages#one" = "{count} message";
|
||||
"lng_forum_messages#other" = "{count} messages";
|
||||
|
||||
// Wnd specific
|
||||
|
||||
|
|
|
@ -276,6 +276,10 @@ rpl::producer<int> RepliesList::fullCount() const {
|
|||
return _fullCount.value() | rpl::filter_optional();
|
||||
}
|
||||
|
||||
rpl::producer<std::optional<int>> RepliesList::maybeFullCount() const {
|
||||
return _fullCount.value();
|
||||
}
|
||||
|
||||
bool RepliesList::unreadCountKnown() const {
|
||||
return _unreadCount.current().has_value();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
int limitAfter);
|
||||
|
||||
[[nodiscard]] rpl::producer<int> fullCount() const;
|
||||
[[nodiscard]] rpl::producer<std::optional<int>> maybeFullCount() const;
|
||||
|
||||
[[nodiscard]] bool unreadCountKnown() const;
|
||||
[[nodiscard]] int unreadCountCurrent() const;
|
||||
|
|
|
@ -2046,20 +2046,28 @@ void RepliesWidget::setReplies(std::shared_ptr<Data::RepliesList> replies) {
|
|||
? _replies->unreadCountCurrent()
|
||||
: std::optional<int>());
|
||||
|
||||
if (_topic) {
|
||||
return;
|
||||
}
|
||||
const auto isTopic = (_topic != nullptr);
|
||||
const auto isTopicCreating = isTopic && _topic->creating();
|
||||
rpl::combine(
|
||||
rpl::single(0) | rpl::then(_replies->fullCount()),
|
||||
rpl::single(
|
||||
std::optional<int>()
|
||||
) | rpl::then(_replies->maybeFullCount()),
|
||||
_areComments.value()
|
||||
) | rpl::map([=](int count, bool areComments) {
|
||||
return count
|
||||
? (areComments
|
||||
) | rpl::map([=](std::optional<int> count, bool areComments) {
|
||||
const auto sub = isTopic ? 1 : 0;
|
||||
return (count && (*count > sub))
|
||||
? (isTopic
|
||||
? tr::lng_forum_messages
|
||||
: areComments
|
||||
? tr::lng_comments_header
|
||||
: tr::lng_replies_header)(
|
||||
lt_count_decimal,
|
||||
rpl::single(count) | tr::to_count())
|
||||
: (areComments
|
||||
rpl::single(*count - sub) | tr::to_count())
|
||||
: (isTopic
|
||||
? ((count.has_value() || isTopicCreating)
|
||||
? tr::lng_forum_no_messages
|
||||
: tr::lng_contacts_loading)
|
||||
: areComments
|
||||
? tr::lng_comments_header_none
|
||||
: tr::lng_replies_header_none)();
|
||||
}) | rpl::flatten_latest(
|
||||
|
|
|
@ -484,7 +484,8 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
width(),
|
||||
st::historyStatusFgTyping,
|
||||
now)) {
|
||||
paintStatus(p, nameleft, statustop, availableWidth, width());
|
||||
p.setPen(st::historyStatusFg);
|
||||
p.drawTextLeft(nameleft, statustop, width(), _customTitleText);
|
||||
}
|
||||
} else if (folder
|
||||
|| history->peer->sharedMediaInfo()
|
||||
|
|
Loading…
Add table
Reference in a new issue