mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
feat: show DC for users
This commit is contained in:
parent
ab7e4bce1a
commit
75bcd2b24b
3 changed files with 51 additions and 1 deletions
|
@ -517,6 +517,50 @@ QString getMediaDC(not_null<HistoryItem*> message) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString getUserDC(not_null<UserData*> user) {
|
||||||
|
if (user->hasUserpic()) {
|
||||||
|
const auto dc = v::match(
|
||||||
|
user->userpicLocation().file().data,
|
||||||
|
[&](const StorageFileLocation &data)
|
||||||
|
{
|
||||||
|
return data.dcId();
|
||||||
|
},
|
||||||
|
[&](const WebFileLocation &)
|
||||||
|
{
|
||||||
|
// should't happen, but still
|
||||||
|
// all webpages are on DC4
|
||||||
|
return 4;
|
||||||
|
},
|
||||||
|
[&](const GeoPointLocation &)
|
||||||
|
{
|
||||||
|
// shouldn't happen naturally
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
[&](const AudioAlbumThumbLocation &)
|
||||||
|
{
|
||||||
|
// shouldn't happen naturally
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
[&](const PlainUrlLocation &)
|
||||||
|
{
|
||||||
|
// should't happen, but still
|
||||||
|
// all webpages are on DC4
|
||||||
|
return 4;
|
||||||
|
},
|
||||||
|
[&](const InMemoryLocation &)
|
||||||
|
{
|
||||||
|
// shouldn't happen naturally
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (dc > 0) {
|
||||||
|
return getDCName(dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
int getScheduleTime(int64 sumSize) {
|
int getScheduleTime(int64 sumSize) {
|
||||||
auto time = 12;
|
auto time = 12;
|
||||||
time += (int) std::ceil(std::max(6.0, std::ceil(sumSize / 1024.0 / 1024.0 * 0.7))) + 1;
|
time += (int) std::ceil(std::max(6.0, std::ceil(sumSize / 1024.0 / 1024.0 * 0.7))) + 1;
|
||||||
|
|
|
@ -43,6 +43,8 @@ QString getMediaName(not_null<HistoryItem*> message);
|
||||||
QString getMediaResolution(not_null<HistoryItem*> message);
|
QString getMediaResolution(not_null<HistoryItem*> message);
|
||||||
QString getMediaDC(not_null<HistoryItem*> message);
|
QString getMediaDC(not_null<HistoryItem*> message);
|
||||||
|
|
||||||
|
QString getUserDC(not_null<UserData*> user);
|
||||||
|
|
||||||
int getScheduleTime(int64 sumSize);
|
int getScheduleTime(int64 sumSize);
|
||||||
|
|
||||||
void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback);
|
void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback);
|
||||||
|
|
|
@ -79,6 +79,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
#include "ayu/ui/utils/ayu_profile_values.h"
|
#include "ayu/ui/utils/ayu_profile_values.h"
|
||||||
|
#include "ayu/utils/telegram_helpers.h"
|
||||||
#include "ui/text/text_entity.h"
|
#include "ui/text/text_entity.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1155,6 +1156,9 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->showPeerId != 0) {
|
if (settings->showPeerId != 0) {
|
||||||
|
const auto dataCenter = getUserDC(user);
|
||||||
|
const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter;
|
||||||
|
|
||||||
auto idDrawableText = IDValue(
|
auto idDrawableText = IDValue(
|
||||||
user
|
user
|
||||||
) | rpl::map([](TextWithEntities &&text)
|
) | rpl::map([](TextWithEntities &&text)
|
||||||
|
@ -1162,7 +1166,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
return Ui::Text::Code(text.text);
|
return Ui::Text::Code(text.text);
|
||||||
});
|
});
|
||||||
auto idInfo = addInfoOneLine(
|
auto idInfo = addInfoOneLine(
|
||||||
rpl::single(QString("ID")),
|
rpl::single(idLabel),
|
||||||
std::move(idDrawableText),
|
std::move(idDrawableText),
|
||||||
tr::ayu_ContextCopyID(tr::now)
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue