From b9ad8bb70033c1d58dd80621e9327d26f0b9645b Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 22 Jan 2018 20:39:20 +0300 Subject: [PATCH] Feed top bar placeholder. --- Telegram/SourceFiles/app.cpp | 8 +- .../SourceFiles/dialogs/dialogs_entry.cpp | 4 +- .../dialogs/dialogs_inner_widget.cpp | 22 +++- .../dialogs/dialogs_inner_widget.h | 4 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 19 ++- Telegram/SourceFiles/dialogs/dialogs_widget.h | 6 +- .../history/feed/history_feed_section.cpp | 6 +- Telegram/SourceFiles/history/history_item.cpp | 4 +- .../SourceFiles/history/history_service.cpp | 4 +- .../SourceFiles/history/history_widget.cpp | 16 ++- .../view/history_view_top_bar_widget.cpp | 121 +++++++++++------- .../view/history_view_top_bar_widget.h | 7 +- Telegram/SourceFiles/mainwidget.cpp | 24 ++-- Telegram/SourceFiles/mainwidget.h | 8 +- .../SourceFiles/window/window_peer_menu.cpp | 2 +- 15 files changed, 156 insertions(+), 99 deletions(-) diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 03ffd91e80..dd915f091c 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -1027,9 +1027,11 @@ namespace { void feedOutboxRead(const PeerId &peer, MsgId upTo, TimeId when) { if (auto history = App::historyLoaded(peer)) { history->outboxRead(upTo); - if (history->lastMsg && history->lastMsg->out() && history->lastMsg->id <= upTo) { - if (App::main()) { - App::main()->dlgUpdated(history, history->lastMsg->id); + if (history->lastMsg + && history->lastMsg->out() + && history->lastMsg->id <= upTo) { + if (const auto main = App::main()) { + main->repaintDialogRow(history, history->lastMsg->id); } } history->updateChatListEntry(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_entry.cpp b/Telegram/SourceFiles/dialogs/dialogs_entry.cpp index ab2d15937c..4b99e9901d 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_entry.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_entry.cpp @@ -153,11 +153,11 @@ void Entry::addChatListEntryByLetter( void Entry::updateChatListEntry() const { if (const auto main = App::main()) { if (inChatList(Mode::All)) { - main->dlgUpdated( + main->repaintDialogRow( Mode::All, mainChatListLink(Mode::All)); if (inChatList(Mode::Important)) { - main->dlgUpdated( + main->repaintDialogRow( Mode::Important, mainChatListLink(Mode::Important)); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 3661f0608c..21094aab14 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -764,7 +764,7 @@ void DialogsInner::mousePressEvent(QMouseEvent *e) { row->addRipple( e->pos() - QPoint(0, filteredOffset() + _filteredPressed * st::dialogsRowHeight), QSize(getFullWidth(), st::dialogsRowHeight), - [=] { dlgUpdated(list, row); }); + [=] { repaintDialogRow(list, row); }); } else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) { auto &result = _peerSearchResults[_peerSearchPressed]; auto row = &result->row; @@ -1222,7 +1222,7 @@ void DialogsInner::removeDialog(Dialogs::Key key) { refresh(); } -void DialogsInner::dlgUpdated( +void DialogsInner::repaintDialogRow( Dialogs::Mode list, not_null row) { if (_state == State::Default) { @@ -1250,9 +1250,11 @@ void DialogsInner::dlgUpdated( } } -void DialogsInner::dlgUpdated(not_null history, MsgId msgId) { +void DialogsInner::repaintDialogRow( + not_null history, + MsgId messageId) { updateDialogRow( - Dialogs::RowDescriptor(history, msgId), + Dialogs::RowDescriptor(history, messageId), QRect(0, 0, getFullWidth(), st::dialogsRowHeight)); } @@ -1275,7 +1277,17 @@ void DialogsInner::updateDialogRow( Dialogs::RowDescriptor row, QRect updateRect, UpdateRowSections sections) { - auto updateRow = [&](int rowTop) { + if (IsServerMsgId(-row.msgId)) { + if (const auto peer = row.key.peer()) { + if (const auto from = peer->migrateFrom()) { + if (const auto migrated = App::historyLoaded(from)) { + row = Dialogs::RowDescriptor(migrated, -row.msgId); + } + } + } + } + + const auto updateRow = [&](int rowTop) { rtlupdate( updateRect.x(), rowTop + updateRect.y(), diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index f76b34e259..2e35206f9f 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -53,8 +53,8 @@ public: void createDialog(Dialogs::Key key); void removeDialog(Dialogs::Key key); - void dlgUpdated(Dialogs::Mode list, not_null row); - void dlgUpdated(not_null history, MsgId msgId); + void repaintDialogRow(Dialogs::Mode list, not_null row); + void repaintDialogRow(not_null history, MsgId messageId); void dragLeft(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 486e01bdeb..63cb4516a7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -203,14 +203,16 @@ void DialogsWidget::createDialog(Dialogs::Key key) { } } -void DialogsWidget::dlgUpdated( +void DialogsWidget::repaintDialogRow( Dialogs::Mode list, not_null row) { - _inner->dlgUpdated(list, row); + _inner->repaintDialogRow(list, row); } -void DialogsWidget::dlgUpdated(not_null history, MsgId msgId) { - _inner->dlgUpdated(history, msgId); +void DialogsWidget::repaintDialogRow( + not_null history, + MsgId messageId) { + _inner->repaintDialogRow(history, messageId); } void DialogsWidget::dialogsToUp() { @@ -928,9 +930,14 @@ void DialogsWidget::onFilterUpdate(bool force) { _lastFilterText = filterText; } -void DialogsWidget::searchInPeer(PeerData *peer) { +void DialogsWidget::searchInChat(Dialogs::Key chat) { onCancelSearch(); - setSearchInPeer(peer); + if (const auto peer = chat.peer()) { + setSearchInPeer(peer); + } else { + // #TODO feeds search + setSearchInPeer(nullptr); + } onFilterUpdate(true); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 2fdcad0f16..d12e78ae0a 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -52,14 +52,14 @@ public: void updateDragInScroll(bool inScroll); - void searchInPeer(PeerData *peer); + void searchInChat(Dialogs::Key chat); void loadDialogs(); void loadPinnedDialogs(); void createDialog(Dialogs::Key key); void removeDialog(Dialogs::Key key); - void dlgUpdated(Dialogs::Mode list, not_null row); - void dlgUpdated(not_null history, MsgId msgId); + void repaintDialogRow(Dialogs::Mode list, not_null row); + void repaintDialogRow(not_null history, MsgId messageId); void dialogsToUp(); diff --git a/Telegram/SourceFiles/history/feed/history_feed_section.cpp b/Telegram/SourceFiles/history/feed/history_feed_section.cpp index 1cee74505d..0e58a36cd6 100644 --- a/Telegram/SourceFiles/history/feed/history_feed_section.cpp +++ b/Telegram/SourceFiles/history/feed/history_feed_section.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_element.h" #include "history/view/history_view_message.h" #include "history/view/history_view_service_message.h" +#include "mainwidget.h" #include "lang/lang_keys.h" #include "ui/widgets/buttons.h" #include "ui/widgets/shadow.h" @@ -60,6 +61,8 @@ Widget::Widget( this, lang(lng_feed_show_next).toUpper(), st::historyComposeButton) { + _topBar->setActiveChat(_feed); + _topBar->move(0, 0); _topBar->resizeToWidth(width()); _topBar->show(); @@ -138,7 +141,8 @@ bool Widget::cmd_search() { if (!inFocusChain()) { return false; } - // #TODO feeds search + + App::main()->searchInChat(_feed); return true; } diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 92a58cb347..f993999587 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -129,9 +129,9 @@ ReplyKeyboard *HistoryItem::inlineReplyKeyboard() { } void HistoryItem::invalidateChatsListEntry() { - if (App::main()) { + if (const auto main = App::main()) { // #TODO feeds search results - App::main()->dlgUpdated(history(), id); + main->repaintDialogRow(history(), id); } // invalidate cache for drawInDialog diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 37f9465f74..13236d529f 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -621,9 +621,9 @@ void HistoryService::updateDependentText() { feed->updateChatListEntry(); } } - if (App::main()) { + if (const auto main = App::main()) { // #TODO feeds search results - App::main()->dlgUpdated(history(), id); + main->repaintDialogRow(history(), id); } App::historyUpdateDependent(this); } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 827d0dac3d..e555633d09 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1423,9 +1423,9 @@ void HistoryWidget::notify_migrateUpdated(PeerData *peer) { } bool HistoryWidget::cmd_search() { - if (!inFocusChain() || !_peer) return false; + if (!inFocusChain() || !_history) return false; - App::main()->searchInPeer(_peer); + App::main()->searchInChat(_history); return true; } @@ -1724,8 +1724,6 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re _canSendMessages = _peer->canWrite(); _tabbedSelector->setCurrentPeer(_peer); } - _topBar->setHistoryPeer(_peer); - updateTopBarSelection(); if (_peer && _peer->isChannel()) { _peer->asChannel()->updateFull(); @@ -1742,7 +1740,6 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re noSelectingScroll(); _nonEmptySelection = false; - _topBar->showSelected(HistoryView::TopBarWidget::SelectedState {}); if (_peer) { App::forgetMedia(); @@ -1752,6 +1749,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re _history = App::history(_peer); _migrated = _history->migrateFrom(); + _topBar->setActiveChat(_history); + updateTopBarSelection(); + if (_channel) { updateNotifySettings(); if (_peer->notifySettingsUnknown()) { @@ -1817,6 +1817,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re } unreadCountChanged(_history); // set _historyDown badge. } else { + _topBar->setActiveChat(Dialogs::Key()); + updateTopBarSelection(); + clearFieldText(); _tabbedSelector->showMegagroupSet(nullptr); doneShow(); @@ -4579,7 +4582,8 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) { } void HistoryWidget::updateControlsGeometry() { - _topBar->setGeometryToLeft(0, 0, width(), st::topBarHeight); + _topBar->resizeToWidth(width()); + _topBar->moveToLeft(0, 0); moveFieldControls(); 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 6e4d3957b0..02af8d2b8c 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_peer_menu.h" #include "calls/calls_instance.h" #include "data/data_peer_values.h" +#include "data/data_feed.h" #include "observer_peer.h" #include "apiwrap.h" #include "styles/style_window.h" @@ -92,11 +93,13 @@ TopBarWidget::TopBarWidget( if (Adaptive::OneColumn()) { createUnreadBadge(); } - subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) { - if (update.history->peer == _historyPeer) { - this->update(); - } - }); + subscribe( + App::histories().sendActionAnimationUpdated(), + [this](const Histories::SendActionAnimationUpdate &update) { + if (update.history == _activeChat.history()) { + this->update(); + } + }); using UpdateFlag = Notify::PeerUpdate::Flag; auto flags = UpdateFlag::UserHasCalls | UpdateFlag::UserOnlineChanged @@ -142,19 +145,22 @@ void TopBarWidget::onClearSelection() { } void TopBarWidget::onSearch() { - if (_historyPeer) { - App::main()->searchInPeer(_historyPeer); + if (_activeChat) { + App::main()->searchInChat(_activeChat); } } void TopBarWidget::onCall() { - if (auto user = _historyPeer->asUser()) { - Calls::Current().startOutgoingCall(user); + if (const auto peer = _activeChat.peer()) { + if (const auto user = peer->asUser()) { + Calls::Current().startOutgoingCall(user); + } } } void TopBarWidget::showMenu() { - if (!_historyPeer || _menu) { + // #TODO feeds menu + if (!_activeChat || _menu || !_activeChat.peer()) { return; } _menu.create(parentWidget()); @@ -178,7 +184,7 @@ void TopBarWidget::showMenu() { _menuToggle->installEventFilter(_menu); Window::FillPeerMenu( _controller, - _historyPeer, + _activeChat.peer(), [this](const QString &text, base::lambda callback) { return _menu->addAction(text, std::move(callback)); }, @@ -192,20 +198,21 @@ void TopBarWidget::toggleInfoSection() { && (Auth().settings().thirdSectionInfoEnabled() || Auth().settings().tabbedReplacedWithInfo())) { _controller->closeThirdSection(); - } else if (_historyPeer) { + } else if (_activeChat.peer()) { + // #TODO feeds profile if (_controller->canShowThirdSection()) { Auth().settings().setThirdSectionInfoEnabled(true); Auth().saveSettingsDelayed(); if (Adaptive::ThreeColumn()) { _controller->showSection( - Info::Memento::Default(_historyPeer), + Info::Memento::Default(_activeChat.peer()), Window::SectionShow().withThirdColumn()); } else { _controller->resizeForThirdSection(); _controller->updateColumnLayout(); } } else { - _controller->showSection(Info::Memento(_historyPeer->id)); + _controller->showSection(Info::Memento(_activeChat.peer()->id)); } } else { updateControlsVisibility(); @@ -231,6 +238,10 @@ bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) { return TWidget::eventFilter(obj, e); } +int TopBarWidget::resizeGetHeight(int newWidth) { + return st::topBarHeight; +} + void TopBarWidget::paintEvent(QPaintEvent *e) { if (_animatingMode) { return; @@ -251,16 +262,30 @@ void TopBarWidget::paintEvent(QPaintEvent *e) { } void TopBarWidget::paintTopBar(Painter &p, TimeMs ms) { - auto history = App::historyLoaded(_historyPeer); - if (!history) return; - + if (!_activeChat) { + return; + } auto nameleft = _leftTaken; auto nametop = st::topBarArrowPadding.top(); auto statustop = st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height; auto namewidth = width() - _rightTaken - nameleft; + auto history = _activeChat.history(); + p.setPen(st::dialogsNameFg); - if (_historyPeer->isSelf()) { + if (const auto feed = _activeChat.feed()) { + auto text = feed->chatsListName(); // TODO feed name emoji + auto textWidth = st::historySavedFont->width(text); + if (namewidth < textWidth) { + text = st::historySavedFont->elided(text, namewidth); + } + p.setFont(st::historySavedFont); + p.drawTextLeft( + nameleft, + (height() - st::historySavedFont->height) / 2, + width(), + text); + } else if (_activeChat.peer()->isSelf()) { auto text = lang(lng_saved_messages); auto textWidth = st::historySavedFont->width(text); if (namewidth < textWidth) { @@ -272,8 +297,8 @@ void TopBarWidget::paintTopBar(Painter &p, TimeMs ms) { (height() - st::historySavedFont->height) / 2, width(), text); - } else { - _historyPeer->dialogName().drawElided(p, nameleft, nametop, namewidth); + } else if (const auto history = _activeChat.history()) { + history->peer->dialogName().drawElided(p, nameleft, nametop, namewidth); p.setFont(st::dialogsTextFont); if (!history->paintSendAction(p, nameleft, statustop, namewidth, width(), st::historyStatusFgTyping, ms)) { @@ -310,19 +335,23 @@ void TopBarWidget::mousePressEvent(QMouseEvent *e) { if (handleClick) { if (_animatingMode && _back->rect().contains(e->pos())) { backClicked(); - } else if (_historyPeer) { + } else { infoClicked(); } } } void TopBarWidget::infoClicked() { - if (_historyPeer && _historyPeer->isSelf()) { + if (!_activeChat) { + return; + } else if (const auto feed = _activeChat.feed()) { + // #TODO feeds profile + } else if (_activeChat.peer()->isSelf()) { _controller->showSection(Info::Memento( - _historyPeer->id, + _activeChat.peer()->id, Info::Section(Storage::SharedMediaType::Photo))); } else { - _controller->showPeerInfo(_historyPeer); + _controller->showPeerInfo(_activeChat.peer()); } } @@ -330,18 +359,18 @@ void TopBarWidget::backClicked() { _controller->showBackFromStack(); } -void TopBarWidget::setHistoryPeer(PeerData *historyPeer) { - if (_historyPeer != historyPeer) { - _historyPeer = historyPeer; +void TopBarWidget::setActiveChat(Dialogs::Key chat) { + if (_activeChat != chat) { + _activeChat = chat; _back->clearState(); update(); updateUnreadBadge(); - if (_historyPeer) { + if (const auto peer = _activeChat.peer()) { _info.create( this, _controller, - _historyPeer, + peer, Ui::UserpicButton::Role::Custom, st::topBarInfoButton); _info->showSavedMessagesOnSelf(true); @@ -456,10 +485,14 @@ void TopBarWidget::updateControlsVisibility() { _menuToggle->show(); _infoToggle->setVisible(!Adaptive::OneColumn() && _controller->canShowThirdSection()); - auto callsEnabled = false; - if (auto user = _historyPeer ? _historyPeer->asUser() : nullptr) { - callsEnabled = Global::PhoneCallsEnabled() && user->hasCalls(); - } + const auto callsEnabled = [&] { + if (const auto peer = _activeChat.peer()) { + if (const auto user = peer->asUser()) { + return Global::PhoneCallsEnabled() && user->hasCalls(); + } + } + return false; + }(); _call->setVisible(callsEnabled); if (_membersShowArea) { @@ -580,10 +613,10 @@ void TopBarWidget::updateUnreadBadge() { + (Global::IncludeMuted() ? 0 : mutedCount); // Do not include currently shown chat in the top bar unread counter. - if (auto historyShown = App::historyLoaded(_historyPeer)) { - auto shownUnreadCount = historyShown->unreadCount(); + if (const auto history = _activeChat.history()) { + auto shownUnreadCount = history->unreadCount(); fullCounter -= shownUnreadCount; - if (historyShown->mute()) { + if (history->mute()) { mutedCount -= shownUnreadCount; } } @@ -614,15 +647,15 @@ void TopBarWidget::updateInfoToggleActive() { } void TopBarWidget::updateOnlineDisplay() { - if (!_historyPeer) return; + if (!_activeChat.peer()) return; QString text; const auto now = unixtime(); bool titlePeerTextOnline = false; - if (const auto user = _historyPeer->asUser()) { + if (const auto user = _activeChat.peer()->asUser()) { text = Data::OnlineText(user, now); titlePeerTextOnline = Data::OnlineTextActive(user, now); - } else if (const auto chat = _historyPeer->asChat()) { + } else if (const auto chat = _activeChat.peer()->asChat()) { if (!chat->amIn()) { text = lang(lng_chat_status_unaccessible); } else if (chat->participants.empty()) { @@ -652,7 +685,7 @@ void TopBarWidget::updateOnlineDisplay() { text = lang(lng_group_status); } } - } else if (auto channel = _historyPeer->asChannel()) { + } else if (const auto channel = _activeChat.peer()->asChannel()) { if (channel->isMegagroup() && channel->membersCount() > 0 && channel->membersCount() <= Global::ChatSizeMax()) { if (channel->mgInfo->lastParticipants.empty() || channel->lastParticipantsCountOutdated()) { Auth().api().requestLastParticipants(channel); @@ -693,7 +726,7 @@ void TopBarWidget::updateOnlineDisplay() { } void TopBarWidget::updateOnlineDisplayTimer() { - if (!_historyPeer) return; + if (!_activeChat.peer()) return; const auto now = unixtime(); auto minTimeout = TimeMs(86400); @@ -701,13 +734,13 @@ void TopBarWidget::updateOnlineDisplayTimer() { auto hisTimeout = Data::OnlineChangeTimeout(user, now); accumulate_min(minTimeout, hisTimeout); }; - if (const auto user = _historyPeer->asUser()) { + if (const auto user = _activeChat.peer()->asUser()) { handleUser(user); - } else if (auto chat = _historyPeer->asChat()) { + } else if (auto chat = _activeChat.peer()->asChat()) { for (auto [user, v] : chat->participants) { handleUser(user); } - } else if (_historyPeer->isChannel()) { + } else if (_activeChat.peer()->isChannel()) { } updateOnlineDisplayIn(minTimeout); } 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 64e05df8a5..f93a88cfa7 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "base/timer.h" +#include "dialogs/dialogs_key.h" namespace Ui { class UserpicButton; @@ -45,7 +46,7 @@ public: } void setAnimatingMode(bool enabled); - void setHistoryPeer(PeerData *historyPeer); + void setActiveChat(Dialogs::Key chat); protected: void paintEvent(QPaintEvent *e) override; @@ -53,6 +54,8 @@ protected: void resizeEvent(QResizeEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override; + int resizeGetHeight(int newWidth) override; + private: void refreshLang(); void updateControlsGeometry(); @@ -84,7 +87,7 @@ private: void updateUnreadBadge(); not_null _controller; - PeerData *_historyPeer = nullptr; + Dialogs::Key _activeChat; int _selectedCount = 0; bool _canDelete = false; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 31e75f7b6b..61b1616ef0 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2771,24 +2771,16 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m return result; } -void MainWidget::dlgUpdated( +void MainWidget::repaintDialogRow( Dialogs::Mode list, not_null row) { - if (row) { - _dialogs->dlgUpdated(list, row); - } + _dialogs->repaintDialogRow(list, row); } -void MainWidget::dlgUpdated(not_null history, MsgId msgId) { - if (msgId < 0 && -msgId < ServerMaxMsgId) { - if (const auto from = history->peer->migrateFrom()) { - if (const auto migrated = App::historyLoaded(from)) { - _dialogs->dlgUpdated(migrated, -msgId); - } - } - } else { - _dialogs->dlgUpdated(history, msgId); - } +void MainWidget::repaintDialogRow( + not_null history, + MsgId messageId) { + _dialogs->repaintDialogRow(history, messageId); } void MainWidget::windowShown() { @@ -3413,8 +3405,8 @@ int MainWidget::backgroundFromY() const { return -getMainSectionTop(); } -void MainWidget::searchInPeer(PeerData *peer) { - _dialogs->searchInPeer(peer); +void MainWidget::searchInChat(Dialogs::Key chat) { + _dialogs->searchInChat(chat); if (Adaptive::OneColumn()) { dialogsToUp(); Ui::showChatsList(); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 64d59e1263..8a1e037b5a 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -110,8 +110,8 @@ public: void createDialog(Dialogs::Key key); void removeDialog(Dialogs::Key key); - void dlgUpdated(Dialogs::Mode list, not_null row); - void dlgUpdated(not_null history, MsgId msgId); + void repaintDialogRow(Dialogs::Mode list, not_null row); + void repaintDialogRow(not_null history, MsgId messageId); void windowShown(); @@ -310,6 +310,8 @@ public: void documentLoadProgress(DocumentData *document); + void searchInChat(Dialogs::Key chat); + void app_sendBotCallback( not_null button, not_null msg, @@ -357,8 +359,6 @@ public slots: void updateOnline(bool gotOtherOffline = false); void checkIdleFinish(); - void searchInPeer(PeerData *peer); - void onUpdateNotifySettings(); void onCacheBackground(); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 14104b9e78..1c24faaf2c 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -242,7 +242,7 @@ void Filler::addNotifications() { void Filler::addSearch() { _addAction(lang(lng_profile_search_messages), [peer = _peer] { - App::main()->searchInPeer(peer); + App::main()->searchInChat(App::history(peer)); }); }