Support psa_message in chats list.
This commit is contained in:
		
							parent
							
								
									aabc8173c3
								
							
						
					
					
						commit
						042ed8f54a
					
				
					 6 changed files with 59 additions and 35 deletions
				
			
		|  | @ -3723,12 +3723,12 @@ void Session::setTopPromoted( | |||
| 		|| (history && history->topPromotionMessage() != message)) { | ||||
| 		if (changed) { | ||||
| 			if (const auto history = historyLoaded(_topPromoted)) { | ||||
| 				history->cacheTopPromoted(false, QString(), QString()); | ||||
| 				history->cacheTopPromotion(false, QString(), QString()); | ||||
| 			} | ||||
| 		} | ||||
| 		const auto old = std::exchange(_topPromoted, promoted); | ||||
| 		if (history) { | ||||
| 			history->cacheTopPromoted(true, type, message); | ||||
| 			history->cacheTopPromotion(true, type, message); | ||||
| 			history->requestChatListMessage(); | ||||
| 			Notify::peerUpdatedDelayed( | ||||
| 				_topPromoted, | ||||
|  |  | |||
|  | @ -86,36 +86,22 @@ void Entry::cachePinnedIndex(FilterId filterId, int index) { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void Entry::cacheTopPromoted( | ||||
| 		bool promoted, | ||||
| 		const QString &type, | ||||
| 		const QString &message) { | ||||
| 	if (_isTopPromoted != promoted | ||||
| 		|| _topPromotedType != type | ||||
| 		|| _topPromotedMessage != message) { | ||||
| void Entry::cacheTopPromoted(bool promoted) { | ||||
| 	if (_isTopPromoted == promoted) { | ||||
| 		return; | ||||
| 	} | ||||
| 	_isTopPromoted = promoted; | ||||
| 		_topPromotedType = type; | ||||
| 		_topPromotedMessage = message; | ||||
| 	updateChatListSortPosition(); | ||||
| 	updateChatListEntry(); | ||||
| 	if (!_isTopPromoted) { | ||||
| 		updateChatListExistence(); | ||||
| 	} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| bool Entry::isTopPromoted() const { | ||||
| 	return _isTopPromoted; | ||||
| } | ||||
| 
 | ||||
| QString Entry::topPromotionType() const { | ||||
| 	return _topPromotedType; | ||||
| } | ||||
| 
 | ||||
| QString Entry::topPromotionMessage() const { | ||||
| 	return _topPromotedMessage; | ||||
| } | ||||
| 
 | ||||
| bool Entry::needUpdateInChatList() const { | ||||
| 	return inChatList() || shouldBeInChatList(); | ||||
| } | ||||
|  |  | |||
|  | @ -120,13 +120,7 @@ public: | |||
| 		return lookupPinnedIndex(filterId) != 0; | ||||
| 	} | ||||
| 	void cachePinnedIndex(FilterId filterId, int index); | ||||
| 	void cacheTopPromoted( | ||||
| 		bool promoted, | ||||
| 		const QString &type, | ||||
| 		const QString &message); | ||||
| 	[[nodiscard]] bool isTopPromoted() const; | ||||
| 	[[nodiscard]] QString topPromotionType() const; | ||||
| 	[[nodiscard]] QString topPromotionMessage() const; | ||||
| 	[[nodiscard]] uint64 sortKeyInChatList(FilterId filterId) const { | ||||
| 		return filterId | ||||
| 			? computeSortPosition(filterId) | ||||
|  | @ -197,6 +191,8 @@ protected: | |||
| 
 | ||||
| 	[[nodiscard]] int lookupPinnedIndex(FilterId filterId) const; | ||||
| 
 | ||||
| 	void cacheTopPromoted(bool promoted); | ||||
| 
 | ||||
| private: | ||||
| 	virtual void changedChatListPinHook(); | ||||
| 	void pinnedIndexChanged(int was, int now); | ||||
|  | @ -214,10 +210,8 @@ private: | |||
| 	uint64 _sortKeyInChatList = 0; | ||||
| 	uint64 _sortKeyByDate = 0; | ||||
| 	base::flat_map<FilterId, int> _pinnedIndex; | ||||
| 	QString _topPromotedMessage; | ||||
| 	QString _topPromotedType; | ||||
| 	bool _isTopPromoted = false; | ||||
| 	TimeId _timeId = 0; | ||||
| 	bool _isTopPromoted = false; | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -325,7 +325,18 @@ void paintRow( | |||
| 	auto texttop = st::dialogsPadding.y() | ||||
| 		+ st::msgNameFont->height | ||||
| 		+ st::dialogsSkip; | ||||
| 	if (draft | ||||
| 	if (promoted && !history->topPromotionMessage().isEmpty()) { | ||||
| 		auto availableWidth = namewidth; | ||||
| 		p.setFont(st::dialogsTextFont); | ||||
| 		if (history->cloudDraftTextCache.isEmpty()) { | ||||
| 			history->cloudDraftTextCache.setText( | ||||
| 				st::dialogsTextStyle, | ||||
| 				history->topPromotionMessage(), | ||||
| 				Ui::DialogTextOptions()); | ||||
| 		} | ||||
| 		p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg)); | ||||
| 		history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1); | ||||
| 	} else if (draft | ||||
| 		|| (supportMode | ||||
| 			&& Auth().supportHelper().isOccupiedBySomeone(history))) { | ||||
| 		if (!promoted) { | ||||
|  |  | |||
|  | @ -2718,6 +2718,29 @@ void History::dialogEntryApplied() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void History::cacheTopPromotion( | ||||
| 		bool promoted, | ||||
| 		const QString &type, | ||||
| 		const QString &message) { | ||||
| 	const auto changed = (isTopPromoted() != promoted); | ||||
| 	cacheTopPromoted(promoted); | ||||
| 	if (_topPromotedType != type || _topPromotedMessage != message) { | ||||
| 		_topPromotedType = type; | ||||
| 		_topPromotedMessage = message; | ||||
| 		cloudDraftTextCache.clear(); | ||||
| 	} else if (changed) { | ||||
| 		cloudDraftTextCache.clear(); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| QString History::topPromotionType() const { | ||||
| 	return _topPromotedType; | ||||
| } | ||||
| 
 | ||||
| QString History::topPromotionMessage() const { | ||||
| 	return _topPromotedMessage; | ||||
| } | ||||
| 
 | ||||
| bool History::clearUnreadOnClientSide() const { | ||||
| 	if (!session().supportMode()) { | ||||
| 		return false; | ||||
|  |  | |||
|  | @ -237,6 +237,13 @@ public: | |||
| 		MsgId maxOutboxRead); | ||||
| 	void dialogEntryApplied(); | ||||
| 
 | ||||
| 	void cacheTopPromotion( | ||||
| 		bool promoted, | ||||
| 		const QString &type, | ||||
| 		const QString &message); | ||||
| 	[[nodiscard]] QString topPromotionType() const; | ||||
| 	[[nodiscard]] QString topPromotionMessage() const; | ||||
| 
 | ||||
| 	MsgId minMsgId() const; | ||||
| 	MsgId maxMsgId() const; | ||||
| 	MsgId msgIdForRead() const; | ||||
|  | @ -559,6 +566,9 @@ private: | |||
| 	TimeId _lastSentDraftTime = 0; | ||||
| 	MessageIdsList _forwardDraft; | ||||
| 
 | ||||
| 	QString _topPromotedMessage; | ||||
| 	QString _topPromotedType; | ||||
| 
 | ||||
| 	base::flat_map<not_null<UserData*>, crl::time> _typing; | ||||
| 	base::flat_map<not_null<UserData*>, SendAction> _sendActions; | ||||
| 	QString _sendActionString; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 John Preston
						John Preston