Refactoring theme files

This commit is contained in:
Sean Edmunds
2025-07-28 19:57:06 -05:00
parent 8fcf9a19f2
commit b4e4f14310
33 changed files with 211 additions and 288 deletions

View File

@@ -28,29 +28,34 @@ function Bookmarks({ contentType }: { contentType: string[] }) {
return category;
});
setGroups(
groupList.sort((a: BookmarkGroup, b: BookmarkGroup) => {
switch (bookmarkSort) {
case 'A>Z':
return a.categoryName > b.categoryName ? 1 : -1;
case 'Z>A':
return a.categoryName < b.categoryName ? 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.categoryIndex > b.categoryIndex ? 1 : -1;
}
}),
groupList
.sort((a: BookmarkGroup, b: BookmarkGroup) => {
switch (bookmarkSort) {
case 'A>Z':
return a.categoryName > b.categoryName ? 1 : -1;
case 'Z>A':
return a.categoryName < b.categoryName ? 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.categoryIndex > b.categoryIndex ? 1 : -1;
}
})
?.filter(
(category: BookmarkGroup) =>
contentType.includes(category.filterName) || contentType.includes('All'),
),
);
}
}, [groupData, groupsIsFetched, bookmarkSort]);
}, [groupData, groupsIsFetched, bookmarkSort, contentType]);
return (
<>
@@ -79,26 +84,18 @@ function Bookmarks({ contentType }: { contentType: string[] }) {
gridTemplateColumns: `repeat(${bookmarkDensity}, 1fr)`,
}}
>
{groups
?.filter(
(category: BookmarkGroup) =>
contentType.includes(category.filterName) ||
contentType.includes('All'),
)
.map((category: BookmarkGroup) => {
return (
<BookmarkGroups
key={category.categoryName}
category={category.categoryName}
bookmarks={bookmarks.filter(
(bookmark: Bookmark) =>
bookmark.category === category.categoryName,
)}
bookmarkScale={bookmarkScale}
/>
);
})}
{groups.map((category: BookmarkGroup) => {
return (
<BookmarkGroups
key={category.categoryName}
category={category.categoryName}
bookmarks={bookmarks.filter(
(bookmark: Bookmark) => bookmark.category === category.categoryName,
)}
bookmarkScale={bookmarkScale}
/>
);
})}
</Stack>
</Stack>
)}