Skip to content

Commit

Permalink
add support for new repo format
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Jun 22, 2024
1 parent 60e4ace commit d84bd96
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 64 deletions.
23 changes: 12 additions & 11 deletions Website/src/activitys/ModuleViewActivity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const ModuleViewActivity = () => {
const { context, extra } = useActivity<Module>();

const { id, name, version, versionCode, author, versions, track } = extra;
const { cover, icon, verified, donate, support } = extra;
const latestVersion = React.useMemo(() => versions[versions.length - 1], [versions]);

const search = React.useMemo(() => new URLSearchParams(window.location.search), [window.location.search]);
Expand All @@ -83,7 +84,7 @@ const ModuleViewActivity = () => {
<Toolbar
modifier="noshadow"
sx={{
...(track.cover
...(cover
? {
// invert
backgroundColor: !isNameVisible ? "transparent" : theme.palette.background.default,
Expand Down Expand Up @@ -135,10 +136,10 @@ const ModuleViewActivity = () => {
modifier="noshadow"
renderToolbar={renderToolbar}
backgroundStyle={{
...(track.cover ? { top: `0px !important` } : {}),
...(cover ? { top: `0px !important` } : {}),
}}
sx={{
...(track.cover ? { top: `0px !important` } : {}),
...(cover ? { top: `0px !important` } : {}),
}}
>
<Box
Expand All @@ -151,7 +152,7 @@ const ModuleViewActivity = () => {
color: "white",
}}
>
{track.cover && (
{cover && (
<Box
sx={(theme) => ({
background: `linear-gradient(to top,${
Expand All @@ -172,7 +173,7 @@ const ModuleViewActivity = () => {
},
objectFit: "cover",
}}
image={track.cover}
image={cover}
alt={name}
/>
<SvgIcon sx={{ display: "none" }}>
Expand All @@ -191,7 +192,7 @@ const ModuleViewActivity = () => {

<Box
sx={(theme) => ({
pt: track.cover ? 0 : 2,
pt: cover ? 0 : 2,
pl: 2,
pr: 2,
pb: 2,
Expand Down Expand Up @@ -219,7 +220,7 @@ const ModuleViewActivity = () => {
mr: 1.5,
fontSize: 50,
})}
src={track.icon}
src={icon}
>
{name.charAt(0).toUpperCase()}
</Avatar>
Expand All @@ -229,7 +230,7 @@ const ModuleViewActivity = () => {
<Disappear as={Typography} variant="body1" fontWeight="bold" onDisappear={(visible) => setIsNameVisible(!visible)}>
{name}
</Disappear>
<VerifiedIcon isVerified={track.verified} />
<VerifiedIcon isVerified={verified} />
</Stack>
<Typography
variant="body2"
Expand Down Expand Up @@ -298,14 +299,14 @@ const ModuleViewActivity = () => {
code
</Typography>
</Stack>
{track.donate && (
{donate && (
<Stack
direction="column"
justifyContent="center"
alignItems="stretch"
spacing={0}
onClick={() => {
os.open(track.donate, {
os.open(donate, {
target: "_blank",
features: {
color: theme.palette.primary.main,
Expand Down Expand Up @@ -361,7 +362,7 @@ const ModuleViewActivity = () => {
component: InstallTerminalV2Activity,
key: "InstallTerminalV2Activity",
extra: {
issues: track.support,
issues: support,
source: track.source,
id: id,
exploreInstall: true,
Expand Down
18 changes: 9 additions & 9 deletions Website/src/activitys/ModuleViewActivity/tabs/AboutTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ const AboutTab = () => {
const { context, extra } = useActivity<Module>();
const { theme } = useTheme();

const { id, name, version, versionCode, description, author, versions, track } = extra;
const { license, verified, support, track } = extra;

return (
<List>
{track.verified && (
{verified && (
<ListItem>
<ListItemIcon>
<VerifiedIcon />
Expand All @@ -32,10 +32,10 @@ const AboutTab = () => {
</ListItem>
)}

{track.license && (
{license && (
<ListItemButton
onClick={() => {
fetch(`https://raw.githubusercontent.com/spdx/license-list-data/main/website/${track.license}.json`)
fetch(`https://raw.githubusercontent.com/spdx/license-list-data/main/website/${license}.json`)
.then((res) => {
if (res.status === 200) {
return res.json();
Expand All @@ -46,7 +46,7 @@ const AboutTab = () => {
.then((json: LicenseSPX) => {
context.pushPage({
component: FetchTextActivity,
key: "license_" + track.license,
key: "license_" + license,
extra: {
raw_data: json.licenseText,
modulename: json.name,
Expand All @@ -59,14 +59,14 @@ const AboutTab = () => {
<ListItemIcon>
<FormatAlignLeftIcon />
</ListItemIcon>
<ListItemText primary={strings("license")} secondary={track.license} />
<ListItemText primary={strings("license")} secondary={license} />
</ListItemButton>
)}

{track.support && (
{support && (
<ListItemButton
onClick={() => {
os.open(track.support, {
os.open(support, {
target: "_blank",
features: {
color: theme.palette.primary.main,
Expand All @@ -77,7 +77,7 @@ const AboutTab = () => {
<ListItemIcon>
<BugReportIcon />
</ListItemIcon>
<ListItemText primary="Issues" secondary={track.support} />
<ListItemText primary="Issues" secondary={support} />
</ListItemButton>
)}

Expand Down
27 changes: 14 additions & 13 deletions Website/src/activitys/ModuleViewActivity/tabs/OverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ const OverviewTab = () => {
const { context, extra } = useActivity<Module>();
const { settings } = useSettings();
const { modules } = useRepos();
const { id, name, version, versionCode, description, author, versions, track } = extra;
const { id, name, description, versions } = extra;
const { antifeatures, screenshots, require, readme: __readme, categories, icon } = extra;

const { filteredCategories } = useCategories(track.categories);
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<Track["antifeatures"]>(() => {
return [...(track.antifeatures || []), ...(blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [])];
}, [id, track.antifeatures]);
const findHardCodedAntifeature = React.useMemo<Module["antifeatures"]>(() => {
return [...(antifeatures || []), ...(blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [])];
}, [id, antifeatures]);

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

return (
<>
Expand Down Expand Up @@ -100,7 +101,7 @@ const OverviewTab = () => {
extra: {
desc: readme,
name: name,
logo: track.icon,
logo: icon,
},
});
}}
Expand Down Expand Up @@ -169,7 +170,7 @@ const OverviewTab = () => {
</Card>
)}

{track.require && track.require.length !== 0 && (
{require && require.length !== 0 && (
<Card
sx={{
width: "100%",
Expand All @@ -191,7 +192,7 @@ const OverviewTab = () => {
}}
>
<List disablePadding sx={{ width: { xs: "100%" } }}>
{track.require.map((req) => {
{require.map((req) => {
const findRequire = React.useMemo(() => modules.find((module) => module.id === req), [modules]);

if (findRequire) {
Expand Down Expand Up @@ -221,7 +222,7 @@ const OverviewTab = () => {
</Card>
)}

{track.screenshots && track.screenshots.length !== 0 && (
{screenshots && screenshots.length !== 0 && (
<Card sx={{ width: "100%" }}>
<CardContent>
<Typography variant="h5" component="div">
Expand All @@ -241,7 +242,7 @@ const OverviewTab = () => {
gridAutoColumns: "minmax(250px, 1fr)",
}}
>
{track.screenshots.map((image, i) => (
{screenshots.map((image, i) => (
<ImageListItem
sx={(theme) => ({
ml: 1,
Expand Down
4 changes: 2 additions & 2 deletions Website/src/activitys/ModuleViewActivity/tabs/VersionsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const VersionItem = React.memo<VersionItemProps>(({ id, version, index }) => {
const { strings } = useStrings();
const { theme } = useTheme();

const { track } = extra;
const { track, support } = extra;

const versionName = `${version.version} (${version.versionCode})`;

Expand All @@ -59,7 +59,7 @@ const VersionItem = React.memo<VersionItemProps>(({ id, version, index }) => {
component: InstallTerminalV2Activity,
key: "InstallTerminalV2Activity",
extra: {
issues: track.support,
issues: support,
source: track.source,
id: id,
exploreInstall: true,
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?: Track["antifeatures"];
antifeatures?: Module["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<Track["antifeatures"]>(() => {
const findHardCodedAntifeature = React.useMemo<Module["antifeatures"]>(() => {
return blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [];
}, [id]);

Expand Down
13 changes: 7 additions & 6 deletions Website/src/components/module/ExploreModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +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 { context } = useActivity();
const { strings } = useStrings();
Expand All @@ -32,9 +33,9 @@ const ExploreModule = React.memo<Props>((props) => {

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 findHardCodedAntifeature = React.useMemo<Module["antifeatures"]>(() => {
return [...(antifeatures || []), ...(blacklistedModules.find((mod) => mod.id === id)?.antifeatures || [])];
}, [id, antifeatures]);

const handleOpenModule = () => {
context.pushPage({
Expand All @@ -58,14 +59,14 @@ const ExploreModule = React.memo<Props>((props) => {
}}
>
<Stack direction="column" justifyContent="center" spacing={1}>
{track.cover && (
{cover && (
<Image
sx={{
height: "100%",
objectFit: "cover",
width: "100%",
}}
src={track.cover}
src={cover}
alt={name}
noOpen
/>
Expand All @@ -74,7 +75,7 @@ const ExploreModule = React.memo<Props>((props) => {
<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={track.verified} />
<VerifiedIcon isVerified={verified} />
</Stack>

<Typography color="text.secondary" variant="caption">
Expand Down
4 changes: 2 additions & 2 deletions Website/src/hooks/useOpenModuleSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function useOpenModuleSearch<L extends Module[]>(list: L) {
borderRadius: "20%",
mr: 1.5,
})}
src={item.track.icon}
src={item.icon}
>
{item.name.charAt(0).toUpperCase()}
</Avatar>
Expand All @@ -60,7 +60,7 @@ export function useOpenModuleSearch<L extends Module[]>(list: L) {
<Stack direction="row" justifyContent="flex-start" alignItems="center" spacing={0.5}>
<Typography>{item.name}</Typography>

<VerifiedIcon isVerified={item.track.verified} />
<VerifiedIcon isVerified={item.verified} />
</Stack>
}
secondary={
Expand Down
Loading

0 comments on commit d84bd96

Please sign in to comment.