mirror of https://github.com/procxx/kepka.git
				
				
				
			Feed top bar placeholder.
This commit is contained in:
		
							parent
							
								
									47ad5ea98a
								
							
						
					
					
						commit
						b9ad8bb700
					
				| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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));
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<Dialogs::Row*> row) {
 | 
			
		||||
	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(
 | 
			
		||||
		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(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,8 +53,8 @@ public:
 | 
			
		|||
 | 
			
		||||
	void createDialog(Dialogs::Key key);
 | 
			
		||||
	void removeDialog(Dialogs::Key key);
 | 
			
		||||
	void dlgUpdated(Dialogs::Mode list, not_null<Dialogs::Row*> row);
 | 
			
		||||
	void dlgUpdated(not_null<History*> history, MsgId msgId);
 | 
			
		||||
	void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
 | 
			
		||||
	void repaintDialogRow(not_null<History*> history, MsgId messageId);
 | 
			
		||||
 | 
			
		||||
	void dragLeft();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -203,14 +203,16 @@ void DialogsWidget::createDialog(Dialogs::Key key) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DialogsWidget::dlgUpdated(
 | 
			
		||||
void DialogsWidget::repaintDialogRow(
 | 
			
		||||
		Dialogs::Mode list,
 | 
			
		||||
		not_null<Dialogs::Row*> row) {
 | 
			
		||||
	_inner->dlgUpdated(list, row);
 | 
			
		||||
	_inner->repaintDialogRow(list, row);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DialogsWidget::dlgUpdated(not_null<History*> history, MsgId msgId) {
 | 
			
		||||
	_inner->dlgUpdated(history, msgId);
 | 
			
		||||
void DialogsWidget::repaintDialogRow(
 | 
			
		||||
		not_null<History*> 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();
 | 
			
		||||
	if (const auto peer = chat.peer()) {
 | 
			
		||||
		setSearchInPeer(peer);
 | 
			
		||||
	} else {
 | 
			
		||||
		// #TODO feeds search
 | 
			
		||||
		setSearchInPeer(nullptr);
 | 
			
		||||
	}
 | 
			
		||||
	onFilterUpdate(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<Dialogs::Row*> row);
 | 
			
		||||
	void dlgUpdated(not_null<History*> history, MsgId msgId);
 | 
			
		||||
	void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
 | 
			
		||||
	void repaintDialogRow(not_null<History*> history, MsgId messageId);
 | 
			
		||||
 | 
			
		||||
	void dialogsToUp();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,8 +93,10 @@ TopBarWidget::TopBarWidget(
 | 
			
		|||
	if (Adaptive::OneColumn()) {
 | 
			
		||||
		createUnreadBadge();
 | 
			
		||||
	}
 | 
			
		||||
	subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) {
 | 
			
		||||
		if (update.history->peer == _historyPeer) {
 | 
			
		||||
	subscribe(
 | 
			
		||||
		App::histories().sendActionAnimationUpdated(),
 | 
			
		||||
		[this](const Histories::SendActionAnimationUpdate &update) {
 | 
			
		||||
			if (update.history == _activeChat.history()) {
 | 
			
		||||
				this->update();
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
| 
						 | 
				
			
			@ -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()) {
 | 
			
		||||
	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<void()> 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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<Window::Controller*> _controller;
 | 
			
		||||
	PeerData *_historyPeer = nullptr;
 | 
			
		||||
	Dialogs::Key _activeChat;
 | 
			
		||||
 | 
			
		||||
	int _selectedCount = 0;
 | 
			
		||||
	bool _canDelete = false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2771,24 +2771,16 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m
 | 
			
		|||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::dlgUpdated(
 | 
			
		||||
void MainWidget::repaintDialogRow(
 | 
			
		||||
		Dialogs::Mode list,
 | 
			
		||||
		not_null<Dialogs::Row*> row) {
 | 
			
		||||
	if (row) {
 | 
			
		||||
		_dialogs->dlgUpdated(list, row);
 | 
			
		||||
	}
 | 
			
		||||
	_dialogs->repaintDialogRow(list, row);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWidget::dlgUpdated(not_null<History*> 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*> 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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -110,8 +110,8 @@ public:
 | 
			
		|||
 | 
			
		||||
	void createDialog(Dialogs::Key key);
 | 
			
		||||
	void removeDialog(Dialogs::Key key);
 | 
			
		||||
	void dlgUpdated(Dialogs::Mode list, not_null<Dialogs::Row*> row);
 | 
			
		||||
	void dlgUpdated(not_null<History*> history, MsgId msgId);
 | 
			
		||||
	void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
 | 
			
		||||
	void repaintDialogRow(not_null<History*> history, MsgId messageId);
 | 
			
		||||
 | 
			
		||||
	void windowShown();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -310,6 +310,8 @@ public:
 | 
			
		|||
 | 
			
		||||
	void documentLoadProgress(DocumentData *document);
 | 
			
		||||
 | 
			
		||||
	void searchInChat(Dialogs::Key chat);
 | 
			
		||||
 | 
			
		||||
	void app_sendBotCallback(
 | 
			
		||||
		not_null<const HistoryMessageMarkupButton*> button,
 | 
			
		||||
		not_null<const HistoryItem*> msg,
 | 
			
		||||
| 
						 | 
				
			
			@ -357,8 +359,6 @@ public slots:
 | 
			
		|||
	void updateOnline(bool gotOtherOffline = false);
 | 
			
		||||
	void checkIdleFinish();
 | 
			
		||||
 | 
			
		||||
	void searchInPeer(PeerData *peer);
 | 
			
		||||
 | 
			
		||||
	void onUpdateNotifySettings();
 | 
			
		||||
 | 
			
		||||
	void onCacheBackground();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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));
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue