Skip to content

Commit

Permalink
make internal anti-features web based
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Aug 26, 2024
1 parent 9b3e123 commit 385a0f2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 149 deletions.
4 changes: 3 additions & 1 deletion src/activitys/ModuleViewActivity/tabs/OverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import { useCategories } from "@Hooks/useCategories";
import { useFormatDate } from "@Hooks/useFormatDate";
import { ModuleViewActivity } from "..";
import { useRepos } from "@Hooks/useRepos";
import { blacklistedModules } from "@Util/blacklisted-modules";
import { useModuleInfo } from "@Hooks/useModuleInfo";
import { Build } from "@Native/Build";
import { os } from "@Native/Os";
import { useFetch } from "@Hooks/useFetch";
import { useBlacklist } from "@Hooks/useBlacklist";

const colorHandler = (color?: ModuleNoteColors) => {
switch (color) {
Expand Down Expand Up @@ -69,6 +69,8 @@ const OverviewTab = () => {
const latestVersion = React.useMemo(() => versions[versions.length - 1], [versions]);
const formatLastUpdate = useFormatDate(latestVersion.timestamp);


const blacklistedModules = useBlacklist();
const findHardCodedAntifeature = React.useMemo<Track["antifeatures"]>(() => {
return [...(track.antifeatures || []), ...(blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [])];
}, [id, track.antifeatures]);
Expand Down
24 changes: 22 additions & 2 deletions src/activitys/ViewBlacklistedModulesActivity.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { ProgressCircular } from "react-onsenui";
import AntiFeatureListItem from "@Components/AntiFeatureListItem";
import { Anchor } from "@Components/dapi/Anchor";
import { Page } from "@Components/onsenui/Page";
import { Toolbar } from "@Components/onsenui/Toolbar";
import { useActivity } from "@Hooks/useActivity";
import { useBlacklist } from "@Hooks/useBlacklist";
import { useStrings } from "@Hooks/useStrings";
import { BlacklistedModule, blacklistedModules } from "@Util/blacklisted-modules";
import { ExpandLess, ExpandMore } from "@mui/icons-material";
import { Card, CardContent, Collapse, List, ListItem, ListItemIcon, ListItemText, Typography } from "@mui/material";
import FlatList from "flatlist-react";
import React from "react";

interface BlacklistItemProps {
module: BlacklistedModule;
module: any;
}

function BlacklistItem({ module }: BlacklistItemProps) {
Expand Down Expand Up @@ -59,6 +60,8 @@ function ViewBlacklistedModulesActivity() {
const { context } = useActivity();
const { strings } = useStrings();

const blacklistedModules = useBlacklist();

const renderToolbar = () => {
return (
<Toolbar modifier="noshadow">
Expand All @@ -70,6 +73,23 @@ function ViewBlacklistedModulesActivity() {
);
};

if (blacklistedModules.length === 0) {
return (
<Page renderToolbar={renderToolbar}>
<ProgressCircular
indeterminate
style={{
position: "absolute",
left: "50%",
top: "50%",
WebkitTransform: "translate(-50%, -50%)",
transform: "translate(-50%, -50%)",
}}
/>
</Page>
);
}

return (
<Page renderToolbar={renderToolbar}>
<Page.RelativeContent zeroMargin>
Expand Down
4 changes: 2 additions & 2 deletions src/components/module/DeviceModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +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";
import Box from "@mui/material/Box";
import { useBlacklist } from "@Hooks/useBlacklist";

interface Props {
module: Module;
Expand Down Expand Up @@ -62,6 +61,7 @@ const DeviceModule = React.memo<Props>((props) => {
const boot_complete = SuFile.exist(format("BOOTCOMP"));
const module_config_file = SuFile.exist(format("CONFINDEX"));

const blacklistedModules = useBlacklist();
const findHardCodedAntifeature = React.useMemo<Track["antifeatures"]>(() => {
return blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [];
}, [id]);
Expand Down
100 changes: 2 additions & 98 deletions src/components/module/ExploreModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useActivity } from "@Hooks/useActivity";
import { useFormatDate } from "@Hooks/useFormatDate";
import { useStrings } from "@Hooks/useStrings";
import { useTheme } from "@Hooks/useTheme";
import { blacklistedModules } from "@Util/blacklisted-modules";
import Card from "@mui/material/Card";
import Chip from "@mui/material/Chip";
import Divider from "@mui/material/Divider";
Expand All @@ -19,6 +18,7 @@ import { SuFile } from "@Native/SuFile";
import { useModFS } from "@Hooks/useModFS";
import { useModuleInfo } from "@Hooks/useModuleInfo";
import { Verified, Tag, PersonOutline, CalendarMonth } from "@mui/icons-material";
import { useBlacklist } from "@Hooks/useBlacklist";

interface Props {
module: Module;
Expand All @@ -30,11 +30,11 @@ const ExploreModule = React.memo<Props>((props) => {

const { context } = useActivity();
const { strings } = useStrings();
const { theme } = useTheme();
const { modFS } = useModFS();

const formatLastUpdate = useFormatDate(timestamp ? timestamp : versions[versions.length - 1].timestamp);

const blacklistedModules = useBlacklist();
const findHardCodedAntifeature = React.useMemo<Track["antifeatures"]>(() => {
return [...(track.antifeatures || []), ...(blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [])];
}, [id, track.antifeatures]);
Expand Down Expand Up @@ -121,100 +121,4 @@ const ExploreModule = React.memo<Props>((props) => {
);
});

const ExploreModule_ = React.memo<Props>((props) => {
const { id, name, author, description, track, timestamp, version, versions, versionCode } = props.module;
const { cover, verified } = useModuleInfo(props.module);

const { context } = useActivity();
const { strings } = useStrings();
const { theme } = useTheme();
const { modFS } = useModFS();

const formatLastUpdate = useFormatDate(timestamp ? timestamp : versions[versions.length - 1].timestamp);

const findHardCodedAntifeature = React.useMemo<Track["antifeatures"]>(() => {
return [...(track.antifeatures || []), ...(blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [])];
}, [id, track.antifeatures]);

const handleOpenModule = () => {
context.pushPage({
component: ModuleViewActivity,
key: "ModuleViewActivity",
extra: props.module,
});
};

return (
<Card
onTap={handleOpenModule}
component={GestureDetector}
onClick={(e) => e.stopPropagation()}
sx={{
p: 2,
":hover": {
opacity: ".8",
cursor: "pointer",
},
width: "100%",
}}
>
<Stack direction="column" justifyContent="center" spacing={1}>
{cover && (
<Image
sx={{
height: "100%",
objectFit: "cover",
width: "100%",
}}
src={cover}
alt={name}
noOpen
/>
)}

<Stack direction="column" justifyContent="center" alignItems="flex-start">
<Stack direction="row" justifyContent="flex-start" alignItems="center" spacing={0.5}>
<Typography variant="h6">{name}</Typography>
<VerifiedIcon isVerified={verified} />
</Stack>

<Typography color="text.secondary" variant="caption">
{version} ({versionCode}) / {author}
</Typography>
</Stack>
<Typography color="text.secondary" variant="body2" display="block">
{description}
</Typography>
<Stack direction="column" justifyContent="center" spacing={1.2}>
<Divider variant="middle" />
<Stack direction="row" justifyContent="space-between" alignItems="center" spacing={1}>
<Stack direction="row" justifyContent="flex-start" alignItems="center" spacing={1}>
<Chip
sx={{
color: theme.palette.text.secondary,
backgroundColor: theme.palette.secondary.dark,
}}
label={formatLastUpdate + " 3 features"}
/>

{SuFile.exist(modFS("PROPS", { MODID: id })) && (
<Chip
sx={{
background: `linear-gradient(333deg, ${theme.palette.secondary.dark} 0%, ${theme.palette.secondary.dark} 83%) padding-box,linear-gradient(22deg, rgba(188,2,194,0.4) 0%, rgba(74,20,140,0.4) 100%) border-box`,
color: theme.palette.text.secondary,
border: "1px solid transparent",
}}
label={strings("installed")}
/>
)}
</Stack>

<Stack direction="row" justifyContent="flex-end" alignItems="center" spacing={1}></Stack>
</Stack>
</Stack>
</Stack>
</Card>
);
});

export default ExploreModule;
15 changes: 15 additions & 0 deletions src/hooks/useBlacklist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SuFile } from "@Native/SuFile";
import { useFetch } from "./useFetch";

interface BlacklistedModule {
id: string;
source: string;
hidden: boolean;
notes: string;
antifeatures: Track["antifeatures"];
}

export const useBlacklist = () => {
const [bl] = useFetch<BlacklistedModule[]>("https://gr.dergoogler.com/gmr/json/blacklist.json", { type: "json" });
return bl ? bl : [];
};
46 changes: 0 additions & 46 deletions src/util/blacklisted-modules.ts

This file was deleted.

0 comments on commit 385a0f2

Please sign in to comment.