mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
feat: improve stickerpack author
Co-authored-by: kotecat <davidshaldunov@gmail.com>
This commit is contained in:
parent
38b5cab006
commit
2804cc2d1e
5 changed files with 23 additions and 14 deletions
|
@ -45,7 +45,6 @@ bool ResolveUser(
|
|||
|
||||
searchById(userId,
|
||||
&controller->session(),
|
||||
false,
|
||||
[=](const QString &title, UserData *data)
|
||||
{
|
||||
if (data) {
|
||||
|
|
|
@ -391,7 +391,7 @@ void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
|
|||
}
|
||||
|
||||
if (isSticker) {
|
||||
const auto authorId = media->document()->sticker()->set.id >> 32;
|
||||
const auto authorId = getUserIdFromPackId(media->document()->sticker()->set.id);
|
||||
|
||||
if (authorId != 0) {
|
||||
menu2->addAction(Ui::ContextActionStickerAuthor(
|
||||
|
@ -404,7 +404,7 @@ void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
|
|||
}
|
||||
|
||||
if (containsSingleCustomEmojiPack) {
|
||||
const auto authorId = emojiPacks.front().id >> 32;
|
||||
const auto authorId = getUserIdFromPackId(emojiPacks.front().id);
|
||||
|
||||
if (authorId != 0) {
|
||||
menu2->addAction(Ui::ContextActionStickerAuthor(
|
||||
|
|
|
@ -232,9 +232,12 @@ void ActionStickerPackAuthor::searchAuthor(ID authorId) {
|
|||
setClickedCallback(
|
||||
[=]
|
||||
{
|
||||
const auto text =
|
||||
QString("int32: %1\nint64: %2").arg(authorId).arg(0x100000000L + authorId);
|
||||
QGuiApplication::clipboard()->setText(text);
|
||||
QGuiApplication::clipboard()->setText(QString::number(authorId));
|
||||
if (const auto window = _session->tryResolveWindow()) {
|
||||
if (const auto mainWidget = window->widget()->sessionController()) {
|
||||
mainWidget->showToast(tr::ayu_IDCopiedToast(tr::now));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
crl::on_main(
|
||||
|
|
|
@ -718,7 +718,7 @@ void searchUser(long long userId, Main::Session *session, bool searchUserFlag, c
|
|||
}).handleAllErrors().send();
|
||||
}
|
||||
|
||||
void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback) {
|
||||
void searchById(ID userId, Main::Session *session, const Callback &callback) {
|
||||
if (userId == 0 || !session) {
|
||||
callback(QString(), nullptr);
|
||||
return;
|
||||
|
@ -737,15 +737,20 @@ void searchById(ID userId, Main::Session *session, bool retry, const Callback &c
|
|||
if (data && data->accessHash()) {
|
||||
callback(title, data);
|
||||
} else {
|
||||
if (retry) {
|
||||
searchById(0x100000000 + userId, session, false, callback);
|
||||
} else {
|
||||
callback(QString(), nullptr);
|
||||
}
|
||||
callback(QString(), nullptr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void searchById(ID userId, Main::Session *session, const Callback &callback) {
|
||||
searchById(userId, session, true, callback);
|
||||
ID getUserIdFromPackId(uint64 id) {
|
||||
// https://github.com/TDesktop-x64/tdesktop/pull/218/commits/844e5f0ab116e7639cfc79633a68afe8fdcbc463
|
||||
auto ownerId = id >> 32;
|
||||
if ((id >> 16 & 0xff) == 0x3f) {
|
||||
ownerId |= 0x80000000;
|
||||
}
|
||||
if (id >> 24 & 0xff) {
|
||||
ownerId += 0x100000000;
|
||||
}
|
||||
|
||||
return ownerId;
|
||||
}
|
||||
|
|
|
@ -47,3 +47,5 @@ int getScheduleTime(int64 sumSize);
|
|||
|
||||
void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback);
|
||||
void searchById(ID userId, Main::Session *session, const Callback &callback);
|
||||
|
||||
ID getUserIdFromPackId(uint64 id);
|
||||
|
|
Loading…
Add table
Reference in a new issue