Skip to content

Commit

Permalink
Home screen improvements
Browse files Browse the repository at this point in the history
- Only show spinner on load rather than fetch
- Add refresh button to explore
- Adjust stale times
  • Loading branch information
jeffvli committed Aug 8, 2023
1 parent 7c59722 commit 1d664bb
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions src/renderer/features/home/routes/home-route.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { useMemo, useRef } from 'react';
import { Stack } from '@mantine/core';
import { ActionIcon, Group, Stack } from '@mantine/core';
import { AlbumListSort, LibraryItem, ServerType, SortOrder } from '/@/renderer/api/types';
import { FeatureCarousel, NativeScrollArea, Spinner } from '/@/renderer/components';
import { FeatureCarousel, NativeScrollArea, Spinner, TextTitle } from '/@/renderer/components';
import { useAlbumList } from '/@/renderer/features/albums';
import { useRecentlyPlayed } from '/@/renderer/features/home/queries/recently-played-query';
import { AnimatedPage, LibraryHeaderBar } from '/@/renderer/features/shared';
import { AppRoute } from '/@/renderer/router/routes';
import { useCurrentServer, useWindowSettings } from '/@/renderer/store';
import { MemoizedSwiperGridCarousel } from '/@/renderer/components/grid-carousel';
import { Platform } from '/@/renderer/types';
import { useQueryClient } from '@tanstack/react-query';
import { queryKeys } from '/@/renderer/api/query-keys';
import { RiRefreshLine } from 'react-icons/ri';

const HomeRoute = () => {
const queryClient = useQueryClient();
const scrollAreaRef = useRef<HTMLDivElement>(null);
const server = useCurrentServer();
const itemsPerPage = 15;
Expand Down Expand Up @@ -62,7 +66,7 @@ const HomeRoute = () => {

const recentlyAdded = useAlbumList({
options: {
staleTime: 0,
staleTime: 1000 * 60 * 5,
},
query: {
limit: itemsPerPage,
Expand All @@ -75,7 +79,7 @@ const HomeRoute = () => {

const mostPlayed = useAlbumList({
options: {
staleTime: 0,
staleTime: 1000 * 60 * 5,
},
query: {
limit: itemsPerPage,
Expand All @@ -87,10 +91,10 @@ const HomeRoute = () => {
});

const isLoading =
random.isFetching ||
recentlyPlayed.isFetching ||
recentlyAdded.isFetching ||
mostPlayed.isFetching;
random.isLoading ||
recentlyPlayed.isLoading ||
recentlyAdded.isLoading ||
mostPlayed.isLoading;

if (isLoading) {
return <Spinner container />;
Expand All @@ -99,7 +103,32 @@ const HomeRoute = () => {
const carousels = [
{
data: random?.data?.items,
title: 'Explore from your library',
title: (
<Group>
<TextTitle
order={2}
weight={700}
>
Explore from your library
</TextTitle>

<ActionIcon
onClick={() =>
queryClient.invalidateQueries({
exact: false,
queryKey: queryKeys.albums.list(server?.id, {
limit: itemsPerPage,
sortBy: AlbumListSort.RANDOM,
sortOrder: SortOrder.ASC,
startIndex: 0,
}),
})
}
>
<RiRefreshLine />
</ActionIcon>
</Group>
),
uniqueId: 'random',
},
{
Expand Down Expand Up @@ -177,7 +206,10 @@ const HomeRoute = () => {
route: {
route: AppRoute.LIBRARY_ALBUM_ARTISTS_DETAIL,
slugs: [
{ idProperty: 'id', slugProperty: 'albumArtistId' },
{
idProperty: 'id',
slugProperty: 'albumArtistId',
},
],
},
},
Expand Down

1 comment on commit 1d664bb

@vercel
Copy link

@vercel vercel bot commented on 1d664bb Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

feishin – ./

feishin-jeffvli.vercel.app
feishin.vercel.app
feishin-git-development-jeffvli.vercel.app

Please sign in to comment.