mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 15:04:57 +00:00
52 lines
1.4 KiB
C++
52 lines
1.4 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, 2026
|
|
#include "ayu/ui/utils/ayu_profile_values.h"
|
|
|
|
#include "ayu/ayu_settings.h"
|
|
#include "ayu/utils/telegram_helpers.h"
|
|
#include "data/data_peer.h"
|
|
#include "lang/lang_text_entity.h"
|
|
|
|
constexpr auto kMaxChannelId = -1000000000000;
|
|
|
|
QString IDString(const not_null<PeerData*> peer) {
|
|
auto resultId = QString::number(getBareID(peer));
|
|
|
|
const auto &settings = AyuSettings::getInstance();
|
|
if (settings.showPeerId() == PeerIdDisplay::BotApi) {
|
|
if (peer->isChannel()) {
|
|
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
|
|
} else if (peer->isChat()) {
|
|
resultId = resultId.prepend("-");
|
|
}
|
|
}
|
|
|
|
return resultId;
|
|
}
|
|
|
|
QString IDString(MsgId topicRootId) {
|
|
return QString::number(topicRootId.bare);
|
|
}
|
|
|
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer) {
|
|
return AyuSettings::getInstance().showPeerIdValue(
|
|
) | rpl::map([=](PeerIdDisplay display) {
|
|
return (display == PeerIdDisplay::Hidden)
|
|
? TextWithEntities()
|
|
: tr::marked(IDString(peer));
|
|
});
|
|
}
|
|
|
|
rpl::producer<TextWithEntities> IDValue(MsgId topicRootId) {
|
|
return AyuSettings::getInstance().showPeerIdValue(
|
|
) | rpl::map([=](PeerIdDisplay display) {
|
|
return (display == PeerIdDisplay::Hidden)
|
|
? TextWithEntities()
|
|
: tr::marked(IDString(topicRootId));
|
|
});
|
|
}
|