diff --git a/src/equicordplugins/hideServers/index.tsx b/src/equicordplugins/hideServers/index.tsx index c593d8181..6f4d4af3f 100644 --- a/src/equicordplugins/hideServers/index.tsx +++ b/src/equicordplugins/hideServers/index.tsx @@ -90,7 +90,7 @@ export default definePlugin({ { find: "#{intl::QUICKSWITCHER_PROTIP}", replacement: { - match: /(?<=renderResults\(\){)let{query/, + match: /(?<=renderResults\(\){.{0,100})let{query/, replace: "this.props.results = $self.filteredGuildResults(this.props.results);$&", }, }, diff --git a/src/equicordplugins/searchFix/index.tsx b/src/equicordplugins/searchFix/index.tsx index c13adc9bd..c1ae81917 100644 --- a/src/equicordplugins/searchFix/index.tsx +++ b/src/equicordplugins/searchFix/index.tsx @@ -43,7 +43,7 @@ export default definePlugin({ authors: [EquicordDevs.Jaxx], patches: [ { - find: '"SearchStore");', + find: '"SearchQueryStore");', replacement: { match: /\i\.searchResultsQuery=(\i)/, replace: "$&,$self.main($1)" diff --git a/src/plugins/hideAttachments/index.tsx b/src/plugins/hideAttachments/index.tsx deleted file mode 100644 index 382130575..000000000 --- a/src/plugins/hideAttachments/index.tsx +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import "./styles.css"; - -import { get, set } from "@api/DataStore"; -import { updateMessage } from "@api/MessageUpdater"; -import { migratePluginSettings } from "@api/Settings"; -import { ImageInvisible, ImageVisible } from "@components/Icons"; -import { Devs } from "@utils/constants"; -import { classes } from "@utils/misc"; -import definePlugin from "@utils/types"; -import { Message } from "@vencord/discord-types"; -import { ChannelStore } from "@webpack/common"; - -const KEY = "HideAttachments_HiddenIds"; - -let hiddenMessages = new Set(); - -async function getHiddenMessages() { - hiddenMessages = await get(KEY) ?? new Set(); - return hiddenMessages; -} - -const saveHiddenMessages = (ids: Set) => set(KEY, ids); - -migratePluginSettings("HideMedia", "HideAttachments"); - -const hasMedia = (msg: Message) => msg.attachments.length > 0 || msg.embeds.length > 0 || msg.stickerItems.length > 0; - -export default definePlugin({ - name: "HideMedia", - description: "Hide attachments and embeds for individual messages via hover button", - authors: [Devs.Ven], - dependencies: ["MessageUpdaterAPI"], - - patches: [{ - find: "this.renderAttachments(", - replacement: { - match: /(?<=\i=)this\.render(?:Attachments|Embeds|StickersAccessories)\((\i)\)/g, - replace: "$self.shouldHide($1?.id)?null:$&" - } - }], - - renderMessagePopoverButton(msg) { - if (!hasMedia(msg) && !msg.messageSnapshots.some(s => hasMedia(s.message))) return null; - - const isHidden = hiddenMessages.has(msg.id); - - return { - label: isHidden ? "Show Media" : "Hide Media", - icon: isHidden ? ImageVisible : ImageInvisible, - message: msg, - channel: ChannelStore.getChannel(msg.channel_id), - onClick: () => this.toggleHide(msg.channel_id, msg.id) - }; - }, - - renderMessageAccessory({ message }) { - if (!this.shouldHide(message.id)) return null; - - return ( - - Media Hidden - - ); - }, - - async start() { - await getHiddenMessages(); - }, - - stop() { - hiddenMessages.clear(); - }, - - shouldHide(messageId: string) { - return hiddenMessages.has(messageId); - }, - - async toggleHide(channelId: string, messageId: string) { - const ids = await getHiddenMessages(); - if (!ids.delete(messageId)) - ids.add(messageId); - - await saveHiddenMessages(ids); - updateMessage(channelId, messageId); - } -}); diff --git a/src/plugins/hideAttachments/styles.css b/src/plugins/hideAttachments/styles.css deleted file mode 100644 index 4cbd10a6f..000000000 --- a/src/plugins/hideAttachments/styles.css +++ /dev/null @@ -1,10 +0,0 @@ -.vc-hideAttachments-accessory { - color: var(--text-muted); - margin-top: 0.5em; - font-style: italic; - font-weight: 400; -} - -.vc-hideAttachments-no-content { - margin-top: 0; -}