diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 403d7ce20..d948bc580 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -707,14 +707,16 @@ void Widget::refreshFolderTopBar() { _folderTopBar.create(this, controller()); updateControlsGeometry(); } + const auto history = _openedForum + ? session().data().history(_openedForum).get() + : nullptr; _folderTopBar->setActiveChat( HistoryView::TopBarWidget::ActiveChat{ .key = (_openedForum - ? Dialogs::Key(session().data().history(_openedForum)) + ? Dialogs::Key(history) : Dialogs::Key(_openedFolder)), .section = Dialogs::EntryState::Section::ChatsList, - }, - nullptr); + }, history ? history->sendActionPainter().get() : nullptr); } else { _folderTopBar.destroy(); } diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp index 050bb5d37..96d77e543 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp @@ -822,7 +822,10 @@ void RowPainter::Paint( const auto badgesState = entry->chatListBadgesState(); const auto item = entry->chatListMessage(); const auto cloudDraft = [&]() -> const Data::Draft*{ - if (thread && (!item || !badgesState.unread)) { + if (!thread) { + return nullptr; + } + if ((!peer || !peer->isForum()) && (!item || !badgesState.unread)) { // Draw item, if there are unread messages. const auto draft = thread->owningHistory()->cloudDraft( thread->topicRootId()); diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 4ffeecc2a..3d48d60bd 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1924,7 +1924,9 @@ void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) { TimeId History::adjustedChatListTimeId() const { const auto result = chatListTimeId(); if (const auto draft = cloudDraft(MsgId(0))) { - if (!Data::DraftIsNull(draft) && !session().supportMode()) { + if (!peer->forum() + && !Data::DraftIsNull(draft) + && !session().supportMode()) { return std::max(result, draft->date); } } @@ -2914,6 +2916,9 @@ void History::forumChanged(Data::Forum *old) { } else { _flags &= ~Flag::IsForum; } + if (cloudDraft(MsgId(0))) { + updateChatListSortPosition(); + } } not_null History::migrateToOrMe() const { diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 0bbab17f3..5c944d732 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "info/info_memento.h" #include "info/info_controller.h" +#include "info/profile/info_profile_values.h" #include "storage/storage_shared_media.h" #include "mainwidget.h" #include "mainwindow.h" @@ -177,11 +178,15 @@ TopBarWidget::TopBarWidget( && (_activeChat.key.peer() == update.peer)) { updateControlsVisibility(); } - if (update.flags - & (UpdateFlag::OnlineStatus - | UpdateFlag::Members - | UpdateFlag::SupportInfo)) { + if ((update.flags & UpdateFlag::OnlineStatus) + && trackOnlineOf(update.peer)) { updateOnlineDisplay(); + } else if (update.flags + & (UpdateFlag::Members | UpdateFlag::SupportInfo)) { + if (update.peer == _activeChat.key.peer() + && !_activeChat.key.topic()) { + updateOnlineDisplay(); + } } if ((update.flags & UpdateFlag::EmojiStatus) && (_activeChat.key.peer() == update.peer)) { @@ -496,8 +501,7 @@ void TopBarWidget::paintTopBar(Painter &p) { } else if (folder || history->peer->sharedMediaInfo() || (_activeChat.section == Section::Scheduled) - || (_activeChat.section == Section::Pinned) - || (_activeChat.section == Section::ChatsList)) { + || (_activeChat.section == Section::Pinned)) { // #TODO forum name emoji. auto text = (_activeChat.section == Section::Scheduled) ? ((history && history->peer->isSelf()) @@ -768,7 +772,17 @@ void TopBarWidget::setActiveChat( return (seen.peer == history->peer); }) | rpl::start_with_next([=](const InteractionSeen &seen) { handleEmojiInteractionSeen(seen.emoticon); - }, lifetime()); + }, _activeChatLifetime); + } + + if (const auto topic = _activeChat.key.topic()) { + Info::Profile::NameValue( + topic->channel() + ) | rpl::start_with_next([=](const QString &name) { + _titlePeerText.setText(st::dialogsTextStyle, name); + _titlePeerTextOnline = false; + update(); + }, _activeChatLifetime); } } updateUnreadBadge(); @@ -930,7 +944,9 @@ void TopBarWidget::updateControlsGeometry() { _rightTaken += _call->width(); } _search->moveToRight(_rightTaken, otherButtonsTop); - _rightTaken += _search->width() + st::topBarCallSkip; + if (!_search->isHidden()) { + _rightTaken += _search->width() + st::topBarCallSkip; + } updateMembersShowArea(); } @@ -1030,7 +1046,10 @@ void TopBarWidget::updateControlsVisibility() { void TopBarWidget::updateMembersShowArea() { const auto membersShowAreaNeeded = [&] { const auto peer = _activeChat.key.peer(); - if (showSelectedState() || !peer) { + if (showSelectedState() + || !peer + || _activeChat.section == Section::ChatsList + || _activeChat.key.topic()) { return false; } else if (const auto chat = peer->asChat()) { return chat->amIn(); @@ -1194,9 +1213,25 @@ void TopBarWidget::updateInfoToggleActive() { _infoToggle->setRippleColorOverride(rippleOverride); } +bool TopBarWidget::trackOnlineOf(not_null user) const { + const auto peer = _activeChat.key.peer(); + if (!peer || _activeChat.key.topic() || !user->isUser()) { + return false; + } else if (peer->isUser()) { + return (peer == user); + } else if (const auto chat = peer->asChat()) { + return chat->participants.contains(user->asUser()); + } else if (const auto channel = peer->asMegagroup()) { + return ranges::contains( + channel->mgInfo->lastParticipants, + not_null{ user->asUser() }); + } + return false; +} + void TopBarWidget::updateOnlineDisplay() { const auto peer = _activeChat.key.peer(); - if (!peer) { + if (!peer || _activeChat.key.topic()) { return; } diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h index 7e0f3016b..5052c89b9 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -138,7 +138,8 @@ private: int availableWidth, int outerWidth); bool paintConnectingState(Painter &p, int left, int top, int outerWidth); - QRect getMembersShowAreaGeometry() const; + [[nodiscard]] QRect getMembersShowAreaGeometry() const; + [[nodiscard]] bool trackOnlineOf(not_null user) const; void updateMembersShowArea(); void updateOnlineDisplay(); void updateOnlineDisplayTimer();