Skip to content

Commit

Permalink
fix: remove unused loading state on medibox and add conditional rende…
Browse files Browse the repository at this point in the history
…ring for mediaboxmodal
  • Loading branch information
caushcani committed Dec 4, 2024
1 parent 955ef1b commit e5ab47f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
12 changes: 0 additions & 12 deletions apps/frontend/src/components/media/mediabox.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { TopTitle } from "../launches/helpers/top.title.component";
import { MultipartFileUploader } from "./new.uploader";
import clsx from "clsx";
import { VideoFrame } from '@gitroom/react/helpers/video.frame';
import { LoadingComponent } from "../layout/loading";
import Image from "next/image";

export const MediaBox: FC<{
Expand All @@ -20,8 +19,6 @@ export const MediaBox: FC<{
const fetch = useFetch();
const mediaDirectory = useMediaDirectory();

const [loading, setLoading] = useState(false);

const loadMedia = useCallback(async () => {
return (await fetch('/media')).json();
}, [fetch]);
Expand All @@ -37,11 +34,9 @@ export const MediaBox: FC<{
const { data, mutate } = useSWR('get-media', loadMedia);

useEffect(() => {
setLoading(true)
if (data?.results && data?.results?.length) {
setListMedia([...data.results]);
}
setLoading(false)
}, [data]);

return (
Expand Down Expand Up @@ -144,13 +139,6 @@ export const MediaBox: FC<{
)}
</div>
))}
{loading && (
<div className="w-[200px] h-[200px] flex border-tableBorder border-2 cursor-pointer relative">
<div className="absolute left-0 top-0 w-full h-full -mt-[50px] flex justify-center items-center">
<LoadingComponent />
</div>
</div>
)}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const ShowMediaBoxModal: FC = () => {
}, []);
if (!showModal) return null;

return (
return callBack && (
<div className="text-textColor">
<MediaBox setMedia={callBack!} closeModal={closeModal} />
<MediaBox setMedia={callBack} closeModal={closeModal} />
</div>
);
};

0 comments on commit e5ab47f

Please sign in to comment.