diff --git a/src/plugins/customFolderIcons/index.tsx b/src/plugins/customFolderIcons/index.tsx index f2d51501a..aacf5d2fb 100644 --- a/src/plugins/customFolderIcons/index.tsx +++ b/src/plugins/customFolderIcons/index.tsx @@ -4,29 +4,26 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import "./style.css"; - import { DataStore } from "@api/index"; import { Devs } from "@utils/constants"; import { closeModal, ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal"; import definePlugin from "@utils/types"; import { Button, Menu, TextInput } from "@webpack/common"; const DATA_STORE_NAME = "CFI_DATA"; -enum ICON_TYPE { - PNG, - SVG -} interface folderIcon{ - type: ICON_TYPE, - url: string + url: string, } -interface config { - [key: string]: folderIcon +interface folderMap { + [key: string]: folderIcon | undefined } -let d: config; +interface folderProp { + folderId: string; + folderColor: number; +} +let d: folderMap; export default definePlugin({ start: async ()=>{ - d = await DataStore.get(DATA_STORE_NAME) || {} as config; + d = await DataStore.get(DATA_STORE_NAME) || {} as folderMap; }, name: "_customFolderIcons", description: "customize folder icons with any png", @@ -37,15 +34,15 @@ export default definePlugin({ { find: ".expandedFolderIconWrapper", replacement: { - match: /(return.{0,80}expandedFolderIconWrapper.*,)\(0,..jsxs\)\(.*]}\)/, - replace: "$1$self.test(e)" + match: /(return.{0,80}expandedFolderIconWrapper.*,)(\(0,..jsxs\)\(.*]}\))/, + replace: "$1$self.shouldReplace(e)?$self.replace(e):$2" } } ], contextMenus: { - "guild-context": (c, a) => { + "guild-context": (c, a: folderProp) => { if(!("folderId" in a)) return; - c.push(makeContextItem(a.folderId)); + c.push(makeContextItem(a)); } }, commands: [ @@ -53,68 +50,52 @@ export default definePlugin({ name: "test", description: "test command for some wack shit", execute: async () => { - console.log("asd"); } } ], - test(e){ - console.log(e); - if(d && e.folderNode.id in d){ - switch(d[e.folderNode.id].type){ - case ICON_TYPE.PNG: - return ( - - ); - case ICON_TYPE.SVG: - return null; - } + shouldReplace(e: any){ + return d && e.folderNode.id in d && d[e.folderNode.id] && d[e.folderNode.id]?.url; + }, + replace(e: any){ + if(d && d[e.folderNode.id]){ + return ( + + ); } - // TODO: when using the default set the color properly - return( -