AyuGramDesktop/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp
ZavaruKitsu 8e7b12a23a feat: add dev badges
Co-authored-by: c0re100 <corehusky@gmail.com>
2023-10-29 14:30:07 +03:00

48 lines
1.2 KiB
C++

// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#include "ayu_profile_values.h"
#include "ayu/ayu_settings.h"
#include "ayu/utils/telegram_helpers.h"
#include "data/data_peer.h"
#include "ui/text/text_utilities.h"
constexpr auto kMaxChannelId = -1000000000000;
QString IDString(not_null<PeerData *> peer)
{
auto resultId = QString::number(getBareID(peer));
const auto settings = &AyuSettings::getInstance();
if (settings->showPeerId == 2) {
if (peer->isChannel()) {
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
}
else if (peer->isChat()) {
resultId = resultId.prepend("-");
}
}
return resultId;
}
QString IDString(MsgId topic_root_id)
{
auto resultId = QString::number(topic_root_id.bare);
return resultId;
}
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer)
{
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
}
rpl::producer<TextWithEntities> IDValue(MsgId topicRootId)
{
return rpl::single(IDString(topicRootId)) | Ui::Text::ToWithEntities();
}