mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-18 21:33:35 -05:00
Some More Fixes
This commit is contained in:
parent
c8acee8955
commit
a5cc68d9a2
6 changed files with 50 additions and 24 deletions
|
@ -32,13 +32,13 @@ function AppIconModal(props: ModalProps) {
|
|||
|
||||
|
||||
appIcons.push(icon);
|
||||
findByProps("ICONS", "ICONS_BY_ID").ICONS.push(icon);
|
||||
findByProps("ICONS", "ICONS_BY_ID").ICONS_BY_ID[icon.id] = icon;
|
||||
findByProps("UZ", "QA").UZ.push(icon);
|
||||
findByProps("UZ", "QA").QA[icon.id] = icon;
|
||||
showToast("Added custom app icon!", Toasts.Type.SUCCESS);
|
||||
props.onClose();
|
||||
const oldIcon = findByProps("getCurrentDesktopIcon").getCurrentDesktopIcon();
|
||||
|
||||
let random_icon = Object.keys(findByProps("ICONS_BY_ID")).filter(icon => icon !== oldIcon) as [];
|
||||
let random_icon = Object.keys(findByProps("UZ")).filter(icon => icon !== oldIcon) as [];
|
||||
random_icon = random_icon[Math.floor(Math.random() * random_icon.length)];
|
||||
|
||||
FluxDispatcher.dispatch({
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
|
@ -32,8 +38,8 @@ function removeAppIcon() {
|
|||
const index = icons.findIndex(icon => current_icon === icon.id);
|
||||
if (index !== -1) {
|
||||
icons = icons.filter(e => e.id !== current_icon);
|
||||
delete findByProps("ICONS", "ICONS_BY_ID").ICONS_BY_ID[current_icon];
|
||||
delete findByProps("ICONS", "ICONS_BY_ID").ICONS[findByProps("ICONS", "ICONS_BY_ID").ICONS.findIndex((icon => current_icon === icon?.id))];
|
||||
delete findByProps("UZ", "QA").QA[current_icon];
|
||||
delete findByProps("UZ", "QA").UZ[findByProps("UZ", "QA").UZ.findIndex((icon => current_icon === icon?.id))];
|
||||
localStorage.setItem("vc_app_icons", JSON.stringify(icons));
|
||||
showToast("Icon successfully deleted!", Toasts.Type.SUCCESS);
|
||||
FluxDispatcher.dispatch({
|
||||
|
@ -54,7 +60,7 @@ export default definePlugin({
|
|||
authors: [Devs.HappyEnderman, EquicordDevs.SerStars],
|
||||
patches: [
|
||||
{
|
||||
find: ".PremiumUpsellTypes.APP_ICON_UPSELL",
|
||||
find: /\i\.\i\.APP_ICON_UPSELL/,
|
||||
replacement: [
|
||||
{
|
||||
match: /\w+\.jsx\)\(\w+,{markAsDismissed:\w+,isCoachmark:\w+}\)/,
|
||||
|
@ -71,8 +77,8 @@ export default definePlugin({
|
|||
console.log("Well hello there!, CustomAppIcons has started :)");
|
||||
const appIcons = JSON.parse(localStorage.getItem("vc_app_icons") ?? "[]");
|
||||
for (const icon of appIcons) {
|
||||
findByProps("ICONS", "ICONS_BY_ID").ICONS.push(icon);
|
||||
findByProps("ICONS", "ICONS_BY_ID").ICONS_BY_ID[icon.id] = icon;
|
||||
findByProps("UZ", "QA").UZ.push(icon);
|
||||
findByProps("UZ", "QA").QA[icon.id] = icon;
|
||||
}
|
||||
},
|
||||
stop() {
|
||||
|
@ -100,12 +106,12 @@ export default definePlugin({
|
|||
<><Forms.FormTitle>
|
||||
<Forms.FormTitle>How to use?</Forms.FormTitle>
|
||||
</Forms.FormTitle>
|
||||
<Forms.FormText>
|
||||
<Forms.FormText>Go to <Link href="/settings/appearance" onClick={e => { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings</Link> tab.</Forms.FormText>
|
||||
<Forms.FormText>Scroll down to "In-app Icons" and click on "Preview App Icon".</Forms.FormText>
|
||||
<Forms.FormText>And upload your own custom icon!</Forms.FormText>
|
||||
<Forms.FormText>You can only use links when you are uploading your Custom Icon.</Forms.FormText>
|
||||
</Forms.FormText></>
|
||||
<Forms.FormText>
|
||||
<Forms.FormText>Go to <Link href="/settings/appearance" onClick={e => { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings</Link> tab.</Forms.FormText>
|
||||
<Forms.FormText>Scroll down to "In-app Icons" and click on "Preview App Icon".</Forms.FormText>
|
||||
<Forms.FormText>And upload your own custom icon!</Forms.FormText>
|
||||
<Forms.FormText>You can only use links when you are uploading your Custom Icon.</Forms.FormText>
|
||||
</Forms.FormText></>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -211,6 +211,13 @@ export function getOldestMessage(loggedMessageIds: LoggedMessages) {
|
|||
return oldestMessage ?? null;
|
||||
}
|
||||
|
||||
export function getMessage(channelId: string, messageId: string) {
|
||||
const messags = Object.values(savedLoggedMessages)
|
||||
.filter(m => !Array.isArray(m) && m.message != null) as MessageRecord[];
|
||||
|
||||
return messags.find(m => m.message.channel_id === channelId && m.message.id === messageId);
|
||||
}
|
||||
|
||||
export async function deleteOldestMessageWithoutSaving(loggedMessages: LoggedMessages) {
|
||||
const oldestMessage = getOldestMessage(loggedMessages);
|
||||
if (!oldestMessage || !oldestMessage.message) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import { openUserProfile } from "@utils/discord";
|
|||
import { copyWithToast } from "@utils/misc";
|
||||
import { closeAllModals, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { LazyComponent, useAwaiter } from "@utils/react";
|
||||
import { find, findByCode, findByPropsLazy } from "@webpack";
|
||||
import { find, findByCode, findByCodeLazy } from "@webpack";
|
||||
import { Alerts, Button, ChannelStore, ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React, TabBar, Text, TextInput, useCallback, useMemo, useRef, useState } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
|
@ -61,7 +61,7 @@ export interface ChildrenAccProops {
|
|||
showClydeAiEmbeds: boolean;
|
||||
}
|
||||
|
||||
const ChannelRecords = findByPropsLazy("PrivateChannelRecord");
|
||||
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:"));
|
||||
|
||||
|
@ -448,7 +448,7 @@ function LMessage({ log, isGroupStart, forceUpdate, }: LMessageProps) {
|
|||
childrenAccessories={
|
||||
<ChildrenAccessories
|
||||
channelMessageProps={{
|
||||
channel: ChannelStore.getChannel(message.channel_id) || new ChannelRecords.PrivateChannelRecord({ id: "" }),
|
||||
channel: ChannelStore.getChannel(message.channel_id) || new PrivateChannelRecord({ id: "" }),
|
||||
message,
|
||||
compact: false,
|
||||
groupId: "1",
|
||||
|
|
|
@ -37,7 +37,7 @@ import { openLogModal } from "./components/LogsModal";
|
|||
import { addMessage, loggedMessages, MessageLoggerStore, removeLog } from "./LoggedMessageManager";
|
||||
import * as LoggedMessageManager from "./LoggedMessageManager";
|
||||
import { LoadMessagePayload, LoggedAttachment, LoggedMessage, LoggedMessageJSON, MessageCreatePayload, MessageDeleteBulkPayload, MessageDeletePayload, MessageUpdatePayload } from "./types";
|
||||
import { addToXAndRemoveFromOpposite, cleanUpCachedMessage, cleanupUserObject, doesBlobUrlExist, getNative, isGhostPinged, ListType, mapEditHistory, reAddDeletedMessages, removeFromX } from "./utils";
|
||||
import { addToXAndRemoveFromOpposite, cleanUpCachedMessage, cleanupUserObject, doesBlobUrlExist, getNative, isGhostPinged, ListType, mapEditHistory, messageJsonToMessageClass, reAddDeletedMessages, removeFromX } from "./utils";
|
||||
import { DEFAULT_IMAGE_CACHE_DIR } from "./utils/constants";
|
||||
import { shouldIgnore } from "./utils/index";
|
||||
import { LimitedMap } from "./utils/LimitedMap";
|
||||
|
@ -594,8 +594,8 @@ export default definePlugin({
|
|||
{
|
||||
find: "THREAD_STARTER_MESSAGE?null===",
|
||||
replacement: {
|
||||
match: /(attachments: \i\(.{1,500})deleted:.{1,50},editHistory:.{1,30},/,
|
||||
replace: "$1deleted: $self.getDeleted(...arguments),editHistory: $self.getEdited(...arguments),"
|
||||
match: / deleted:\i\.deleted, editHistory:\i\.editHistory,/,
|
||||
replace: "deleted:$self.getDeleted(...arguments), editHistory:$self.getEdited(...arguments),"
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -637,7 +637,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "Using PollReferenceMessageContext without",
|
||||
replacement: {
|
||||
match: /\i\.(?:default\.)?focusMessage\(/,
|
||||
match: /(?:\i\.)?\i\.(?:default\.)?focusMessage\(/,
|
||||
replace: "!(arguments[0]?.message?.deleted || arguments[0]?.message?.editHistory?.length > 0) && $&"
|
||||
}
|
||||
},
|
||||
|
@ -747,10 +747,23 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
async start() {
|
||||
this.oldGetMessage = MessageStore.getMessage;
|
||||
// we have to do this because the original message logger fetches the message from the store now
|
||||
MessageStore.getMessage = (channelId: string, messageId: string) => {
|
||||
const MLMessage = LoggedMessageManager.getMessage(channelId, messageId);
|
||||
if (MLMessage?.message) return messageJsonToMessageClass(MLMessage);
|
||||
|
||||
return this.oldGetMessage(channelId, messageId);
|
||||
};
|
||||
|
||||
Native.init();
|
||||
|
||||
const { imageCacheDir, logsDir } = await Native.getSettings();
|
||||
settings.store.imageCacheDir = imageCacheDir;
|
||||
settings.store.logsDir = logsDir;
|
||||
},
|
||||
|
||||
stop() {
|
||||
MessageStore.getMessage = this.oldGetMessage;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import { get, set } from "@api/DataStore";
|
||||
import { PluginNative } from "@utils/types";
|
||||
import { findByPropsLazy, findLazy } from "@webpack";
|
||||
import { findByCodeLazy, findLazy } from "@webpack";
|
||||
import { ChannelStore, moment, UserStore } from "@webpack/common";
|
||||
|
||||
import { LOGGED_MESSAGES_KEY, MessageLoggerStore } from "../LoggedMessageManager";
|
||||
|
@ -29,7 +29,7 @@ import { memoize } from "./memoize";
|
|||
|
||||
const MessageClass: any = findLazy(m => m?.prototype?.isEdited);
|
||||
const AuthorClass = findLazy(m => m?.prototype?.getAvatarURL);
|
||||
const embedModule = findByPropsLazy("sanitizeEmbed");
|
||||
const sanitizeEmbed = findByCodeLazy('"embed_"),');
|
||||
|
||||
export function getGuildIdByChannel(channel_id: string) {
|
||||
return ChannelStore.getChannel(channel_id)?.guild_id;
|
||||
|
@ -104,7 +104,7 @@ export const messageJsonToMessageClass = memoize((log: { message: LoggedMessageJ
|
|||
message.author = new AuthorClass(message.author);
|
||||
message.author.nick = message.author.globalName ?? message.author.username;
|
||||
|
||||
message.embeds = message.embeds.map(e => embedModule.sanitizeEmbed(message.channel_id, message.id, e));
|
||||
message.embeds = message.embeds.map(e => sanitizeEmbed(message.channel_id, message.id, e));
|
||||
|
||||
if (message.poll)
|
||||
message.poll.expiry = moment(message.poll.expiry);
|
||||
|
|
Loading…
Reference in a new issue