mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-29 11:13:53 +02:00
Added experimental option to display date when you joined to channel.
This commit is contained in:
parent
9b2b8b6796
commit
165cf6809f
4 changed files with 66 additions and 15 deletions
|
@ -2221,6 +2221,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_you_paid_stars#one" = "You paid {count} Star.";
|
"lng_you_paid_stars#one" = "You paid {count} Star.";
|
||||||
"lng_you_paid_stars#other" = "You paid {count} Stars.";
|
"lng_you_paid_stars#other" = "You paid {count} Stars.";
|
||||||
|
|
||||||
|
"lng_you_joined_group" = "You joined this group";
|
||||||
|
|
||||||
"lng_similar_channels_title" = "Similar channels";
|
"lng_similar_channels_title" = "Similar channels";
|
||||||
"lng_similar_channels_view_all" = "View all";
|
"lng_similar_channels_view_all" = "View all";
|
||||||
"lng_similar_channels_more" = "More Channels";
|
"lng_similar_channels_more" = "More Channels";
|
||||||
|
|
|
@ -113,6 +113,12 @@ base::options::toggle ShowPeerIdBelowAbout({
|
||||||
" Add contact IDs to exported data.",
|
" Add contact IDs to exported data.",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
base::options::toggle ShowChannelJoinedBelowAbout({
|
||||||
|
.id = kOptionShowChannelJoinedBelowAbout,
|
||||||
|
.name = "Show Channel Joined Date in Profile",
|
||||||
|
.description = "Show when you join Channel under its Description.",
|
||||||
|
});
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> UsernamesSubtext(
|
[[nodiscard]] rpl::producer<TextWithEntities> UsernamesSubtext(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
rpl::producer<QString> fallback) {
|
rpl::producer<QString> fallback) {
|
||||||
|
@ -183,24 +189,47 @@ base::options::toggle ShowPeerIdBelowAbout({
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> AboutWithIdValue(
|
[[nodiscard]] rpl::producer<TextWithEntities> AboutWithAdvancedValue(
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer) {
|
||||||
|
|
||||||
return AboutValue(
|
return AboutValue(
|
||||||
peer
|
peer
|
||||||
) | rpl::map([=](TextWithEntities &&value) {
|
) | rpl::map([=](TextWithEntities &&value) {
|
||||||
if (!ShowPeerIdBelowAbout.value()) {
|
if (ShowPeerIdBelowAbout.value()) {
|
||||||
return std::move(value);
|
using namespace Ui::Text;
|
||||||
|
if (!value.empty()) {
|
||||||
|
value.append("\n\n");
|
||||||
|
}
|
||||||
|
value.append(Italic(u"id: "_q));
|
||||||
|
const auto raw = peer->id.value & PeerId::kChatTypeMask;
|
||||||
|
value.append(Link(
|
||||||
|
Italic(Lang::FormatCountDecimal(raw)),
|
||||||
|
"internal:~peer_id~:copy:" + QString::number(raw)));
|
||||||
}
|
}
|
||||||
using namespace Ui::Text;
|
if (ShowChannelJoinedBelowAbout.value()) {
|
||||||
if (!value.empty()) {
|
if (const auto channel = peer->asChannel()) {
|
||||||
value.append("\n\n");
|
if (!channel->amCreator() && channel->inviteDate) {
|
||||||
|
if (!value.empty()) {
|
||||||
|
if (ShowPeerIdBelowAbout.value()) {
|
||||||
|
value.append("\n");
|
||||||
|
} else {
|
||||||
|
value.append("\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using namespace Ui::Text;
|
||||||
|
value.append((channel->isMegagroup()
|
||||||
|
? tr::lng_you_joined_group
|
||||||
|
: tr::lng_action_you_joined)(
|
||||||
|
tr::now,
|
||||||
|
Ui::Text::Italic));
|
||||||
|
value.append(Italic(": "));
|
||||||
|
const auto raw = channel->inviteDate;
|
||||||
|
value.append(Link(
|
||||||
|
Italic(langDateTimeFull(base::unixtime::parse(raw))),
|
||||||
|
"internal:~join_date~:show:" + QString::number(raw)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
value.append(Italic(u"id: "_q));
|
|
||||||
const auto raw = peer->id.value & PeerId::kChatTypeMask;
|
|
||||||
value.append(Link(
|
|
||||||
Italic(Lang::FormatCountDecimal(raw)),
|
|
||||||
"internal:~peer_id~:copy:" + QString::number(raw)));
|
|
||||||
return std::move(value);
|
return std::move(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1178,6 +1207,23 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
return false;
|
return false;
|
||||||
} else if (SetClickContext<CashtagClickHandler>(handler, context)) {
|
} else if (SetClickContext<CashtagClickHandler>(handler, context)) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (handler->url().startsWith(u"internal:~join_date~:"_q)) {
|
||||||
|
const auto joinDate = handler->url().split(
|
||||||
|
u"show:"_q,
|
||||||
|
Qt::SkipEmptyParts).last();
|
||||||
|
if (!joinDate.isEmpty()) {
|
||||||
|
const auto weak = base::make_weak(window);
|
||||||
|
window->session().api().resolveJumpToDate(
|
||||||
|
Dialogs::Key(peer->owner().history(peer)),
|
||||||
|
base::unixtime::parse(joinDate.toULongLong()).date(),
|
||||||
|
[=](not_null<PeerData*> p, MsgId m) {
|
||||||
|
const auto f = Window::SectionShow::Way::Forward;
|
||||||
|
if (const auto strong = weak.get()) {
|
||||||
|
strong->showPeerHistory(p, f, m);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else if (SetClickContext<UrlClickHandler>(handler, context)) {
|
} else if (SetClickContext<UrlClickHandler>(handler, context)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1386,8 +1432,8 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
? tr::lng_info_about_label()
|
? tr::lng_info_about_label()
|
||||||
: tr::lng_info_bio_label();
|
: tr::lng_info_bio_label();
|
||||||
addTranslateToMenu(
|
addTranslateToMenu(
|
||||||
addInfoLine(std::move(label), AboutWithIdValue(user)).text,
|
addInfoLine(std::move(label), AboutWithAdvancedValue(user)).text,
|
||||||
AboutWithIdValue(user));
|
AboutWithAdvancedValue(user));
|
||||||
|
|
||||||
const auto usernameLine = addInfoOneLine(
|
const auto usernameLine = addInfoOneLine(
|
||||||
UsernamesSubtext(_peer, tr::lng_info_username_label()),
|
UsernamesSubtext(_peer, tr::lng_info_username_label()),
|
||||||
|
@ -1517,9 +1563,9 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
|
|
||||||
const auto about = addInfoLine(tr::lng_info_about_label(), _topic
|
const auto about = addInfoLine(tr::lng_info_about_label(), _topic
|
||||||
? rpl::single(TextWithEntities())
|
? rpl::single(TextWithEntities())
|
||||||
: AboutWithIdValue(_peer));
|
: AboutWithAdvancedValue(_peer));
|
||||||
if (!_topic) {
|
if (!_topic) {
|
||||||
addTranslateToMenu(about.text, AboutWithIdValue(_peer));
|
addTranslateToMenu(about.text, AboutWithAdvancedValue(_peer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_peer->isSelf()) {
|
if (!_peer->isSelf()) {
|
||||||
|
@ -2641,6 +2687,7 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about";
|
const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about";
|
||||||
|
const char kOptionShowChannelJoinedBelowAbout[] = "show-channel-joined-below-about";
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> SetupDetails(
|
object_ptr<Ui::RpWidget> SetupDetails(
|
||||||
not_null<Controller*> controller,
|
not_null<Controller*> controller,
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Controller;
|
||||||
namespace Info::Profile {
|
namespace Info::Profile {
|
||||||
|
|
||||||
extern const char kOptionShowPeerIdBelowAbout[];
|
extern const char kOptionShowPeerIdBelowAbout[];
|
||||||
|
extern const char kOptionShowChannelJoinedBelowAbout[];
|
||||||
|
|
||||||
class Cover;
|
class Cover;
|
||||||
struct Origin;
|
struct Origin;
|
||||||
|
|
|
@ -147,6 +147,7 @@ void SetupExperimental(
|
||||||
addToggle(Core::kOptionFractionalScalingEnabled);
|
addToggle(Core::kOptionFractionalScalingEnabled);
|
||||||
addToggle(Window::kOptionViewProfileInChatsListContextMenu);
|
addToggle(Window::kOptionViewProfileInChatsListContextMenu);
|
||||||
addToggle(Info::Profile::kOptionShowPeerIdBelowAbout);
|
addToggle(Info::Profile::kOptionShowPeerIdBelowAbout);
|
||||||
|
addToggle(Info::Profile::kOptionShowChannelJoinedBelowAbout);
|
||||||
addToggle(Ui::kOptionUseSmallMsgBubbleRadius);
|
addToggle(Ui::kOptionUseSmallMsgBubbleRadius);
|
||||||
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
||||||
addToggle(kOptionSendLargePhotos);
|
addToggle(kOptionSendLargePhotos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue