mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-29 19:23:58 +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#other" = "You paid {count} Stars.";
|
||||
|
||||
"lng_you_joined_group" = "You joined this group";
|
||||
|
||||
"lng_similar_channels_title" = "Similar channels";
|
||||
"lng_similar_channels_view_all" = "View all";
|
||||
"lng_similar_channels_more" = "More Channels";
|
||||
|
|
|
@ -113,6 +113,12 @@ base::options::toggle ShowPeerIdBelowAbout({
|
|||
" 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(
|
||||
not_null<PeerData*> peer,
|
||||
rpl::producer<QString> fallback) {
|
||||
|
@ -183,15 +189,13 @@ base::options::toggle ShowPeerIdBelowAbout({
|
|||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] rpl::producer<TextWithEntities> AboutWithIdValue(
|
||||
[[nodiscard]] rpl::producer<TextWithEntities> AboutWithAdvancedValue(
|
||||
not_null<PeerData*> peer) {
|
||||
|
||||
return AboutValue(
|
||||
peer
|
||||
) | rpl::map([=](TextWithEntities &&value) {
|
||||
if (!ShowPeerIdBelowAbout.value()) {
|
||||
return std::move(value);
|
||||
}
|
||||
if (ShowPeerIdBelowAbout.value()) {
|
||||
using namespace Ui::Text;
|
||||
if (!value.empty()) {
|
||||
value.append("\n\n");
|
||||
|
@ -201,6 +205,31 @@ base::options::toggle ShowPeerIdBelowAbout({
|
|||
value.append(Link(
|
||||
Italic(Lang::FormatCountDecimal(raw)),
|
||||
"internal:~peer_id~:copy:" + QString::number(raw)));
|
||||
}
|
||||
if (ShowChannelJoinedBelowAbout.value()) {
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::move(value);
|
||||
});
|
||||
}
|
||||
|
@ -1178,6 +1207,23 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
return false;
|
||||
} else if (SetClickContext<CashtagClickHandler>(handler, context)) {
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1386,8 +1432,8 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
? tr::lng_info_about_label()
|
||||
: tr::lng_info_bio_label();
|
||||
addTranslateToMenu(
|
||||
addInfoLine(std::move(label), AboutWithIdValue(user)).text,
|
||||
AboutWithIdValue(user));
|
||||
addInfoLine(std::move(label), AboutWithAdvancedValue(user)).text,
|
||||
AboutWithAdvancedValue(user));
|
||||
|
||||
const auto usernameLine = addInfoOneLine(
|
||||
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
|
||||
? rpl::single(TextWithEntities())
|
||||
: AboutWithIdValue(_peer));
|
||||
: AboutWithAdvancedValue(_peer));
|
||||
if (!_topic) {
|
||||
addTranslateToMenu(about.text, AboutWithIdValue(_peer));
|
||||
addTranslateToMenu(about.text, AboutWithAdvancedValue(_peer));
|
||||
}
|
||||
}
|
||||
if (!_peer->isSelf()) {
|
||||
|
@ -2641,6 +2687,7 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
|||
} // namespace
|
||||
|
||||
const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about";
|
||||
const char kOptionShowChannelJoinedBelowAbout[] = "show-channel-joined-below-about";
|
||||
|
||||
object_ptr<Ui::RpWidget> SetupDetails(
|
||||
not_null<Controller*> controller,
|
||||
|
|
|
@ -25,6 +25,7 @@ class Controller;
|
|||
namespace Info::Profile {
|
||||
|
||||
extern const char kOptionShowPeerIdBelowAbout[];
|
||||
extern const char kOptionShowChannelJoinedBelowAbout[];
|
||||
|
||||
class Cover;
|
||||
struct Origin;
|
||||
|
|
|
@ -147,6 +147,7 @@ void SetupExperimental(
|
|||
addToggle(Core::kOptionFractionalScalingEnabled);
|
||||
addToggle(Window::kOptionViewProfileInChatsListContextMenu);
|
||||
addToggle(Info::Profile::kOptionShowPeerIdBelowAbout);
|
||||
addToggle(Info::Profile::kOptionShowChannelJoinedBelowAbout);
|
||||
addToggle(Ui::kOptionUseSmallMsgBubbleRadius);
|
||||
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
||||
addToggle(kOptionSendLargePhotos);
|
||||
|
|
Loading…
Add table
Reference in a new issue