mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
feat: hide reactions in private chats
This commit is contained in:
@@ -7669,8 +7669,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"ayu_HideChannelReactions" = "Hide Reactions in Channels";
|
||||
"ayu_HideGroupReactions" = "Hide Reactions in Groups";
|
||||
"ayu_HideReactions" = "Hide Reactions";
|
||||
"ayu_HideReactionsInChannels" = "In Channels";
|
||||
"ayu_HideReactionsInGroups" = "In Groups";
|
||||
"ayu_HideReactionsInChannels" = "Channels";
|
||||
"ayu_HideReactionsInGroups" = "Groups";
|
||||
"ayu_HideReactionsInPrivateChats" = "Private Chats";
|
||||
"ayu_QuickAdminShortcuts" = "Quick Admin Shortcuts";
|
||||
"ayu_TranslationProvider" = "Translation Provider";
|
||||
"ayu_LinksHeader" = "Links";
|
||||
|
||||
@@ -53,6 +53,9 @@ bool UnreadThings::trackReactions(Data::Thread *thread) const {
|
||||
if (peer->isMegagroup() && !settings.showGroupReactions()) {
|
||||
return false;
|
||||
}
|
||||
if (peer->isUser() && !settings.showPrivateChatReactions()) {
|
||||
return false;
|
||||
}
|
||||
return peer->isUser() || peer->isChat() || peer->isMegagroup();
|
||||
}
|
||||
|
||||
|
||||
@@ -621,6 +621,12 @@ void AyuSettings::setShowGroupReactions(bool val) {
|
||||
save();
|
||||
}
|
||||
|
||||
void AyuSettings::setShowPrivateChatReactions(bool val) {
|
||||
if (_showPrivateChatReactions.current() == val) return;
|
||||
_showPrivateChatReactions = val;
|
||||
save();
|
||||
}
|
||||
|
||||
void AyuSettings::setAppIcon(const QString &val) {
|
||||
if (_appIcon.current() == val) return;
|
||||
_appIcon = val;
|
||||
@@ -970,6 +976,7 @@ void to_json(nlohmann::json &j, const AyuSettings &s) {
|
||||
{"localPremium", s._localPremium.current()},
|
||||
{"showChannelReactions", s._showChannelReactions.current()},
|
||||
{"showGroupReactions", s._showGroupReactions.current()},
|
||||
{"showPrivateChatReactions", s._showPrivateChatReactions.current()},
|
||||
{"appIcon", s._appIcon.current()},
|
||||
{"simpleQuotesAndReplies", s._simpleQuotesAndReplies.current()},
|
||||
{"hideFastShare", s._hideFastShare.current()},
|
||||
@@ -1063,6 +1070,7 @@ void from_json(const nlohmann::json &j, AyuSettings &s) {
|
||||
s._localPremium = j.value("localPremium", defaults._localPremium.current());
|
||||
s._showChannelReactions = j.value("showChannelReactions", defaults._showChannelReactions.current());
|
||||
s._showGroupReactions = j.value("showGroupReactions", defaults._showGroupReactions.current());
|
||||
s._showPrivateChatReactions = j.value("showPrivateChatReactions", defaults._showPrivateChatReactions.current());
|
||||
s._appIcon = j.value("appIcon", defaults._appIcon.current());
|
||||
s._simpleQuotesAndReplies = j.value("simpleQuotesAndReplies", defaults._simpleQuotesAndReplies.current());
|
||||
s._hideFastShare = j.value("hideFastShare", defaults._hideFastShare.current());
|
||||
|
||||
@@ -249,6 +249,7 @@ public:
|
||||
[[nodiscard]] bool localPremium() const { return _localPremium.current(); }
|
||||
[[nodiscard]] bool showChannelReactions() const { return _showChannelReactions.current(); }
|
||||
[[nodiscard]] bool showGroupReactions() const { return _showGroupReactions.current(); }
|
||||
[[nodiscard]] bool showPrivateChatReactions() const { return _showPrivateChatReactions.current(); }
|
||||
[[nodiscard]] const QString &appIcon() const { return _appIcon.current(); }
|
||||
[[nodiscard]] bool simpleQuotesAndReplies() const { return _simpleQuotesAndReplies.current(); }
|
||||
[[nodiscard]] bool hideFastShare() const { return _hideFastShare.current(); }
|
||||
@@ -325,6 +326,7 @@ public:
|
||||
void setLocalPremium(bool val);
|
||||
void setShowChannelReactions(bool val);
|
||||
void setShowGroupReactions(bool val);
|
||||
void setShowPrivateChatReactions(bool val);
|
||||
void setAppIcon(const QString &val);
|
||||
void setSimpleQuotesAndReplies(bool val);
|
||||
void setHideFastShare(bool val);
|
||||
@@ -402,6 +404,7 @@ public:
|
||||
[[nodiscard]] rpl::producer<bool> localPremiumChanges() const { return _localPremium.value(); }
|
||||
[[nodiscard]] rpl::producer<bool> showChannelReactionsChanges() const { return _showChannelReactions.value(); }
|
||||
[[nodiscard]] rpl::producer<bool> showGroupReactionsChanges() const { return _showGroupReactions.value(); }
|
||||
[[nodiscard]] rpl::producer<bool> showPrivateChatReactionsChanges() const { return _showPrivateChatReactions.value(); }
|
||||
[[nodiscard]] rpl::producer<QString> appIconChanges() const { return _appIcon.value(); }
|
||||
[[nodiscard]] rpl::producer<bool> simpleQuotesAndRepliesChanges() const { return _simpleQuotesAndReplies.value(); }
|
||||
[[nodiscard]] rpl::producer<bool> hideFastShareChanges() const { return _hideFastShare.value(); }
|
||||
@@ -487,6 +490,7 @@ private:
|
||||
rpl::variable<bool> _localPremium = false;
|
||||
rpl::variable<bool> _showChannelReactions = true;
|
||||
rpl::variable<bool> _showGroupReactions = true;
|
||||
rpl::variable<bool> _showPrivateChatReactions = true;
|
||||
rpl::variable<QString> _appIcon;
|
||||
rpl::variable<bool> _simpleQuotesAndReplies = false;
|
||||
rpl::variable<bool> _hideFastShare = false;
|
||||
|
||||
@@ -58,6 +58,11 @@ void BuildStickersAndEmoji(SectionBuilder &builder, AyuSectionBuilder &ayu) {
|
||||
tr::ayu_HideReactionsInGroups(tr::now),
|
||||
[] { return !AyuSettings::getInstance().showGroupReactions(); },
|
||||
[](bool v) { AyuSettings::getInstance().setShowGroupReactions(!v); }
|
||||
},
|
||||
NestedEntry{
|
||||
tr::ayu_HideReactionsInPrivateChats(tr::now),
|
||||
[] { return !AyuSettings::getInstance().showPrivateChatReactions(); },
|
||||
[](bool v) { AyuSettings::getInstance().setShowPrivateChatReactions(!v); }
|
||||
}
|
||||
},
|
||||
.toggledWhenAll = false,
|
||||
|
||||
@@ -2455,7 +2455,8 @@ Dialogs::UnreadState History::computeUnreadState() const {
|
||||
const auto peer = this->peer.get();
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
const auto hideReactions = (peer->isChannel() && !peer->isMegagroup() && !settings.showChannelReactions())
|
||||
|| (peer->isMegagroup() && !settings.showGroupReactions());
|
||||
|| (peer->isMegagroup() && !settings.showGroupReactions())
|
||||
|| (peer->isUser() && !settings.showPrivateChatReactions());
|
||||
result.reactions = hideReactions ? 0 : (unreadReactions().has() ? 1 : 0);
|
||||
result.messagesMuted = muted ? result.messages : 0;
|
||||
result.chatsMuted = muted ? result.chats : 0;
|
||||
|
||||
@@ -1244,7 +1244,8 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||
const auto peer = item->history()->peer;
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
const auto hide = (!settings.showChannelReactions() && peer->isChannel() && !peer->isMegagroup()) ||
|
||||
(!settings.showGroupReactions() && peer->isMegagroup());
|
||||
(!settings.showGroupReactions() && peer->isMegagroup()) ||
|
||||
(!settings.showPrivateChatReactions() && peer->isUser());
|
||||
if (!hide) {
|
||||
startEffects.emplace(view);
|
||||
} else {
|
||||
|
||||
@@ -1187,7 +1187,8 @@ void CheckReactionNotificationSchedule(
|
||||
const auto peer = item->history()->peer;
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
if ((peer->isChannel() && !peer->isMegagroup() && !settings.showChannelReactions())
|
||||
|| (peer->isMegagroup() && !settings.showGroupReactions())) {
|
||||
|| (peer->isMegagroup() && !settings.showGroupReactions())
|
||||
|| (peer->isUser() && !settings.showPrivateChatReactions())) {
|
||||
item->markEffectWatched();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -854,6 +854,10 @@ InlineListData InlineListDataFromMessage(not_null<Element*> view) {
|
||||
&& item->history()->peer->isMegagroup()) {
|
||||
return InlineListData();
|
||||
}
|
||||
if (!settings.showPrivateChatReactions()
|
||||
&& item->history()->peer->isUser()) {
|
||||
return InlineListData();
|
||||
}
|
||||
auto result = InlineListData();
|
||||
result.reactions = item->reactionsWithLocal();
|
||||
|
||||
|
||||
@@ -1394,7 +1394,8 @@ AttachSelectorResult AttachSelectorToMenu(
|
||||
|
||||
const auto peer = item->history()->peer;
|
||||
if ((peer->isChannel() && !peer->isMegagroup() && !settings.showChannelReactions())
|
||||
|| (peer->isMegagroup() && !settings.showGroupReactions())) {
|
||||
|| (peer->isMegagroup() && !settings.showGroupReactions())
|
||||
|| (peer->isUser() && !settings.showPrivateChatReactions())) {
|
||||
return AttachSelectorResult::Skipped;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user