mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-11 00:02:54 +02:00
feat: disable reactions in channels and groups
This commit is contained in:
parent
3f5f17705d
commit
3bbb9daa34
10 changed files with 129 additions and 16 deletions
|
@ -6643,6 +6643,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ayu_DisableAds" = "Disable Ads";
|
||||
"ayu_DisableStories" = "Disable Stories";
|
||||
"ayu_DisableCustomBackgrounds" = "Disable Custom Backgrounds";
|
||||
"ayu_HideChannelReactions" = "Hide Reactions in Channels";
|
||||
"ayu_HideGroupReactions" = "Hide Reactions in Groups";
|
||||
"ayu_DisableNotificationsDelay" = "Disable Notify Delay";
|
||||
"ayu_LocalPremium" = "Local Telegram Premium";
|
||||
"ayu_DisplayGhostStatus" = "Display Ghost Mode Status";
|
||||
|
|
|
@ -17,6 +17,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_unread_things.h"
|
||||
#include "apiwrap.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
|
@ -36,7 +40,17 @@ bool UnreadThings::trackMentions(Data::Thread *thread) const {
|
|||
|
||||
bool UnreadThings::trackReactions(Data::Thread *thread) const {
|
||||
const auto peer = thread ? thread->peer().get() : nullptr;
|
||||
return peer && (peer->isUser() || peer->isChat() || peer->isMegagroup());
|
||||
if (!peer) {
|
||||
return false;
|
||||
}
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
if (peer->isChannel() && !peer->isMegagroup() && !settings.hideChannelReactions) {
|
||||
return false;
|
||||
}
|
||||
if (peer->isMegagroup() && !settings.hideGroupReactions) {
|
||||
return false;
|
||||
}
|
||||
return peer->isUser() || peer->isChat() || peer->isMegagroup();
|
||||
}
|
||||
|
||||
void UnreadThings::preloadEnough(Data::Thread *thread) {
|
||||
|
|
|
@ -231,6 +231,8 @@ AyuGramSettings::AyuGramSettings() {
|
|||
|
||||
disableNotificationsDelay = false;
|
||||
localPremium = false;
|
||||
hideChannelReactions = true;
|
||||
hideGroupReactions = true;
|
||||
|
||||
// ~ Customization
|
||||
appIcon =
|
||||
|
@ -417,6 +419,14 @@ void set_localPremium(bool val) {
|
|||
settings->localPremium = val;
|
||||
}
|
||||
|
||||
void set_hideChannelReactions(bool val) {
|
||||
settings->hideChannelReactions = val;
|
||||
}
|
||||
|
||||
void set_hideGroupReactions(bool val) {
|
||||
settings->hideGroupReactions = val;
|
||||
}
|
||||
|
||||
void set_appIcon(const QString &val) {
|
||||
settings->appIcon = val;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ public:
|
|||
|
||||
bool disableNotificationsDelay;
|
||||
bool localPremium;
|
||||
bool hideChannelReactions;
|
||||
bool hideGroupReactions;
|
||||
|
||||
QString appIcon;
|
||||
bool simpleQuotesAndReplies;
|
||||
|
@ -158,6 +160,8 @@ void set_increaseWebviewWidth(bool val);
|
|||
|
||||
void set_disableNotificationsDelay(bool val);
|
||||
void set_localPremium(bool val);
|
||||
void set_hideChannelReactions(bool val);
|
||||
void set_hideGroupReactions(bool val);
|
||||
|
||||
void set_appIcon(const QString &val);
|
||||
void set_simpleQuotesAndReplies(bool val);
|
||||
|
@ -255,6 +259,8 @@ inline void to_json(nlohmann::json &nlohmann_json_j, const AyuGramSettings &nloh
|
|||
NLOHMANN_JSON_TO(showGhostToggleInTray)
|
||||
NLOHMANN_JSON_TO(showStreamerToggleInTray)
|
||||
NLOHMANN_JSON_TO(monoFont)
|
||||
NLOHMANN_JSON_TO(hideChannelReactions)
|
||||
NLOHMANN_JSON_TO(hideGroupReactions)
|
||||
NLOHMANN_JSON_TO(hideNotificationCounters)
|
||||
NLOHMANN_JSON_TO(hideNotificationBadge)
|
||||
NLOHMANN_JSON_TO(hideAllChatsFolder)
|
||||
|
@ -318,6 +324,8 @@ inline void from_json(const nlohmann::json &nlohmann_json_j, AyuGramSettings &nl
|
|||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showGhostToggleInTray)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(showStreamerToggleInTray)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(monoFont)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideChannelReactions)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideGroupReactions)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideNotificationCounters)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideNotificationBadge)
|
||||
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideAllChatsFolder)
|
||||
|
|
|
@ -845,6 +845,48 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
|
|||
AyuSettings::save();
|
||||
},
|
||||
container->lifetime());
|
||||
|
||||
AddSkip(container);
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_HideChannelReactions(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(!settings->hideChannelReactions)
|
||||
)->toggledValue(
|
||||
) | rpl::filter(
|
||||
[=](bool enabled)
|
||||
{
|
||||
return (!enabled != settings->hideChannelReactions);
|
||||
}) | start_with_next(
|
||||
[=](bool enabled)
|
||||
{
|
||||
AyuSettings::set_hideChannelReactions(!enabled);
|
||||
AyuSettings::save();
|
||||
},
|
||||
container->lifetime());
|
||||
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_HideGroupReactions(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(!settings->hideGroupReactions)
|
||||
)->toggledValue(
|
||||
) | rpl::filter(
|
||||
[=](bool enabled)
|
||||
{
|
||||
return (!enabled != settings->hideGroupReactions);
|
||||
}) | start_with_next(
|
||||
[=](bool enabled)
|
||||
{
|
||||
AyuSettings::set_hideGroupReactions(!enabled);
|
||||
AyuSettings::save();
|
||||
},
|
||||
container->lifetime());
|
||||
}
|
||||
|
||||
void SetupAppIcon(not_null<Ui::VerticalLayout*> container) {
|
||||
|
|
|
@ -2279,7 +2279,11 @@ Dialogs::UnreadState History::computeUnreadState() const {
|
|||
result.chats = count ? 1 : 0;
|
||||
result.marks = mark ? 1 : 0;
|
||||
result.mentions = unreadMentions().has() ? 1 : 0;
|
||||
result.reactions = unreadReactions().has() ? 1 : 0;
|
||||
const auto peer = this->peer.get();
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
const auto hideReactions = (peer->isChannel() && !peer->isMegagroup() && !settings.hideChannelReactions)
|
||||
|| (peer->isMegagroup() && !settings.hideGroupReactions);
|
||||
result.reactions = hideReactions ? 0 : (unreadReactions().has() ? 1 : 0);
|
||||
result.messagesMuted = muted ? result.messages : 0;
|
||||
result.chatsMuted = muted ? result.chats : 0;
|
||||
result.marksMuted = muted ? result.marks : 0;
|
||||
|
|
|
@ -101,6 +101,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtCore/QMimeData>
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/ui/context_menu/context_menu.h"
|
||||
#include "ayu/utils/telegram_helpers.h"
|
||||
#include "data/data_document_media.h"
|
||||
|
@ -1152,7 +1153,15 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
|||
readTill = item;
|
||||
}
|
||||
if (markingAsViewed && item->hasUnwatchedEffect()) {
|
||||
startEffects.emplace(view);
|
||||
const auto peer = item->history()->peer;
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
const auto hide = (!settings.hideChannelReactions && peer->isChannel() && !peer->isMegagroup()) ||
|
||||
(!settings.hideGroupReactions && peer->isMegagroup());
|
||||
if (!hide) {
|
||||
startEffects.emplace(view);
|
||||
} else {
|
||||
item->markEffectWatched();
|
||||
}
|
||||
}
|
||||
if (markingAsViewed && item->hasViews()) {
|
||||
session().api().views().scheduleIncrement(item);
|
||||
|
|
|
@ -1081,6 +1081,13 @@ void CheckReactionNotificationSchedule(
|
|||
if (!item->hasUnreadReaction()) {
|
||||
return;
|
||||
}
|
||||
const auto peer = item->history()->peer;
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
if ((peer->isChannel() && !peer->isMegagroup() && !settings.hideChannelReactions)
|
||||
|| (peer->isMegagroup() && !settings.hideGroupReactions)) {
|
||||
item->markEffectWatched();
|
||||
return;
|
||||
}
|
||||
for (const auto &[emoji, reactions] : item->recentReactions()) {
|
||||
for (const auto &reaction : reactions) {
|
||||
if (!reaction.unread) {
|
||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_chat_helpers.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/features/messageshot/message_shot.h"
|
||||
|
||||
|
||||
|
@ -101,9 +102,12 @@ std::vector<ReactionId> InlineList::computeTagsList() const {
|
|||
if (!areTags()) {
|
||||
return {};
|
||||
}
|
||||
return _buttons | ranges::views::transform(
|
||||
&Button::id
|
||||
) | ranges::to_vector;
|
||||
auto result = std::vector<ReactionId>();
|
||||
result.reserve(_buttons.size());
|
||||
for (const auto &button : _buttons) {
|
||||
result.push_back(button.id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool InlineList::hasCustomEmoji() const {
|
||||
|
@ -132,11 +136,11 @@ void InlineList::layoutButtons() {
|
|||
_buttons.clear();
|
||||
return;
|
||||
}
|
||||
auto sorted = ranges::views::all(
|
||||
_data.reactions
|
||||
) | ranges::views::transform([](const MessageReaction &reaction) {
|
||||
return not_null{ &reaction };
|
||||
}) | ranges::to_vector;
|
||||
auto sorted = std::vector<not_null<const MessageReaction*>>();
|
||||
sorted.reserve(_data.reactions.size());
|
||||
for (const auto &reaction : _data.reactions) {
|
||||
sorted.push_back(&reaction);
|
||||
}
|
||||
const auto tags = areTags();
|
||||
if (!tags) {
|
||||
const auto &list = _owner->list(::Data::Reactions::Type::All);
|
||||
|
@ -830,6 +834,16 @@ void InlineList::continueAnimations(base::flat_map<
|
|||
InlineListData InlineListDataFromMessage(not_null<Element*> view) {
|
||||
using Flag = InlineListData::Flag;
|
||||
const auto item = view->data();
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
if (!settings.hideChannelReactions
|
||||
&& item->history()->peer->isChannel()
|
||||
&& !item->history()->peer->isMegagroup()) {
|
||||
return InlineListData();
|
||||
}
|
||||
if (!settings.hideGroupReactions
|
||||
&& item->history()->peer->isMegagroup()) {
|
||||
return InlineListData();
|
||||
}
|
||||
auto result = InlineListData();
|
||||
result.reactions = item->reactionsWithLocal();
|
||||
if (const auto user = item->history()->peer->asUser()) {
|
||||
|
@ -867,9 +881,11 @@ InlineListData InlineListDataFromMessage(not_null<Element*> view) {
|
|||
if (showUserpics) {
|
||||
result.recent.reserve(recent.size());
|
||||
for (const auto &[id, list] : recent) {
|
||||
result.recent.emplace(id).first->second = list
|
||||
| ranges::views::transform(&Data::RecentReaction::peer)
|
||||
| ranges::to_vector;
|
||||
auto &out = result.recent.emplace(id).first->second;
|
||||
out.reserve(list.size());
|
||||
for (const auto &r : list) {
|
||||
out.push_back(r.peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,8 +273,9 @@ ReactionView::ReactionView(
|
|||
|
||||
void ReactionView::setupCustomChatStylePalette() {
|
||||
const auto color = uchar(_data.dark ? 255 : 0);
|
||||
_chatStyle->historyTextInFg().set(color, color, color, 255);
|
||||
_chatStyle->applyCustomPalette(_chatStyle.get());
|
||||
Ui::ChatStyle custom{_chatStyle.get()};
|
||||
custom.historyTextInFg().set(color, color, color, 255);
|
||||
_chatStyle->applyCustomPalette(&custom);
|
||||
}
|
||||
|
||||
void ReactionView::setAreaGeometry(QRect geometry, float64 radius) {
|
||||
|
|
Loading…
Add table
Reference in a new issue