Skip to content

Commit

Permalink
Fix loading of videos
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor committed Jun 16, 2024
1 parent 4dfb06f commit 83f7b71
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/server/app/views/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const getVideos = async (
left join users requester
on requester.discord_id = videos.requested_by_id
where ${'discordUserId' in options ? 'requested_by_id' : 'requester.username'} = ?
and pending = ?
and video_url is not null
and deleted_at is null
${sortableId ? 'and (videos.created_at < ? or (videos.created_at = ? and videos.share_id > ?))' : ''}
Expand All @@ -90,6 +91,7 @@ const getVideos = async (
limit ${MAX_VIDEOS_PER_REQUEST}`,
[
'discordUserId' in options ? options.discordUserId : options.discordUserName,
PendingStatus.FinishedRender,
...(sortableId ? [sortableId.date, sortableId.date, sortableId.shareId] : []),
],
);
Expand Down Expand Up @@ -222,10 +224,6 @@ export const Profile = () => {
const state = React.useContext(AppStateContext);
const { user, videos, stats } = useLoaderData<Data>();

const renderedVideos = videos.filter(
(video) => video.pending === PendingStatus.FinishedRender,
);

if (!user) {
return (
<div className={tw`lg:flex lg:justify-center`}>
Expand Down Expand Up @@ -338,9 +336,9 @@ export const Profile = () => {
className={tw`justify-items-center grid mt-4 grid-cols sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 2xl:grid-cols-4 gap-4`}
x-last-video={getSortableIdByCreated(videos.at(-1))}
>
{renderedVideos.map((video) => <VideoCard video={video} />)}
{videos.map((video) => <VideoCard video={video} />)}
</div>
{renderedVideos.length === MAX_VIDEOS_PER_REQUEST && (
{videos.length === MAX_VIDEOS_PER_REQUEST && (
<div id='loading' className={tw`text-center mt-10 mb-10`}>
<div role='status'>
<svg
Expand Down

0 comments on commit 83f7b71

Please sign in to comment.