Added ability to mark as read selected chat with shortcut.

This commit is contained in:
23rd 2020-09-16 15:14:35 +03:00 committed by John Preston
parent f81271d1fe
commit 5968219fe4
3 changed files with 20 additions and 0 deletions

View File

@ -89,6 +89,8 @@ const auto CommandByName = base::flat_map<QString, Command>{
{ qsl("show_archive") , Command::ShowArchive },
{ qsl("read_chat") , Command::ReadChat },
// Shortcuts that have no default values.
{ qsl("message") , Command::JustSendMessage },
{ qsl("message_silently") , Command::SendSilentMessage },
@ -130,6 +132,8 @@ const auto CommandNames = base::flat_map<Command, QString>{
{ Command::ShowFolderLast , qsl("last_folder") },
{ Command::ShowArchive , qsl("show_archive") },
{ Command::ReadChat , qsl("read_chat") },
};
class Manager {
@ -379,6 +383,8 @@ void Manager::fillDefaults() {
set(qsl("ctrl+0"), Command::ChatSelf);
set(qsl("ctrl+9"), Command::ShowArchive);
set(qsl("ctrl+r"), Command::ReadChat);
}
void Manager::writeDefaultFile() {

View File

@ -53,6 +53,8 @@ enum class Command {
SendSilentMessage,
ScheduleMessage,
ReadChat,
SupportReloadTemplates,
SupportToggleMuted,
SupportScrollToCurrent,

View File

@ -3166,6 +3166,18 @@ void InnerWidget::setupShortcuts() {
return nearFolder(false);
});
request->check(Command::ReadChat) && request->handle([=] {
const auto history = _selected ? _selected->history() : nullptr;
if (history) {
if ((history->chatListUnreadCount() > 0)
|| history->chatListUnreadMark()) {
session().data().histories().readInbox(history);
}
return true;
}
return (history != nullptr);
});
if (session().supportMode() && row.key.history()) {
request->check(
Command::SupportScrollToCurrent