Refactoring theme files
This commit is contained in:
@@ -15,29 +15,35 @@ function Applications({ contentType }: { contentType: string[] }) {
|
||||
useEffect(() => {
|
||||
if (applicationData && !isApplicationDataFetching) {
|
||||
setApplications(
|
||||
applicationData.sort((a: Application, b: Application) => {
|
||||
switch (appSort) {
|
||||
case 'A>Z':
|
||||
return a.name > b.name ? 1 : -1;
|
||||
case 'Z>A':
|
||||
return a.name < b.name ? 1 : -1;
|
||||
case 'Newest':
|
||||
if (a.id && b.id) {
|
||||
return a.id < b.id ? 1 : -1;
|
||||
}
|
||||
return -1;
|
||||
case 'Oldest':
|
||||
if (a.id && b.id) {
|
||||
return a.id > b.id ? 1 : -1;
|
||||
}
|
||||
return -1;
|
||||
case 'Custom':
|
||||
return a.index > b.index ? 1 : -1;
|
||||
}
|
||||
}),
|
||||
applicationData
|
||||
.sort((a: Application, b: Application) => {
|
||||
switch (appSort) {
|
||||
case 'A>Z':
|
||||
return a.name > b.name ? 1 : -1;
|
||||
case 'Z>A':
|
||||
return a.name < b.name ? 1 : -1;
|
||||
case 'Newest':
|
||||
if (a.id && b.id) {
|
||||
return a.id < b.id ? 1 : -1;
|
||||
}
|
||||
return -1;
|
||||
case 'Oldest':
|
||||
if (a.id && b.id) {
|
||||
return a.id > b.id ? 1 : -1;
|
||||
}
|
||||
return -1;
|
||||
case 'Custom':
|
||||
return a.index > b.index ? 1 : -1;
|
||||
}
|
||||
})
|
||||
?.filter(
|
||||
(application: Application) =>
|
||||
contentType.includes(application.filterName) || contentType.includes('All'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}, [applicationData, isApplicationDataFetching, appSort]);
|
||||
}, [applicationData, isApplicationDataFetching, appSort, contentType]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{applications.length > 0 && contentType.length > 0 && (
|
||||
@@ -60,25 +66,19 @@ function Applications({ contentType }: { contentType: string[] }) {
|
||||
gridTemplateColumns: `repeat(${appDensity}, 1fr)`,
|
||||
}}
|
||||
>
|
||||
{applications
|
||||
?.filter(
|
||||
(application: Application) =>
|
||||
contentType.includes(application.filterName) ||
|
||||
contentType.includes('All'),
|
||||
)
|
||||
.map((application: Application) => {
|
||||
return (
|
||||
<AppItem
|
||||
key={application.name}
|
||||
name={application.name}
|
||||
url={application.url}
|
||||
icon={application.icon}
|
||||
enabled={application.enabled}
|
||||
scale={appScale}
|
||||
linksActive
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{applications.map((application: Application) => {
|
||||
return (
|
||||
<AppItem
|
||||
key={application.name}
|
||||
name={application.name}
|
||||
url={application.url}
|
||||
icon={application.icon}
|
||||
enabled={application.enabled}
|
||||
scale={appScale}
|
||||
linksActive
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Stack>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user