Skip to content

Commit

Permalink
better handle readme's
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Jun 26, 2024
1 parent f64a2ef commit f2ebc24
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
17 changes: 10 additions & 7 deletions Website/src/activitys/ModuleViewActivity/tabs/OverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@ const OverviewTab = () => {
const { settings } = useSettings();
const { modules } = useRepos();
const { id, name, description, versions } = extra;
const { antifeatures, screenshots, require, readme: __readme, categories, icon } = extra;
const { screenshots, require, readme: __readme, categories, icon, track } = extra;

// handle when the dev does not define a readme
const moduleReadme = __readme || track.readme;

const { filteredCategories } = useCategories(categories);
const isLowQuality = useLowQualityModule(extra, !settings._low_quality_module);
const latestVersion = React.useMemo(() => versions[versions.length - 1], [versions]);
const formatLastUpdate = useFormatDate(latestVersion.timestamp);
const [readme, setReadme] = React.useState<string | undefined>(undefined);

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

React.useEffect(() => {
if (__readme) {
fetch(__readme)
if (moduleReadme) {
fetch(moduleReadme)
.then((res) => {
if (res.status === 200) {
return res.text();
Expand All @@ -61,7 +64,7 @@ const OverviewTab = () => {
})
.then((text) => setReadme(text));
}
}, [__readme]);
}, [moduleReadme]);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion Website/src/components/AntifeaturesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GestureDetector } from "./onsenui/GestureDetector";

type Props = {
sx?: SxProps;
antifeatures?: Module["antifeatures"];
antifeatures?: Track["antifeatures"];
};

export const AntifeatureButton = (props: Props) => {
Expand Down
2 changes: 1 addition & 1 deletion Website/src/components/module/DeviceModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const DeviceModule = React.memo<Props>((props) => {
const boot_complete = SuFile.exist(format("BOOTCOMP"));
const module_config_file = SuFile.exist(format("CONFINDEX"));

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

Expand Down
8 changes: 4 additions & 4 deletions Website/src/components/module/ExploreModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Props {

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

const { context } = useActivity();
const { strings } = useStrings();
Expand All @@ -33,9 +33,9 @@ const ExploreModule = React.memo<Props>((props) => {

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

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

const handleOpenModule = () => {
context.pushPage({
Expand Down
3 changes: 2 additions & 1 deletion Website/src/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ declare global {
categories?: string[];
stars?: number;
readme?: string;
antifeatures?: string | string[];
verified: boolean;

/**
Expand All @@ -183,6 +182,8 @@ declare global {
type: string;
added: number;
source: string;
readme?: string;
antifeatures?: string | string[];
}

export interface Version {
Expand Down
2 changes: 1 addition & 1 deletion Website/src/util/blacklisted-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface BlacklistedModule {
source: string;
hidden: boolean;
notes: string;
antifeatures: Module["antifeatures"];
antifeatures: Track["antifeatures"];
}

export const blacklistedModules: BlacklistedModule[] = [
Expand Down

0 comments on commit f2ebc24

Please sign in to comment.