MLE: More Updates I forgot
This commit is contained in:
parent
ede9193d9f
commit
27f647a167
3 changed files with 41 additions and 75 deletions
|
|
@ -10,8 +10,8 @@ import { Flex } from "@components/Flex";
|
|||
import { InfoIcon } from "@components/Icons";
|
||||
import { copyWithToast, openUserProfile } from "@utils/discord";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import { RenderModalProps, type User } from "@vencord/discord-types";
|
||||
import { find, findByCode, findByCodeLazy } from "@webpack";
|
||||
import { Channel, RenderModalProps, type User } from "@vencord/discord-types";
|
||||
import { find, findByCodeLazy } from "@webpack";
|
||||
import { Alerts, ChannelStore, closeAllModals, ContextMenuApi, FluxDispatcher, GuildStore, Menu, Modal, NavigationRouter, openModal, React, TabBar, TextInput, Tooltip, useMemo, useRef, useState } from "@webpack/common";
|
||||
|
||||
import { DBMessageRecord, deleteMessageIDB, deleteMessagesBulkIDB } from "../db";
|
||||
|
|
@ -25,33 +25,14 @@ export interface MessagePreviewProps {
|
|||
className: string;
|
||||
author: User;
|
||||
message: LoggedMessage;
|
||||
channel: Channel,
|
||||
compact: boolean;
|
||||
isGroupStart: boolean;
|
||||
hideSimpleEmbedContent: boolean;
|
||||
|
||||
childrenAccessories: any;
|
||||
}
|
||||
|
||||
export interface ChildrenAccProops {
|
||||
channelMessageProps: {
|
||||
compact: boolean;
|
||||
channel: any;
|
||||
message: LoggedMessage;
|
||||
groupId: string;
|
||||
id: string;
|
||||
isLastItem: boolean;
|
||||
isHighlight: boolean;
|
||||
renderContentOnly: boolean;
|
||||
};
|
||||
hasSpoilerEmbeds: boolean;
|
||||
isInteracting: boolean;
|
||||
isAutomodBlockedMessage: boolean;
|
||||
showClydeAiEmbeds: boolean;
|
||||
}
|
||||
|
||||
const PrivateChannelRecord = findByCodeLazy(".is_message_request_timestamp,");
|
||||
const MessagePreview = LazyComponent<MessagePreviewProps>(() => find(m => m?.type?.toString().includes("previewLinkTarget:") && !m?.type?.toString().includes("HAS_THREAD")));
|
||||
const ChildrenAccessories = LazyComponent<ChildrenAccProops>(() => findByCode("channelMessageProps:{message:"));
|
||||
|
||||
export enum LogTabs {
|
||||
DELETED = "Deleted",
|
||||
|
|
@ -404,28 +385,10 @@ function LMessage({ log, isGroupStart, reset, }: LMessageProps) {
|
|||
className={`${cl("modal-msg-preview")} ${message.deleted ? "messagelogger-deleted" : ""}`}
|
||||
author={message.author}
|
||||
message={message}
|
||||
channel={ChannelStore.getChannel(message.channel_id) || new PrivateChannelRecord({ id: "" })}
|
||||
compact={false}
|
||||
isGroupStart={isGroupStart}
|
||||
hideSimpleEmbedContent={false}
|
||||
|
||||
childrenAccessories={
|
||||
<ChildrenAccessories
|
||||
channelMessageProps={{
|
||||
channel: ChannelStore.getChannel(message.channel_id) || new PrivateChannelRecord({ id: "" }),
|
||||
message,
|
||||
compact: false,
|
||||
groupId: "1",
|
||||
id: message.id,
|
||||
isLastItem: false,
|
||||
isHighlight: false,
|
||||
renderContentOnly: false,
|
||||
}}
|
||||
hasSpoilerEmbeds={false}
|
||||
isInteracting={false}
|
||||
showClydeAiEmbeds={true}
|
||||
isAutomodBlockedMessage={false}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{settings.store.ShowWhereMessageIsFrom && channel?.isDM() && message?.author && (
|
||||
<span className={`${cl("modal-from")} ${message.deleted ? cl("modal-from-deleted") : cl("modal-from-edited")}`}>From {message.author.username}'s DMs</span>
|
||||
|
|
|
|||
|
|
@ -50,12 +50,7 @@ let oldGetMessage: typeof MessageStore.getMessage;
|
|||
|
||||
const handledMessageIds = new Set();
|
||||
async function messageDeleteHandler(payload: MessageDeletePayload & { isBulk: boolean; }) {
|
||||
if (payload.mlDeleted) {
|
||||
if (settings.store.permanentlyRemoveLogByDefault)
|
||||
await idb.deleteMessageIDB(payload.id);
|
||||
|
||||
return;
|
||||
}
|
||||
if (payload.mlDeleted) return;
|
||||
|
||||
if (handledMessageIds.has(payload.id)) {
|
||||
return;
|
||||
|
|
@ -284,14 +279,6 @@ export default definePlugin({
|
|||
replace: "deleted:$self.getDeleted(...arguments), editHistory:$self.getEdited(...arguments),"
|
||||
}
|
||||
},
|
||||
// MessagePreview component in LogsModal
|
||||
{
|
||||
find: "=!0,disableInteraction:",
|
||||
replacement: {
|
||||
match: /childrenHeader:.{0,100}childrenMessageContent/,
|
||||
replace: "childrenAccessories:arguments[0].childrenAccessories || null,$&"
|
||||
}
|
||||
},
|
||||
// fix vidoes failing because there are no thumbnails
|
||||
{
|
||||
find: ".handleImageLoad)",
|
||||
|
|
|
|||
|
|
@ -5,13 +5,17 @@
|
|||
*/
|
||||
|
||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||
import { FluxDispatcher, Menu, MessageActions, React, SortedGuildStore, Toasts, UserStore } from "@webpack/common";
|
||||
import { updateMessage } from "@api/MessageUpdater";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
import { FluxDispatcher, Menu, MessageActions, React, Toasts, UserStore } from "@webpack/common";
|
||||
|
||||
import { openLogModal } from "../components/LogsModal";
|
||||
import { deleteMessageIDB } from "../db";
|
||||
import { settings } from "../index";
|
||||
import { addToXAndRemoveFromOpposite, ListType, removeFromX } from ".";
|
||||
|
||||
const SortedGuildStore = findStoreLazy("SortedGuildStore");
|
||||
|
||||
const idFunctions = {
|
||||
Folder: props =>
|
||||
props?.folderId &&
|
||||
|
|
@ -64,10 +68,40 @@ function renderOpenLogs(idType: idKeys, props: any) {
|
|||
);
|
||||
}
|
||||
|
||||
const removeMessageAction = async (props: any) => {
|
||||
try {
|
||||
await deleteMessageIDB(props.message.id);
|
||||
if (props.message.deleted) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_DELETE",
|
||||
channelId: props.message.channel_id,
|
||||
id: props.message.id,
|
||||
mlDeleted: true
|
||||
});
|
||||
} else {
|
||||
updateMessage(props.message.channel_id, props.message.id, { editHistory: [] });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to remove message", e);
|
||||
Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
message: "Failed to remove message. Check console for details.",
|
||||
id: Toasts.genId()
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const contextMenuPath: NavContextMenuPatchCallback = (children, props) => {
|
||||
if (!props) return;
|
||||
|
||||
if (!children.some(child => child?.props?.id === "message-logger")) {
|
||||
if (settings.store.permanentlyRemoveLogByDefault) {
|
||||
const mlRemoveHistory = children.find(c => c?.props?.id === "ml-remove-history");
|
||||
if (mlRemoveHistory) {
|
||||
mlRemoveHistory.props.action = () => removeMessageAction(props);
|
||||
}
|
||||
}
|
||||
|
||||
children.push(
|
||||
<Menu.MenuSeparator />,
|
||||
<Menu.MenuItem
|
||||
|
|
@ -102,25 +136,7 @@ export const contextMenuPath: NavContextMenuPatchCallback = (children, props) =>
|
|||
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()
|
||||
}))
|
||||
}
|
||||
action={() => removeMessageAction(props)}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue