diff --git a/src/App.jsx b/src/App.jsx index 1b79fa3..58c2042 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -71,6 +71,7 @@ import { delUser, getUser } from "./utils/storage/user.js"; import axios from "axios"; import { useBackdropStore } from "./utils/store/backdrop.js"; +import { useAppLoadingStore } from "./utils/store/appLoading.js"; const jellyfin = new Jellyfin({ clientInfo: { @@ -131,6 +132,21 @@ function App() { const [serverReachable, setServerReachable] = useState(true); + const [setIsAppLoading, setIsAppSuccess, setIsAppError] = + useAppLoadingStore((state) => [ + state.setIsLoading, + state.setIsSuccess, + state.setIsError, + ]); + + useEffect(() => { + const appLoadingStateTimer = setInterval(() => { + setIsAppSuccess(false); + setIsAppError(false); + }, 8000); + return () => clearInterval(appLoadingStateTimer); + }, [setIsAppSuccess, setIsAppError]); + const { enqueueSnackbar } = useSnackbar(); const createApi = async () => { diff --git a/src/components/appBar/appBar.jsx b/src/components/appBar/appBar.jsx index eb1f2a6..5249c18 100644 --- a/src/components/appBar/appBar.jsx +++ b/src/components/appBar/appBar.jsx @@ -40,6 +40,7 @@ import { MdiCogSync } from "../icons/mdiCogSync"; import { useAppLoadingStore } from "../../utils/store/appLoading"; import { MdiCheck } from "../icons/mdiCheck"; import { MdiAlertDecagram } from "../icons/mdiAlertDecagram"; +import { green, red } from "@mui/material/colors"; export const AppBar = () => { const navigate = useNavigate(); @@ -61,7 +62,7 @@ export const AppBar = () => { const trigger = useScrollTrigger({ disableHysteresis: true, - threshold: 0, + threshold: 20, }); const [anchorEl, setAnchorEl] = useState(null); @@ -82,7 +83,6 @@ export const AppBar = () => { const [syncLoading, syncSuccess, syncError] = useAppLoadingStore( (state) => [state.isLoading, state.isSuccess, state.isError], ); - console.log([syncLoading, syncSuccess, syncError]); useEffect(() => { if ( @@ -162,9 +162,10 @@ export const AppBar = () => { - - {syncLoading && ( + + {syncLoading ? ( { animate={{ opacity: 1 }} exit={{ opacity: 0, - transition: { - delay: 10, - duration: 5, - }, + }} + transition={{ + duration: 0.2, }} > { justifyContent: "center", }} > - {syncSuccess ? ( - - ) : syncError ? ( - - ) : ( - - )} + + ) : syncSuccess ? ( + + + + + + + ) : syncError ? ( + + + + + + + ) : ( + <> )} + diff --git a/src/components/appBar/appBar.module.scss b/src/components/appBar/appBar.module.scss index ccb8cd9..a9505e8 100644 --- a/src/components/appBar/appBar.module.scss +++ b/src/components/appBar/appBar.module.scss @@ -15,3 +15,7 @@ } } } + +.appLoading { + opacity: 0; +} diff --git a/src/components/buttons/likeButton.jsx b/src/components/buttons/likeButton.jsx index 090a9ab..7fa5b9f 100644 --- a/src/components/buttons/likeButton.jsx +++ b/src/components/buttons/likeButton.jsx @@ -75,8 +75,6 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => { return { currentLatestMedia }; }, onError: (error, a, context) => { - setIsLoading(false); - setIsError(true); enqueueSnackbar( `An error occured while updating "${itemName}"`, { @@ -85,12 +83,14 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => { ); queryClient.setQueryData(queryKey, context.previousData); console.error(error); + setIsError(true); + setIsLoading(false); }, onSuccess: () => { - setIsLoading(false); - setIsSuccess(true); console.log("Successfully updated", itemId); queryClient.invalidateQueries(queryKey); + setIsSuccess(true); + setIsLoading(false); }, }); return ( diff --git a/src/components/buttons/markPlayedButton.jsx b/src/components/buttons/markPlayedButton.jsx index 81ce848..d488abf 100644 --- a/src/components/buttons/markPlayedButton.jsx +++ b/src/components/buttons/markPlayedButton.jsx @@ -73,8 +73,6 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => { return { previousData }; }, onError: (error, a, context) => { - setIsLoading(false); - setIsError(true); enqueueSnackbar( `An error occured while updating "${itemName}"`, { @@ -83,12 +81,14 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => { ); queryClient.setQueryData(queryKey, context.previousData); console.error(error); + setIsError(true); + setIsLoading(false); }, onSuccess: () => { - setIsLoading(false); - setIsSuccess(true); console.log("Successfully updated", itemId); queryClient.invalidateQueries(queryKey); + setIsSuccess(true); + setIsLoading(false); }, }); return ( diff --git a/src/components/carouselSlide/index.jsx b/src/components/carouselSlide/index.jsx index 82dd037..f105fbf 100644 --- a/src/components/carouselSlide/index.jsx +++ b/src/components/carouselSlide/index.jsx @@ -83,13 +83,16 @@ const CarouselSlide = ({ item }) => { punch={1} /> )} - (e.target.style.opacity = 1) } @@ -107,8 +110,8 @@ const CarouselSlide = ({ item }) => { initial={{ transform: animationDirection == "right" - ? "translateX(40px)" - : "translateX(-40px)", + ? "translateX(20%)" + : "translateX(-20%)", opacity: 0, }} animate={{ @@ -118,8 +121,8 @@ const CarouselSlide = ({ item }) => { exit={{ transform: animationDirection == "right" - ? "translateX(-40px)" - : "translateX(40px)", + ? "translateX(-20%)" + : "translateX(20%)", opacity: 0, }} @@ -140,7 +143,7 @@ const CarouselSlide = ({ item }) => { {!item.ImageTags.Logo ? ( item.Name ) : ( - { } style={{ opacity: 0, - transition: "opacity 250ms", + transition: "opacity 0.2s", }} onLoad={(e) => (e.target.style.opacity = 1) diff --git a/src/routes/home/home.module.scss b/src/routes/home/home.module.scss index dd713fe..f39df3d 100644 --- a/src/routes/home/home.module.scss +++ b/src/routes/home/home.module.scss @@ -63,11 +63,10 @@ right: 0; bottom: 0; background-position: center; - opacity: 0; object-fit: cover; width: 100%; height: 100%; - transition: opacity $transition-time-fast; + transition: opacity 0.5s; } &-icon { position: absolute; diff --git a/src/routes/library/index.jsx b/src/routes/library/index.jsx index 89d6d3e..e7d047b 100644 --- a/src/routes/library/index.jsx +++ b/src/routes/library/index.jsx @@ -905,7 +905,7 @@ const LibraryView = () => { - {items.isLoading || items.isFetching ? ( + {items.isLoading ? (