mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
feat: jump to beginning
This commit is contained in:
parent
257b8552f7
commit
b2efc2ad14
6 changed files with 84 additions and 0 deletions
BIN
Telegram/Resources/icons/ayu/to_beginning.png
Normal file
BIN
Telegram/Resources/icons/ayu/to_beginning.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 480 B |
BIN
Telegram/Resources/icons/ayu/to_beginning@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/to_beginning@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 855 B |
BIN
Telegram/Resources/icons/ayu/to_beginning@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/to_beginning@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -5681,6 +5681,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"ayu_AyuForwardStatusFinished" = "Done";
|
"ayu_AyuForwardStatusFinished" = "Done";
|
||||||
"ayu_AyuForwardStatusSentCount" = "sent %1$d of %2$d";
|
"ayu_AyuForwardStatusSentCount" = "sent %1$d of %2$d";
|
||||||
"ayu_AyuForwardStatusChunkCount" = "chunk %1$d of %2$d";
|
"ayu_AyuForwardStatusChunkCount" = "chunk %1$d of %2$d";
|
||||||
|
"ayu_JumpToBeginning" = "To Beginning";
|
||||||
"ayu_ExpireMediaContextMenuText" = "Burn";
|
"ayu_ExpireMediaContextMenuText" = "Burn";
|
||||||
"ayu_ExpiringVoiceMessageNote" = "This voice message can be played as many times as you want.";
|
"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.";
|
"ayu_ExpiringVideoMessageNote" = "This video message can be played as many times as you want.";
|
||||||
|
|
|
@ -17,6 +17,8 @@ ayuLReadMenuIcon: icon {{ "ayu/lread", menuIconColor }};
|
||||||
ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }};
|
ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }};
|
||||||
ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }};
|
ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }};
|
||||||
|
|
||||||
|
ayuMenuIconToBeginning: icon {{ "ayu/to_beginning", menuIconColor }};
|
||||||
|
|
||||||
inChannelBadgeIcon: icon {{ "ayu/channel", msgInDateFg }};
|
inChannelBadgeIcon: icon {{ "ayu/channel", msgInDateFg }};
|
||||||
inChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgInDateFgSelected }};
|
inChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgInDateFgSelected }};
|
||||||
outChannelBadgeIcon: icon {{ "ayu/channel", msgOutDateFg }};
|
outChannelBadgeIcon: icon {{ "ayu/channel", msgOutDateFg }};
|
||||||
|
|
|
@ -98,6 +98,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "styles/style_ayu_icons.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -305,6 +309,7 @@ private:
|
||||||
void addVideoChat();
|
void addVideoChat();
|
||||||
void addViewStatistics();
|
void addViewStatistics();
|
||||||
void addBoostChat();
|
void addBoostChat();
|
||||||
|
void addJumpToBeginning();
|
||||||
|
|
||||||
not_null<SessionController*> _controller;
|
not_null<SessionController*> _controller;
|
||||||
Dialogs::EntryState _request;
|
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<PeerData*> 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<PeerData*>, MsgId id)
|
||||||
|
{
|
||||||
|
showTopic(topic, id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&st::ayuMenuIconToBeginning);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Filler::addViewStatistics() {
|
void Filler::addViewStatistics() {
|
||||||
if (const auto channel = _peer->asChannel()) {
|
if (const auto channel = _peer->asChannel()) {
|
||||||
const auto controller = _controller;
|
const auto controller = _controller;
|
||||||
|
@ -1407,6 +1486,7 @@ void Filler::fillContextMenuActions() {
|
||||||
void Filler::fillHistoryActions() {
|
void Filler::fillHistoryActions() {
|
||||||
addToggleMuteSubmenu(true);
|
addToggleMuteSubmenu(true);
|
||||||
addInfo();
|
addInfo();
|
||||||
|
addJumpToBeginning();
|
||||||
addViewAsTopics();
|
addViewAsTopics();
|
||||||
addStoryArchive();
|
addStoryArchive();
|
||||||
addSupportInfo();
|
addSupportInfo();
|
||||||
|
@ -1450,6 +1530,7 @@ void Filler::fillProfileActions() {
|
||||||
void Filler::fillRepliesActions() {
|
void Filler::fillRepliesActions() {
|
||||||
if (_topic) {
|
if (_topic) {
|
||||||
addInfo();
|
addInfo();
|
||||||
|
addJumpToBeginning();
|
||||||
addManageTopic();
|
addManageTopic();
|
||||||
}
|
}
|
||||||
addCreatePoll();
|
addCreatePoll();
|
||||||
|
|
Loading…
Add table
Reference in a new issue