Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Home videos and Photos View #5622

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/apps/experimental/components/library/SortButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const movieOrFavoriteOptions = [
{ label: 'Runtime', value: ItemSortBy.Runtime }
];

const photosOrPhotoAlbumsOptions = [
{ label: 'Name', value: ItemSortBy.SortName },
{ label: 'OptionRandom', value: ItemSortBy.Random },
{ label: 'OptionDateAdded', value: ItemSortBy.DateCreated }
];

const sortOptionsMapping: SortOptionsMapping = {
[LibraryTab.Movies]: movieOrFavoriteOptions,
[LibraryTab.Trailers]: [
Expand Down Expand Up @@ -89,6 +95,16 @@ const sortOptionsMapping: SortOptionsMapping = {
{ label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate },
{ label: 'Runtime', value: ItemSortBy.Runtime },
{ label: 'OptionRandom', value: ItemSortBy.Random }
],
[LibraryTab.PhotoAlbums]: photosOrPhotoAlbumsOptions,
[LibraryTab.Photos]: photosOrPhotoAlbumsOptions,
[LibraryTab.Videos]: [
{ label: 'Name', value: ItemSortBy.SortName },
{ label: 'OptionDateAdded', value: ItemSortBy.DateCreated },
{ label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed },
{ label: 'OptionPlayCount', value: ItemSortBy.PlayCount },
{ label: 'Runtime', value: ItemSortBy.Runtime },
{ label: 'OptionRandom', value: ItemSortBy.Random }
]
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const FiltersStatus: FC<FiltersStatusProps> = ({
&& viewType !== LibraryTab.AlbumArtists
&& viewType !== LibraryTab.Songs
&& viewType !== LibraryTab.Channels
&& viewType !== LibraryTab.PhotoAlbums
&& viewType !== LibraryTab.Photos
) {
visibleFiltersStatus.push(ItemFilter.IsUnplayed);
visibleFiltersStatus.push(ItemFilter.IsPlayed);
Expand Down
22 changes: 22 additions & 0 deletions src/apps/experimental/components/tabs/tabRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ const TabRoutes: TabRoute[] = [
value: LibraryTab.Episodes
}
]
},
{
path: '/homevideos.html',
tabs: [
{
index: 0,
label: globalize.translate('Photos'),
value: LibraryTab.Photos,
isDefault: true
},
{
index: 1,
label: globalize.translate('HeaderPhotoAlbums'),
value: LibraryTab.PhotoAlbums,
isDefault: true
},
{
index: 2,
label: globalize.translate('HeaderVideos'),
value: LibraryTab.Videos
}
]
}
];

Expand Down
4 changes: 3 additions & 1 deletion src/apps/experimental/routes/asyncRoutes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export const ASYNC_USER_ROUTES: AsyncRoute[] = [
{ path: 'tv.html', page: 'shows', type: AsyncRouteType.Experimental },
{ path: 'music.html', page: 'music', type: AsyncRouteType.Experimental },
{ path: 'livetv.html', page: 'livetv', type: AsyncRouteType.Experimental },
{ path: 'mypreferencesdisplay.html', page: 'user/display', type: AsyncRouteType.Experimental }
{ path: 'mypreferencesdisplay.html', page: 'user/display', type: AsyncRouteType.Experimental },

{ path: 'homevideos.html', page: 'homevideos', type: AsyncRouteType.Experimental }
];
59 changes: 59 additions & 0 deletions src/apps/experimental/routes/homevideos/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
import React, { type FC } from 'react';
import useCurrentTab from 'hooks/useCurrentTab';
import Page from 'components/Page';
import PageTabContent from '../../components/library/PageTabContent';
import { LibraryTab } from 'types/libraryTab';
import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type';
import { LibraryTabContent, LibraryTabMapping } from 'types/libraryTabContent';

const photosTabContent: LibraryTabContent = {
viewType: LibraryTab.Photos,
collectionType: CollectionType.Homevideos,
isBtnPlayAllEnabled: true,
isBtnShuffleEnabled: true,
itemType: [BaseItemKind.Photo]
};

const photoAlbumsTabContent: LibraryTabContent = {
viewType: LibraryTab.PhotoAlbums,
collectionType: CollectionType.Homevideos,
isBtnPlayAllEnabled: true,
isBtnShuffleEnabled: true,
itemType: [BaseItemKind.PhotoAlbum]
};

const videosTabContent: LibraryTabContent = {
viewType: LibraryTab.Videos,
collectionType: CollectionType.Homevideos,
isBtnPlayAllEnabled: true,
isBtnShuffleEnabled: true,
itemType: [BaseItemKind.Video]
};

const homevideosTabMapping: LibraryTabMapping = {
0: photosTabContent,
1: photoAlbumsTabContent,
2: videosTabContent
};

const HomeVideos: FC = () => {
const { libraryId, activeTab } = useCurrentTab();
const currentTab = homevideosTabMapping[activeTab];

return (
<Page
id='homevideos'
className='mainAnimatedPage libraryPage backdropPage collectionEditorPage pageWithAbsoluteTabs withTabs'
backDropType='video, photo'
>
<PageTabContent
key={`${currentTab.viewType} - ${libraryId}`}
currentTab={currentTab}
parentId={libraryId}
/>
</Page>
);
};

export default HomeVideos;
8 changes: 8 additions & 0 deletions src/components/router/appRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,14 @@ class AppRouter {

return url;
}

const layoutMode = localStorage.getItem('layout');

if (layoutMode === 'experimental' && item.CollectionType == CollectionType.Homevideos) {
url = '#/homevideos.html?topParentId=' + item.Id;

return url;
}
}

const itemTypes = ['Playlist', 'TvChannel', 'Program', 'BoxSet', 'MusicAlbum', 'MusicGenre', 'Person', 'Recording', 'MusicArtist'];
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useFetchItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ export const useGetItemsViewByType = (
LibraryTab.Playlists,
LibraryTab.Songs,
LibraryTab.Books,
LibraryTab.PhotoAlbums,
LibraryTab.Photos,
LibraryTab.Videos,
LibraryTab.Channels,
Expand Down
1 change: 1 addition & 0 deletions src/types/libraryTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum LibraryTab {
Suggestions = 'suggestions',
Trailers = 'trailers',
Upcoming = 'upcoming',
PhotoAlbums = 'photoalbums',
Photos = 'photos',
Videos = 'videos',
Books = 'books',
Expand Down
Loading