fix: revert share link box & copy as username

This commit is contained in:
AlexeyZavar 2024-08-18 14:40:55 +03:00
parent 9dbc9e59e5
commit 6f754bef8c
3 changed files with 19 additions and 11 deletions

View file

@ -136,13 +136,10 @@ void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
const auto messageDate = base::unixtime::parse(item->date());
const auto messageEditDate = base::unixtime::parse(view ? view->displayedEditDate() : TimeId(0));
#pragma clang diagnostic push
#pragma ide diagnostic ignored "NullDereference"
const auto messageForwardedDate =
isForwarded
isForwarded && forwarded
? base::unixtime::parse(forwarded->originalDate)
: QDateTime();
#pragma clang diagnostic pop
const auto
messageViews = item->hasViews() && item->viewsCount() > 0 ? QString::number(item->viewsCount()) : QString();

View file

@ -146,8 +146,17 @@ base::options::toggle ShowPeerIdBelowAbout({
+ addToLink;
}
if (!link.isEmpty()) {
if (const auto strong = weak.get()) {
FastShareLink(strong, link);
if (addToLink.isEmpty()) {
link = '@' + link.replace("https://t.me/", "");
}
QGuiApplication::clipboard()->setText(link);
const auto isLink = link.startsWith(u"https://t.me/"_q);
if (const auto window = weak.get()) {
window->showToast(isLink
? tr::lng_username_copied(tr::now) // "Link copied to clipboard."
: tr::lng_text_copied(tr::now)); // "Text copied to clipboard."
}
}
};

View file

@ -188,11 +188,13 @@ void CollectibleInfoBox(
Ui::Text::Link(formatted),
Ui::Text::WithEntities);
const auto copyCallback = [box, type, formatted, text = info.copyText] {
QGuiApplication::clipboard()->setText(
text.isEmpty() ? formatted : text);
box->uiShow()->showToast((type == CollectibleType::Phone)
? tr::lng_text_copied(tr::now)
: tr::lng_username_copied(tr::now));
auto toCopy = text.isEmpty() ? formatted : text;
if (type == CollectibleType::Username) {
toCopy = "@" + toCopy.replace("https://t.me/", "");
}
QGuiApplication::clipboard()->setText(toCopy);
box->uiShow()->showToast(tr::lng_text_copied(tr::now));
};
box->addRow(
object_ptr<Ui::FlatLabel>(