Skip to content

Commit 8c7424c

Browse files
authored
Merge pull request #52 from PixyTM/dev
Added an option to remove the libraries section from the home screen
2 parents 68b5d2a + 1485c9a commit 8c7424c

File tree

4 files changed

+69
-55
lines changed

4 files changed

+69
-55
lines changed

frontend/src/pages/Home.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ export default function Home() {
126126
width: "100%",
127127
height: "auto",
128128
aspectRatio: "16/9",
129-
display: "flex",
129+
display:
130+
settings["DISABLE_HOME_SCREEN_LIBRARIES"] === "true"
131+
? "none"
132+
: "flex",
130133
alignItems: "center",
131134
justifyContent: "center",
132135
borderRadius: "7px",

frontend/src/pages/Settings.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function Settings() {
5353
>
5454
<SettingsDivider title="General" />
5555
<SettingsItem title="About" link="/settings/info" />
56-
5756
<SettingsDivider title="Experience" />
5857
<SettingsItem title="Playback" link="/settings/experience-playback" />
5958
<SettingsItem title="Recommendations" link="/settings/experience-recommendations" />
Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,36 @@
1-
import { Typography, Box } from "@mui/material";
1+
import { Typography, Box, Divider, CircularProgress } from "@mui/material";
22
import React, { useEffect } from "react";
3-
import {
4-
getAllLibraries
5-
} from "../../plex";
3+
import { getAllLibraries } from "../../plex";
64
import CheckBoxOption from "../../components/settings/CheckBoxOption";
75
import { useUserSettings } from "../../states/UserSettingsState";
86

9-
107
function SettingsLibraries() {
11-
const [libraries, setLibraries] = React.useState<Plex.LibarySection[]>([]);
12-
const [loading, setLoading] = React.useState(true);
13-
const { settings, setSetting } = useUserSettings();
8+
const [libraries, setLibraries] = React.useState<Plex.LibarySection[]>([]);
9+
const [loading, setLoading] = React.useState(true);
10+
const { settings, setSetting } = useUserSettings();
1411

15-
useEffect(() => {
16-
async function fetchData() {
17-
setLoading(true);
18-
try {
19-
const librariesData = await getAllLibraries();
20-
21-
22-
const filteredLibraries = librariesData.filter((lib) =>
23-
["movie", "show"].includes(lib.type)
24-
);
12+
useEffect(() => {
13+
async function fetchData() {
14+
setLoading(true);
15+
try {
16+
const librariesData = await getAllLibraries();
17+
18+
const filteredLibraries = librariesData.filter((lib) =>
19+
["movie", "show"].includes(lib.type)
20+
);
2521

26-
setLibraries(filteredLibraries);
22+
setLibraries(filteredLibraries);
2723

28-
console.log("filteredLibraries", filteredLibraries)
29-
30-
} catch (error) {
31-
console.error("Error fetching data", error);
32-
} finally {
33-
setLoading(false);
34-
}
35-
}
36-
37-
fetchData();
38-
}, []);
24+
console.log("filteredLibraries", filteredLibraries);
25+
} catch (error) {
26+
console.error("Error fetching data", error);
27+
} finally {
28+
setLoading(false);
29+
}
30+
}
31+
32+
fetchData();
33+
}, []);
3934

4035
return (
4136
<>
@@ -51,35 +46,50 @@ function SettingsLibraries() {
5146
}}
5247
/>
5348

54-
<Box sx={{ mt: 2, display: "flex", flexDirection: "column", gap: 2 }}>
55-
56-
<Typography variant="subtitle1">
57-
Enable or disable libraries to show throughout Nevu. <br />
58-
Disabled libraries will not be shown in the home page, recommendations, search results, or any other place.
59-
</Typography>
49+
<Box sx={{ mt: 2, display: "flex", flexDirection: "column", gap: 2, width: "100%" }}>
50+
<CheckBoxOption
51+
title="Disable Home Libraries Section"
52+
subtitle="Disables the section on the home screen where the libraries are displayed."
53+
checked={settings.DISABLE_HOME_SCREEN_LIBRARIES === "true"}
54+
onChange={() => {
55+
setSetting(
56+
"DISABLE_HOME_SCREEN_LIBRARIES",
57+
settings["DISABLE_HOME_SCREEN_LIBRARIES"] === "true"
58+
? "false"
59+
: "true"
60+
);
61+
}}
62+
/>
6063

61-
{libraries.map((library) => {
62-
const key = `LIBRARY_${library.uuid}`;
63-
const rawValue = settings[key];
64+
<Divider sx={{ my: 2 }} />
6465

65-
const checked = rawValue === undefined ? true : rawValue === "true";
66+
{loading && (
67+
<CircularProgress
68+
sx={{ alignSelf: "center", mt: 2 }}
69+
size={24}
70+
/>
71+
)}
6672

67-
return (
68-
<CheckBoxOption
69-
key={library.key}
70-
title={library.title}
71-
subtitle={`Type: ${library.type.toUpperCase()}`}
72-
checked={checked}
73-
onChange={() => {
74-
setSetting(key, checked ? "false" : "true");
75-
}}
76-
/>
77-
);
78-
})}
73+
{libraries.map((library) => {
74+
const key = `LIBRARY_${library.uuid}`;
75+
const rawValue = settings[key];
7976

77+
const checked = rawValue === undefined ? true : rawValue === "true";
8078

79+
return (
80+
<CheckBoxOption
81+
key={library.key}
82+
title={library.title}
83+
subtitle={`Type: ${library.type.toUpperCase()}`}
84+
checked={checked}
85+
onChange={() => {
86+
setSetting(key, checked ? "false" : "true");
87+
}}
88+
/>
89+
);
90+
})}
8191
</Box>
8292
</>
8393
);
8494
}
85-
export default SettingsLibraries;
95+
export default SettingsLibraries;

frontend/src/states/UserSettingsState.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getBackendURL } from '../backendURL';
44

55
type UserSettingsOptions =
66
"DISABLE_WATCHSCREEN_DARKENING" |
7+
"DISABLE_HOME_SCREEN_LIBRARIES" |
78
"AUTO_MATCH_TRACKS" |
89
"AUTO_NEXT_EP" |
910
string;
@@ -21,6 +22,7 @@ export const useUserSettings = create<UserSettingsState>((set) => ({
2122
loaded: false,
2223
settings: {
2324
DISABLE_WATCHSCREEN_DARKENING: "false",
25+
DISABLE_HOME_SCREEN_LIBRARIES: "false",
2426
AUTO_MATCH_TRACKS: "true",
2527
AUTO_NEXT_EP: "true",
2628
},

0 commit comments

Comments
 (0)