mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
feat: improve hide from blocked users
This commit is contained in:
parent
1c85a81f1f
commit
b6c966f18b
6 changed files with 56 additions and 13 deletions
|
@ -29,12 +29,14 @@
|
|||
#include "data/data_session.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_unread_things.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/text/format_values.h"
|
||||
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/ayu_state.h"
|
||||
|
||||
// https://github.com/AyuGram/AyuGram4AX/blob/rewrite/TMessagesProj/src/main/java/com/radolyn/ayugram/AyuConstants.java
|
||||
std::unordered_set<ID> ayugram_channels = {
|
||||
|
@ -160,6 +162,30 @@ bool isExteraRelated(ID peerId) {
|
|||
return extera_devs.contains(peerId) || extera_channels.contains(peerId);
|
||||
}
|
||||
|
||||
bool isMessageHidden(const not_null<HistoryItem*> item) {
|
||||
if (AyuState::isHidden(item)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (settings->hideFromBlocked) {
|
||||
if (item->from()->isUser() &&
|
||||
item->from()->asUser()->isBlocked()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||
if (forwarded->originalSender &&
|
||||
forwarded->originalSender->isUser() &&
|
||||
forwarded->originalSender->asUser()->isBlocked()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MarkAsReadChatList(not_null<Dialogs::MainList*> list) {
|
||||
auto mark = std::vector<not_null<History*>>();
|
||||
for (const auto &row : list->indexed()->all()) {
|
||||
|
|
|
@ -25,6 +25,8 @@ ID getBareID(not_null<PeerData*> peer);
|
|||
bool isAyuGramRelated(ID peerId);
|
||||
bool isExteraRelated(ID peerId);
|
||||
|
||||
bool isMessageHidden(not_null<HistoryItem*> item);
|
||||
|
||||
void MarkAsReadChatList(not_null<Dialogs::MainList*> list);
|
||||
void MarkAsReadThread(not_null<Data::Thread*> thread);
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/ayu_state.h"
|
||||
#include "ayu/features/messageshot/message_shot.h"
|
||||
#include "ayu/utils/telegram_helpers.h"
|
||||
|
||||
|
@ -3200,6 +3201,10 @@ MessageGroupId HistoryItem::groupId() const {
|
|||
}
|
||||
|
||||
bool HistoryItem::isEmpty() const {
|
||||
if (isMessageHidden(const_cast<HistoryItem*>(this))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return _text.empty()
|
||||
&& !_media
|
||||
&& !Has<HistoryMessageLogEntryOriginal>();
|
||||
|
|
|
@ -52,7 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/ayu_state.h"
|
||||
#include "ayu/features/messageshot/message_shot.h"
|
||||
|
||||
#include "ayu/utils/telegram_helpers.h"
|
||||
|
||||
namespace HistoryView {
|
||||
namespace {
|
||||
|
@ -715,18 +715,7 @@ bool Element::isHiddenByGroup() const {
|
|||
}
|
||||
|
||||
bool Element::isHidden() const {
|
||||
if (AyuState::isHidden(data())) {
|
||||
return true;
|
||||
}
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (settings->hideFromBlocked) {
|
||||
if (data()->from()->isUser() &&
|
||||
data()->from()->asUser()->isBlocked()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return isHiddenByGroup();
|
||||
return isMessageHidden(data()) || isHiddenByGroup();
|
||||
}
|
||||
|
||||
void Element::overrideMedia(std::unique_ptr<Media> media) {
|
||||
|
|
|
@ -20,6 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/painter.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace HistoryView {
|
||||
namespace {
|
||||
|
||||
|
@ -63,6 +67,13 @@ bool SendActionPainter::updateNeedsAnimating(
|
|||
return false;
|
||||
}
|
||||
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (settings->hideFromBlocked) {
|
||||
if (user->isBlocked()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const auto now = crl::now();
|
||||
const auto emplaceAction = [&](
|
||||
Type type,
|
||||
|
|
|
@ -26,6 +26,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_info.h"
|
||||
#include "styles/style_overview.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/utils/telegram_helpers.h"
|
||||
|
||||
|
||||
namespace Info::Media {
|
||||
namespace {
|
||||
|
||||
|
@ -410,6 +415,11 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
|
|||
if (!item) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (isMessageHidden(item)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto getPhoto = [&]() -> PhotoData* {
|
||||
if (const auto media = item->media()) {
|
||||
return media->photo();
|
||||
|
|
Loading…
Add table
Reference in a new issue