mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 14:13:01 -04:00
Rip MessagePeek For Now
This commit is contained in:
parent
334ce7c113
commit
1aa62ebb3f
12 changed files with 12 additions and 170 deletions
|
@ -10,7 +10,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
|||
|
||||
### Extra included plugins
|
||||
<details>
|
||||
<summary>152 additional plugins</summary>
|
||||
<summary>151 additional plugins</summary>
|
||||
|
||||
### All Platforms
|
||||
- AllCallTimers by MaxHerbold & D3SOX
|
||||
|
@ -90,7 +90,6 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
|||
- MessageColors by Hen
|
||||
- MessageLinkTooltip by Kyuuhachi
|
||||
- MessageLoggerEnhanced by Aria
|
||||
- MessagePeek by HypedDomi
|
||||
- MessageTranslate by Samwich
|
||||
- ModalFade by Kyuuhachi
|
||||
- MoreStickers by Leko & Arjix
|
||||
|
|
|
@ -52,7 +52,7 @@ export default definePlugin({
|
|||
replacement:
|
||||
{
|
||||
// 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,"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -471,7 +471,7 @@ export default definePlugin({
|
|||
// still broken btw
|
||||
find: "#{intl::ACTIVITY_REACTION_REPLY_TITLE}",
|
||||
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"
|
||||
},
|
||||
predicate: () => settings.store.userPopout
|
||||
|
|
|
@ -43,7 +43,7 @@ export default definePlugin({
|
|||
// 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
|
||||
{
|
||||
find: ".defaultRules.text,match:",
|
||||
find: ".defaultRules.text)",
|
||||
group: true,
|
||||
replacement: {
|
||||
// $)/)
|
||||
|
|
|
@ -256,7 +256,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "THREAD_STARTER_MESSAGE?null===",
|
||||
replacement: {
|
||||
match: / deleted:\i\.deleted, editHistory:\i\.editHistory,/,
|
||||
match: /deleted:\i\.deleted, editHistory:\i\.editHistory,/,
|
||||
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: {
|
||||
match: /(cozyMessage.{1,50},)childrenHeader:/,
|
||||
replace: "$1childrenAccessories:arguments[0].childrenAccessories || null,childrenHeader:"
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
a[href^="/channels/@me"] [class^="layout"] {
|
||||
min-height: 42px;
|
||||
max-height: 50px;
|
||||
height: unset;
|
||||
}
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
});
|
|
@ -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 };
|
|
@ -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;
|
||||
}
|
|
@ -34,19 +34,19 @@ export default definePlugin({
|
|||
{
|
||||
find: "ChannelStickerPickerButton",
|
||||
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) => {
|
||||
const isMoreStickers = "arguments[0]?.stickersType";
|
||||
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) => {
|
||||
const newCb = cb.replace(/(?<=\(\)=>\{\(.*?\)\().+?\.STICKER/, "\"stickers+\"");
|
||||
return `${decl}arguments[0]?.stickersType?${newCb}:${cb};`;
|
||||
}
|
||||
}, {
|
||||
match: /(\i)=((\i)===\w+?\.\w+?\.STICKER)/,
|
||||
match: /(\i)=((\i)===\i\.\i\.STICKER)/,
|
||||
replace: (_, isActive, isStickerTab, currentTab) => {
|
||||
const c = "arguments[0].stickersType";
|
||||
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: {
|
||||
match: /role:"tablist",.*?,?"aria-label":.+?\),children:(\[.*?\)\]}\)}\):null,)(.*?closePopout:\w.*?:null)/s,
|
||||
replace: m => {
|
||||
|
|
|
@ -166,10 +166,9 @@ export default definePlugin({
|
|||
{
|
||||
find: "#{intl::STATUS_MENU_LABEL}",
|
||||
replacement: {
|
||||
match: /"set-status-submenu-mobile-web".{150,165}void 0\}\)/,
|
||||
match: /:void 0\}\)/,
|
||||
replace: "$&,$self.render()"
|
||||
},
|
||||
all: true
|
||||
}
|
||||
}
|
||||
],
|
||||
render() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue