Feed top bar placeholder.

This commit is contained in:
John Preston 2018-01-22 20:39:20 +03:00
parent 47ad5ea98a
commit b9ad8bb700
15 changed files with 156 additions and 99 deletions

View File

@ -1027,9 +1027,11 @@ namespace {
void feedOutboxRead(const PeerId &peer, MsgId upTo, TimeId when) { void feedOutboxRead(const PeerId &peer, MsgId upTo, TimeId when) {
if (auto history = App::historyLoaded(peer)) { if (auto history = App::historyLoaded(peer)) {
history->outboxRead(upTo); history->outboxRead(upTo);
if (history->lastMsg && history->lastMsg->out() && history->lastMsg->id <= upTo) { if (history->lastMsg
if (App::main()) { && history->lastMsg->out()
App::main()->dlgUpdated(history, history->lastMsg->id); && history->lastMsg->id <= upTo) {
if (const auto main = App::main()) {
main->repaintDialogRow(history, history->lastMsg->id);
} }
} }
history->updateChatListEntry(); history->updateChatListEntry();

View File

@ -153,11 +153,11 @@ void Entry::addChatListEntryByLetter(
void Entry::updateChatListEntry() const { void Entry::updateChatListEntry() const {
if (const auto main = App::main()) { if (const auto main = App::main()) {
if (inChatList(Mode::All)) { if (inChatList(Mode::All)) {
main->dlgUpdated( main->repaintDialogRow(
Mode::All, Mode::All,
mainChatListLink(Mode::All)); mainChatListLink(Mode::All));
if (inChatList(Mode::Important)) { if (inChatList(Mode::Important)) {
main->dlgUpdated( main->repaintDialogRow(
Mode::Important, Mode::Important,
mainChatListLink(Mode::Important)); mainChatListLink(Mode::Important));
} }

View File

@ -764,7 +764,7 @@ void DialogsInner::mousePressEvent(QMouseEvent *e) {
row->addRipple( row->addRipple(
e->pos() - QPoint(0, filteredOffset() + _filteredPressed * st::dialogsRowHeight), e->pos() - QPoint(0, filteredOffset() + _filteredPressed * st::dialogsRowHeight),
QSize(getFullWidth(), st::dialogsRowHeight), QSize(getFullWidth(), st::dialogsRowHeight),
[=] { dlgUpdated(list, row); }); [=] { repaintDialogRow(list, row); });
} else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) { } else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) {
auto &result = _peerSearchResults[_peerSearchPressed]; auto &result = _peerSearchResults[_peerSearchPressed];
auto row = &result->row; auto row = &result->row;
@ -1222,7 +1222,7 @@ void DialogsInner::removeDialog(Dialogs::Key key) {
refresh(); refresh();
} }
void DialogsInner::dlgUpdated( void DialogsInner::repaintDialogRow(
Dialogs::Mode list, Dialogs::Mode list,
not_null<Dialogs::Row*> row) { not_null<Dialogs::Row*> row) {
if (_state == State::Default) { if (_state == State::Default) {
@ -1250,9 +1250,11 @@ void DialogsInner::dlgUpdated(
} }
} }
void DialogsInner::dlgUpdated(not_null<History*> history, MsgId msgId) { void DialogsInner::repaintDialogRow(
not_null<History*> history,
MsgId messageId) {
updateDialogRow( updateDialogRow(
Dialogs::RowDescriptor(history, msgId), Dialogs::RowDescriptor(history, messageId),
QRect(0, 0, getFullWidth(), st::dialogsRowHeight)); QRect(0, 0, getFullWidth(), st::dialogsRowHeight));
} }
@ -1275,7 +1277,17 @@ void DialogsInner::updateDialogRow(
Dialogs::RowDescriptor row, Dialogs::RowDescriptor row,
QRect updateRect, QRect updateRect,
UpdateRowSections sections) { 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( rtlupdate(
updateRect.x(), updateRect.x(),
rowTop + updateRect.y(), rowTop + updateRect.y(),

View File

@ -53,8 +53,8 @@ public:
void createDialog(Dialogs::Key key); void createDialog(Dialogs::Key key);
void removeDialog(Dialogs::Key key); void removeDialog(Dialogs::Key key);
void dlgUpdated(Dialogs::Mode list, not_null<Dialogs::Row*> row); void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
void dlgUpdated(not_null<History*> history, MsgId msgId); void repaintDialogRow(not_null<History*> history, MsgId messageId);
void dragLeft(); void dragLeft();

View File

@ -203,14 +203,16 @@ void DialogsWidget::createDialog(Dialogs::Key key) {
} }
} }
void DialogsWidget::dlgUpdated( void DialogsWidget::repaintDialogRow(
Dialogs::Mode list, Dialogs::Mode list,
not_null<Dialogs::Row*> row) { not_null<Dialogs::Row*> row) {
_inner->dlgUpdated(list, row); _inner->repaintDialogRow(list, row);
} }
void DialogsWidget::dlgUpdated(not_null<History*> history, MsgId msgId) { void DialogsWidget::repaintDialogRow(
_inner->dlgUpdated(history, msgId); not_null<History*> history,
MsgId messageId) {
_inner->repaintDialogRow(history, messageId);
} }
void DialogsWidget::dialogsToUp() { void DialogsWidget::dialogsToUp() {
@ -928,9 +930,14 @@ void DialogsWidget::onFilterUpdate(bool force) {
_lastFilterText = filterText; _lastFilterText = filterText;
} }
void DialogsWidget::searchInPeer(PeerData *peer) { void DialogsWidget::searchInChat(Dialogs::Key chat) {
onCancelSearch(); onCancelSearch();
setSearchInPeer(peer); if (const auto peer = chat.peer()) {
setSearchInPeer(peer);
} else {
// #TODO feeds search
setSearchInPeer(nullptr);
}
onFilterUpdate(true); onFilterUpdate(true);
} }

View File

@ -52,14 +52,14 @@ public:
void updateDragInScroll(bool inScroll); void updateDragInScroll(bool inScroll);
void searchInPeer(PeerData *peer); void searchInChat(Dialogs::Key chat);
void loadDialogs(); void loadDialogs();
void loadPinnedDialogs(); void loadPinnedDialogs();
void createDialog(Dialogs::Key key); void createDialog(Dialogs::Key key);
void removeDialog(Dialogs::Key key); void removeDialog(Dialogs::Key key);
void dlgUpdated(Dialogs::Mode list, not_null<Dialogs::Row*> row); void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
void dlgUpdated(not_null<History*> history, MsgId msgId); void repaintDialogRow(not_null<History*> history, MsgId messageId);
void dialogsToUp(); void dialogsToUp();

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "history/view/history_view_message.h" #include "history/view/history_view_message.h"
#include "history/view/history_view_service_message.h" #include "history/view/history_view_service_message.h"
#include "mainwidget.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/shadow.h" #include "ui/widgets/shadow.h"
@ -60,6 +61,8 @@ Widget::Widget(
this, this,
lang(lng_feed_show_next).toUpper(), lang(lng_feed_show_next).toUpper(),
st::historyComposeButton) { st::historyComposeButton) {
_topBar->setActiveChat(_feed);
_topBar->move(0, 0); _topBar->move(0, 0);
_topBar->resizeToWidth(width()); _topBar->resizeToWidth(width());
_topBar->show(); _topBar->show();
@ -138,7 +141,8 @@ bool Widget::cmd_search() {
if (!inFocusChain()) { if (!inFocusChain()) {
return false; return false;
} }
// #TODO feeds search
App::main()->searchInChat(_feed);
return true; return true;
} }

View File

@ -129,9 +129,9 @@ ReplyKeyboard *HistoryItem::inlineReplyKeyboard() {
} }
void HistoryItem::invalidateChatsListEntry() { void HistoryItem::invalidateChatsListEntry() {
if (App::main()) { if (const auto main = App::main()) {
// #TODO feeds search results // #TODO feeds search results
App::main()->dlgUpdated(history(), id); main->repaintDialogRow(history(), id);
} }
// invalidate cache for drawInDialog // invalidate cache for drawInDialog

View File

@ -621,9 +621,9 @@ void HistoryService::updateDependentText() {
feed->updateChatListEntry(); feed->updateChatListEntry();
} }
} }
if (App::main()) { if (const auto main = App::main()) {
// #TODO feeds search results // #TODO feeds search results
App::main()->dlgUpdated(history(), id); main->repaintDialogRow(history(), id);
} }
App::historyUpdateDependent(this); App::historyUpdateDependent(this);
} }

View File

@ -1423,9 +1423,9 @@ void HistoryWidget::notify_migrateUpdated(PeerData *peer) {
} }
bool HistoryWidget::cmd_search() { bool HistoryWidget::cmd_search() {
if (!inFocusChain() || !_peer) return false; if (!inFocusChain() || !_history) return false;
App::main()->searchInPeer(_peer); App::main()->searchInChat(_history);
return true; return true;
} }
@ -1724,8 +1724,6 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
_canSendMessages = _peer->canWrite(); _canSendMessages = _peer->canWrite();
_tabbedSelector->setCurrentPeer(_peer); _tabbedSelector->setCurrentPeer(_peer);
} }
_topBar->setHistoryPeer(_peer);
updateTopBarSelection();
if (_peer && _peer->isChannel()) { if (_peer && _peer->isChannel()) {
_peer->asChannel()->updateFull(); _peer->asChannel()->updateFull();
@ -1742,7 +1740,6 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
noSelectingScroll(); noSelectingScroll();
_nonEmptySelection = false; _nonEmptySelection = false;
_topBar->showSelected(HistoryView::TopBarWidget::SelectedState {});
if (_peer) { if (_peer) {
App::forgetMedia(); App::forgetMedia();
@ -1752,6 +1749,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
_history = App::history(_peer); _history = App::history(_peer);
_migrated = _history->migrateFrom(); _migrated = _history->migrateFrom();
_topBar->setActiveChat(_history);
updateTopBarSelection();
if (_channel) { if (_channel) {
updateNotifySettings(); updateNotifySettings();
if (_peer->notifySettingsUnknown()) { if (_peer->notifySettingsUnknown()) {
@ -1817,6 +1817,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
} }
unreadCountChanged(_history); // set _historyDown badge. unreadCountChanged(_history); // set _historyDown badge.
} else { } else {
_topBar->setActiveChat(Dialogs::Key());
updateTopBarSelection();
clearFieldText(); clearFieldText();
_tabbedSelector->showMegagroupSet(nullptr); _tabbedSelector->showMegagroupSet(nullptr);
doneShow(); doneShow();
@ -4579,7 +4582,8 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
} }
void HistoryWidget::updateControlsGeometry() { void HistoryWidget::updateControlsGeometry() {
_topBar->setGeometryToLeft(0, 0, width(), st::topBarHeight); _topBar->resizeToWidth(width());
_topBar->moveToLeft(0, 0);
moveFieldControls(); moveFieldControls();

View File

@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "calls/calls_instance.h" #include "calls/calls_instance.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "data/data_feed.h"
#include "observer_peer.h" #include "observer_peer.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "styles/style_window.h" #include "styles/style_window.h"
@ -92,11 +93,13 @@ TopBarWidget::TopBarWidget(
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
createUnreadBadge(); createUnreadBadge();
} }
subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) { subscribe(
if (update.history->peer == _historyPeer) { App::histories().sendActionAnimationUpdated(),
this->update(); [this](const Histories::SendActionAnimationUpdate &update) {
} if (update.history == _activeChat.history()) {
}); this->update();
}
});
using UpdateFlag = Notify::PeerUpdate::Flag; using UpdateFlag = Notify::PeerUpdate::Flag;
auto flags = UpdateFlag::UserHasCalls auto flags = UpdateFlag::UserHasCalls
| UpdateFlag::UserOnlineChanged | UpdateFlag::UserOnlineChanged
@ -142,19 +145,22 @@ void TopBarWidget::onClearSelection() {
} }
void TopBarWidget::onSearch() { void TopBarWidget::onSearch() {
if (_historyPeer) { if (_activeChat) {
App::main()->searchInPeer(_historyPeer); App::main()->searchInChat(_activeChat);
} }
} }
void TopBarWidget::onCall() { void TopBarWidget::onCall() {
if (auto user = _historyPeer->asUser()) { if (const auto peer = _activeChat.peer()) {
Calls::Current().startOutgoingCall(user); if (const auto user = peer->asUser()) {
Calls::Current().startOutgoingCall(user);
}
} }
} }
void TopBarWidget::showMenu() { void TopBarWidget::showMenu() {
if (!_historyPeer || _menu) { // #TODO feeds menu
if (!_activeChat || _menu || !_activeChat.peer()) {
return; return;
} }
_menu.create(parentWidget()); _menu.create(parentWidget());
@ -178,7 +184,7 @@ void TopBarWidget::showMenu() {
_menuToggle->installEventFilter(_menu); _menuToggle->installEventFilter(_menu);
Window::FillPeerMenu( Window::FillPeerMenu(
_controller, _controller,
_historyPeer, _activeChat.peer(),
[this](const QString &text, base::lambda<void()> callback) { [this](const QString &text, base::lambda<void()> callback) {
return _menu->addAction(text, std::move(callback)); return _menu->addAction(text, std::move(callback));
}, },
@ -192,20 +198,21 @@ void TopBarWidget::toggleInfoSection() {
&& (Auth().settings().thirdSectionInfoEnabled() && (Auth().settings().thirdSectionInfoEnabled()
|| Auth().settings().tabbedReplacedWithInfo())) { || Auth().settings().tabbedReplacedWithInfo())) {
_controller->closeThirdSection(); _controller->closeThirdSection();
} else if (_historyPeer) { } else if (_activeChat.peer()) {
// #TODO feeds profile
if (_controller->canShowThirdSection()) { if (_controller->canShowThirdSection()) {
Auth().settings().setThirdSectionInfoEnabled(true); Auth().settings().setThirdSectionInfoEnabled(true);
Auth().saveSettingsDelayed(); Auth().saveSettingsDelayed();
if (Adaptive::ThreeColumn()) { if (Adaptive::ThreeColumn()) {
_controller->showSection( _controller->showSection(
Info::Memento::Default(_historyPeer), Info::Memento::Default(_activeChat.peer()),
Window::SectionShow().withThirdColumn()); Window::SectionShow().withThirdColumn());
} else { } else {
_controller->resizeForThirdSection(); _controller->resizeForThirdSection();
_controller->updateColumnLayout(); _controller->updateColumnLayout();
} }
} else { } else {
_controller->showSection(Info::Memento(_historyPeer->id)); _controller->showSection(Info::Memento(_activeChat.peer()->id));
} }
} else { } else {
updateControlsVisibility(); updateControlsVisibility();
@ -231,6 +238,10 @@ bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) {
return TWidget::eventFilter(obj, e); return TWidget::eventFilter(obj, e);
} }
int TopBarWidget::resizeGetHeight(int newWidth) {
return st::topBarHeight;
}
void TopBarWidget::paintEvent(QPaintEvent *e) { void TopBarWidget::paintEvent(QPaintEvent *e) {
if (_animatingMode) { if (_animatingMode) {
return; return;
@ -251,16 +262,30 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
} }
void TopBarWidget::paintTopBar(Painter &p, TimeMs ms) { void TopBarWidget::paintTopBar(Painter &p, TimeMs ms) {
auto history = App::historyLoaded(_historyPeer); if (!_activeChat) {
if (!history) return; return;
}
auto nameleft = _leftTaken; auto nameleft = _leftTaken;
auto nametop = st::topBarArrowPadding.top(); auto nametop = st::topBarArrowPadding.top();
auto statustop = st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height; auto statustop = st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height;
auto namewidth = width() - _rightTaken - nameleft; auto namewidth = width() - _rightTaken - nameleft;
auto history = _activeChat.history();
p.setPen(st::dialogsNameFg); 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 text = lang(lng_saved_messages);
auto textWidth = st::historySavedFont->width(text); auto textWidth = st::historySavedFont->width(text);
if (namewidth < textWidth) { if (namewidth < textWidth) {
@ -272,8 +297,8 @@ void TopBarWidget::paintTopBar(Painter &p, TimeMs ms) {
(height() - st::historySavedFont->height) / 2, (height() - st::historySavedFont->height) / 2,
width(), width(),
text); text);
} else { } else if (const auto history = _activeChat.history()) {
_historyPeer->dialogName().drawElided(p, nameleft, nametop, namewidth); history->peer->dialogName().drawElided(p, nameleft, nametop, namewidth);
p.setFont(st::dialogsTextFont); p.setFont(st::dialogsTextFont);
if (!history->paintSendAction(p, nameleft, statustop, namewidth, width(), st::historyStatusFgTyping, ms)) { if (!history->paintSendAction(p, nameleft, statustop, namewidth, width(), st::historyStatusFgTyping, ms)) {
@ -310,19 +335,23 @@ void TopBarWidget::mousePressEvent(QMouseEvent *e) {
if (handleClick) { if (handleClick) {
if (_animatingMode && _back->rect().contains(e->pos())) { if (_animatingMode && _back->rect().contains(e->pos())) {
backClicked(); backClicked();
} else if (_historyPeer) { } else {
infoClicked(); infoClicked();
} }
} }
} }
void TopBarWidget::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( _controller->showSection(Info::Memento(
_historyPeer->id, _activeChat.peer()->id,
Info::Section(Storage::SharedMediaType::Photo))); Info::Section(Storage::SharedMediaType::Photo)));
} else { } else {
_controller->showPeerInfo(_historyPeer); _controller->showPeerInfo(_activeChat.peer());
} }
} }
@ -330,18 +359,18 @@ void TopBarWidget::backClicked() {
_controller->showBackFromStack(); _controller->showBackFromStack();
} }
void TopBarWidget::setHistoryPeer(PeerData *historyPeer) { void TopBarWidget::setActiveChat(Dialogs::Key chat) {
if (_historyPeer != historyPeer) { if (_activeChat != chat) {
_historyPeer = historyPeer; _activeChat = chat;
_back->clearState(); _back->clearState();
update(); update();
updateUnreadBadge(); updateUnreadBadge();
if (_historyPeer) { if (const auto peer = _activeChat.peer()) {
_info.create( _info.create(
this, this,
_controller, _controller,
_historyPeer, peer,
Ui::UserpicButton::Role::Custom, Ui::UserpicButton::Role::Custom,
st::topBarInfoButton); st::topBarInfoButton);
_info->showSavedMessagesOnSelf(true); _info->showSavedMessagesOnSelf(true);
@ -456,10 +485,14 @@ void TopBarWidget::updateControlsVisibility() {
_menuToggle->show(); _menuToggle->show();
_infoToggle->setVisible(!Adaptive::OneColumn() _infoToggle->setVisible(!Adaptive::OneColumn()
&& _controller->canShowThirdSection()); && _controller->canShowThirdSection());
auto callsEnabled = false; const auto callsEnabled = [&] {
if (auto user = _historyPeer ? _historyPeer->asUser() : nullptr) { if (const auto peer = _activeChat.peer()) {
callsEnabled = Global::PhoneCallsEnabled() && user->hasCalls(); if (const auto user = peer->asUser()) {
} return Global::PhoneCallsEnabled() && user->hasCalls();
}
}
return false;
}();
_call->setVisible(callsEnabled); _call->setVisible(callsEnabled);
if (_membersShowArea) { if (_membersShowArea) {
@ -580,10 +613,10 @@ void TopBarWidget::updateUnreadBadge() {
+ (Global::IncludeMuted() ? 0 : mutedCount); + (Global::IncludeMuted() ? 0 : mutedCount);
// Do not include currently shown chat in the top bar unread counter. // Do not include currently shown chat in the top bar unread counter.
if (auto historyShown = App::historyLoaded(_historyPeer)) { if (const auto history = _activeChat.history()) {
auto shownUnreadCount = historyShown->unreadCount(); auto shownUnreadCount = history->unreadCount();
fullCounter -= shownUnreadCount; fullCounter -= shownUnreadCount;
if (historyShown->mute()) { if (history->mute()) {
mutedCount -= shownUnreadCount; mutedCount -= shownUnreadCount;
} }
} }
@ -614,15 +647,15 @@ void TopBarWidget::updateInfoToggleActive() {
} }
void TopBarWidget::updateOnlineDisplay() { void TopBarWidget::updateOnlineDisplay() {
if (!_historyPeer) return; if (!_activeChat.peer()) return;
QString text; QString text;
const auto now = unixtime(); const auto now = unixtime();
bool titlePeerTextOnline = false; bool titlePeerTextOnline = false;
if (const auto user = _historyPeer->asUser()) { if (const auto user = _activeChat.peer()->asUser()) {
text = Data::OnlineText(user, now); text = Data::OnlineText(user, now);
titlePeerTextOnline = Data::OnlineTextActive(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()) { if (!chat->amIn()) {
text = lang(lng_chat_status_unaccessible); text = lang(lng_chat_status_unaccessible);
} else if (chat->participants.empty()) { } else if (chat->participants.empty()) {
@ -652,7 +685,7 @@ void TopBarWidget::updateOnlineDisplay() {
text = lang(lng_group_status); 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->isMegagroup() && channel->membersCount() > 0 && channel->membersCount() <= Global::ChatSizeMax()) {
if (channel->mgInfo->lastParticipants.empty() || channel->lastParticipantsCountOutdated()) { if (channel->mgInfo->lastParticipants.empty() || channel->lastParticipantsCountOutdated()) {
Auth().api().requestLastParticipants(channel); Auth().api().requestLastParticipants(channel);
@ -693,7 +726,7 @@ void TopBarWidget::updateOnlineDisplay() {
} }
void TopBarWidget::updateOnlineDisplayTimer() { void TopBarWidget::updateOnlineDisplayTimer() {
if (!_historyPeer) return; if (!_activeChat.peer()) return;
const auto now = unixtime(); const auto now = unixtime();
auto minTimeout = TimeMs(86400); auto minTimeout = TimeMs(86400);
@ -701,13 +734,13 @@ void TopBarWidget::updateOnlineDisplayTimer() {
auto hisTimeout = Data::OnlineChangeTimeout(user, now); auto hisTimeout = Data::OnlineChangeTimeout(user, now);
accumulate_min(minTimeout, hisTimeout); accumulate_min(minTimeout, hisTimeout);
}; };
if (const auto user = _historyPeer->asUser()) { if (const auto user = _activeChat.peer()->asUser()) {
handleUser(user); handleUser(user);
} else if (auto chat = _historyPeer->asChat()) { } else if (auto chat = _activeChat.peer()->asChat()) {
for (auto [user, v] : chat->participants) { for (auto [user, v] : chat->participants) {
handleUser(user); handleUser(user);
} }
} else if (_historyPeer->isChannel()) { } else if (_activeChat.peer()->isChannel()) {
} }
updateOnlineDisplayIn(minTimeout); updateOnlineDisplayIn(minTimeout);
} }

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "base/timer.h" #include "base/timer.h"
#include "dialogs/dialogs_key.h"
namespace Ui { namespace Ui {
class UserpicButton; class UserpicButton;
@ -45,7 +46,7 @@ public:
} }
void setAnimatingMode(bool enabled); void setAnimatingMode(bool enabled);
void setHistoryPeer(PeerData *historyPeer); void setActiveChat(Dialogs::Key chat);
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
@ -53,6 +54,8 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;
int resizeGetHeight(int newWidth) override;
private: private:
void refreshLang(); void refreshLang();
void updateControlsGeometry(); void updateControlsGeometry();
@ -84,7 +87,7 @@ private:
void updateUnreadBadge(); void updateUnreadBadge();
not_null<Window::Controller*> _controller; not_null<Window::Controller*> _controller;
PeerData *_historyPeer = nullptr; Dialogs::Key _activeChat;
int _selectedCount = 0; int _selectedCount = 0;
bool _canDelete = false; bool _canDelete = false;

View File

@ -2771,24 +2771,16 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams &param
return result; return result;
} }
void MainWidget::dlgUpdated( void MainWidget::repaintDialogRow(
Dialogs::Mode list, Dialogs::Mode list,
not_null<Dialogs::Row*> row) { not_null<Dialogs::Row*> row) {
if (row) { _dialogs->repaintDialogRow(list, row);
_dialogs->dlgUpdated(list, row);
}
} }
void MainWidget::dlgUpdated(not_null<History*> history, MsgId msgId) { void MainWidget::repaintDialogRow(
if (msgId < 0 && -msgId < ServerMaxMsgId) { not_null<History*> history,
if (const auto from = history->peer->migrateFrom()) { MsgId messageId) {
if (const auto migrated = App::historyLoaded(from)) { _dialogs->repaintDialogRow(history, messageId);
_dialogs->dlgUpdated(migrated, -msgId);
}
}
} else {
_dialogs->dlgUpdated(history, msgId);
}
} }
void MainWidget::windowShown() { void MainWidget::windowShown() {
@ -3413,8 +3405,8 @@ int MainWidget::backgroundFromY() const {
return -getMainSectionTop(); return -getMainSectionTop();
} }
void MainWidget::searchInPeer(PeerData *peer) { void MainWidget::searchInChat(Dialogs::Key chat) {
_dialogs->searchInPeer(peer); _dialogs->searchInChat(chat);
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
dialogsToUp(); dialogsToUp();
Ui::showChatsList(); Ui::showChatsList();

View File

@ -110,8 +110,8 @@ public:
void createDialog(Dialogs::Key key); void createDialog(Dialogs::Key key);
void removeDialog(Dialogs::Key key); void removeDialog(Dialogs::Key key);
void dlgUpdated(Dialogs::Mode list, not_null<Dialogs::Row*> row); void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
void dlgUpdated(not_null<History*> history, MsgId msgId); void repaintDialogRow(not_null<History*> history, MsgId messageId);
void windowShown(); void windowShown();
@ -310,6 +310,8 @@ public:
void documentLoadProgress(DocumentData *document); void documentLoadProgress(DocumentData *document);
void searchInChat(Dialogs::Key chat);
void app_sendBotCallback( void app_sendBotCallback(
not_null<const HistoryMessageMarkupButton*> button, not_null<const HistoryMessageMarkupButton*> button,
not_null<const HistoryItem*> msg, not_null<const HistoryItem*> msg,
@ -357,8 +359,6 @@ public slots:
void updateOnline(bool gotOtherOffline = false); void updateOnline(bool gotOtherOffline = false);
void checkIdleFinish(); void checkIdleFinish();
void searchInPeer(PeerData *peer);
void onUpdateNotifySettings(); void onUpdateNotifySettings();
void onCacheBackground(); void onCacheBackground();

View File

@ -242,7 +242,7 @@ void Filler::addNotifications() {
void Filler::addSearch() { void Filler::addSearch() {
_addAction(lang(lng_profile_search_messages), [peer = _peer] { _addAction(lang(lng_profile_search_messages), [peer = _peer] {
App::main()->searchInPeer(peer); App::main()->searchInChat(App::history(peer));
}); });
} }