mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-01 12:00:48 +00:00
Go through open history in support mode.
This commit is contained in:
parent
c11b977f1d
commit
2cd3cec478
@ -43,6 +43,8 @@ const auto SupportCommands = base::flat_set<Command>{
|
||||
Command::SupportReloadTemplates,
|
||||
Command::SupportToggleMuted,
|
||||
Command::SupportScrollToCurrent,
|
||||
Command::SupportHistoryBack,
|
||||
Command::SupportHistoryForward,
|
||||
};
|
||||
|
||||
const auto CommandByName = base::flat_map<QString, Command>{
|
||||
@ -310,6 +312,8 @@ void Manager::fillDefaults() {
|
||||
set(qsl("f5"), Command::SupportReloadTemplates);
|
||||
set(qsl("ctrl+delete"), Command::SupportToggleMuted);
|
||||
set(qsl("ctrl+insert"), Command::SupportScrollToCurrent);
|
||||
set(qsl("ctrl+shift+x"), Command::SupportHistoryBack);
|
||||
set(qsl("ctrl+shift+c"), Command::SupportHistoryForward);
|
||||
|
||||
set(qsl("ctrl+1"), Command::ChatPinned1);
|
||||
set(qsl("ctrl+2"), Command::ChatPinned2);
|
||||
|
@ -37,6 +37,8 @@ enum class Command {
|
||||
SupportReloadTemplates,
|
||||
SupportToggleMuted,
|
||||
SupportScrollToCurrent,
|
||||
SupportHistoryBack,
|
||||
SupportHistoryForward,
|
||||
};
|
||||
|
||||
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
|
||||
|
@ -2921,25 +2921,12 @@ Dialogs::RowDescriptor DialogsInner::computeJump(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DialogsInner::jumpToDialogRow(const Dialogs::RowDescriptor &to) {
|
||||
bool DialogsInner::jumpToDialogRow(Dialogs::RowDescriptor to) {
|
||||
if (to == chatListEntryLast()) {
|
||||
_listBottomReached.fire({});
|
||||
}
|
||||
|
||||
if (const auto history = to.key.history()) {
|
||||
Ui::showPeerHistory(
|
||||
history,
|
||||
(uniqueSearchResults()
|
||||
? ShowAtUnreadMsgId
|
||||
: to.fullId.msg));
|
||||
return true;
|
||||
} else if (const auto feed = to.key.feed()) {
|
||||
if (const auto item = App::histItemById(to.fullId)) {
|
||||
_controller->showSection(
|
||||
HistoryFeed::Memento(feed, item->position()));
|
||||
} else {
|
||||
_controller->showSection(HistoryFeed::Memento(feed));
|
||||
}
|
||||
if (uniqueSearchResults()) {
|
||||
to.fullId = FullMsgId();
|
||||
}
|
||||
return false;
|
||||
return _controller->jumpToChatListEntry(to);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ private:
|
||||
Dialogs::RowDescriptor computeJump(
|
||||
const Dialogs::RowDescriptor &to,
|
||||
JumpSkip skip);
|
||||
bool jumpToDialogRow(const Dialogs::RowDescriptor &to);
|
||||
bool jumpToDialogRow(Dialogs::RowDescriptor to);
|
||||
|
||||
Dialogs::RowDescriptor chatListEntryBefore(
|
||||
const Dialogs::RowDescriptor &which) const;
|
||||
|
@ -13,10 +13,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/feed/history_feed_section.h"
|
||||
#include "media/player/media_player_round_controller.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "boxes/calendar_box.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
@ -27,6 +29,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
namespace Window {
|
||||
namespace {
|
||||
|
||||
constexpr auto kMaxChatEntryHistorySize = 50;
|
||||
|
||||
} // namespace
|
||||
|
||||
DateClickHandler::DateClickHandler(Dialogs::Key chat, QDate date)
|
||||
: _chat(chat)
|
||||
@ -53,12 +60,70 @@ Controller::Controller(not_null<MainWindow*> window)
|
||||
}, lifetime());
|
||||
|
||||
if (Auth().supportMode()) {
|
||||
Auth().supportHelper().registerWindow(this);
|
||||
initSupportMode();
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::initSupportMode() {
|
||||
Auth().supportHelper().registerWindow(this);
|
||||
|
||||
Shortcuts::Requests(
|
||||
) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||
using C = Shortcuts::Command;
|
||||
|
||||
request->check(C::SupportHistoryBack) && request->handle([=] {
|
||||
return chatEntryHistoryMove(-1);
|
||||
});
|
||||
request->check(C::SupportHistoryForward) && request->handle([=] {
|
||||
return chatEntryHistoryMove(1);
|
||||
});
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void Controller::setActiveChatEntry(Dialogs::RowDescriptor row) {
|
||||
_activeChatEntry = row;
|
||||
if (Auth().supportMode()) {
|
||||
pushToChatEntryHistory(row);
|
||||
}
|
||||
}
|
||||
|
||||
bool Controller::chatEntryHistoryMove(int steps) {
|
||||
if (_chatEntryHistory.empty()) {
|
||||
return false;
|
||||
}
|
||||
const auto position = _chatEntryHistoryPosition + steps;
|
||||
if (!base::in_range(position, 0, int(_chatEntryHistory.size()))) {
|
||||
return false;
|
||||
}
|
||||
_chatEntryHistoryPosition = position;
|
||||
return jumpToChatListEntry(_chatEntryHistory[position]);
|
||||
}
|
||||
|
||||
bool Controller::jumpToChatListEntry(Dialogs::RowDescriptor row) {
|
||||
if (const auto history = row.key.history()) {
|
||||
Ui::showPeerHistory(history, row.fullId.msg);
|
||||
return true;
|
||||
} else if (const auto feed = row.key.feed()) {
|
||||
if (const auto item = App::histItemById(row.fullId)) {
|
||||
showSection(HistoryFeed::Memento(feed, item->position()));
|
||||
} else {
|
||||
showSection(HistoryFeed::Memento(feed));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Controller::pushToChatEntryHistory(Dialogs::RowDescriptor row) {
|
||||
if (!_chatEntryHistory.empty()
|
||||
&& _chatEntryHistory[_chatEntryHistoryPosition] == row) {
|
||||
return;
|
||||
}
|
||||
_chatEntryHistory.resize(++_chatEntryHistoryPosition);
|
||||
_chatEntryHistory.push_back(row);
|
||||
if (_chatEntryHistory.size() > kMaxChatEntryHistorySize) {
|
||||
_chatEntryHistory.pop_front();
|
||||
--_chatEntryHistoryPosition;
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::setActiveChatEntry(Dialogs::Key key) {
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
rpl::producer<Dialogs::Key> activeChatChanges() const;
|
||||
rpl::producer<Dialogs::RowDescriptor> activeChatEntryValue() const;
|
||||
rpl::producer<Dialogs::Key> activeChatValue() const;
|
||||
bool jumpToChatListEntry(Dialogs::RowDescriptor row);
|
||||
|
||||
void enableGifPauseReason(GifPauseReason reason);
|
||||
void disableGifPauseReason(GifPauseReason reason);
|
||||
@ -259,6 +260,8 @@ public:
|
||||
~Controller();
|
||||
|
||||
private:
|
||||
void initSupportMode();
|
||||
|
||||
int minimalThreeColumnWidth() const;
|
||||
not_null<MainWidget*> chats() const;
|
||||
int countDialogsWidthFromRatio(int bodyWidth) const;
|
||||
@ -272,6 +275,9 @@ private:
|
||||
int thirdWidth,
|
||||
int bodyWidth) const;
|
||||
|
||||
void pushToChatEntryHistory(Dialogs::RowDescriptor row);
|
||||
bool chatEntryHistoryMove(int steps);
|
||||
|
||||
not_null<MainWindow*> _window;
|
||||
|
||||
std::unique_ptr<Passport::FormController> _passportForm;
|
||||
@ -283,6 +289,8 @@ private:
|
||||
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
|
||||
base::Variable<bool> _dialogsListFocused = { false };
|
||||
base::Variable<bool> _dialogsListDisplayForced = { false };
|
||||
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
||||
int _chatEntryHistoryPosition = -1;
|
||||
|
||||
std::unique_ptr<RoundController> _roundVideo;
|
||||
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
||||
|
Loading…
Reference in New Issue
Block a user