From 223a87c7cc8f42a394f7e09111a1ba7bac13fe3f Mon Sep 17 00:00:00 2001 From: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Date: Wed, 15 May 2024 22:37:53 +0200 Subject: [PATCH] antifeatures --- .../src/components/AntiFeatureListItem.tsx | 17 +-- Website/src/components/AntifeaturesButton.tsx | 48 +++++++ .../src/components/module/DeviceModule.tsx | 11 ++ .../src/components/module/ExploreModule.tsx | 119 ++++++++++-------- Website/src/locales/antifeatures/en.ts | 57 +++++++++ Website/src/typings/global.d.ts | 2 +- Website/src/util/blacklisted-modules.ts | 6 + 7 files changed, 196 insertions(+), 64 deletions(-) create mode 100644 Website/src/components/AntifeaturesButton.tsx create mode 100644 Website/src/locales/antifeatures/en.ts create mode 100644 Website/src/util/blacklisted-modules.ts diff --git a/Website/src/components/AntiFeatureListItem.tsx b/Website/src/components/AntiFeatureListItem.tsx index b48885a3..b6f7da8e 100644 --- a/Website/src/components/AntiFeatureListItem.tsx +++ b/Website/src/components/AntiFeatureListItem.tsx @@ -1,26 +1,21 @@ import { useStrings } from "@Hooks/useStrings"; -import Avatar from "@mui/material/Avatar"; -import Card from "@mui/material/Card"; -import CardContent from "@mui/material/CardContent"; import ListItem from "@mui/material/ListItem"; -import ListItemAvatar from "@mui/material/ListItemAvatar"; -import ListItemText from "@mui/material/ListItemText"; -import Stack from "@mui/material/Stack"; -import Typography from "@mui/material/Typography"; -import ImageIcon from "@mui/icons-material/Image"; +import { en_antifeatures } from "./../locales/antifeatures/en"; import React from "react"; +import { ListItemText } from "@mui/material"; interface AntiFeatureListItemProps { type: string; } const AntiFeatureListItem = (props: AntiFeatureListItemProps) => { - const { strings } = useStrings(); + const find = React.useMemo(() => en_antifeatures.find((anti) => anti.id === props.type), []); + + if (!find) return null; return ( - {/* @ts-ignore */} - + ); }; diff --git a/Website/src/components/AntifeaturesButton.tsx b/Website/src/components/AntifeaturesButton.tsx new file mode 100644 index 00000000..66f4c5a6 --- /dev/null +++ b/Website/src/components/AntifeaturesButton.tsx @@ -0,0 +1,48 @@ +import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, List, SxProps } from "@mui/material"; +import Button from "@mui/material/Button"; +import WarningAmberIcon from "@mui/icons-material/WarningAmber"; +import React from "react"; +import { useStrings } from "@Hooks/useStrings"; +import AntiFeatureListItem from "./AntiFeatureListItem"; + +type Props = { + sx?: SxProps; + antifeatures?: Track["antifeatures"]; +}; + +export const AntifeatureButton = (props: Props) => { + const [open, setOpen] = React.useState(false); + + const { strings } = useStrings(); + + const handleClickOpen = () => { + setOpen(true); + }; + + const handleClose = () => { + setOpen(false); + }; + + return ( + <> + + + {strings("antifeatures")} + + + {typeof props.antifeatures === "string" ? ( + + ) : ( + Array.isArray(props.antifeatures) && props.antifeatures.map((anti) => ) + )} + + + + + + + + ); +}; diff --git a/Website/src/components/module/DeviceModule.tsx b/Website/src/components/module/DeviceModule.tsx index 7d086ec3..78d88ee2 100644 --- a/Website/src/components/module/DeviceModule.tsx +++ b/Website/src/components/module/DeviceModule.tsx @@ -23,6 +23,8 @@ import { SuFile } from "@Native/SuFile"; import { useConfirm } from "material-ui-confirm"; import Switch from "@mui/material/Switch"; import { Image } from "@Components/dapi/Image"; +import { blacklistedModules } from "@Util/blacklisted-modules"; +import { AntifeatureButton } from "@Components/AntifeaturesButton"; interface Props { module: Module; @@ -59,6 +61,10 @@ const DeviceModule = React.memo((props) => { const boot_complete = SuFile.exist(format("BOOTCOMP")); const module_config_file = SuFile.exist(format("CONFINDEX")); + const findHardCodedAntifeature = React.useMemo(() => { + return blacklistedModules[id]?.antifeatures || []; + }, [id]); + return ( @@ -167,6 +173,11 @@ const DeviceModule = React.memo((props) => { + {findHardCodedAntifeature && findHardCodedAntifeature.length !== 0 && ( + + + + )}