diff --git a/backend/models/jf_library_items.js b/backend/models/jf_library_items.js
index c19a1cf..16db1b1 100644
--- a/backend/models/jf_library_items.js
+++ b/backend/models/jf_library_items.js
@@ -50,7 +50,7 @@ const jf_library_items_mapping = (item) => ({
? item.ImageBlurHashes.Primary[item.ImageTags["Primary"]]
: null,
archived: false,
- Genres: item.Genres && Array.isArray(item.Genres) ? JSON.stringify(filterInvalidGenres(item.Genres.map(titleCase))) : [],
+ Genres: item.Genres && Array.isArray(item.Genres) ? JSON.stringify(item.Genres.map(titleCase)) : [],
});
// Utility function to title-case a string
@@ -62,53 +62,6 @@ function titleCase(str) {
.join(" ");
}
-function filterInvalidGenres(genres) {
- const validGenres = [
- "Action",
- "Adventure",
- "Animated",
- "Biography",
- "Comedy",
- "Crime",
- "Dance",
- "Disaster",
- "Documentary",
- "Drama",
- "Erotic",
- "Family",
- "Fantasy",
- "Found Footage",
- "Historical",
- "Horror",
- "Independent",
- "Legal",
- "Live Action",
- "Martial Arts",
- "Musical",
- "Mystery",
- "Noir",
- "Performance",
- "Political",
- "Romance",
- "Satire",
- "Science Fiction",
- "Short",
- "Silent",
- "Slasher",
- "Sports",
- "Spy",
- "Superhero",
- "Supernatural",
- "Suspense",
- "Teen",
- "Thriller",
- "War",
- "Western",
- ];
-
- return genres.filter((genre) => validGenres.map((g) => g.toLowerCase()).includes(genre.toLowerCase()));
-}
-
module.exports = {
jf_library_items_columns,
jf_library_items_mapping,
diff --git a/src/pages/components/library/library-items.jsx b/src/pages/components/library/library-items.jsx
index 04e420b..3a45cce 100644
--- a/src/pages/components/library/library-items.jsx
+++ b/src/pages/components/library/library-items.jsx
@@ -23,8 +23,6 @@ function LibraryItems(props) {
localStorage.getItem("PREF_sortAsc") != undefined ? localStorage.getItem("PREF_sortAsc") == "true" : true
);
- console.log(sortOrder);
-
const archive = {
all: "all",
archived: "true",
@@ -212,7 +210,11 @@ function LibraryItems(props) {
}
})
.map((item) => (
-
+
))}
diff --git a/src/pages/components/statCards/genre-stat-card.jsx b/src/pages/components/statCards/genre-stat-card.jsx
index c1d96a4..df213e2 100644
--- a/src/pages/components/statCards/genre-stat-card.jsx
+++ b/src/pages/components/statCards/genre-stat-card.jsx
@@ -10,12 +10,26 @@ import i18next from "i18next";
function GenreStatCard(props) {
const [maxRange, setMaxRange] = useState(100);
+ const [data, setData] = useState(props.data);
useEffect(() => {
const maxDuration = props.data.reduce((max, item) => {
return Math.max(max, parseFloat((props.dataKey == "duration" ? item.duration : item.plays) || 0));
}, 0);
setMaxRange(maxDuration);
+
+ let sorted = [...props.data]
+ .sort((a, b) => {
+ const valueA = parseFloat(props.dataKey === "duration" ? a.duration : a.plays) || 0;
+ const valueB = parseFloat(props.dataKey === "duration" ? b.duration : b.plays) || 0;
+ return valueB - valueA; // Descending order
+ })
+ .slice(0, 15); // Take only the top 10
+
+ // Sort top 10 genres alphabetically
+ sorted = sorted.sort((a, b) => a.genre.localeCompare(b.genre));
+
+ setData(sorted);
}, [props.data, props.dataKey]);
const CustomTooltip = ({ active, payload }) => {
@@ -67,7 +81,7 @@ function GenreStatCard(props) {
-
+