mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
feat: implement read after actions
This commit is contained in:
parent
474de0cc46
commit
4090064561
5 changed files with 60 additions and 11 deletions
|
@ -20,6 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_item_helpers.h" // ShouldSendSilent
|
||||
#include "main/main_session.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_state.h"
|
||||
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
|
@ -148,6 +152,13 @@ void Polls::sendVotes(
|
|||
_pollVotesRequestIds.erase(itemId);
|
||||
hideSending();
|
||||
_session->updates().applyUpdates(result);
|
||||
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (!settings->sendReadMessages && settings->markReadAfterPoll && item)
|
||||
{
|
||||
AyuState::setAllowSendReadPacket(true);
|
||||
item->history()->session().data().histories().readInboxOnNewMessage(item);
|
||||
}
|
||||
}).fail([=] {
|
||||
_pollVotesRequestIds.erase(itemId);
|
||||
hideSending();
|
||||
|
|
|
@ -210,6 +210,16 @@ void AyuGramSettings::set_markReadAfterSend(bool val)
|
|||
markReadAfterSend = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_markReadAfterReaction(bool val)
|
||||
{
|
||||
markReadAfterReaction = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_markReadAfterPoll(bool val)
|
||||
{
|
||||
markReadAfterPoll = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_useScheduledMessages(bool val)
|
||||
{
|
||||
useScheduledMessages = val;
|
||||
|
|
|
@ -87,6 +87,8 @@ public:
|
|||
bool sendUploadProgress;
|
||||
bool sendOfflinePacketAfterOnline;
|
||||
bool markReadAfterSend;
|
||||
bool markReadAfterReaction;
|
||||
bool markReadAfterPoll;
|
||||
bool useScheduledMessages;
|
||||
bool saveDeletedMessages;
|
||||
bool saveMessagesHistory;
|
||||
|
@ -124,6 +126,10 @@ public:
|
|||
|
||||
void set_markReadAfterSend(bool val);
|
||||
|
||||
void set_markReadAfterReaction(bool val);
|
||||
|
||||
void set_markReadAfterPoll(bool val);
|
||||
|
||||
void set_useScheduledMessages(bool val);
|
||||
|
||||
void set_keepDeletedMessages(bool val);
|
||||
|
@ -175,6 +181,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
|||
sendUploadProgress,
|
||||
sendOfflinePacketAfterOnline,
|
||||
markReadAfterSend,
|
||||
markReadAfterReaction,
|
||||
markReadAfterPoll,
|
||||
useScheduledMessages,
|
||||
saveDeletedMessages,
|
||||
saveMessagesHistory,
|
||||
|
|
|
@ -69,6 +69,7 @@ not_null<Ui::RpWidget *> AddInnerToggle(
|
|||
not_null<Ui::SlideWrap<> *> wrap,
|
||||
rpl::producer<QString> buttonLabel,
|
||||
std::optional<QString> locked,
|
||||
bool toggledWhenAll,
|
||||
Settings::IconDescriptor &&icon)
|
||||
{
|
||||
const auto button = container->add(object_ptr<Ui::SettingsButton>(
|
||||
|
@ -165,8 +166,14 @@ not_null<Ui::RpWidget *> AddInnerToggle(
|
|||
rpl::empty_value()
|
||||
) | rpl::map(countChecked) | start_with_next([=](int count)
|
||||
{
|
||||
checkView->setChecked(count == totalInnerChecks,
|
||||
anim::type::normal);
|
||||
if (toggledWhenAll) {
|
||||
checkView->setChecked(count == totalInnerChecks,
|
||||
anim::type::normal);
|
||||
}
|
||||
else {
|
||||
checkView->setChecked(count != 0,
|
||||
anim::type::normal);
|
||||
}
|
||||
}, toggleButton->lifetime());
|
||||
checkView->setLocked(locked.has_value());
|
||||
checkView->finishAnimating();
|
||||
|
@ -470,6 +477,7 @@ void Ayu::SetupGhostModeToggle(not_null<Ui::VerticalLayout *> container)
|
|||
raw,
|
||||
tr::ayu_GhostModeToggle(),
|
||||
std::nullopt,
|
||||
true,
|
||||
{});
|
||||
container->add(std::move(wrap));
|
||||
container->widthValue(
|
||||
|
@ -545,24 +553,24 @@ void Ayu::SetupReadAfterActionToggle(not_null<Ui::VerticalLayout *> container)
|
|||
|
||||
std::vector checkboxes{
|
||||
NestedEntry{
|
||||
tr::ayu_MarkReadAfterSend(tr::now), false, [=](bool enabled)
|
||||
tr::ayu_MarkReadAfterSend(tr::now), settings->markReadAfterSend, [=](bool enabled)
|
||||
{
|
||||
// settings->set_sendReadMessages(!enabled);
|
||||
// AyuSettings::save();
|
||||
settings->set_markReadAfterSend(enabled);
|
||||
AyuSettings::save();
|
||||
}
|
||||
},
|
||||
NestedEntry{
|
||||
tr::ayu_MarkReadAfterReaction(tr::now), false, [=](bool enabled)
|
||||
tr::ayu_MarkReadAfterReaction(tr::now), settings->markReadAfterReaction, [=](bool enabled)
|
||||
{
|
||||
// settings->set_sendReadStories(!enabled);
|
||||
// AyuSettings::save();
|
||||
settings->set_markReadAfterReaction(enabled);
|
||||
AyuSettings::save();
|
||||
}
|
||||
},
|
||||
NestedEntry{
|
||||
tr::ayu_MarkReadAfterPoll(tr::now), false, [=](bool enabled)
|
||||
tr::ayu_MarkReadAfterPoll(tr::now), settings->markReadAfterPoll, [=](bool enabled)
|
||||
{
|
||||
// settings->set_sendOnlinePackets(!enabled);
|
||||
// AyuSettings::save();
|
||||
settings->set_markReadAfterPoll(enabled);
|
||||
AyuSettings::save();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -591,6 +599,7 @@ void Ayu::SetupReadAfterActionToggle(not_null<Ui::VerticalLayout *> container)
|
|||
raw,
|
||||
tr::ayu_MarkReadAfterAction(),
|
||||
std::nullopt,
|
||||
false,
|
||||
{});
|
||||
container->add(std::move(wrap));
|
||||
container->widthValue(
|
||||
|
|
|
@ -30,6 +30,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "apiwrap.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_state.h"
|
||||
|
||||
|
||||
namespace Data {
|
||||
namespace {
|
||||
|
||||
|
@ -821,6 +825,13 @@ void Reactions::send(not_null<HistoryItem*> item, bool addToRecent) {
|
|||
)).done([=](const MTPUpdates &result) {
|
||||
_sentRequests.remove(id);
|
||||
_owner->session().api().applyUpdates(result);
|
||||
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (!settings->sendReadMessages && settings->markReadAfterReaction && item)
|
||||
{
|
||||
AyuState::setAllowSendReadPacket(true);
|
||||
item->history()->session().data().histories().readInboxOnNewMessage(item);
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
_sentRequests.remove(id);
|
||||
}).send();
|
||||
|
|
Loading…
Add table
Reference in a new issue