Removed text commands from dialogs row.

This commit is contained in:
23rd 2021-12-25 19:19:00 +03:00 committed by John Preston
parent 889d7c0c15
commit 10df3dce7c

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/text/text_utilities.h"
#include "dialogs/dialogs_entry.h" #include "dialogs/dialogs_entry.h"
#include "data/data_folder.h" #include "data/data_folder.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
@ -20,10 +21,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Dialogs { namespace Dialogs {
namespace { namespace {
QString ComposeFolderListEntryText(not_null<Data::Folder*> folder) { [[nodiscard]] TextWithEntities ComposeFolderListEntryText(
not_null<Data::Folder*> folder) {
const auto &list = folder->lastHistories(); const auto &list = folder->lastHistories();
if (list.empty()) { if (list.empty()) {
return QString(); return {};
} }
const auto count = std::max( const auto count = std::max(
@ -39,11 +41,15 @@ QString ComposeFolderListEntryText(not_null<Data::Folder*> folder) {
); );
const auto wrapName = [](not_null<History*> history) { const auto wrapName = [](not_null<History*> history) {
const auto name = TextUtilities::Clean(history->peer->name); const auto name = TextUtilities::Clean(history->peer->name);
return (history->unreadCount() > 0) return TextWithEntities{
? (textcmdStartSemibold() .text = name,
+ textcmdLink(1, name) .entities = (history->unreadCount() > 0)
+ textcmdStopSemibold()) ? EntitiesInText{
: name; { EntityType::Semibold, 0, int(name.size()), QString() },
{ EntityType::CustomUrl, 0, int(name.size()), QString() },
}
: EntitiesInText{}
};
}; };
const auto shown = int(peers.size()); const auto shown = int(peers.size());
const auto accumulated = [&] { const auto accumulated = [&] {
@ -57,12 +63,19 @@ QString ComposeFolderListEntryText(not_null<Data::Folder*> folder) {
lt_accumulated, lt_accumulated,
result, result,
lt_chat, lt_chat,
wrapName(*i)); wrapName(*i),
Ui::Text::WithEntities);
} }
return result; return result;
}(); }();
return (shown < count) return (shown < count)
? tr::lng_archived_last(tr::now, lt_count, (count - shown), lt_chats, accumulated) ? tr::lng_archived_last(
tr::now,
lt_count,
(count - shown),
lt_chats,
accumulated,
Ui::Text::WithEntities)
: accumulated; : accumulated;
} }
@ -277,7 +290,7 @@ void Row::validateListEntryCache() const {
return; return;
} }
_listEntryCacheVersion = version; _listEntryCacheVersion = version;
_listEntryCache.setText( _listEntryCache.setMarkedText(
st::dialogsTextStyle, st::dialogsTextStyle,
ComposeFolderListEntryText(folder), ComposeFolderListEntryText(folder),
Ui::DialogTextOptions()); Ui::DialogTextOptions());
@ -288,4 +301,4 @@ FakeRow::FakeRow(Key searchInChat, not_null<HistoryItem*> item)
, _item(item) { , _item(item) {
} }
} // namespace Dialogs } // namespace Dialogs