Implement placeholder image and randomly sort catogorys

This commit is contained in:
sussy-code 2024-04-30 18:14:06 +00:00
parent d370a9ea7c
commit e829896bcd
4 changed files with 5257 additions and 4240 deletions

View File

@ -28,7 +28,7 @@
Type the following commands into your terminal / command line to run Sudo-Flix locally Type the following commands into your terminal / command line to run Sudo-Flix locally
```bash ```bash
git clone https://github.com/sussy-code/smov.git git clone https://github.com/sussy-code/smov.git
cd sudo-flix cd smov
git pull git pull
pnpm install pnpm install
pnpm run dev pnpm run dev
@ -40,7 +40,7 @@ Then you can visit the local instance [here](http://localhost:5173) or, at local
To update a sudo-flix instance you can type the below commands into a terminal at the root of your project. To update a sudo-flix instance you can type the below commands into a terminal at the root of your project.
```bash ```bash
git remote add upstream https://github.com/sussy-code/smov.git git remote add upstream https://github.com/sussy-code/smov.git
git fetch sudo-flix # Grab the contents of the new remote source git fetch upstream # Grab the contents of the new remote source
git checkout <YOUR_MAIN_BRANCH> # Most likely this would be `origin/main` git checkout <YOUR_MAIN_BRANCH> # Most likely this would be `origin/main`
git merge upstream/main git merge upstream/main
# * Fix any conflicts present during merge * # * Fix any conflicts present during merge *

File diff suppressed because it is too large Load Diff

BIN
public/placeholder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -4,6 +4,7 @@ import { Helmet } from "react-helmet-async";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { get } from "@/backend/metadata/tmdb";
import { ThiccContainer } from "@/components/layout/ThinContainer"; import { ThiccContainer } from "@/components/layout/ThinContainer";
import { Divider } from "@/components/utils/Divider"; import { Divider } from "@/components/utils/Divider";
import { Flare } from "@/components/utils/Flare"; import { Flare } from "@/components/utils/Flare";
@ -20,7 +21,7 @@ import {
import { SubPageLayout } from "./layouts/SubPageLayout"; import { SubPageLayout } from "./layouts/SubPageLayout";
import { PageTitle } from "./parts/util/PageTitle"; import { PageTitle } from "./parts/util/PageTitle";
import { get } from "../backend/metadata/tmdb"; import placeholderImageLogo from "../../public/placeholder.png";
import { Icon, Icons } from "../components/Icon"; import { Icon, Icons } from "../components/Icon";
export function Discover() { export function Discover() {
@ -56,6 +57,15 @@ export function Discover() {
language: "en-US", language: "en-US",
}); });
// Shuffle the movies
for (let i = data.results.length - 1; i > 0; i -= 1) {
const j = Math.floor(Math.random() * (i + 1));
[data.results[i], data.results[j]] = [
data.results[j],
data.results[i],
];
}
setCategoryMovies((prevCategoryMovies) => ({ setCategoryMovies((prevCategoryMovies) => ({
...prevCategoryMovies, ...prevCategoryMovies,
[category.name]: data.results, [category.name]: data.results,
@ -78,6 +88,15 @@ export function Discover() {
language: "en-US", language: "en-US",
}); });
// Shuffle the TV shows
for (let i = data.results.length - 1; i > 0; i -= 1) {
const j = Math.floor(Math.random() * (i + 1));
[data.results[i], data.results[j]] = [
data.results[j],
data.results[i],
];
}
setCategoryShows((prevCategoryShows) => ({ setCategoryShows((prevCategoryShows) => ({
...prevCategoryShows, ...prevCategoryShows,
[category.name]: data.results, [category.name]: data.results,
@ -126,6 +145,16 @@ export function Discover() {
with_genres: genreId.toString(), with_genres: genreId.toString(),
language: "en-US", language: "en-US",
}); });
// Shuffle the TV shows
for (let i = data.results.length - 1; i > 0; i -= 1) {
const j = Math.floor(Math.random() * (i + 1));
[data.results[i], data.results[j]] = [
data.results[j],
data.results[i],
];
}
setTVShowGenres((prevTVShowGenres) => ({ setTVShowGenres((prevTVShowGenres) => ({
...prevTVShowGenres, ...prevTVShowGenres,
[genreId]: data.results, [genreId]: data.results,
@ -273,7 +302,8 @@ export function Discover() {
onMouseLeave={handleMouseLeave} onMouseLeave={handleMouseLeave}
onWheel={(e) => handleWheel(e, categorySlug)} onWheel={(e) => handleWheel(e, categorySlug)}
> >
{medias.slice(0, 20).map((media) => ( {/* Ik its an odd number and i dont give a shit */}
{medias.slice(0, 26).map((media) => (
<a <a
key={media.id} key={media.id}
onClick={() => onClick={() =>
@ -294,8 +324,12 @@ export function Discover() {
className="rounded-xl bg-background-main group-hover:opacity-100" className="rounded-xl bg-background-main group-hover:opacity-100"
/> />
<img <img
src={`https://image.tmdb.org/t/p/w500${media.poster_path}`} src={
alt="failed to fetch :(" media.poster_path
? `https://image.tmdb.org/t/p/w500${media.poster_path}`
: placeholderImageLogo
}
alt={media.poster_path ? "" : "failed to fetch :("}
loading="lazy" loading="lazy"
className="rounded-xl relative" className="rounded-xl relative"
/> />
@ -415,6 +449,13 @@ export function Discover() {
movies.push(...data.results); movies.push(...data.results);
} }
// Shuffle the movies
for (let i = movies.length - 1; i > 0; i -= 1) {
const j = Math.floor(Math.random() * (i + 1));
[movies[i], movies[j]] = [movies[j], movies[i]];
}
setGenreMovies((prevGenreMovies) => ({ setGenreMovies((prevGenreMovies) => ({
...prevGenreMovies, ...prevGenreMovies,
[genreId]: movies, [genreId]: movies,