Rip MessagePeek For Now

This commit is contained in:
thororen1234 2025-02-20 09:03:35 -05:00
parent 334ce7c113
commit 1aa62ebb3f
No known key found for this signature in database
12 changed files with 12 additions and 170 deletions

View file

@ -10,7 +10,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
### Extra included plugins ### Extra included plugins
<details> <details>
<summary>152 additional plugins</summary> <summary>151 additional plugins</summary>
### All Platforms ### All Platforms
- AllCallTimers by MaxHerbold & D3SOX - AllCallTimers by MaxHerbold & D3SOX
@ -90,7 +90,6 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
- MessageColors by Hen - MessageColors by Hen
- MessageLinkTooltip by Kyuuhachi - MessageLinkTooltip by Kyuuhachi
- MessageLoggerEnhanced by Aria - MessageLoggerEnhanced by Aria
- MessagePeek by HypedDomi
- MessageTranslate by Samwich - MessageTranslate by Samwich
- ModalFade by Kyuuhachi - ModalFade by Kyuuhachi
- MoreStickers by Leko & Arjix - MoreStickers by Leko & Arjix

View file

@ -52,7 +52,7 @@ export default definePlugin({
replacement: replacement:
{ {
// We cant access the user id here, so we take the banner property we set earlier // We cant access the user id here, so we take the banner property we set earlier
match: /let{avatar:\i.*?focusProps:\i.*?=(\i).*?children:\[/, match: /wrappedLayout.{0,10}children:\[/,
replace: "$&$1.banner," replace: "$&$1.banner,"
} }
} }

View file

@ -471,7 +471,7 @@ export default definePlugin({
// still broken btw // still broken btw
find: "#{intl::ACTIVITY_REACTION_REPLY_TITLE}", find: "#{intl::ACTIVITY_REACTION_REPLY_TITLE}",
replacement: { replacement: {
match: /(?<=\(0,\i\.jsx\)\()(\i\.\i)(?=,{...(\i),activity:\i,user:\i,application:\i)/, match: /(?<=\(0,\i\.jsx\)\()(\i\.\i)(?=.{0,10},{activity:\i,user:\i,application:\i)/,
replace: "$2.type==='BiteSizePopout'?$self.showAllActivitiesComponent:$1" replace: "$2.type==='BiteSizePopout'?$self.showAllActivitiesComponent:$1"
}, },
predicate: () => settings.store.userPopout predicate: () => settings.store.userPopout

View file

@ -43,7 +43,7 @@ export default definePlugin({
// Changes text md rule regex, so it stops right before hsl( | rgb( // Changes text md rule regex, so it stops right before hsl( | rgb(
// Without it discord will try to pass a string without those to color rule // Without it discord will try to pass a string without those to color rule
{ {
find: ".defaultRules.text,match:", find: ".defaultRules.text)",
group: true, group: true,
replacement: { replacement: {
// $)/) // $)/)

View file

@ -256,7 +256,7 @@ export default definePlugin({
{ {
find: "THREAD_STARTER_MESSAGE?null===", find: "THREAD_STARTER_MESSAGE?null===",
replacement: { replacement: {
match: / deleted:\i\.deleted, editHistory:\i\.editHistory,/, match: /deleted:\i\.deleted, editHistory:\i\.editHistory,/,
replace: "deleted:$self.getDeleted(...arguments), editHistory:$self.getEdited(...arguments)," replace: "deleted:$self.getDeleted(...arguments), editHistory:$self.getEdited(...arguments),"
} }
}, },
@ -270,7 +270,7 @@ export default definePlugin({
}, },
{ {
find: ",guildId:void 0}),childrenMessageContent", find: "childrenMessageContent:null",
replacement: { replacement: {
match: /(cozyMessage.{1,50},)childrenHeader:/, match: /(cozyMessage.{1,50},)childrenHeader:/,
replace: "$1childrenAccessories:arguments[0].childrenAccessories || null,childrenHeader:" replace: "$1childrenAccessories:arguments[0].childrenAccessories || null,childrenHeader:"

View file

@ -1,53 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./styles.css";
import { findByPropsLazy } from "@webpack";
import { MessageStore, Parser, TooltipContainer, useStateFromStores } from "@webpack/common";
import { Message } from "discord-types/general";
import { MessagePeekProps } from "../types";
const ChannelWrapperStyles = findByPropsLazy("muted", "subText");
const ChannelStyles = findByPropsLazy("closeButton", "subtext");
declare module "discord-types/general" {
interface User {
globalName?: string;
}
}
export default function MessagePeek(props: MessagePeekProps) {
const { channel, channel_url } = props;
if (!channel && !channel_url) return null;
const channelId = channel ? channel.id : channel_url.split("/").pop() as string;
const lastMessage: Message = useStateFromStores([MessageStore], () => MessageStore.getMessages(channelId)?.last());
if (!lastMessage) return null;
const attachmentCount = lastMessage.attachments.length;
const content =
lastMessage.content ||
lastMessage.embeds?.[0]?.rawDescription ||
lastMessage.stickerItems.length && "Sticker" ||
attachmentCount && `${attachmentCount} attachment${attachmentCount > 1 ? "s" : ""}`;
if (!content) return null;
return (
<div
className={ChannelWrapperStyles.subText}
style={{ marginBottom: "2px" }}
>
<TooltipContainer text={content.length > 256 ? Parser.parse(content.slice(0, 256).trim()) : Parser.parse(content)}>
<div className={ChannelStyles.subtext}>
{`${lastMessage.author.globalName || lastMessage.author.username}: `}
{Parser.parseInlineReply(content)}
</div>
</TooltipContainer>
</div>
);
}

View file

@ -1,5 +0,0 @@
a[href^="/channels/@me"] [class^="layout"] {
min-height: 42px;
max-height: 50px;
height: unset;
}

View file

@ -1,60 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import ErrorBoundary from "@components/ErrorBoundary";
import { EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
import MessagePeek from "./components/MessagePeek";
import { settings } from "./settings";
import { MessagePeekProps } from "./types";
export default definePlugin({
name: "MessagePeek",
description: "See the last message in a Channel like on mobile",
authors: [EquicordDevs.HypedDomi],
settings: settings,
patches: [
{
// DMs
find: /let{className:[^],focusProps:[^],...[^]}=[^];return\(/,
replacement: {
match: /(?<=\.\.\.([^])[^]*)}=[^];/,
replace: `$&
if ($1.children?.props?.children?.[0]?.props?.children?.props)
$1.children.props.children[0].props.children.props.subText = [
$1.children.props.children[0].props.children.props?.subText,
$self.renderMessagePeek({ channel_url: $1.children.props.children[0].props.to })
];
`.replace(/\s+/g, "")
},
predicate: () => settings.store.dms === true
},
{
// Guild channels
find: /{href:[^],children:[^],onClick:[^],onKeyPress:[^],focusProps:[^],/,
replacement: {
match: /(?<=children:([^])[^]*)}\);/,
replace: `$&
if ($1[0] && $1[0].props && $1[0].props.children) {
$1[0].props.children[1].props.children=[
$1[0].props.children[1].props.children,
$self.renderMessagePeek({ channel: $1[0].props.children[0].props.channel })
];};`.replace(/\s+/g, "")
},
predicate: () => settings.store.guildChannels === true
}
],
renderMessagePeek: (props: MessagePeekProps) => {
return (
<ErrorBoundary noop>
<MessagePeek {...props} />
</ErrorBoundary>
);
}
});

View file

@ -1,26 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import { OptionType } from "@utils/types";
const settings = definePluginSettings({
guildChannels: {
description: "Show message peek in guild channels",
type: OptionType.BOOLEAN,
default: true,
restartNeeded: true
},
dms: {
description: "Show message peek in DMs",
type: OptionType.BOOLEAN,
default: true,
restartNeeded: true
}
});
export default settings;
export { settings };

View file

@ -1,12 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Channel } from "discord-types/general";
export interface MessagePeekProps {
channel: Channel;
channel_url: string;
}

View file

@ -34,19 +34,19 @@ export default definePlugin({
{ {
find: "ChannelStickerPickerButton", find: "ChannelStickerPickerButton",
replacement: [{ replacement: [{
match: /(children:\(0,\i\.jsx\)\()([\w.]+?)(,{innerClassName.{10,30}\.stickerButton)/, match: /(children:\(0,\i\.jsx\)\()(.{0,10})({innerClassName.{10,30}\.stickerButton)/,
replace: (_, head, button, tail) => { replace: (_, head, button, tail) => {
const isMoreStickers = "arguments[0]?.stickersType"; const isMoreStickers = "arguments[0]?.stickersType";
return `${head}${isMoreStickers}?$self.stickerButton:${button}${tail}`; return `${head}${isMoreStickers}?$self.stickerButton:${button}${tail}`;
} }
}, { }, {
match: /(\i=)(\i\.useCallback\(\(\)=>\{\(0,\w+\.\w+\)\([\w.]*?\.STICKER,.*?);/, match: /(\i=)(\i\.useCallback.{0,25}\.STICKER,.{0,10});/,
replace: (_, decl, cb) => { replace: (_, decl, cb) => {
const newCb = cb.replace(/(?<=\(\)=>\{\(.*?\)\().+?\.STICKER/, "\"stickers+\""); const newCb = cb.replace(/(?<=\(\)=>\{\(.*?\)\().+?\.STICKER/, "\"stickers+\"");
return `${decl}arguments[0]?.stickersType?${newCb}:${cb};`; return `${decl}arguments[0]?.stickersType?${newCb}:${cb};`;
} }
}, { }, {
match: /(\i)=((\i)===\w+?\.\w+?\.STICKER)/, match: /(\i)=((\i)===\i\.\i\.STICKER)/,
replace: (_, isActive, isStickerTab, currentTab) => { replace: (_, isActive, isStickerTab, currentTab) => {
const c = "arguments[0].stickersType"; const c = "arguments[0].stickersType";
return `${isActive}=${c}?(${currentTab}===${c}):(${isStickerTab})`; return `${isActive}=${c}?(${currentTab}===${c}):(${isStickerTab})`;
@ -64,7 +64,7 @@ export default definePlugin({
} }
}, },
{ {
find: "role:\"tablist\",\"aria-label\":", find: "#{intl::EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL}",
replacement: { replacement: {
match: /role:"tablist",.*?,?"aria-label":.+?\),children:(\[.*?\)\]}\)}\):null,)(.*?closePopout:\w.*?:null)/s, match: /role:"tablist",.*?,?"aria-label":.+?\),children:(\[.*?\)\]}\)}\):null,)(.*?closePopout:\w.*?:null)/s,
replace: m => { replace: m => {

View file

@ -166,10 +166,9 @@ export default definePlugin({
{ {
find: "#{intl::STATUS_MENU_LABEL}", find: "#{intl::STATUS_MENU_LABEL}",
replacement: { replacement: {
match: /"set-status-submenu-mobile-web".{150,165}void 0\}\)/, match: /:void 0\}\)/,
replace: "$&,$self.render()" replace: "$&,$self.render()"
}, }
all: true
} }
], ],
render() { render() {