Fix Patches
This commit is contained in:
parent
7cfb4350d3
commit
36234b9044
12 changed files with 64 additions and 114 deletions
|
|
@ -9,11 +9,8 @@ import "./styles.css";
|
|||
import { EquicordDevs } from "@utils/constants";
|
||||
import { getIntlMessage, openUserProfile } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Button, React, RelationshipStore, TextInput, UserStore } from "@webpack/common";
|
||||
|
||||
const ChannelActions = findByPropsLazy("openPrivateChannel");
|
||||
|
||||
let lastSearch = "";
|
||||
let updateFunc = (v: any) => { };
|
||||
|
||||
|
|
@ -30,8 +27,8 @@ export default definePlugin({
|
|||
replace: ",$1.listType==='blocked'?$self.renderSearchInput():null"
|
||||
},
|
||||
{
|
||||
match: /(?<=userId:(\i).*?\}\)\]\}\),)(\(.*?\)\}\))/,
|
||||
replace: "$self.renderUser($1,$2),",
|
||||
match: /(?<=userId:(\i).*?\}\)\]\}\),)(\(.*?loading:\i\}\))/,
|
||||
replace: "$self.renderUser($1,$2)",
|
||||
},
|
||||
{
|
||||
match: /(?<=\}=(\i).{0,10}(\i).useState\(.{0,1}\);)/,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ export default definePlugin({
|
|||
|
||||
toolbarAction(e) {
|
||||
if (Array.isArray(e.toolbar))
|
||||
return e.toolbar.push(
|
||||
return e.toolbar.unshift(
|
||||
<ErrorBoundary noop={true}>
|
||||
<ToolBarHeader />
|
||||
</ErrorBoundary>
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export default definePlugin({
|
|||
replacement: {
|
||||
// Find the Edit User Profile button and insert our custom button.
|
||||
// A bit jank, but whatever
|
||||
match: /,(\(.{1,90}#{intl::USER_SETTINGS_EDIT_USER_PROFILE}\)}\))/,
|
||||
match: /,(\(.{1,90}#{intl::USER_SETTINGS_EDIT_USER_PROFILE}\),onClick:\i\}\))/,
|
||||
replace: ",$self.insertScanQrButton($1)",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
export const VERSION = "4.0.0";
|
||||
|
||||
export const Native = getNative();
|
||||
|
||||
import "./styles.css";
|
||||
|
|
@ -318,7 +316,7 @@ export default definePlugin({
|
|||
|
||||
addIconToToolBar(e: { toolbar: React.ReactNode[] | React.ReactNode; }) {
|
||||
if (Array.isArray(e.toolbar))
|
||||
return e.toolbar.push(
|
||||
return e.toolbar.unshift(
|
||||
<ErrorBoundary noop={true}>
|
||||
<OpenLogsButton />
|
||||
</ErrorBoundary>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export const settings = definePluginSettings({
|
|||
saveMessages: {
|
||||
default: true,
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Wether to save the deleted and edited messages.",
|
||||
description: "Whether to save the deleted and edited messages.",
|
||||
},
|
||||
|
||||
saveImages: {
|
||||
|
|
@ -103,12 +103,6 @@ export const settings = definePluginSettings({
|
|||
description: "Vencord's base MessageLogger remove log button wiil delete logs permanently",
|
||||
},
|
||||
|
||||
hideMessageFromMessageLoggers: {
|
||||
default: false,
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "When enabled, a context menu button will be added to messages to allow you to delete messages without them being logged by other loggers. Might not be safe, use at your own risk."
|
||||
},
|
||||
|
||||
ShowLogsButton: {
|
||||
default: true,
|
||||
type: OptionType.BOOLEAN,
|
||||
|
|
@ -122,12 +116,6 @@ export const settings = definePluginSettings({
|
|||
description: "Number of messages to display at once in logs & number of messages to load when loading more messages in logs.",
|
||||
},
|
||||
|
||||
hideMessageFromMessageLoggersDeletedMessage: {
|
||||
default: "redacted eh",
|
||||
type: OptionType.STRING,
|
||||
description: "The message content to replace the message with when using the hide message from message loggers feature.",
|
||||
},
|
||||
|
||||
messageLimit: {
|
||||
default: 200,
|
||||
type: OptionType.NUMBER,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||
import { FluxDispatcher, Menu, MessageActions, React, Toasts, UserStore } from "@webpack/common";
|
||||
import { FluxDispatcher, Menu, React, Toasts } from "@webpack/common";
|
||||
|
||||
import { openLogModal } from "../components/LogsModal";
|
||||
import { deleteMessageIDB } from "../db";
|
||||
|
|
@ -62,8 +62,37 @@ export const contextMenuPath: NavContextMenuPatchCallback = (children, props) =>
|
|||
if (!props) return;
|
||||
|
||||
if (!children.some(child => child?.props?.id === "message-logger")) {
|
||||
if (props.navId === "message" && (props.message?.deleted || props.message?.editHistory?.length > 0)) {
|
||||
children.push(
|
||||
<Menu.MenuItem
|
||||
id="remove-message"
|
||||
label={props.message?.deleted ? "Remove Message (Permanent)" : "Remove Message History (Permanent)"}
|
||||
color="danger"
|
||||
action={() =>
|
||||
deleteMessageIDB(props.message.id)
|
||||
.then(() => {
|
||||
if (props.message.deleted) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_DELETE",
|
||||
channelId: props.message.channel_id,
|
||||
id: props.message.id,
|
||||
mlDeleted: true
|
||||
});
|
||||
} else {
|
||||
props.message.editHistory = [];
|
||||
}
|
||||
}).catch(() => Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
message: "Failed to remove message",
|
||||
id: Toasts.genId()
|
||||
}))
|
||||
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
children.push(
|
||||
<Menu.MenuSeparator />,
|
||||
<Menu.MenuItem
|
||||
id="message-logger"
|
||||
label="Message Logger"
|
||||
|
|
@ -85,70 +114,6 @@ export const contextMenuPath: NavContextMenuPatchCallback = (children, props) =>
|
|||
{renderListOption("whitelistedIds", IdType as idKeys, props)}
|
||||
</React.Fragment>
|
||||
))}
|
||||
|
||||
{
|
||||
props.navId === "message"
|
||||
&& (props.message?.deleted || props.message?.editHistory?.length > 0)
|
||||
&& (
|
||||
<>
|
||||
<Menu.MenuSeparator />
|
||||
<Menu.MenuItem
|
||||
id="remove-message"
|
||||
label={props.message?.deleted ? "Remove Message (Permanent)" : "Remove Message History (Permanent)"}
|
||||
color="danger"
|
||||
action={() =>
|
||||
deleteMessageIDB(props.message.id)
|
||||
.then(() => {
|
||||
if (props.message.deleted) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_DELETE",
|
||||
channelId: props.message.channel_id,
|
||||
id: props.message.id,
|
||||
mlDeleted: true
|
||||
});
|
||||
} else {
|
||||
props.message.editHistory = [];
|
||||
}
|
||||
}).catch(() => Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
message: "Failed to remove message",
|
||||
id: Toasts.genId()
|
||||
}))
|
||||
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
settings.store.hideMessageFromMessageLoggers
|
||||
&& props.navId === "message"
|
||||
&& props.message?.author?.id === UserStore.getCurrentUser().id
|
||||
&& props.message?.deleted === false
|
||||
&& (
|
||||
<>
|
||||
<Menu.MenuSeparator />
|
||||
<Menu.MenuItem
|
||||
id="hide-from-message-loggers"
|
||||
label="Delete Message (Hide From Message Loggers)"
|
||||
color="danger"
|
||||
|
||||
action={async () => {
|
||||
await MessageActions.deleteMessage(props.message.channel_id, props.message.id);
|
||||
MessageActions._sendMessage(props.message.channel_id, {
|
||||
"content": settings.store.hideMessageFromMessageLoggersDeletedMessage,
|
||||
"tts": false,
|
||||
"invalidEmojis": [],
|
||||
"validNonShortcutEmojis": []
|
||||
}, { nonce: props.message.id });
|
||||
}}
|
||||
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
</Menu.MenuItem>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ export default definePlugin({
|
|||
},
|
||||
toolbarAction(e) {
|
||||
if (Array.isArray(e.toolbar))
|
||||
return e.toolbar.push(
|
||||
return e.toolbar.unshift(
|
||||
<ErrorBoundary noop={true}>
|
||||
<ToolBarHeader />
|
||||
</ErrorBoundary>
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ export default definePlugin({
|
|||
// taken from message logger lol
|
||||
addIconToToolBar(e: { toolbar: React.ReactNode[] | React.ReactNode; }) {
|
||||
if (Array.isArray(e.toolbar))
|
||||
return e.toolbar.push(
|
||||
return e.toolbar.unshift(
|
||||
<ErrorBoundary noop={true}>
|
||||
<SoggyButton />
|
||||
</ErrorBoundary>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export default definePlugin({
|
|||
settings,
|
||||
addSBIconToToolBar(e: { toolbar: React.ReactNode[] | React.ReactNode; }) {
|
||||
if (Array.isArray(e.toolbar))
|
||||
return e.toolbar.push(
|
||||
return e.toolbar.unshift(
|
||||
<ErrorBoundary noop={true}>
|
||||
<OpenSBLogsButton />
|
||||
</ErrorBoundary>
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "#{intl::CUSTOM_STATUS_SET_CUSTOM_STATUS}",
|
||||
replacement: {
|
||||
match: /\.\i\i,children:\i\.\i\.string\(\i\.\i#{intl::SAVE}\)\}\)/,
|
||||
match: /cancelButton,children:\i\.\i\.string\(\i\.\i#{intl::CANCEL}\)\}\)/,
|
||||
replace: "$&,$self.renderRememberButton(this.state)"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}",
|
||||
replacement: {
|
||||
match: /#{intl::USER_SETTINGS_RESET_PROFILE_THEME}\)}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/,
|
||||
match: /#{intl::USER_SETTINGS_RESET_PROFILE_THEME}\),onClick:.{0,25}\}\)(?=\]\}\))(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/,
|
||||
replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,26 +74,28 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (
|
|||
);
|
||||
}
|
||||
|
||||
children.push(
|
||||
<Menu.MenuItem
|
||||
id={REMOVE_HISTORY_ID}
|
||||
key={REMOVE_HISTORY_ID}
|
||||
label="Remove Message History"
|
||||
color="danger"
|
||||
action={() => {
|
||||
if (deleted) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_DELETE",
|
||||
channelId: channel_id,
|
||||
id,
|
||||
mlDeleted: true,
|
||||
});
|
||||
} else {
|
||||
message.editHistory = [];
|
||||
}
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
if (!Vencord.Plugins.isPluginEnabled("MessageLoggerEnhanced")) {
|
||||
children.push(
|
||||
<Menu.MenuItem
|
||||
id={REMOVE_HISTORY_ID}
|
||||
key={REMOVE_HISTORY_ID}
|
||||
label="Remove Message History"
|
||||
color="danger"
|
||||
action={() => {
|
||||
if (deleted) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_DELETE",
|
||||
channelId: channel_id,
|
||||
id,
|
||||
mlDeleted: true,
|
||||
});
|
||||
} else {
|
||||
message.editHistory = [];
|
||||
}
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const patchChannelContextMenu: NavContextMenuPatchCallback = (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue