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
1 changed files with 24 additions and 11 deletions

View File

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