Skip to content

Commit

Permalink
perf: ignore blocked users
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed May 19, 2024
1 parent 986e0b9 commit 0e43427
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
15 changes: 15 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
import java.util.Objects;
import java.util.Stack;

import tw.nekomimi.nekogram.helpers.AyuFilter;
import tw.nekomimi.nekogram.ui.MessageHelper;
import tw.nekomimi.nekogram.NekoConfig;
import xyz.nextalone.nagram.NaConfig;
Expand Down Expand Up @@ -3178,6 +3179,20 @@ public void onAnimationEnd(Animator animation) {
}
}

// --- AyuGram hook
if (AyuFilter.isFiltered(message, null)) {
xyz.nextalone.nagram.helper.MessageHelper.INSTANCE.blurify(message);
}
// --- AyuGram hook
// --- NaGram hook
if (message != null && message.messageOwner != null && message.messageOwner.hide) {
xyz.nextalone.nagram.helper.MessageHelper.INSTANCE.blurify(message);
}
if (NekoConfig.ignoreBlocked.Bool() && message != null && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(message.getFromChatId()) >= 0) {
xyz.nextalone.nagram.helper.MessageHelper.INSTANCE.blurify(message);
}
// --- NaGram hook

if (!animated) {
dialogMutedProgress = (dialogMuted || drawUnmute) ? 1f : 0f;
if (countAnimator != null) {
Expand Down
11 changes: 11 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34344,6 +34344,14 @@ public int getItemViewType(int position) {
}
}
// --- AyuGram hook
// --- NaGram hook
if (msg != null && msg.messageOwner != null && msg.messageOwner.hide) {
return -1000;
}
if (NekoConfig.ignoreBlocked.Bool() && msg != null && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(msg.getFromChatId()) >= 0) {
return -1000;
}
// --- NaGram hook

return msg.contentType;
} else if (position == botInfoRow) {
Expand Down Expand Up @@ -39111,6 +39119,9 @@ private void nkbtn_onclick_actionbar(int id) {
int msgId = messages.get(i).getId();
if (NekoConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messages.get(i).getSenderId()) >= 0)
continue;
if (NaConfig.INSTANCE.getRegexFiltersEnabled().Bool() && AyuFilter.isFiltered(messages.get(i), null)) {
continue;
}
if (msgId > begin && msgId < end && selectedMessagesIds[0].indexOfKey(msgId) < 0) {
MessageObject message = messages.get(i);
int type = getMessageType(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.telegram.tgnet.TLRPC.TL_messageEntityEmail
import org.telegram.tgnet.TLRPC.TL_messageEntityHashtag
import org.telegram.tgnet.TLRPC.TL_messageEntityMention
import org.telegram.tgnet.TLRPC.TL_messageEntityPhone
import org.telegram.tgnet.TLRPC.TL_messageEntitySpoiler
import org.telegram.tgnet.TLRPC.TL_messageEntityUrl
import org.telegram.tgnet.TLRPC.TL_messageMediaPoll
import org.telegram.ui.ActionBar.Theme
Expand Down Expand Up @@ -308,4 +309,21 @@ object MessageHelper {
}
return text
}

fun blurify(messageObject: MessageObject?) {
if (messageObject?.messageOwner == null) {
return
}

if (!TextUtils.isEmpty(messageObject.messageOwner.message)) {
val entity = TL_messageEntitySpoiler()
entity.offset = 0
entity.length = messageObject.messageOwner.message.length
messageObject.messageOwner.entities.add(entity)

This comment has been minimized.

Copy link
@qwq233

qwq233 May 25, 2024

Contributor
TL_messageEntitySpoiler().apply {
    offset = 0
    length = messageObject.messageOwner.message.length
}.also { messageObject.messageOwner.entities.add(it) }
}

if (messageObject.messageOwner.media != null) {
messageObject.messageOwner.media.spoiler = true
}
}
}

0 comments on commit 0e43427

Please sign in to comment.