diff --git a/Telegram/Resources/icons/ayu/to_beginning.png b/Telegram/Resources/icons/ayu/to_beginning.png new file mode 100644 index 000000000..f43574b34 Binary files /dev/null and b/Telegram/Resources/icons/ayu/to_beginning.png differ diff --git a/Telegram/Resources/icons/ayu/to_beginning@2x.png b/Telegram/Resources/icons/ayu/to_beginning@2x.png new file mode 100644 index 000000000..609770ec0 Binary files /dev/null and b/Telegram/Resources/icons/ayu/to_beginning@2x.png differ diff --git a/Telegram/Resources/icons/ayu/to_beginning@3x.png b/Telegram/Resources/icons/ayu/to_beginning@3x.png new file mode 100644 index 000000000..0bc4291a1 Binary files /dev/null and b/Telegram/Resources/icons/ayu/to_beginning@3x.png differ diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 334110cac..a47cec723 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -5681,6 +5681,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ayu_AyuForwardStatusFinished" = "Done"; "ayu_AyuForwardStatusSentCount" = "sent %1$d of %2$d"; "ayu_AyuForwardStatusChunkCount" = "chunk %1$d of %2$d"; +"ayu_JumpToBeginning" = "To Beginning"; "ayu_ExpireMediaContextMenuText" = "Burn"; "ayu_ExpiringVoiceMessageNote" = "This voice message can be played as many times as you want."; "ayu_ExpiringVideoMessageNote" = "This video message can be played as many times as you want."; diff --git a/Telegram/SourceFiles/ayu/ui/ayu_icons.style b/Telegram/SourceFiles/ayu/ui/ayu_icons.style index fa8f664c3..fb98cb99d 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_icons.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_icons.style @@ -17,6 +17,8 @@ ayuLReadMenuIcon: icon {{ "ayu/lread", menuIconColor }}; ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }}; ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }}; +ayuMenuIconToBeginning: icon {{ "ayu/to_beginning", menuIconColor }}; + inChannelBadgeIcon: icon {{ "ayu/channel", msgInDateFg }}; inChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgInDateFgSelected }}; outChannelBadgeIcon: icon {{ "ayu/channel", msgOutDateFg }}; diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 712e022b0..f05e40fa1 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -98,6 +98,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +// AyuGram includes +#include "styles/style_ayu_icons.h" + + namespace Window { namespace { @@ -305,6 +309,7 @@ private: void addVideoChat(); void addViewStatistics(); void addBoostChat(); + void addJumpToBeginning(); not_null _controller; Dialogs::EntryState _request; @@ -1081,6 +1086,80 @@ void Filler::addBoostChat() { } } +void Filler::addJumpToBeginning() { + const auto user = _peer->asUser(); + const auto group = _peer->isChat() ? _peer->asChat() : nullptr; + const auto chat = _peer->isMegagroup() ? _peer->asMegagroup() : _peer->isChannel() ? _peer->asChannel() : nullptr; + const auto topic = _peer->isForum() ? _thread->asTopic() : nullptr; + if (!user && !group && !chat && !topic) { + return; + } + if (topic && topic->creating()) { + return; + } + + const auto controller = _controller; + const auto jumpToDate = [=](auto history, auto callback) + { + const auto weak = base::make_weak(controller); + controller->session().api().resolveJumpToDate( + history, + QDate(2013, 8, 1), + [=](not_null peer, MsgId id) + { + if (const auto strong = weak.get()) { + callback(peer, id); + } + }); + }; + + const auto showPeerHistory = [=](auto peer, MsgId id) + { + controller->showPeerHistory( + peer, + SectionShow::Way::Forward, + id); + }; + + const auto showTopic = [=](auto topic, MsgId id) + { + controller->showTopic( + topic, + id, + SectionShow::Way::Forward); + }; + + _addAction( + tr::ayu_JumpToBeginning(tr::now), + [=] + { + if (user) { + jumpToDate(controller->session().data().history(user), showPeerHistory); + } else if (group && !chat) { + jumpToDate(controller->session().data().history(group), showPeerHistory); + } else if (chat && !topic) { + if (!chat->migrateFrom()) { + showPeerHistory(chat, 1); + } else { + jumpToDate(controller->session().data().history(chat), showPeerHistory); + } + } else if (topic) { + if (topic->isGeneral()) { + showTopic(topic, 1); + } else { + jumpToDate( + topic, + [=](not_null, MsgId id) + { + showTopic(topic, id); + }); + } + } + }, + &st::ayuMenuIconToBeginning); +} + + void Filler::addViewStatistics() { if (const auto channel = _peer->asChannel()) { const auto controller = _controller; @@ -1407,6 +1486,7 @@ void Filler::fillContextMenuActions() { void Filler::fillHistoryActions() { addToggleMuteSubmenu(true); addInfo(); + addJumpToBeginning(); addViewAsTopics(); addStoryArchive(); addSupportInfo(); @@ -1450,6 +1530,7 @@ void Filler::fillProfileActions() { void Filler::fillRepliesActions() { if (_topic) { addInfo(); + addJumpToBeginning(); addManageTopic(); } addCreatePoll();