mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-18 02:47:03 -04:00
HideAttachments, UnsupressEmbeds: Work with forwarded messages (#2928)
This commit is contained in:
parent
7ee70e831a
commit
79cbfe96c8
3 changed files with 20 additions and 4 deletions
|
@ -21,6 +21,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons";
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { ChannelStore } from "@webpack/common";
|
||||
import { MessageSnapshot } from "@webpack/types";
|
||||
|
||||
let style: HTMLStyleElement;
|
||||
|
||||
|
@ -39,7 +40,12 @@ export default definePlugin({
|
|||
authors: [Devs.Ven],
|
||||
|
||||
renderMessagePopoverButton(msg) {
|
||||
if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length) return null;
|
||||
// @ts-ignore - discord-types lags behind discord.
|
||||
const hasAttachmentsInShapshots = msg.messageSnapshots.some(
|
||||
(snapshot: MessageSnapshot) => snapshot?.message.attachments.length
|
||||
);
|
||||
|
||||
if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInShapshots) return null;
|
||||
|
||||
const isHidden = hiddenMessages.has(msg.id);
|
||||
|
||||
|
|
|
@ -21,12 +21,18 @@ import { ImageInvisible, ImageVisible } from "@components/Icons";
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common";
|
||||
import { MessageSnapshot } from "@webpack/types";
|
||||
|
||||
|
||||
const EMBED_SUPPRESSED = 1 << 2;
|
||||
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, embeds, flags, id: messageId } }) => {
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => {
|
||||
const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0;
|
||||
if (!isEmbedSuppressed && !embeds.length) return;
|
||||
const hasEmbedsInSnapshots = messageSnapshots.some(
|
||||
(snapshot: MessageSnapshot) => snapshot?.message.embeds.length
|
||||
);
|
||||
|
||||
if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return;
|
||||
|
||||
const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS);
|
||||
if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue