Compare commits
76
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
295b8da8eb | ||
|
|
6d1c55dda5 | ||
|
|
0c47660501 | ||
|
|
e9b37d99aa | ||
|
|
f19ffb4361 | ||
|
|
ce533dde4b | ||
|
|
6d2448ef36 | ||
|
|
c572cb35cb | ||
|
|
f57e78b244 | ||
|
|
af8dec5844 | ||
|
|
7d2659f32b | ||
|
|
06015d7702 | ||
|
|
0847c2b2ef | ||
|
|
bc6d39b004 | ||
|
|
9f7fde2173 | ||
|
|
7410c8f3e3 | ||
|
|
fcf18c01e8 | ||
|
|
620b4ce253 | ||
|
|
9dbe11ce23 | ||
|
|
5d5f127525 | ||
|
|
d7f3892ff3 | ||
|
|
dc72f381e8 | ||
|
|
d238aeff1f | ||
|
|
1c38893c68 | ||
|
|
000e62873a | ||
|
|
5b322d49e6 | ||
|
|
232aad5e8a | ||
|
|
7aceb89e11 | ||
|
|
42c154f17a | ||
|
|
27cc14c1f5 | ||
|
|
cf8c5d4490 | ||
|
|
97526e29b4 | ||
|
|
e049ce9ad6 | ||
|
|
561daa7d81 | ||
|
|
2ad920af9d | ||
|
|
907753b041 | ||
|
|
591fce7e5c | ||
|
|
9d96667d60 | ||
|
|
5c8624a73c | ||
|
|
0319d9711e | ||
|
|
70da3b3754 | ||
|
|
98078585d6 | ||
|
|
cf66b8d20c | ||
|
|
a198e09864 | ||
|
|
25d9702283 | ||
|
|
0790f0afd5 | ||
|
|
240ed3b365 | ||
|
|
5cd9b57e1f | ||
|
|
88b016f6f5 | ||
|
|
8a459f588d | ||
|
|
6c5335648d | ||
|
|
fc9abf6c5b | ||
|
|
a53224f802 | ||
|
|
865c42b419 | ||
|
|
12f963d718 | ||
|
|
8917dd240a | ||
|
|
685ef4b2fc | ||
|
|
f141ddbaf3 | ||
|
|
6e55a287eb | ||
|
|
9c110ea8fa | ||
|
|
ebbe686a57 | ||
|
|
2cb10aa342 | ||
|
|
a64f5876f2 | ||
|
|
95a180e968 | ||
|
|
99ec17501d | ||
|
|
a7eab72639 | ||
|
|
81695a583d | ||
|
|
c6b5d6a4a2 | ||
|
|
7ef8e33669 | ||
|
|
9be02b6392 | ||
|
|
dd16f3a204 | ||
|
|
7e7f44ce94 | ||
|
|
61fa734629 | ||
|
|
45f67aac40 | ||
|
|
19343b4ea3 | ||
|
|
0dde74ab70 |
No files matched your search
@@ -107,7 +107,7 @@ jobs:
|
|||||||
run: pnpm install --no-frozen-lockfile
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
- name: Build app
|
- name: Build app
|
||||||
run: pnpm run tauri build
|
run: pnpm run tauri build --debug
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
@@ -119,4 +119,4 @@ jobs:
|
|||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
||||||
path: src-tauri/target/release/bundle/*
|
path: src-tauri/target/debug/bundle/*
|
||||||
@@ -28,6 +28,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Rust setup
|
- name: Rust setup
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
|
||||||
|
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: swatinem/rust-cache@v2
|
uses: swatinem/rust-cache@v2
|
||||||
@@ -78,3 +81,4 @@ jobs:
|
|||||||
releaseBody: "See the assets to download and install this version."
|
releaseBody: "See the assets to download and install this version."
|
||||||
releaseDraft: true
|
releaseDraft: true
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
args: ${{ matrix.platform == 'macos-latest' && '--target universal-apple-darwin' || '' }}
|
||||||
+3
-1
@@ -37,4 +37,6 @@ target/
|
|||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
generateBanner
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"encodings":["src\\main.tsx","ProviderWrapper",[52,0,71,1],[53,39,57,3],[53,8,53,11],[53,13,53,22],[53,24,53,35],[58,34,61,3],[58,8,58,12],[58,14,58,30],[66,2,69,4],"src\\components\\notices\\errorNotice\\errorNotice.tsx","ErrorNotice",[6,27,54,1],[6,28,6,56],[9,2,52,8],[20,3,31,9],[32,3,34,16],[35,3,51,16],"src\\utils\\store\\api.tsx","ApiProvider",[50,27,67,1],[50,28,50,65],[51,17,65,2],[66,8,66,75],"useApiInContext",[69,7,75,1],[70,15,70,37],[74,8,74,57],"src\\utils\\store\\central.tsx","CentralProvider",[48,31,71,1],[48,32,48,69],[49,17,67,2],[69,2,69,77],"useCentralStore",[73,7,79,1],[74,15,74,41],[78,8,78,57],"src\\routes\\_api\\player\\index.tsx","VideoPlayer",[88,0,918,1],[89,13,89,42],[90,21,90,32],[90,9,90,16],[91,39,91,54],[92,16,92,48],[94,14,94,51],[106,5,116,3],[97,2,97,16],[98,2,98,6],[99,2,99,10],[100,2,100,14],[101,2,101,15],[102,2,102,14],[103,2,103,13],[104,2,104,15],[105,2,105,11],[117,40,120,3],[117,8,117,29],[117,31,117,36],[122,31,122,45],[123,41,125,2],[127,51,127,66],[130,31,130,46],[131,31,131,45],[132,35,132,50],[133,45,133,68],[134,33,134,56],[135,43,135,58],[137,29,137,40],[138,27,138,42],[140,1,140,41],[142,41,142,72],[219,24,257,7],[259,1,267,21],[267,5,267,19],[269,1,287,7],[289,1,292,15],[292,5,292,13],[294,41,311,62],[311,5,311,31],[311,33,311,60],[313,1,334,3],[331,2,331,28],[332,2,332,29],[333,2,333,37],[336,29,344,15],[344,5,344,13],[346,24,364,25],[364,5,364,13],[364,15,364,23],[366,25,370,15],[370,5,370,13],[372,49,372,64],[373,27,375,7],[376,1,376,56],[376,46,376,54],[378,22,384,21],[384,5,384,19],[464,5,481,11],[465,6,474,8],[475,6,477,19],[478,6,480,19],[485,4,499,10],[486,5,495,7],[496,5,498,18],[504,4,511,10],[505,5,507,18],[508,5,510,18],[515,3,519,9],[516,4,518,17],[523,51,523,66],[524,1,530,13],[530,5,530,11],[542,2,916,8],[543,3,566,21],[545,5,564,18],[563,6,563,52],[568,4,582,13],[585,4,585,55],[587,3,605,21],[589,5,603,18],[595,6,597,12],[598,6,602,8],[606,3,883,16],[642,4,696,10],[643,5,645,18],[644,6,644,66],[646,5,648,18],[647,6,647,64],[649,5,695,12],[670,6,694,18],[686,7,688,18],[690,8,692,19],[698,5,881,11],[699,6,706,19],[702,8,704,21],[707,6,880,12],[708,7,763,13],[709,8,756,10],[757,8,762,14],[758,9,760,22],[761,9,761,62],[764,7,879,13],[765,8,800,14],[766,9,766,31],[767,9,777,22],[774,10,776,17],[778,9,782,22],[779,10,781,17],[783,9,793,22],[790,10,792,17],[794,9,794,27],[795,9,799,22],[801,8,878,14],[802,9,840,22],[824,10,826,23],[827,10,839,12],[841,9,854,22],[847,10,853,17],[855,9,855,24],[856,9,865,22],[860,10,864,17],[866,9,877,22],[874,10,876,17],[884,3,915,5],"sliderDisplayFormat",[386,29,521,2],"src\\routes\\_api\\home\\index.tsx","Home",[40,0,400,1],[41,13,41,42],[42,14,42,51],[44,19,54,3],[56,21,80,3],[82,26,96,3],[98,26,111,3],[113,21,130,3],[132,47,134,6],[136,18,136,31],[138,21,138,59],[140,24,142,2],[144,1,157,26],[157,5,157,24],[161,3,397,10],[168,4,208,20],[170,6,170,26],[173,7,205,9],[210,4,245,20],[212,6,214,12],[213,7,213,51],[218,6,218,23],[220,6,243,21],[224,10,240,12],[246,4,301,20],[248,6,250,12],[249,7,249,52],[254,6,254,23],[258,6,299,21],[261,9,296,11],[302,4,354,20],[304,6,306,12],[305,7,305,59],[310,6,310,23],[315,6,352,21],[318,9,349,11],[355,4,385,20],[357,6,359,12],[358,7,358,59],[363,6,363,23],[368,6,383,21],[371,9,380,11],[386,4,396,20],[388,6,390,12],[389,7,389,62],[394,13,394,69],"src\\routes\\_api\\search\\index.jsx","SearchPage",[32,0,386,1],[33,13,33,36],[35,18,35,31],[36,19,36,36],[36,9,36,14],[38,37,38,49],[41,14,41,51],[45,16,58,3],[59,16,72,3],[73,20,86,3],[87,15,100,3],[101,14,114,3],[115,22,128,3],[129,16,140,3],[141,18,153,3],[155,23,155,71],[155,8,155,19],[157,1,160,7],[162,2,384,8],[172,3,203,9],[173,4,194,6],[195,4,202,10],[201,5,201,61],[204,3,358,9],[210,5,229,20],[212,7,227,9],[232,5,257,20],[234,7,255,9],[260,5,274,20],[263,8,271,10],[277,5,290,20],[279,7,288,9],[293,5,307,20],[295,7,305,9],[310,5,324,20],[312,7,322,9],[327,5,340,20],[329,7,338,9],[343,5,356,20],[345,7,354,9],[375,5,381,11],[380,6,380,68],[383,3,383,13],"src\\routes\\_api\\favorite\\index.tsx","FavoritePage",[21,0,297,1],[22,13,22,36],[23,23,23,71],[23,8,23,19],[25,14,25,51],[27,16,38,3],[40,16,51,3],[53,20,64,3],[66,15,77,3],[79,14,90,3],[92,22,103,3],[105,16,116,3],[118,1,120,3],[123,2,295,9],[134,4,153,19],[136,6,151,8],[156,4,181,19],[158,6,179,8],[184,4,203,19],[186,6,201,8],[206,4,226,19],[208,6,224,8],[229,4,249,19],[231,6,247,8],[252,4,271,19],[254,6,269,8],[274,4,293,19],[276,6,291,8],"src\\routes\\setup\\server.list.tsx","ServerList",[28,0,206,1],[29,18,29,31],[30,39,30,53],[31,29,31,42],[31,9,31,24],[33,19,33,54],[35,21,35,37],[37,17,40,3],[42,23,45,3],[47,28,65,3],[90,1,92,7],[95,2,204,8],[96,3,96,21],[97,3,117,9],[106,4,108,17],[109,4,116,17],[115,5,115,56],[118,3,203,11],[121,6,201,12],[122,7,124,13],[125,7,173,13],[126,8,154,21],[136,10,152,12],[138,12,144,25],[155,8,163,21],[164,8,172,21],[174,7,200,13],[175,8,186,21],[185,9,185,62],[187,8,199,21],[198,9,198,71],"src\\routes\\setup\\server.add.tsx","ServerSetup",Line truncated
|
{"encodings":["src\\main.tsx","ProviderWrapper",[52,0,71,1],[53,39,57,3],[53,8,53,11],[53,13,53,22],[53,24,53,35],[58,34,61,3],[58,8,58,12],[58,14,58,30],[66,2,69,4],"src\\components\\notices\\errorNotice\\errorNotice.tsx","ErrorNotice",[6,27,54,1],[6,28,6,56],[9,2,52,8],[20,3,31,9],[32,3,34,16],[35,3,51,16],"src\\utils\\store\\api.tsx","ApiProvider",[50,27,67,1],[50,28,50,65],[51,17,65,2],[66,8,66,75],"useApiInContext",[69,7,75,1],[70,15,70,37],[74,8,74,57],"src\\utils\\store\\central.tsx","CentralProvider",[48,31,71,1],[48,32,48,69],[49,17,67,2],[69,2,69,77],"useCentralStore",[73,7,79,1],[74,15,74,41],[78,8,78,57],"src\\routes\\_api\\player\\index.tsx","VideoPlayer",[88,0,918,1],[89,13,89,42],[90,21,90,32],[90,9,90,16],[91,39,91,54],[92,16,92,48],[94,14,94,51],[106,5,116,3],[97,2,97,16],[98,2,98,6],[99,2,99,10],[100,2,100,14],[101,2,101,15],[102,2,102,14],[103,2,103,13],[104,2,104,15],[105,2,105,11],[117,40,120,3],[117,8,117,29],[117,31,117,36],[122,31,122,45],[123,41,125,2],[127,51,127,66],[130,31,130,46],[131,31,131,45],[132,35,132,50],[133,45,133,68],[134,33,134,56],[135,43,135,58],[137,29,137,40],[138,27,138,42],[140,1,140,41],[142,41,142,72],[219,24,257,7],[259,1,267,21],[267,5,267,19],[269,1,287,7],[289,1,292,15],[292,5,292,13],[294,41,311,62],[311,5,311,31],[311,33,311,60],[313,1,334,3],[331,2,331,28],[332,2,332,29],[333,2,333,37],[336,29,344,15],[344,5,344,13],[346,24,364,25],[364,5,364,13],[364,15,364,23],[366,25,370,15],[370,5,370,13],[372,49,372,64],[373,27,375,7],[376,1,376,56],[376,46,376,54],[378,22,384,21],[384,5,384,19],[464,5,481,11],[465,6,474,8],[475,6,477,19],[478,6,480,19],[485,4,499,10],[486,5,495,7],[496,5,498,18],[504,4,511,10],[505,5,507,18],[508,5,510,18],[515,3,519,9],[516,4,518,17],[523,51,523,66],[524,1,530,13],[530,5,530,11],[542,2,916,8],[543,3,566,21],[545,5,564,18],[563,6,563,52],[568,4,582,13],[585,4,585,55],[587,3,605,21],[589,5,603,18],[595,6,597,12],[598,6,602,8],[606,3,883,16],[642,4,696,10],[643,5,645,18],[644,6,644,66],[646,5,648,18],[647,6,647,64],[649,5,695,12],[670,6,694,18],[686,7,688,18],[690,8,692,19],[698,5,881,11],[699,6,706,19],[702,8,704,21],[707,6,880,12],[708,7,763,13],[709,8,756,10],[757,8,762,14],[758,9,760,22],[761,9,761,62],[764,7,879,13],[765,8,800,14],[766,9,766,31],[767,9,777,22],[774,10,776,17],[778,9,782,22],[779,10,781,17],[783,9,793,22],[790,10,792,17],[794,9,794,27],[795,9,799,22],[801,8,878,14],[802,9,840,22],[824,10,826,23],[827,10,839,12],[841,9,854,22],[847,10,853,17],[855,9,855,24],[856,9,865,22],[860,10,864,17],[866,9,877,22],[874,10,876,17],[884,3,915,5],"sliderDisplayFormat",[386,29,521,2],"src\\routes\\_api\\home\\index.tsx","Home",[40,0,400,1],[41,13,41,42],[42,14,42,51],[44,19,54,3],[56,21,80,3],[82,26,96,3],[98,26,111,3],[113,21,130,3],[132,47,134,6],[136,18,136,31],[138,21,138,59],[140,24,142,2],[144,1,157,26],[157,5,157,24],[161,3,397,10],[168,4,208,20],[170,6,170,26],[173,7,205,9],[210,4,245,20],[212,6,214,12],[213,7,213,51],[218,6,218,23],[220,6,243,21],[224,10,240,12],[246,4,301,20],[248,6,250,12],[249,7,249,52],[254,6,254,23],[258,6,299,21],[261,9,296,11],[302,4,354,20],[304,6,306,12],[305,7,305,59],[310,6,310,23],[315,6,352,21],[318,9,349,11],[355,4,385,20],[357,6,359,12],[358,7,358,59],[363,6,363,23],[368,6,383,21],[371,9,380,11],[386,4,396,20],[388,6,390,12],[389,7,389,62],[394,13,394,69],"src\\routes\\_api\\search\\index.jsx","SearchPage",[32,0,386,1],[33,13,33,36],[35,18,35,31],[36,19,36,36],[36,9,36,14],[38,37,38,49],[41,14,41,51],[45,16,58,3],[59,16,72,3],[73,20,86,3],[87,15,100,3],[101,14,114,3],[115,22,128,3],[129,16,140,3],[141,18,153,3],[155,23,155,71],[155,8,155,19],[157,1,160,7],[162,2,384,8],[172,3,203,9],[173,4,194,6],[195,4,202,10],[201,5,201,61],[204,3,358,9],[210,5,229,20],[212,7,227,9],[232,5,257,20],[234,7,255,9],[260,5,274,20],[263,8,271,10],[277,5,290,20],[279,7,288,9],[293,5,307,20],[295,7,305,9],[310,5,324,20],[312,7,322,9],[327,5,340,20],[329,7,338,9],[343,5,356,20],[345,7,354,9],[375,5,381,11],[380,6,380,68],[383,3,383,13],"src\\routes\\_api\\favorite\\index.tsx","FavoritePage",[21,0,297,1],[22,13,22,36],[23,23,23,71],[23,8,23,19],[25,14,25,51],[27,16,38,3],[40,16,51,3],[53,20,64,3],[66,15,77,3],[79,14,90,3],[92,22,103,3],[105,16,116,3],[118,1,120,3],[123,2,295,9],[134,4,153,19],[136,6,151,8],[156,4,181,19],[158,6,179,8],[184,4,203,19],[186,6,201,8],[206,4,226,19],[208,6,224,8],[229,4,249,19],[231,6,247,8],[252,4,271,19],[254,6,269,8],[274,4,293,19],[276,6,291,8],"src\\routes\\setup\\server.list.tsx","ServerList",[28,0,206,1],[29,18,29,31],[30,39,30,53],[31,29,31,42],[31,9,31,24],[33,19,33,54],[35,21,35,37],[37,17,40,3],[42,23,45,3],[47,28,65,3],[90,1,92,7],[95,2,204,8],[96,3,96,21],[97,3,117,9],[106,4,108,17],[109,4,116,17],[115,5,115,56],[118,3,203,11],[121,6,201,12],[122,7,124,13],[125,7,173,13],[126,8,154,21],[136,10,152,12],[138,12,144,25],[155,8,163,21],[164,8,172,21],[174,7,200,13],[175,8,186,21],[185,9,185,62],[187,8,199,21],[198,9,198,71],"src\\routes\\setup\\server.add.tsx","ServerSetup",Line truncated
|
||||||
@@ -1,3 +1,79 @@
|
|||||||
|
- # Alpha 3 (11/12/2024)
|
||||||
|
- refactor: prepare for alpha 3
|
||||||
|
- refactor: cleanup
|
||||||
|
- refactor: remove unused imports
|
||||||
|
- fix: series page not fetching correct season
|
||||||
|
- feat: add key binding for macos users #435
|
||||||
|
- refactor: remove jellyPlayer naming from code #460
|
||||||
|
- feat: add playlist playback support
|
||||||
|
- refactor: improve server add process
|
||||||
|
- feat: show current time while scrubbing video progress #339
|
||||||
|
- style: increase the sharpness of card images
|
||||||
|
- feat: add skip recap button
|
||||||
|
- refactor: cleanup video player
|
||||||
|
- feat: add chapter navigation buttons to video player #457
|
||||||
|
- feat: allow changing audio track from video player
|
||||||
|
- feat: allow changing chapters from a chapter list #457
|
||||||
|
- refactor: cleanup search route
|
||||||
|
- refactor: cleanup some components
|
||||||
|
- refactor: unmount card image if not inView
|
||||||
|
- refactor: cleanup person route
|
||||||
|
- style: replace noto-sans with plus-jakarta-sans
|
||||||
|
- refactor: cleanup login routes
|
||||||
|
- fix: library items not of same size #380
|
||||||
|
- refactor: cleanup item.tsx
|
||||||
|
- fix: series page breaking if season is not loaded
|
||||||
|
- fix: do not display missing items in series
|
||||||
|
- refactor: move more files to ts
|
||||||
|
- refactor: move more files to ts
|
||||||
|
- refactor: move more files to ts
|
||||||
|
- refactor: move more files to typescript
|
||||||
|
- refactor: move more components to ts
|
||||||
|
- refactore: cleanup __root.tsx
|
||||||
|
- chore(deps): update dependencies
|
||||||
|
- fix: collections page not rendering #447
|
||||||
|
- fix: quick connect not working #445
|
||||||
|
- fix: playback error if subtitle is not set
|
||||||
|
- fix: index not being assigned proper value #420
|
||||||
|
- fix: synced lyrics not working
|
||||||
|
- Merge pull request #446 from prayag17/renovate/node-22.x-lockfile
|
||||||
|
- refactor: use saved lyrics
|
||||||
|
- refactor: change GenreView to genreFilter
|
||||||
|
- fix(deps): update dependency @types/node to v22.10.1
|
||||||
|
- Merge pull request #393 from prayag17/renovate/tanstack-router-monorepo
|
||||||
|
- Merge pull request #424 from prayag17/renovate/tanstack-query-monorepo
|
||||||
|
- fix(deps): update tanstack-router monorepo
|
||||||
|
- Merge pull request #426 from prayag17/renovate/node-22.x-lockfile
|
||||||
|
- fix(deps): update dependency @types/node to v22.10.0
|
||||||
|
- Merge pull request #437 from prayag17/dependabot/cargo/src-tauri/rustls-0.23.18
|
||||||
|
- fix(deps): update tanstack-query monorepo to v5.61.4
|
||||||
|
- Merge pull request #438 from prayag17/renovate/axios-1.x-lockfile
|
||||||
|
- Merge pull request #439 from prayag17/renovate/vitejs-plugin-react-4.x-lockfile
|
||||||
|
- chore(deps): update dependency @vitejs/plugin-react to v4.3.4
|
||||||
|
- refactore: move more components to typescript
|
||||||
|
- fix: episode and series not playing if episode is not present in nextUp and continueWatching
|
||||||
|
- feat: show current episode in PlayButton
|
||||||
|
- fix: episode indexing for absolute numbering indexNumbers in PlayButton
|
||||||
|
- fix: unable to read Id of undefined in PlayButton
|
||||||
|
- fix(deps): update dependency axios to v1.7.8
|
||||||
|
- chore(deps): bump rustls from 0.23.16 to 0.23.18 in /src-tauri
|
||||||
|
- fix(ci): not uploading debug builds
|
||||||
|
- refactor(ci): build debug builds in CI
|
||||||
|
- Merge pull request #425 from prayag17/renovate/serde_json-1.x-lockfile
|
||||||
|
- Merge pull request #436 from sambartik/macos-universal-dmg
|
||||||
|
- chore(deps): update dependencies
|
||||||
|
- refactor: convert more files to typescript
|
||||||
|
- fix: improper handling of undefined api leading to crashes
|
||||||
|
- refactor: move all buttons to tsx #338
|
||||||
|
- Add universal dmg for macOS in release job
|
||||||
|
- fix: audio queue not moving after 2 changes #182
|
||||||
|
- fix: playing track from album not updating the queue #182
|
||||||
|
- refactor: use MediaSegments api for intro/outro skipping
|
||||||
|
- fix: trickplay images not showing up
|
||||||
|
- refactor: improve login page UI #338 #202
|
||||||
|
- chore(release): update latest.json
|
||||||
|
- fix(deps): update rust crate serde_json to v1.0.133
|
||||||
|
|
||||||
- # 0.0.7-dev (20/11/2024)
|
- # 0.0.7-dev (20/11/2024)
|
||||||
- chore(deps): update dependencies
|
- chore(deps): update dependencies
|
||||||
- refactor: change UI of login/list and fix Api not being defined in context
|
- refactor: change UI of login/list and fix Api not being defined in context
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||

|

|
||||||
<div align="center">
|
<div align="center">
|
||||||
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/prayag17/JellyPlayer?sort=date&display_name=tag&style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODc4IiBoZWlnaHQ9IjEwMTIiIHZpZXdCb3g9IjAgMCA4NzggMTAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00MzguODA5IDUwNkwzNS40MDQ4IDczOC45MDZMNDM4LjgwOSA5NzEuODEyTDg0Mi4yMTQgNzM4LjkwNlYyNzMuMDk0TDQzOC44MDkgNDAuMTg4NUwzNS40MDQ4IDI3My4wOTRMNDM4LjgwOSA1MDZaTTQzOC44MDkgMEw4NzcuMDE4IDI1M1Y3NTlMNDM4LjgwOSAxMDEyTDAuNjAwNTg2IDc1OVY3MTguODEyVjI5My4xODhWMjUzTDQzOC44MDkgMFoiIGZpbGw9IndoaXRlIi8%2BCjwvc3ZnPgo%3D&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%2FJellyPlayer%2Freleases%2Flatest">
|
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/prayag17/Blink?sort=date&display_name=tag&style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODc4IiBoZWlnaHQ9IjEwMTIiIHZpZXdCb3g9IjAgMCA4NzggMTAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00MzguODA5IDUwNkwzNS40MDQ4IDczOC45MDZMNDM4LjgwOSA5NzEuODEyTDg0Mi4yMTQgNzM4LjkwNlYyNzMuMDk0TDQzOC44MDkgNDAuMTg4NUwzNS40MDQ4IDI3My4wOTRMNDM4LjgwOSA1MDZaTTQzOC44MDkgMEw4NzcuMDE4IDI1M1Y3NTlMNDM4LjgwOSAxMDEyTDAuNjAwNTg2IDc1OVY3MTguODEyVjI5My4xODhWMjUzTDQzOC44MDkgMFoiIGZpbGw9IndoaXRlIi8%2BCjwvc3ZnPgo%3D&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%Blink%2Freleases%2Flatest">
|
||||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/prayag17/JellyPlayer?style=for-the-badge&logo=github&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%2FJellyPlayer%2Fstargazers">
|
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/prayag17/Blink?style=for-the-badge&logo=github&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%Blink%2Fstargazers">
|
||||||
<img alt="GitHub License" src="https://img.shields.io/github/license/prayag17/JellyPlayer?style=for-the-badge&labelColor=000">
|
<img alt="GitHub License" src="https://img.shields.io/github/license/prayag17/Blink?style=for-the-badge&labelColor=000">
|
||||||
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/prayag17/JellyPlayer/continuous-integration.yml?style=for-the-badge&logo=github&label=CI&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%2FJellyPlayer%2Factions%2Fworkflows%2Fcontinuous-integration.yml">
|
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/prayag17/Blink/continuous-integration.yml?style=for-the-badge&logo=github&label=CI&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%Blink%2Factions%2Fworkflows%2Fcontinuous-integration.yml">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
###
|
###
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
pnpm run tauri build
|
pnpm run tauri build
|
||||||
```
|
```
|
||||||
|
|
||||||
- other commands can be found inside the `"scripts"` inside [package.json](https://github.com/prayag17/JellyPlayer/blob/main/package.json)
|
- other commands can be found inside the `"scripts"` inside [package.json](https://github.com/prayag17/Blink/blob/main/package.json)
|
||||||
|
|
||||||
## 💻 Contribution
|
## 💻 Contribution
|
||||||
|
|
||||||
@@ -64,17 +64,17 @@
|
|||||||
## 📷 Screenshots
|
## 📷 Screenshots
|
||||||
|
|
||||||
- Home
|
- Home
|
||||||

|

|
||||||
- Title Page - Movie
|
- Title Page - Movie
|
||||||

|

|
||||||
- Title Page - Show
|
- Title Page - Show
|
||||||

|

|
||||||
- Episode List
|
- Episode List
|
||||||

|

|
||||||
- Video Player
|
- Video Player
|
||||||

|

|
||||||
- About Dialog
|
- About Dialog
|
||||||

|

|
||||||
|
|
||||||
## 📃 Roadmap
|
## 📃 Roadmap
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
|
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
|
||||||
"organizeImports": {
|
"organizeImports": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
},
|
},
|
||||||
"suspicious": {
|
"suspicious": {
|
||||||
"noExplicitAny": "off"
|
"noExplicitAny": "off"
|
||||||
|
},
|
||||||
|
"nursery": {
|
||||||
|
"useComponentExportOnlyModules": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<script src="http://localhost:8097"></script>
|
<script src="http://localhost:8097"></script>
|
||||||
<title>Jellyplayer</title>
|
<title>Blink</title>
|
||||||
<style>
|
<style>
|
||||||
.app-loading {
|
.app-loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
+9
-9
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"version": "0.0.6-dev",
|
"version": "0.0.7-dev",
|
||||||
"notes": "- feat: add video player slider bubble theming #337\n- feat: add trickplay support #338 #337\n- fix(ci): update env variables\n- fix(ci): fix ubuntu build failing\n- chore(deps): update js and rust deps\n- feat: add chapter markers #337\n- feat: add subtitle support #337\n- fix(ci): invalid tauri build command\n- fix(ci):workflow repo name\n- feat: remember last search query\n- feat: add new audioPlayer route and allow reordering queue\n- chore(deps): update deps\n- chore(deps): cleanup unused dependencies and update dependencies\n- refactor: replace wavesurfer with html audio player\n- feat: add new album page\n- fix: quick connect not working\n- chore: change tauri updater signing keys\n- feat: show upNext card for episode items in player\n- fix: login page not working\n- Merge pull request #332 from pypp/feat/double-click-fullscreen\n- Merge pull request #333 from pypp/feat/scrollwheel-volume-control\n- fix: removed subtitleRenderer state that was added while merging\n- fix: fixed bug caused by merge econflicts\n- Merge remote-tracking branch 'upstream/main' into feat/scrollwheel-volume-control\n- fix: fixed fucntion to use the new API\n- Merge remote-tracking branch 'upstream/main' into feat/double-click-fullscreen\n- Merge branch 'main' of https://github.com/pypp/JellyPlayer into feat/double-click-fullscreen\n- fix(deps): update dependency babel-plugin-react-compiler to v0.0.0\n- fix(deps): update tauri monorepo\n- chore(deps): update dependencies\n- feat: allow toggling subtitles on and off from player\n- fix: playNext and playPrevious logic\n- feat: add intro-skipper\n- refactor: cleanup unused variables in playbackStore\n- chore(deps): update packages\n- refactor: support vtt and ass subtitles\n- refactor: add sorting options to library page for Series and BoxSets\n- style: update hero-carousel styling\n- chore(deps): update deps\n- fix(deps): update dependency framer-motion to v11.2.9\n- refactor: move most routing logic to tanstack\n- refactor: implement new login logic and verify context.api status\n- chore(deps): update dependencies\n- refactor: move to tanstack router\n- fix: videoPlayer not restoring playback position when queueItem is updated\n- fix: Slight UI regression when changing servers on latest version #288\n- fix: eac3 codec support\n- refactor: queueItem playback\n- fix(deps): update rust crate tauri to 1.6.2 (#298)\n- fix: episode playback\n- feat: add queueButton\n- Merge branch 'main' of https://github.com/prayag17/JellyPlayer\n- chore(deps): fix vite 5.2 bundle\n- fix(deps): update dependency @types/react to v18.3.1 (#295)\n- fix: scrollTrigger in libraryView\n- style: improve styling\n- fix: backdrop flashing\n- feat: use tanstack virtual for rendering library items\n- style: improve login notice ui\n- refactor: fetch mediaSource for series\n- refactor: implement new playback method for playbutton (wip)\n- ui: improve glass texture\n- ui: implement new appBar #284\n- feat: display sdr and hdr only videoRange\n- style: improve hdr10 logo spacing\n- chore: update title-movie screenshot in README.md\n- chore: update title-movie.png\n- fix: hdr10 icon height not matching\n- style: update mediainfo icons\n- style: update mediainfo icons\n- fix: no subtitle option not selecting\n- feat: use brand logo for hdr10plus\n- fix: default subtitle not being selected properly\n- style: display backdrops in boxset\n- fix: videoPlayer not exiting if subtitles are disabled\n- chore: add kitsu icon to iconLink\n- fix: carousel not rendering\n- chore: update readme\n- chore: update screenshots\n- fix: improve hdr10+ detection\n- feat: add quality and audio brand labels\n- style: improve page-margin\n- fix(player): unable to play media without subtitles\n- fix: album not displaying if no parent backdrop is found\n- chore: add screenshots and some features of JellyPlayer #242\n- chore: upload screenshots\n- fix(nsis): nsis setup images not displaying correctly\n- style: Improve titlePage styling\n- style: change cardText styling\n- style: Improve overall app component paddings and margins and rollback vite to 5.1.6\n- chore(deps): update dependency vite to v5.2.6 (#286)\n- fix(deps): update material-ui monorepo (#270)\n- fix(deps): update dependency @types/node to v20.11.29 (#292)\n- fix(deps): update dependency @types/react to v18.2.67 (#293)\n- fix(deps): update tanstack-query monorepo to v5.28.6 (#271)\n- fix(deps): update dependency @types/react to v18.2.67 (#272)\n- fix(deps): update dependency @types/node to v20.11.29 (#274)\n- fix(deps): update dependency framer-motion to v11.0.15 (#278)\n- fix(deps): update dependency typescript to v5.4.3 (#287)\n- fix(deps): update dependency material-symbols to v0.17.1 (#289)\n- chore(deps): update dependency @biomejs/biome to v1.6.2 (#290)\n- fix(deps): update rust crate log to ^0.4.21 (#276)\n- chore: update latest.json",
|
"notes": "\n- chore(deps): update dependencies\n- refactor: change UI of login/list and fix Api not being defined in context\n- fix: player/audio route not able to interact with audioPlayer\n- fix: audio player info not visible\n- fix: audio player not playing audio\n- fix: toggling ssubtitles not working\n- fix: subtitles not being rendered #401\n- fix: hero carousel indicators not scrolling\n- fix: vite build error for safari13\n- fix: blink not launching or rendering on opening\n- Merge branch 'main' of https://github.com/prayag17/JellyPlayer\n- chore(deps): update dependencies\n- Merge pull request #410 from prayag17/renovate/tauri-plugin-notification-2.x-lockfile\n- Merge pull request #409 from Blackspirits/patch-1\n- chore(deps): update dependencies\n- fix(deps): update rust crate tauri-plugin-notification to v2.0.1\n- feat: allow downloading images from ImageViewer\n- Update index.tsx\n- feat: implement basic image viewer #338 #240\n- fix: react infinite depth error\n- fix: vite config\n- refactor: remove @million/js and @million/lint\n- refactor: remove Cargo.lock from .gitignore #400\n- chore(deps): update dependencies\n- refactor: code cleanup\n- fix: bug_report showing extra fields\n- refactor: remove redundant calls for getCurrentUser\n- feat: show queue item from currently playing item in queueButton\n- chore(deps): update dependencies\n- feat: remember library filters #192\n- Merge pull request #370 from prayag17/renovate/tauri-apps-plugin-clipboard-manager-2.x\n- fix(deps): update dependency @tauri-apps/plugin-clipboard-manager to v2.1.0-beta.6\n- Merge pull request #381 from prayag17/renovate/wavesurfer.js-7.x-lockfile\n- Merge pull request #342 from prayag17/renovate/tanstack-router-monorepo\n- Merge pull request #368 from prayag17/renovate/tauri-monorepo\n- chore(release): update latest.json",
|
||||||
"pub_date": "2024-09-06T20:40:35.324Z",
|
"pub_date": "2024-11-20T07:04:53.965Z",
|
||||||
"platforms": {
|
"platforms": {
|
||||||
"darwin-aarch64": {
|
"darwin-aarch64": {
|
||||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1VsZ01leXRhMXFrek9ENWZCWHZPR3Y1Ky9SZ3BOc2hEeFlMU0pVR1gzL1NNdytOL1hGTzU5enpZNVRlY01JaDNjaTN3azdDMU9BcVVUWEg5RzdOY1FvPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzI1NjU0NzUzCWZpbGU6QmxpbmsuYXBwLnRhci5negphcUh0QXFNUnBEWUFGZGU3V0pzQXN5eXhzSmNOdzNoSDFLV3BlbHNGKzFvWXpJR0V4UmJoYTNNV0tZZ0VKcHdDbERxWFpEYk5kUVVxZWFnWnIrSThBUT09Cg==",
|
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL2RHaC9wc3VMQzJxeFRYaHVVN0xEZW91WWgwZkluYkYrdW5hUWl2UFlSeEUyRk93dm13WUdmQVZETWhmNW9MZ2lPUFdOdERzbGFibkpPNHJWMU1BYlFrPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzMyMDg1ODYyCWZpbGU6QmxpbmsuYXBwLnRhci5negpjK0VIaW9oVzlrUU92UWZudzcvRGlZNExwM0NOdmpHVGd1QUc2WWZ0bnRkU2NsWkdqQUJrR01ucVVRTktvR0RaV0l0L09KQ2luZHNUdjMvTGVlM2RCUT09Cg==",
|
||||||
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.6-dev/Blink_aarch64.app.tar.gz"
|
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.7-dev/Blink_aarch64.app.tar.gz"
|
||||||
},
|
},
|
||||||
"linux-x86_64": {
|
"linux-x86_64": {
|
||||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1JtYjlPdWJ2WngrU21iV1ZSd3BCWjBSdDVxT0VGcSs5VFZ0YUs1eFlIbnNlUnN1VzJLOUg4K25sdVRWUzhkR0VJWDBIa081R01aUyt4S3VQZHlSQ3d3PQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzI1NjU1MTAxCWZpbGU6QmxpbmtfMC4wLjYtZGV2X2FtZDY0LkFwcEltYWdlLnRhci5nego4ZllLcnRyWW5FM0JRY0dZUkJocFdsNlRzdjdnY3dDUFpGSENNSVNwdkRMZStvZWZTSlFLL25IR1A3a2pzdTlBUjNveVJ5VDFqYkxJdWF5MWFFeWxDdz09Cg==",
|
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1hKZGoxZFUvZzl5SmNnUEFRTGQ2TmFNMlphK25lTU9MTjJEM0JYQWt0Sy91Um9yRmk4QTl6dEtUSmRuRmFNODRwajJ2YW4rTGJzYVZjcmhFb1IxZkFnPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzMyMDg2MTQxCWZpbGU6QmxpbmtfMC4wLjctZGV2X2FtZDY0LkFwcEltYWdlCndKZURUdjF0bkNna1VCVDNEMFNodEZBZGkzZFBKVWx2cThSNE5najBmd2U5Rzh5SDFIbUxqRHlKOWdxMnY2QU9NdTRiQmtWY2VVaVlhNjRrNDVHMUFRPT0K",
|
||||||
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.6-dev/Blink_0.0.6-dev_amd64.AppImage.tar.gz"
|
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.7-dev/Blink_0.0.7-dev_amd64.AppImage"
|
||||||
},
|
},
|
||||||
"windows-x86_64": {
|
"windows-x86_64": {
|
||||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL2F4bGtQUmxDVjZadzRuNHk0RTd5RmRJbmVsOEwxaTV1U3FzZHAveEhiU0xmcGx2N0toaUR4alRiS2lmTTU0QStHc2JzT2diR1JjRm5VZU1SUWFuS0F3PQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzI1NjU1MjMyCWZpbGU6QmxpbmtfMC4wLjYtZGV2X3g2NC1zZXR1cC5uc2lzLnppcApPdk5zQ0NFcFQySXNjck8zTEM4SitwdTV6UXRKYnpPKzBJQnVJRDkxWjdqWGgwaXBSb1k0aGMvVEhwWWhBTEJzZHRhVy9KU0lCbjl2bG45WUJxOUlBZz09Cg==",
|
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1MwRVJ0UXBUUEYvd01JbXhBalFwQ0w5bEdkZkdlblZNeW1EMXQxajhYeVd0cERWcnhWOWFOaXV4Q0hDU1VRTEhabXF1ekFIbzB0KzRmL0pxdEIzMEFrPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzMyMDg2Mjg5CWZpbGU6QmxpbmtfMC4wLjctZGV2X3g2NC1zZXR1cC5uc2lzLnppcApJMmRORUFhV3NKV3BCTTliQkIwcWtSZStKTzEwY002QndCWmxKb0ZRd2p2K0cvek90dmdsbmQ0MHhNOVJsWnE3Y29qQmNDckdxdUNabWpTWjJ3d0xBUT09Cg==",
|
||||||
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.6-dev/Blink_0.0.6-dev_x64-setup.nsis.zip"
|
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.7-dev/Blink_0.0.7-dev_x64-setup.nsis.zip"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+28
-23
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "blink",
|
"name": "blink",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.7-dev",
|
"version": "1.0.0-alpha.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --force && tsr watch",
|
"dev": "vite --force && tsr watch",
|
||||||
@@ -13,23 +13,26 @@
|
|||||||
"tanstack-router-dev": "tsr watch"
|
"tanstack-router-dev": "tsr watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.1.0",
|
"@dnd-kit/core": "^6.2.0",
|
||||||
"@dnd-kit/modifiers": "^7.0.0",
|
"@dnd-kit/modifiers": "^8.0.0",
|
||||||
"@dnd-kit/sortable": "^8.0.0",
|
"@dnd-kit/sortable": "^9.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.5",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.5",
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.1.1",
|
"@fontsource-variable/jetbrains-mono": "^5.1.1",
|
||||||
"@fontsource-variable/noto-sans": "^5.1.0",
|
"@fontsource-variable/noto-sans": "^5.1.0",
|
||||||
|
"@fontsource-variable/plus-jakarta-sans": "^5.1.0",
|
||||||
|
"@fontsource-variable/space-grotesk": "^5.1.0",
|
||||||
"@jellyfin/sdk": "0.11.0",
|
"@jellyfin/sdk": "0.11.0",
|
||||||
"@million/lint": "^1.0.12",
|
"@million/lint": "^1.0.13",
|
||||||
"@mui/lab": "6.0.0-beta.15",
|
"@mui/lab": "6.0.0-beta.17",
|
||||||
"@mui/material": "6.1.7",
|
"@mui/material": "6.1.9",
|
||||||
|
"@popperjs/core": "^2.11.8",
|
||||||
"@react-spring/web": "^9.7.5",
|
"@react-spring/web": "^9.7.5",
|
||||||
"@tanem/react-nprogress": "^5.0.53",
|
"@tanem/react-nprogress": "^5.0.53",
|
||||||
"@tanstack/react-query": "^5.60.6",
|
"@tanstack/react-query": "^5.62.0",
|
||||||
"@tanstack/react-query-devtools": "^5.60.6",
|
"@tanstack/react-query-devtools": "^5.62.0",
|
||||||
"@tanstack/react-router": "^1.82.1",
|
"@tanstack/react-router": "^1.85.0",
|
||||||
"@tanstack/react-virtual": "^3.10.9",
|
"@tanstack/react-virtual": "^3.10.9",
|
||||||
"@tauri-apps/api": "2.1.1",
|
"@tauri-apps/api": "2.1.1",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.6",
|
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.6",
|
||||||
@@ -39,17 +42,17 @@
|
|||||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||||
"@tauri-apps/plugin-updater": "2.0.0",
|
"@tauri-apps/plugin-updater": "2.0.0",
|
||||||
"@tauri-apps/plugin-upload": "2.1.0",
|
"@tauri-apps/plugin-upload": "2.1.0",
|
||||||
"@types/node": "^22.9.1",
|
"@types/node": "^22.10.1",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.1",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.8",
|
||||||
"axios-tauri-api-adapter": "^2.0.3",
|
"axios-tauri-api-adapter": "^2.0.3",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"framer-motion": "^11.11.17",
|
"framer-motion": "^11.12.0",
|
||||||
"immer": "^10.1.1",
|
"immer": "^10.1.1",
|
||||||
"jassub": "^1.7.17",
|
"jassub": "^1.7.17",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"material-symbols": "^0.27.0",
|
"material-symbols": "^0.27.1",
|
||||||
"million": "^3.1.11",
|
"million": "^3.1.11",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
@@ -58,28 +61,30 @@
|
|||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-error-boundary": "^4.1.2",
|
"react-error-boundary": "^4.1.2",
|
||||||
|
"react-intersection-observer": "^9.13.1",
|
||||||
"react-markdown": "^9.0.1",
|
"react-markdown": "^9.0.1",
|
||||||
"react-multi-carousel": "^2.8.5",
|
"react-multi-carousel": "^2.8.5",
|
||||||
"react-player": "^2.16.0",
|
"react-player": "^2.16.0",
|
||||||
|
"react-popper": "^2.3.0",
|
||||||
"react-use-konami": "^1.1.0",
|
"react-use-konami": "^1.1.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.0",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.7.2",
|
||||||
"vite-plugin-svgr": "^4.3.0",
|
"vite-plugin-svgr": "^4.3.0",
|
||||||
"wavesurfer.js": "^7.8.8",
|
"wavesurfer.js": "^7.8.10",
|
||||||
"zustand": "5.0.1"
|
"zustand": "5.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.25.9",
|
"@babel/plugin-proposal-optional-chaining-assign": "^7.25.9",
|
||||||
"@biomejs/biome": "^1.9.4",
|
"@biomejs/biome": "^1.9.4",
|
||||||
"@tanstack/router-cli": "^1.81.9",
|
"@tanstack/router-cli": "^1.84.4",
|
||||||
"@tanstack/router-devtools": "^1.82.1",
|
"@tanstack/router-devtools": "^1.85.0",
|
||||||
"@tanstack/router-vite-plugin": "^1.81.9",
|
"@tanstack/router-vite-plugin": "^1.84.4",
|
||||||
"@tauri-apps/cli": "2.1.0",
|
"@tauri-apps/cli": "2.1.0",
|
||||||
"@types/lodash": "^4.17.13",
|
"@types/lodash": "^4.17.13",
|
||||||
"@vitejs/plugin-react": "^4.3.3",
|
"@vitejs/plugin-react": "^4.3.4",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"sass": "^1.81.0",
|
"sass": "^1.81.0",
|
||||||
"vite": "^5.4.11"
|
"vite": "^6.0.2"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only"
|
"license": "GPL-3.0-only"
|
||||||
}
|
}
|
||||||
Generated
+833
-592
File diff suppressed because it is too large.
Load diff
Generated
+6
-6
@@ -390,7 +390,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blink"
|
name = "blink"
|
||||||
version = "0.0.7-dev"
|
version = "1.0.0-alpha.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"portpicker",
|
"portpicker",
|
||||||
@@ -2460,7 +2460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3828,9 +3828,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.16"
|
version = "0.23.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e"
|
checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"ring",
|
"ring",
|
||||||
@@ -4002,9 +4002,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.132"
|
version = "1.0.133"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
|
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa 1.0.11",
|
"itoa 1.0.11",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "blink"
|
name = "blink"
|
||||||
version = "0.0.7-dev"
|
version = "1.0.0-alpha.3"
|
||||||
description = "A Modern Jellyfin Client"
|
description = "A Modern Jellyfin Client"
|
||||||
authors = ["prayag17", "JellyPlayer contributors (https://github.com/prayag17/JellyPlayer/graphs/contributors)"]
|
authors = ["prayag17", "Blink contributors (https://github.com/prayag17/Blink/graphs/contributors)"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
repository = "https://github.com/prayag17/JellyPlayer/"
|
repository = "https://github.com/prayag17/Blink/"
|
||||||
default-run = "blink"
|
default-run = "blink"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.59"
|
rust-version = "1.59"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"notification:default",
|
"notification:default",
|
||||||
"core:webview:allow-internal-toggle-devtools",
|
"core:webview:allow-internal-toggle-devtools",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"upload:allow-download"
|
"upload:allow-download",
|
||||||
|
"clipboard-manager:allow-write-text"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
{"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen"]}}
|
{"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download","clipboard-manager:allow-write-text"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen"]}}
|
||||||
@@ -18,5 +18,5 @@ fn main() {
|
|||||||
.plugin(tauri_plugin_updater::Builder::default().build())
|
.plugin(tauri_plugin_updater::Builder::default().build())
|
||||||
// .plugin(tauri_plugin_window_state::Builder::default().build())
|
// .plugin(tauri_plugin_window_state::Builder::default().build())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running JellyPlayer");
|
.expect("error while running Blink");
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
|
||||||
"build": {
|
"build": {
|
||||||
"beforeBuildCommand": "pnpm run build",
|
"beforeBuildCommand": "pnpm run build",
|
||||||
"beforeDevCommand": "pnpm run dev",
|
"beforeDevCommand": "pnpm run dev",
|
||||||
@@ -59,7 +58,11 @@
|
|||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZEMTg0MjEzRDYzRjJDN0EKUldSNkxEL1dFMElZL1dxbHA0V2lyVDFEdGpOZXkxMG9XdHVLVnRpVVV5c1Z0OFNRUE45dkpxbFAK",
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZEMTg0MjEzRDYzRjJDN0EKUldSNkxEL1dFMElZL1dxbHA0V2lyVDFEdGpOZXkxMG9XdHVLVnRpVVV5c1Z0OFNRUE45dkpxbFAK",
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
"https://rawcdn.githack.com/prayag17/Blink/refs/heads/main/latest.json"
|
"https://rawcdn.githack.com/prayag17/Blink/refs/heads/main/latest.json"
|
||||||
]
|
],
|
||||||
|
"windows": {
|
||||||
|
"installMode": "passive"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB |
@@ -0,0 +1,135 @@
|
|||||||
|
import { setServer } from "@/utils/storage/servers";
|
||||||
|
import { jellyfin } from "@/utils/store/api";
|
||||||
|
import { LoadingButton } from "@mui/lab";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogTitle,
|
||||||
|
TextField,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import { enqueueSnackbar } from "notistack";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
type AddServerDialogProps = {
|
||||||
|
open: boolean;
|
||||||
|
setAddServerDialog: (value: boolean) => void;
|
||||||
|
sideEffect?: () => Promise<unknown>;
|
||||||
|
hideBackdrop?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AddServerDialog(props: AddServerDialogProps) {
|
||||||
|
const { open, setAddServerDialog, sideEffect, hideBackdrop } = props;
|
||||||
|
|
||||||
|
const [serverIp, setServerIp] = useState("");
|
||||||
|
const addServer = useMutation({
|
||||||
|
mutationKey: ["add-server"],
|
||||||
|
mutationFn: async () => {
|
||||||
|
const servers =
|
||||||
|
await jellyfin.discovery.getRecommendedServerCandidates(serverIp);
|
||||||
|
const bestServer = jellyfin.discovery.findBestServer(servers);
|
||||||
|
return bestServer;
|
||||||
|
},
|
||||||
|
onSuccess: async (bestServer) => {
|
||||||
|
if (bestServer) {
|
||||||
|
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||||
|
setAddServerDialog(false);
|
||||||
|
enqueueSnackbar(
|
||||||
|
"Client added successfully. You might need to refresh client list.",
|
||||||
|
{
|
||||||
|
variant: "success",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (sideEffect) {
|
||||||
|
await sideEffect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (err) => {
|
||||||
|
console.error(err);
|
||||||
|
enqueueSnackbar(`${err}`, { variant: "error" });
|
||||||
|
enqueueSnackbar("Something went wrong", { variant: "error" });
|
||||||
|
},
|
||||||
|
onSettled: async (bestServer) => {
|
||||||
|
if (!bestServer) {
|
||||||
|
enqueueSnackbar("Provided server address is not a Jellyfin server.", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
hideBackdrop={Boolean(hideBackdrop)}
|
||||||
|
fullWidth
|
||||||
|
maxWidth="sm"
|
||||||
|
disableScrollLock={true}
|
||||||
|
>
|
||||||
|
<DialogTitle variant="h4" align="center" mb={1}>
|
||||||
|
Add Server
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent className="settings-server-add">
|
||||||
|
<TextField
|
||||||
|
variant="filled"
|
||||||
|
label="Address"
|
||||||
|
fullWidth
|
||||||
|
onChange={(e) => setServerIp(e.target.value)}
|
||||||
|
/>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions
|
||||||
|
style={{
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
padding: "1em",
|
||||||
|
gap: "1em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
startIcon={
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
marginRight: "0.25em",
|
||||||
|
fontVariationSettings:
|
||||||
|
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
cancel
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
color="error"
|
||||||
|
onClick={() => setAddServerDialog(false)}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
{/* @ts-ignore */}
|
||||||
|
<LoadingButton
|
||||||
|
startIcon={
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
marginRight: "0.25em",
|
||||||
|
fontVariationSettings:
|
||||||
|
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
add_circle
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
variant="contained"
|
||||||
|
loading={addServer.isPending}
|
||||||
|
loadingPosition="start"
|
||||||
|
onClick={addServer.mutate}
|
||||||
|
color="success"
|
||||||
|
>
|
||||||
|
Add
|
||||||
|
</LoadingButton>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
.item-info-track{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3em 60% 6em 1fr;
|
||||||
|
gap: 1em;
|
||||||
|
padding: 1em;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
transition: background $transition-time-fast;
|
||||||
|
&.header {
|
||||||
|
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
||||||
|
color: rgb(255 255 255 / 0.7);
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
|
.index-container {
|
||||||
|
justify-self: center;
|
||||||
|
position: relative;
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 2em !important;
|
||||||
|
opacity: 0;
|
||||||
|
transition: none !important;
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.1em
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1) !important;
|
||||||
|
.index-container {
|
||||||
|
// font-size: 0em;
|
||||||
|
.index {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0;
|
||||||
|
}
|
||||||
|
.material-symbols-rounded {
|
||||||
|
opacity: 1;
|
||||||
|
font-size: 2.2em !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.playing {
|
||||||
|
background: rgb(0 0 0 / 0.4) !important;
|
||||||
|
.item-info-track-info-name, .index {
|
||||||
|
color: $clr-accent-default;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4em
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import {
|
||||||
|
generateAudioStreamUrl,
|
||||||
|
playAudio,
|
||||||
|
useAudioPlayback,
|
||||||
|
} from "@/utils/store/audioPlayback";
|
||||||
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
BaseItemDtoQueryResult,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { setQueue } from "@/utils/store/queue";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||||
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
|
||||||
|
import "./albumMusicTrack.scss";
|
||||||
|
|
||||||
|
type AlbumMusicTrackProps = {
|
||||||
|
track: BaseItemDto;
|
||||||
|
/**
|
||||||
|
* This is the index of the track in the musicTracks array (not to be confused with IndexNumber property of the track)
|
||||||
|
*/
|
||||||
|
trackIndex: number;
|
||||||
|
musicTracks: BaseItemDtoQueryResult | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
||||||
|
const { track, musicTracks, trackIndex } = props;
|
||||||
|
const [currentPlayingItem] = useAudioPlayback((state) => [state.item]);
|
||||||
|
|
||||||
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
const handlePlayback = (
|
||||||
|
index: number,
|
||||||
|
item: BaseItemDto,
|
||||||
|
queue: BaseItemDto[],
|
||||||
|
) => {
|
||||||
|
if (!user?.Id || !api) {
|
||||||
|
console.error("User not logged in");
|
||||||
|
enqueueSnackbar("You need to be logged in to play music", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.Id) {
|
||||||
|
const url = generateAudioStreamUrl(
|
||||||
|
item.Id,
|
||||||
|
user.Id,
|
||||||
|
api.deviceInfo.id,
|
||||||
|
api.basePath,
|
||||||
|
api.accessToken,
|
||||||
|
);
|
||||||
|
playAudio(url, item);
|
||||||
|
setQueue(queue, index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
currentPlayingItem?.Id === track.Id
|
||||||
|
? "item-info-track playing"
|
||||||
|
: "item-info-track"
|
||||||
|
}
|
||||||
|
key={track.Id}
|
||||||
|
onClick={() => {
|
||||||
|
if (musicTracks?.Items) {
|
||||||
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="index-container">
|
||||||
|
<span className="material-symbols-rounded fill ">play_arrow</span>
|
||||||
|
<Typography className="index">{track.IndexNumber ?? "-"}</Typography>
|
||||||
|
</div>
|
||||||
|
<div className="item-info-track-info">
|
||||||
|
<Typography className="item-info-track-info-name">
|
||||||
|
{track.Name}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
style={{
|
||||||
|
opacity: 0.6,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "0.6em",
|
||||||
|
}}
|
||||||
|
fontWeight={300}
|
||||||
|
>
|
||||||
|
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
||||||
|
{track.Artists?.join(", ")}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<Typography>{getRuntimeMusic(track.RunTimeTicks ?? 0)}</Typography>
|
||||||
|
<div className="flex flex-align-center">
|
||||||
|
<LikeButton
|
||||||
|
itemId={track.Id}
|
||||||
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
|
queryKey={["item", "musicTracks"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={track.Name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
import React, { useCallback, useMemo, type ReactNode } from "react";
|
import React, {
|
||||||
|
type MouseEventHandler,
|
||||||
|
useCallback,
|
||||||
|
useMemo,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import MuiAppBar from "@mui/material/AppBar";
|
import MuiAppBar from "@mui/material/AppBar";
|
||||||
@@ -9,7 +14,12 @@ import Menu from "@mui/material/Menu";
|
|||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||||
|
|
||||||
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
import {
|
||||||
|
Link,
|
||||||
|
useLocation,
|
||||||
|
useNavigate,
|
||||||
|
useRouter,
|
||||||
|
} from "@tanstack/react-router";
|
||||||
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||||
|
|
||||||
@@ -74,22 +84,31 @@ const MemoizeBackButton = React.memo(BackButton);
|
|||||||
|
|
||||||
export const AppBar = () => {
|
export const AppBar = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const createApi = useApiInContext((s) => s.createApi);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [display, setDisplay] = useState(false);
|
const [display, setDisplay] = useState(false);
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const [user, resetCurrentUser] = useCentralStore((s) => [
|
||||||
|
s.currentUser,
|
||||||
|
s.resetCurrentUser,
|
||||||
|
]);
|
||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!user?.Id || !api?.accessToken) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
});
|
});
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id && !!api.accessToken,
|
enabled: !!user?.Id && !!api?.accessToken,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,11 +117,14 @@ export const AppBar = () => {
|
|||||||
threshold: 20,
|
threshold: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||||
const openMenu = Boolean(anchorEl);
|
const openMenu = Boolean(anchorEl);
|
||||||
const handleMenuOpen = useCallback((event) => {
|
const handleMenuOpen: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||||
setAnchorEl(event.currentTarget);
|
(event) => {
|
||||||
}, []);
|
setAnchorEl(event.currentTarget);
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
const handleMenuClose = useCallback(() => {
|
const handleMenuClose = useCallback(() => {
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -110,9 +132,13 @@ export const AppBar = () => {
|
|||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
console.log("Logging out user...");
|
console.log("Logging out user...");
|
||||||
await api.logout();
|
await api?.logout();
|
||||||
|
createApi(api?.basePath ?? "", undefined);
|
||||||
|
console.log(api);
|
||||||
|
resetCurrentUser();
|
||||||
delUser();
|
delUser();
|
||||||
sessionStorage.removeItem("accessToken");
|
sessionStorage.removeItem("accessToken");
|
||||||
|
await router.invalidate();
|
||||||
queryClient.clear();
|
queryClient.clear();
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
navigate({ to: "/login" });
|
navigate({ to: "/login" });
|
||||||
@@ -224,7 +250,7 @@ export const AppBar = () => {
|
|||||||
) : (
|
) : (
|
||||||
<Avatar
|
<Avatar
|
||||||
className="appBar-avatar"
|
className="appBar-avatar"
|
||||||
src={`${api.basePath}/Users/${user?.Id}/Images/Primary`}
|
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||||
alt={user?.Name ?? "image"}
|
alt={user?.Name ?? "image"}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||||
@@ -303,7 +329,7 @@ export const AppBar = () => {
|
|||||||
<List>
|
<List>
|
||||||
<ListItemLink to="/home" icon="home" primary="Home" />
|
<ListItemLink to="/home" icon="home" primary="Home" />
|
||||||
{libraries.isSuccess &&
|
{libraries.isSuccess &&
|
||||||
libraries.data.Items?.map((library) => (
|
libraries.data?.Items?.map((library) => (
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
key={library.Id}
|
key={library.Id}
|
||||||
to={`/library/${library.Id}`}
|
to={`/library/${library.Id}`}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
import AppBar from "@mui/material/AppBar";
|
import AppBar from "@mui/material/AppBar";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import { useRouter } from "@tanstack/react-router";
|
import { useLocation, useRouter } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import QuickConnectButton from "../buttons/quickConnectButton";
|
import QuickConnectButton from "../buttons/quickConnectButton";
|
||||||
|
|
||||||
export const AppBarBackOnly = () => {
|
export default function AppBarBackOnly() {
|
||||||
const { history } = useRouter();
|
const { history } = useRouter();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
history.go(-1);
|
history.go(-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hideQuickConnect = location.pathname === "/setup/server/list";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar elevation={0} color="transparent" position="fixed">
|
<AppBar elevation={0} color="transparent" position="fixed">
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
@@ -27,14 +30,16 @@ export const AppBarBackOnly = () => {
|
|||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<QuickConnectButton
|
{!hideQuickConnect && (
|
||||||
sx={{
|
<QuickConnectButton
|
||||||
marginLeft: "auto",
|
sx={{
|
||||||
flex: "none !important",
|
marginLeft: "auto",
|
||||||
borderRadius: "10px",
|
flex: "none !important",
|
||||||
}}
|
borderRadius: "10px",
|
||||||
color="secondary"
|
}}
|
||||||
/>
|
color="secondary"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
|
|
||||||
import "./avatar.module.scss";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export const AvatarImage = ({ userId }) => {
|
|
||||||
const api = useRouteContext({ from: "/_api" }).api;
|
|
||||||
return (
|
|
||||||
<Box className="avatar-image-container">
|
|
||||||
<div
|
|
||||||
className="avatar-image"
|
|
||||||
style={{
|
|
||||||
backgroundImage: `url('${api.basePath}/Users/${userId}/Images/Primary')`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="avatar-image-icon-container">
|
|
||||||
<span className="material-symbols-rounded avatar-image-icon">
|
|
||||||
account_circle
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
AvatarImage.propType = {
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
userImageTags: PropTypes.any,
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import "./avatar.module.scss";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
|
export const AvatarImage = ({ userId }: { userId: string }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
if (!api) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="avatar-image-container">
|
||||||
|
<div
|
||||||
|
className="avatar-image"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url('${api.basePath}/Users/${userId}/Images/Primary')`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="avatar-image-icon-container">
|
||||||
|
<span className="material-symbols-rounded avatar-image-icon">
|
||||||
|
account_circle
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
|
import React, { useLayoutEffect, useState } from "react";
|
||||||
|
|
||||||
|
export default function Backdrop() {
|
||||||
|
const [backdropLoading, setBackdropLoading] = useState(true);
|
||||||
|
|
||||||
|
const [backdropId, backdropUrl] = useBackdropStore((state) => [
|
||||||
|
state.backdropId,
|
||||||
|
state.backdropUrl,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Reset loading status for backdrop
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
setBackdropLoading(true);
|
||||||
|
}, [backdropId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="app-backdrop-container">
|
||||||
|
<AnimatePresence>
|
||||||
|
<motion.img
|
||||||
|
key={backdropId}
|
||||||
|
src={backdropUrl}
|
||||||
|
alt=""
|
||||||
|
className="app-backdrop"
|
||||||
|
initial={{
|
||||||
|
opacity: 0,
|
||||||
|
}}
|
||||||
|
animate={{
|
||||||
|
opacity: backdropLoading ? 0 : 1,
|
||||||
|
}}
|
||||||
|
exit={{
|
||||||
|
opacity: 0,
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
opacity: {
|
||||||
|
duration: 1.2,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
onLoad={() => setBackdropLoading(false)}
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
</AnimatePresence>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ export default function BackButton() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={handleClick}>
|
<IconButton onClick={handleClick} disabled={history.length === 0}>
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,50 +1,57 @@
|
|||||||
import PropTypes from "prop-types";
|
import React from "react";
|
||||||
|
|
||||||
import React, { useEffect } from "react";
|
|
||||||
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import type { UserItemDataDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import { pink } from "@mui/material/colors";
|
import { pink } from "@mui/material/colors";
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => {
|
export default function LikeButton({
|
||||||
|
itemId,
|
||||||
|
isFavorite,
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
itemName,
|
||||||
|
}: {
|
||||||
|
itemId: string | undefined;
|
||||||
|
isFavorite: boolean | undefined;
|
||||||
|
queryKey: string[] | undefined;
|
||||||
|
userId: string | undefined;
|
||||||
|
itemName?: string | null;
|
||||||
|
}) {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const handleLiking = async () => {
|
const handleLiking = async () => {
|
||||||
let result = null;
|
let result: UserItemDataDto = null!;
|
||||||
|
if (!api) return;
|
||||||
|
if (!userId) return;
|
||||||
|
if (!itemId) return;
|
||||||
|
if (!itemName) return;
|
||||||
if (isFavorite) {
|
if (isFavorite) {
|
||||||
result = await getUserLibraryApi(api).unmarkFavoriteItem({
|
result = (
|
||||||
userId: userId,
|
await getUserLibraryApi(api).unmarkFavoriteItem({
|
||||||
itemId: itemId,
|
userId: userId,
|
||||||
});
|
itemId: itemId,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
} else if (!isFavorite) {
|
} else if (!isFavorite) {
|
||||||
result = await getUserLibraryApi(api).markFavoriteItem({
|
result = (
|
||||||
userId: userId,
|
await getUserLibraryApi(api).markFavoriteItem({
|
||||||
itemId: itemId,
|
userId: userId,
|
||||||
});
|
itemId: itemId,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
}
|
}
|
||||||
return result.data;
|
return result; // We need to return the result so that the onSettled function can invalidate the query
|
||||||
};
|
};
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
// mutationFn: async () => {
|
|
||||||
// new Promise((resolve, reject) => {
|
|
||||||
// setTimeout(() => {
|
|
||||||
// resolve("foo");
|
|
||||||
// }, 4000);
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
mutationFn: handleLiking,
|
mutationFn: handleLiking,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`${error}`, {
|
|
||||||
variant: "error",
|
|
||||||
});
|
|
||||||
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
@@ -76,27 +83,19 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => {
|
|||||||
style={
|
style={
|
||||||
isFavorite
|
isFavorite
|
||||||
? {
|
? {
|
||||||
|
//@ts-ignore
|
||||||
"--fill": mutation.isPending ? 0 : 1,
|
"--fill": mutation.isPending ? 0 : 1,
|
||||||
color: mutation.isPending ? "white" : pink.A700,
|
color: mutation.isPending ? "white" : pink.A700,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
|
//@ts-ignore
|
||||||
"--fill": mutation.isPending ? 1 : 0,
|
"--fill": mutation.isPending ? 1 : 0,
|
||||||
color: mutation.isPending ? pink.A700 : "white",
|
color: mutation.isPending ? pink.A700 : "white",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
favorite
|
favorite
|
||||||
</div>
|
</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
LikeButton.propTypes = {
|
|
||||||
itemId: PropTypes.string.isRequired,
|
|
||||||
isFavorite: PropTypes.bool.isRequired,
|
|
||||||
queryKey: PropTypes.any.isRequired,
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
itemName: PropTypes.string,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default LikeButton;
|
|
||||||
+24
-19
@@ -1,8 +1,5 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
|
||||||
import { green } from "@mui/material/colors";
|
import { green } from "@mui/material/colors";
|
||||||
@@ -10,10 +7,21 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
export default function MarkPlayedButton({
|
||||||
|
itemId,
|
||||||
|
isPlayed,
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
itemName,
|
||||||
|
}: {
|
||||||
|
itemId?: string;
|
||||||
|
isPlayed?: boolean;
|
||||||
|
queryKey?: string[];
|
||||||
|
userId?: string;
|
||||||
|
itemName?: string | null;
|
||||||
|
}) {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -21,6 +29,12 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
|
|
||||||
const handleMarking = async () => {
|
const handleMarking = async () => {
|
||||||
let result = null;
|
let result = null;
|
||||||
|
if (!api) return;
|
||||||
|
if (!api) return;
|
||||||
|
if (!userId) return;
|
||||||
|
if (!itemId) return;
|
||||||
|
if (!itemName) return;
|
||||||
|
|
||||||
if (!isPlayed) {
|
if (!isPlayed) {
|
||||||
result = await getPlaystateApi(api).markPlayedItem({
|
result = await getPlaystateApi(api).markPlayedItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -32,11 +46,11 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result; // We need to return the result so that the onSettled function can invalidate the query
|
||||||
};
|
};
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: handleMarking,
|
mutationFn: handleMarking,
|
||||||
onError: (error, a, context) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`${error}`, {
|
enqueueSnackbar(`${error}`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
@@ -73,21 +87,12 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
? "white"
|
? "white"
|
||||||
: green.A700
|
: green.A700
|
||||||
: mutation.isPending
|
: mutation.isPending
|
||||||
? green.A700
|
? green.A700
|
||||||
: "white",
|
: "white",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
done
|
done
|
||||||
</div>
|
</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
MarkPlayedButton.propTypes = {
|
|
||||||
itemId: PropTypes.string.isRequired,
|
|
||||||
isPlayed: PropTypes.bool.isRequired,
|
|
||||||
queryKey: PropTypes.any.isRequired,
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MarkPlayedButton;
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { memo, type MouseEvent } from "react"; // Import memo
|
||||||
import React, { memo } from "react"; // Import memo
|
|
||||||
|
|
||||||
import Button, {
|
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||||
type ButtonProps,
|
|
||||||
type ButtonPropsSizeOverrides,
|
|
||||||
} from "@mui/material/Button";
|
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
import LinearProgress from "@mui/material/LinearProgress";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
@@ -17,20 +13,18 @@ import {
|
|||||||
ItemFields,
|
ItemFields,
|
||||||
ItemFilter,
|
ItemFilter,
|
||||||
LocationType,
|
LocationType,
|
||||||
MediaProtocol,
|
type MediaSegmentDtoQueryResult,
|
||||||
type PlaybackInfoResponse,
|
type PlaybackInfoResponse,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
type UserItemDataDto,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getDlnaApi } from "@jellyfin/sdk/lib/utils/api/dlna-api";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
||||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import useQueue, { setQueue } from "@/utils/store/queue";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
|
|
||||||
import { playItem, usePlaybackDataLoadStore } from "@/utils/store/playback";
|
import { playItem, usePlaybackDataLoadStore } from "@/utils/store/playback";
|
||||||
|
|
||||||
@@ -38,29 +32,20 @@ import type PlayResult from "@//utils/types/playResult";
|
|||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
import getSubtitle from "@/utils/methods/getSubtitles";
|
import getSubtitle from "@/utils/methods/getSubtitles";
|
||||||
import playbackProfile from "@/utils/playback-profiles";
|
import playbackProfile from "@/utils/playback-profiles";
|
||||||
import { axiosClient, useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||||
import type IntroMediaInfo from "@/utils/types/introMediaInfo";
|
|
||||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { LoadingButton } from "@mui/lab";
|
||||||
import type { SxProps } from "@mui/material";
|
import type { SxProps } from "@mui/material";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
|
|
||||||
type PlayButtonProps = {
|
type PlayButtonProps = {
|
||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
itemId?: string;
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
itemUserData?: UserItemDataDto;
|
|
||||||
userId: string | undefined;
|
userId: string | undefined;
|
||||||
itemType: BaseItemKind;
|
itemType: BaseItemKind;
|
||||||
currentAudioTrack?: number;
|
currentAudioTrack?: number | "auto";
|
||||||
currentVideoTrack?: number;
|
currentVideoTrack?: number;
|
||||||
currentSubTrack?: number | "nosub";
|
currentSubTrack?: number | "nosub";
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -68,8 +53,8 @@ type PlayButtonProps = {
|
|||||||
buttonProps?: ButtonProps;
|
buttonProps?: ButtonProps;
|
||||||
iconOnly?: boolean;
|
iconOnly?: boolean;
|
||||||
audio?: boolean;
|
audio?: boolean;
|
||||||
size?: ButtonPropsSizeOverrides;
|
size?: "small" | "large" | "medium";
|
||||||
playlistItem?: BaseItemDto;
|
playlistItem?: boolean;
|
||||||
playlistItemId?: string;
|
playlistItemId?: string;
|
||||||
trackIndex?: number;
|
trackIndex?: number;
|
||||||
};
|
};
|
||||||
@@ -91,14 +76,13 @@ const MemoizedLinearProgress = memo(({ value }: { value: number }) => (
|
|||||||
zIndex: 0,
|
zIndex: 0,
|
||||||
mixBlendMode: "difference",
|
mixBlendMode: "difference",
|
||||||
}}
|
}}
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
const PlayButton = ({
|
const PlayButton = ({
|
||||||
item,
|
item,
|
||||||
itemId,
|
|
||||||
itemUserData,
|
|
||||||
userId,
|
userId,
|
||||||
itemType,
|
itemType,
|
||||||
currentAudioTrack,
|
currentAudioTrack,
|
||||||
@@ -112,7 +96,6 @@ const PlayButton = ({
|
|||||||
size = "large",
|
size = "large",
|
||||||
playlistItem,
|
playlistItem,
|
||||||
playlistItemId = "",
|
playlistItemId = "",
|
||||||
trackIndex,
|
|
||||||
}: PlayButtonProps) => {
|
}: PlayButtonProps) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
@@ -126,12 +109,18 @@ const PlayButton = ({
|
|||||||
|
|
||||||
const itemQuery = useMutation({
|
const itemQuery = useMutation({
|
||||||
mutationKey: ["playButton", item?.Id, userId],
|
mutationKey: ["playButton", item?.Id, userId],
|
||||||
mutationFn: async () => {
|
mutationFn: async (currentEpisodeId?: string) => {
|
||||||
setPlaybackDataLoading(true);
|
setPlaybackDataLoading(true);
|
||||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
||||||
let introInfo: undefined | IntroMediaInfo;
|
let introInfo: undefined | MediaSegmentDtoQueryResult;
|
||||||
const indexNumber = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
let index = 0;
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("API is not available");
|
||||||
|
}
|
||||||
|
if (!item.Id) {
|
||||||
|
throw new Error("Item ID is not available");
|
||||||
|
}
|
||||||
if (playlistItem) {
|
if (playlistItem) {
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -153,37 +142,61 @@ const PlayButton = ({
|
|||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
seasonId: item.SeasonId,
|
seasonId: item.SeasonId,
|
||||||
|
isMissing: false,
|
||||||
// startItemId: item.Id,
|
// startItemId: item.Id,
|
||||||
});
|
});
|
||||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
|
||||||
audioStreamIndex: currentAudioTrack,
|
if (
|
||||||
subtitleStreamIndex:
|
result.data.Items?.map((i) => i.Id).indexOf(
|
||||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
currentEpisodeId,
|
||||||
itemId: result.data.Items?.[indexNumber].Id,
|
) === -1
|
||||||
startTimeTicks:
|
) {
|
||||||
result.data.Items?.[indexNumber].UserData
|
throw new Error(
|
||||||
?.PlaybackPositionTicks,
|
`Episode having id ${currentEpisodeId} not found, index return -1`,
|
||||||
userId: userId,
|
);
|
||||||
mediaSourceId:
|
|
||||||
result.data.Items?.[indexNumber].MediaSources?.[0].Id,
|
|
||||||
playbackInfoDto: {
|
|
||||||
DeviceProfile: playbackProfile,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
introInfo = (
|
|
||||||
await axiosClient.get(
|
|
||||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)?.data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
|
index =
|
||||||
|
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ??
|
||||||
|
0;
|
||||||
|
if (currentAudioTrack === "auto") {
|
||||||
|
const defaultAudioStreamIndex =
|
||||||
|
result.data.Items?.[index].MediaSources?.[0]
|
||||||
|
.DefaultAudioStreamIndex;
|
||||||
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: result.data.Items?.[index]?.Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[index].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[index].MediaSources?.[0]?.Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: currentAudioTrack,
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: result.data.Items?.[index]?.Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[index].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[index].MediaSources?.[0]?.Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
introInfo = (
|
||||||
|
await getMediaSegmentsApi(api).getItemSegments({
|
||||||
|
itemId: result.data.Items?.[index]?.Id ?? "",
|
||||||
|
})
|
||||||
|
)?.data;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Series:
|
case BaseItemKind.Series:
|
||||||
@@ -198,45 +211,75 @@ const PlayButton = ({
|
|||||||
],
|
],
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
isMissing: false,
|
||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
result.data.Items?.[0].Id &&
|
currentEpisodeId &&
|
||||||
result.data.Items?.[0].MediaSources?.[0].Id
|
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ===
|
||||||
)
|
-1
|
||||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
) {
|
||||||
audioStreamIndex: currentAudioTrack,
|
throw new Error(
|
||||||
subtitleStreamIndex:
|
`Episode having id=${currentEpisodeId} not found, index return -1`,
|
||||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
);
|
||||||
itemId: result.data.Items?.[0].Id,
|
}
|
||||||
startTimeTicks:
|
if (!currentEpisodeId) {
|
||||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
index = 0;
|
||||||
userId: userId,
|
} else {
|
||||||
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id,
|
index =
|
||||||
playbackInfoDto: {
|
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ??
|
||||||
DeviceProfile: playbackProfile,
|
0;
|
||||||
},
|
}
|
||||||
});
|
if (
|
||||||
try {
|
result.data.Items?.[index].Id &&
|
||||||
introInfo = (
|
result.data.Items?.[index].MediaSources?.[0]?.Id
|
||||||
await axiosClient.get(
|
) {
|
||||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
if (currentAudioTrack === "auto") {
|
||||||
{
|
const defaultAudioStreamIndex =
|
||||||
headers: {
|
result.data.Items?.[index].MediaSources?.[0]
|
||||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
.DefaultAudioStreamIndex;
|
||||||
},
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: result.data.Items[index].Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
},
|
},
|
||||||
)
|
});
|
||||||
|
} else {
|
||||||
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: currentAudioTrack,
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: result.data.Items[index].Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
introInfo = (
|
||||||
|
await getMediaSegmentsApi(api).getItemSegments({
|
||||||
|
itemId: result.data.Items?.[index].Id ?? "",
|
||||||
|
})
|
||||||
)?.data;
|
)?.data;
|
||||||
} catch (error) {
|
} else {
|
||||||
console.error(error);
|
throw new Error(
|
||||||
|
`No media source id provieded for the episode. Return values are seriesId = ${result.data.Items?.[index].Id}, mediaSourceId = ${result.data.Items?.[index].MediaSources?.[0]?.Id}, index = ${index}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Playlist:
|
case BaseItemKind.Playlist:
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
|
||||||
userId: userId,
|
|
||||||
playlistId: playlistItemId,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicAlbum:
|
case BaseItemKind.MusicAlbum:
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
parentId: item.Id,
|
parentId: item.Id,
|
||||||
@@ -248,7 +291,7 @@ const PlayButton = ({
|
|||||||
break;
|
break;
|
||||||
case BaseItemKind.MusicArtist:
|
case BaseItemKind.MusicArtist:
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
artistIds: [item.Id],
|
artistIds: [item.Id ?? ""],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -270,16 +313,55 @@ const PlayButton = ({
|
|||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
sortBy: ["IndexNumber"],
|
sortBy: ["IndexNumber"],
|
||||||
});
|
});
|
||||||
|
if (
|
||||||
|
result.data.Items?.[index]?.Id &&
|
||||||
|
result.data.Items?.[index].MediaSources?.[0]?.Id
|
||||||
|
) {
|
||||||
|
if (currentAudioTrack === "auto") {
|
||||||
|
const defaultAudioStreamIndex =
|
||||||
|
result.data.Items?.[index].MediaSources?.[0]
|
||||||
|
.DefaultAudioStreamIndex;
|
||||||
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: result.data.Items?.[index].Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: currentAudioTrack,
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: result.data.Items?.[index].Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Photo:
|
case BaseItemKind.Photo:
|
||||||
if (item.Id) {
|
{
|
||||||
const photo = (
|
const photo = (
|
||||||
await getUserLibraryApi(api).getItem({
|
await getUserLibraryApi(api).getItem({
|
||||||
itemId: item.Id,
|
itemId: item.Id,
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
parentId: photo.ParentId,
|
parentId: photo.ParentId ?? "",
|
||||||
filters: [ItemFilter.IsNotFolder],
|
filters: [ItemFilter.IsNotFolder],
|
||||||
recursive: false,
|
recursive: false,
|
||||||
sortBy: ["SortName"],
|
sortBy: ["SortName"],
|
||||||
@@ -291,7 +373,7 @@ const PlayButton = ({
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
ids: [item.Id],
|
ids: [item.Id ?? ""],
|
||||||
userId: userId,
|
userId: userId,
|
||||||
fields: [
|
fields: [
|
||||||
ItemFields.MediaSources,
|
ItemFields.MediaSources,
|
||||||
@@ -302,37 +384,74 @@ const PlayButton = ({
|
|||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
sortBy: ["IndexNumber"],
|
sortBy: ["IndexNumber"],
|
||||||
});
|
});
|
||||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
if (currentAudioTrack === "auto") {
|
||||||
audioStreamIndex: currentAudioTrack,
|
const defaultAudioStreamIndex =
|
||||||
subtitleStreamIndex:
|
result.data.Items?.[index].MediaSources?.[0]
|
||||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
.DefaultAudioStreamIndex;
|
||||||
itemId: item.Id,
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
startTimeTicks:
|
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
subtitleStreamIndex:
|
||||||
userId: userId,
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id,
|
itemId: item.Id ?? "",
|
||||||
playbackInfoDto: {
|
startTimeTicks:
|
||||||
DeviceProfile: playbackProfile,
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
},
|
userId: userId,
|
||||||
});
|
mediaSourceId:
|
||||||
|
result.data.Items?.[0].MediaSources?.[0]?.Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||||
|
audioStreamIndex: currentAudioTrack,
|
||||||
|
subtitleStreamIndex:
|
||||||
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
|
itemId: item.Id ?? "",
|
||||||
|
startTimeTicks:
|
||||||
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
|
userId: userId,
|
||||||
|
mediaSourceId:
|
||||||
|
result.data.Items?.[0].MediaSources?.[0]?.Id ?? "",
|
||||||
|
playbackInfoDto: {
|
||||||
|
DeviceProfile: playbackProfile,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { item: result?.data, mediaSource: mediaSource?.data, introInfo };
|
return {
|
||||||
|
item: result?.data,
|
||||||
|
mediaSource: mediaSource?.data,
|
||||||
|
introInfo,
|
||||||
|
episodeIndex: index,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
onSuccess: (result: PlayResult | null) => {
|
onSuccess: (result: PlayResult | null) => {
|
||||||
if (trackIndex) {
|
if (!api) {
|
||||||
// Playlist Playback
|
console.error("API is not available");
|
||||||
enqueueSnackbar("Playlist playback is WIP", { variant: "info" });
|
enqueueSnackbar("API is not available", { variant: "error" });
|
||||||
} else if (audio) {
|
return;
|
||||||
|
}
|
||||||
|
if (!userId) {
|
||||||
|
console.error("User ID is not available");
|
||||||
|
enqueueSnackbar("User ID is not available", { variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!result?.item?.Items?.length) {
|
||||||
|
console.error("No items found");
|
||||||
|
enqueueSnackbar("No items found", { variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!result?.item?.Items?.[0]?.Id) {
|
||||||
|
console.error("No item ID found");
|
||||||
|
enqueueSnackbar("No item ID found", { variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audio) {
|
||||||
// Album/Individual audio track playback
|
// Album/Individual audio track playback
|
||||||
const urlOptions: Record<string, string> = {
|
|
||||||
deviceId: api?.deviceInfo.id,
|
|
||||||
//@ts-ignore
|
|
||||||
userId: userId,
|
|
||||||
api_key: api?.accessToken,
|
|
||||||
};
|
|
||||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
|
||||||
const playbackUrl = generateAudioStreamUrl(
|
const playbackUrl = generateAudioStreamUrl(
|
||||||
result?.item?.Items?.[0].Id,
|
result?.item?.Items?.[0].Id,
|
||||||
userId,
|
userId,
|
||||||
@@ -349,24 +468,47 @@ const PlayButton = ({
|
|||||||
navigate({ to: "/player/photos" });
|
navigate({ to: "/player/photos" });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const episodeIndex = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||||
|
console.error("No media source ID found");
|
||||||
|
enqueueSnackbar("No media source ID found", { variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const episodeIndex = result.episodeIndex;
|
||||||
|
|
||||||
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
||||||
const queue = result?.item.Items;
|
const queue = result?.item?.Items;
|
||||||
|
|
||||||
let itemName = item.Name;
|
let itemName = item.Name;
|
||||||
let episodeTitle = "";
|
let episodeTitle = "";
|
||||||
if (result?.item.Items?.[episodeIndex].SeriesId) {
|
if (result?.item?.Items?.[episodeIndex].SeriesId) {
|
||||||
itemName = result?.item.Items[episodeIndex].SeriesName;
|
itemName = result?.item.Items[episodeIndex].SeriesName;
|
||||||
episodeTitle = `S${result?.item.Items[episodeIndex].ParentIndexNumber ?? 0}:E${
|
episodeTitle = `S${result?.item.Items[episodeIndex].ParentIndexNumber ?? 0}:E${
|
||||||
result?.item.Items[episodeIndex].IndexNumber ?? 0
|
result?.item.Items[episodeIndex].IndexNumber ?? 0
|
||||||
} ${result?.item.Items[episodeIndex].Name}`;
|
} ${result?.item.Items[episodeIndex].Name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemType === "BoxSet") {
|
||||||
|
itemName = result.item.Items[0].Name;
|
||||||
|
}
|
||||||
|
|
||||||
// Subtitle
|
// Subtitle
|
||||||
const subtitle = getSubtitle(
|
const subtitle = getSubtitle(
|
||||||
currentSubTrack,
|
result.mediaSource.MediaSources?.[0].DefaultSubtitleStreamIndex ?? -1,
|
||||||
result?.mediaSource.MediaSources?.[0].MediaStreams,
|
result?.mediaSource?.MediaSources?.[0]?.MediaStreams,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
const audio = {
|
||||||
|
track:
|
||||||
|
result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex ?? 0,
|
||||||
|
allTracks: result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||||
|
(value) => value.Type === "Audio",
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
// URL generation
|
// URL generation
|
||||||
const urlOptions: URLSearchParams = {
|
const urlOptions: URLSearchParams = {
|
||||||
|
//@ts-ignore
|
||||||
Static: true,
|
Static: true,
|
||||||
tag: result?.mediaSource.MediaSources?.[0].ETag,
|
tag: result?.mediaSource.MediaSources?.[0].ETag,
|
||||||
mediaSourceId: result?.mediaSource.MediaSources?.[0].Id,
|
mediaSourceId: result?.mediaSource.MediaSources?.[0].Id,
|
||||||
@@ -381,28 +523,32 @@ const PlayButton = ({
|
|||||||
) {
|
) {
|
||||||
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
||||||
}
|
}
|
||||||
let playItemValue = item;
|
let playItemValue = result?.item?.Items?.[episodeIndex];
|
||||||
if (itemType === BaseItemKind.Movie) {
|
if (itemType === BaseItemKind.Movie) {
|
||||||
playItemValue = result?.item.Items?.[0];
|
playItemValue = result?.item?.Items?.[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const startPosition =
|
||||||
|
result?.item?.Items?.[episodeIndex].UserData?.PlaybackPositionTicks;
|
||||||
|
|
||||||
playItem(
|
playItem(
|
||||||
itemName,
|
itemName,
|
||||||
episodeTitle,
|
episodeTitle,
|
||||||
currentVideoTrack,
|
currentVideoTrack ?? 0,
|
||||||
currentAudioTrack,
|
Number(result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex),
|
||||||
result?.mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
result?.mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
||||||
playbackUrl,
|
playbackUrl,
|
||||||
userId,
|
userId ?? "",
|
||||||
item.UserData?.PlaybackPositionTicks,
|
startPosition,
|
||||||
item.RunTimeTicks,
|
result?.item?.Items?.[episodeIndex].RunTimeTicks,
|
||||||
playItemValue,
|
playItemValue ?? item,
|
||||||
queue,
|
queue,
|
||||||
episodeIndex,
|
episodeIndex,
|
||||||
result?.mediaSource.MediaSources?.[0]?.Id,
|
result?.mediaSource?.MediaSources?.[0]?.Id,
|
||||||
result?.mediaSource.PlaySessionId,
|
result?.mediaSource?.PlaySessionId,
|
||||||
subtitle,
|
subtitle,
|
||||||
result?.introInfo,
|
result?.introInfo,
|
||||||
|
audio,
|
||||||
);
|
);
|
||||||
navigate({ to: "/player" });
|
navigate({ to: "/player" });
|
||||||
}
|
}
|
||||||
@@ -417,17 +563,23 @@ const PlayButton = ({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const handleClick = (e) => {
|
const handleClick = (
|
||||||
|
e: MouseEvent<HTMLAnchorElement | MouseEvent>,
|
||||||
|
currentEpisodeId?: string | undefined,
|
||||||
|
) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
itemQuery.mutate();
|
itemQuery.mutate(currentEpisodeId);
|
||||||
};
|
};
|
||||||
if (iconOnly) {
|
if (iconOnly) {
|
||||||
return (
|
return (
|
||||||
|
//@ts-ignore
|
||||||
<Fab
|
<Fab
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label="Play"
|
aria-label="Play"
|
||||||
className={className}
|
className={className}
|
||||||
onClick={handleClick}
|
onClick={(e) =>
|
||||||
|
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||||
|
}
|
||||||
sx={sx}
|
sx={sx}
|
||||||
size={size}
|
size={size}
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
@@ -443,6 +595,116 @@ const PlayButton = ({
|
|||||||
</Fab>
|
</Fab>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemType === BaseItemKind.Series) {
|
||||||
|
const currentEpisode = useQuery({
|
||||||
|
queryKey: ["playButton", "currentEpisode", item?.Id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("API is not available");
|
||||||
|
}
|
||||||
|
if (!userId) {
|
||||||
|
throw new Error("User ID is not available");
|
||||||
|
}
|
||||||
|
if (!item.Id) {
|
||||||
|
throw new Error("Item ID is not available");
|
||||||
|
}
|
||||||
|
let data: BaseItemDtoQueryResult | null = null;
|
||||||
|
const continueWatching = await getItemsApi(api).getResumeItems({
|
||||||
|
userId: userId,
|
||||||
|
limit: 1,
|
||||||
|
mediaTypes: ["Video"],
|
||||||
|
parentId: item.Id,
|
||||||
|
enableUserData: true,
|
||||||
|
fields: [ItemFields.MediaStreams, ItemFields.MediaSources],
|
||||||
|
});
|
||||||
|
const nextUp = await getTvShowsApi(api).getNextUp({
|
||||||
|
userId: userId,
|
||||||
|
parentId: item.Id,
|
||||||
|
limit: 1,
|
||||||
|
});
|
||||||
|
if ((continueWatching.data.Items?.length ?? 0) > 0) {
|
||||||
|
data = continueWatching.data;
|
||||||
|
} else if ((nextUp.data.Items?.length ?? 0) > 0) {
|
||||||
|
data = nextUp.data;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
// enabled: itemType === BaseItemKind.Series,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="play-button"
|
||||||
|
style={{
|
||||||
|
width: "auto",
|
||||||
|
position: "relative",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LoadingButton
|
||||||
|
loading={currentEpisode.isPending}
|
||||||
|
className={className ?? "play-button"}
|
||||||
|
variant="contained"
|
||||||
|
onClick={(e) => handleClick(e, currentEpisode.data?.Items?.[0]?.Id)}
|
||||||
|
startIcon={
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded fill"
|
||||||
|
style={{
|
||||||
|
zIndex: 1,
|
||||||
|
fontSize: "2em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
play_arrow
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{...buttonProps}
|
||||||
|
sx={{
|
||||||
|
position: "relative",
|
||||||
|
overflow: "hidden",
|
||||||
|
}}
|
||||||
|
//@ts-ignore - white color is a custom color in the theme which mui's types don't know about
|
||||||
|
color="white"
|
||||||
|
size={size}
|
||||||
|
>
|
||||||
|
Watch S{currentEpisode.data?.Items?.[0].ParentIndexNumber ?? 1}E
|
||||||
|
{currentEpisode.data?.Items?.[0]?.IndexNumber ?? 1}
|
||||||
|
<MemoizedLinearProgress
|
||||||
|
//@ts-ignore
|
||||||
|
value={
|
||||||
|
100 >
|
||||||
|
(currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage ??
|
||||||
|
100) &&
|
||||||
|
(currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage ??
|
||||||
|
0) > 0
|
||||||
|
? currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</LoadingButton>
|
||||||
|
{(currentEpisode.data?.Items?.[0].UserData?.PlaybackPositionTicks ??
|
||||||
|
0) > 0 && (
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
opacity: 0.8,
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "-1.8em",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%)",
|
||||||
|
}}
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
|
{getRuntimeCompact(
|
||||||
|
(currentEpisode.data?.Items?.[0].RunTimeTicks ?? 0) -
|
||||||
|
(currentEpisode.data?.Items?.[0].UserData
|
||||||
|
?.PlaybackPositionTicks ?? 0),
|
||||||
|
)}{" "}
|
||||||
|
left
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="play-button"
|
className="play-button"
|
||||||
@@ -454,7 +716,9 @@ const PlayButton = ({
|
|||||||
<Button
|
<Button
|
||||||
className={className ?? "play-button"}
|
className={className ?? "play-button"}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={handleClick}
|
onClick={(e) =>
|
||||||
|
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||||
|
}
|
||||||
startIcon={
|
startIcon={
|
||||||
<div
|
<div
|
||||||
className="material-symbols-rounded fill"
|
className="material-symbols-rounded fill"
|
||||||
@@ -471,10 +735,11 @@ const PlayButton = ({
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
|
//@ts-ignore - white color is a custom color in the theme which mui's types don't know about
|
||||||
color="white"
|
color="white"
|
||||||
size={size}
|
size={size}
|
||||||
>
|
>
|
||||||
{itemUserData?.PlaybackPositionTicks
|
{item.UserData?.PlaybackPositionTicks
|
||||||
? "Continue Watching"
|
? "Continue Watching"
|
||||||
: item?.Type === "MusicAlbum" ||
|
: item?.Type === "MusicAlbum" ||
|
||||||
item?.Type === "Audio" ||
|
item?.Type === "Audio" ||
|
||||||
@@ -484,15 +749,16 @@ const PlayButton = ({
|
|||||||
? "Play Now"
|
? "Play Now"
|
||||||
: "Watch Now"}
|
: "Watch Now"}
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
|
//@ts-ignore
|
||||||
value={
|
value={
|
||||||
100 > itemUserData?.PlayedPercentage &&
|
100 > (item.UserData?.PlayedPercentage ?? 100) &&
|
||||||
itemUserData?.PlayedPercentage > 0
|
(item.UserData?.PlayedPercentage ?? 0) > 0
|
||||||
? itemUserData?.PlayedPercentage
|
? item.UserData?.PlayedPercentage
|
||||||
: 0
|
: 0
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
{itemUserData?.PlaybackPositionTicks > 0 && (
|
{(item.UserData?.PlaybackPositionTicks ?? 0) > 0 && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
@@ -504,7 +770,8 @@ const PlayButton = ({
|
|||||||
variant="caption"
|
variant="caption"
|
||||||
>
|
>
|
||||||
{getRuntimeCompact(
|
{getRuntimeCompact(
|
||||||
item.RunTimeTicks - itemUserData.PlaybackPositionTicks,
|
(item.RunTimeTicks ?? 0) -
|
||||||
|
(item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
left
|
left
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -4,23 +4,23 @@ import useQueue from "@/utils/store/queue";
|
|||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { IconButton } from "@mui/material";
|
import { IconButton } from "@mui/material";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const PlayNextButton = () => {
|
const PlayNextButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
const result = await getUserApi(api).getCurrentUser();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const navigate = useNavigate();
|
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
||||||
onError: (error) => [console.error(error)],
|
onError: (error) => console.error(error),
|
||||||
});
|
});
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
state.tracks,
|
state.tracks,
|
||||||
@@ -28,7 +28,7 @@ const PlayNextButton = () => {
|
|||||||
]);
|
]);
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={queueItems.length === currentItemIndex + 1}
|
disabled={queueItems?.length === currentItemIndex + 1}
|
||||||
onClick={() => handlePlayNext.mutate()}
|
onClick={() => handlePlayNext.mutate()}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
<span className="material-symbols-rounded">skip_next</span>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import useQueue from "@/utils/store/queue";
|
|||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { IconButton } from "@mui/material";
|
import { IconButton } from "@mui/material";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const PlayPreviousButton = () => {
|
const PlayPreviousButton = () => {
|
||||||
@@ -12,6 +11,7 @@ const PlayPreviousButton = () => {
|
|||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
const result = await getUserApi(api).getCurrentUser();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -21,10 +21,7 @@ const PlayPreviousButton = () => {
|
|||||||
mutationFn: () => playItemFromQueue("previous", user.data?.Id, api),
|
mutationFn: () => playItemFromQueue("previous", user.data?.Id, api),
|
||||||
onError: (error) => [console.error(error)],
|
onError: (error) => [console.error(error)],
|
||||||
});
|
});
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [currentItemIndex] = useQueue((state) => [state.currentItemIndex]);
|
||||||
state.tracks,
|
|
||||||
state.currentItemIndex,
|
|
||||||
]);
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={currentItemIndex === 0}
|
disabled={currentItemIndex === 0}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
const QueueButton = () => {
|
const QueueButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
state.tracks,
|
state.tracks,
|
||||||
state.currentItemIndex,
|
state.currentItemIndex,
|
||||||
@@ -25,6 +26,7 @@ const QueueButton = () => {
|
|||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
const result = await getUserApi(api).getCurrentUser();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -76,7 +78,7 @@ const QueueButton = () => {
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{queueItems[currentItemIndex]?.Id && (
|
{queueItems?.[currentItemIndex]?.Id && (
|
||||||
<>
|
<>
|
||||||
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
||||||
Currently Playing:
|
Currently Playing:
|
||||||
@@ -97,27 +99,34 @@ const QueueButton = () => {
|
|||||||
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
queueItems[currentItemIndex]?.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
queueItems[currentItemIndex]?.Id,
|
||||||
tag: queueItems[currentItemIndex].ImageTags?.Primary,
|
"Primary",
|
||||||
},
|
{
|
||||||
)}
|
tag: queueItems[currentItemIndex].ImageTags
|
||||||
|
?.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
||||||
?.length ?? -1) > 0 ? (
|
?.length ?? -1) > 0 ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
queueItems[currentItemIndex]?.AlbumId,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
queueItems?.[currentItemIndex]?.AlbumId ?? "",
|
||||||
tag: queueItems[currentItemIndex]
|
"Primary",
|
||||||
.AlbumPrimaryImageTag[0],
|
{
|
||||||
},
|
tag: queueItems?.[currentItemIndex]
|
||||||
)}
|
.AlbumPrimaryImageTag?.[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -134,6 +143,7 @@ const QueueButton = () => {
|
|||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translate(-50%,-50%)",
|
transform: "translate(-50%,-50%)",
|
||||||
fontSize: "2em",
|
fontSize: "2em",
|
||||||
|
//@ts-ignore
|
||||||
"--wght": "100",
|
"--wght": "100",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -163,14 +173,15 @@ const QueueButton = () => {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
{queueItems &&
|
||||||
.length > 0 && (
|
queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||||
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
.length > 0 && (
|
||||||
Queue:
|
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
||||||
</Typography>
|
Queue:
|
||||||
)}
|
</Typography>
|
||||||
|
)}
|
||||||
{queueItems
|
{queueItems
|
||||||
.slice(currentItemIndex + 1, queueItems.length - 1)
|
?.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||||
.map((item, index) => {
|
.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -191,25 +202,31 @@ const QueueButton = () => {
|
|||||||
{item.ImageTags?.Primary ? (
|
{item.ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item?.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item?.Id ?? "",
|
||||||
tag: item.ImageTags?.Primary,
|
"Primary",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.ImageTags?.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "image"}
|
alt={item.Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item?.AlbumId,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item?.AlbumId ?? "",
|
||||||
tag: item.AlbumPrimaryImageTag[0],
|
"Primary",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.AlbumPrimaryImageTag?.[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "image"}
|
alt={item.Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import useInterval from "@/utils/hooks/useInterval";
|
import useInterval from "@/utils/hooks/useInterval";
|
||||||
|
import { saveUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { LoadingButton, type LoadingButtonProps } from "@mui/lab";
|
import { LoadingButton, type LoadingButtonProps } from "@mui/lab";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -16,9 +18,10 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import type { TransitionProps } from "@mui/material/transitions";
|
import type { TransitionProps } from "@mui/material/transitions";
|
||||||
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, { useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
|
|
||||||
const Transition = React.forwardRef(function Transition(
|
const Transition = React.forwardRef(function Transition(
|
||||||
props: TransitionProps & {
|
props: TransitionProps & {
|
||||||
@@ -40,10 +43,20 @@ const Transition = React.forwardRef(function Transition(
|
|||||||
|
|
||||||
const QuickConnectButton = (props: LoadingButtonProps) => {
|
const QuickConnectButton = (props: LoadingButtonProps) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const createApi = useApiInContext((s) => s.createApi);
|
||||||
|
// if (!api) {
|
||||||
|
// console.error(
|
||||||
|
// "Unable to display quick connect button, api is not available",
|
||||||
|
// );
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
"X-Emby-Authorization": `MediaBrowser Client="${api?.clientInfo.name}", Device="${api?.deviceInfo.name}", DeviceId="${api?.deviceInfo.id}", Version="${api?.clientInfo.version}"`,
|
"X-Emby-Authorization": `MediaBrowser Client="${api?.clientInfo.name}", Device="${api?.deviceInfo.name}", DeviceId="${api?.deviceInfo.id}", Version="${api?.clientInfo.version}"`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const quickConnectEnabled = useQuery({
|
const quickConnectEnabled = useQuery({
|
||||||
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
||||||
queryFn: api
|
queryFn: api
|
||||||
@@ -54,18 +67,56 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const [quickConnectCode, setQuickConnectCode] = useState<string | null>();
|
const [quickConnectCode, setQuickConnectCode] = useState<string | null>();
|
||||||
|
const [quickConnectSecret, setQuickConnectSecret] = useState<string | null>();
|
||||||
|
const [checkForQuickConnect, setCheckForQuickConnect] = useState(false);
|
||||||
const [rememberUser, setRememberUser] = useState(true);
|
const [rememberUser, setRememberUser] = useState(true);
|
||||||
|
const authenticateUser = useMutation({
|
||||||
|
mutationKey: ["quick-connect-button", "authenticate-user"],
|
||||||
|
mutationFn: async () => {
|
||||||
|
if (api && quickConnectSecret) {
|
||||||
|
return await getUserApi(api).authenticateWithQuickConnect(
|
||||||
|
{ quickConnectDto: { Secret: quickConnectSecret } },
|
||||||
|
{ headers },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess: (result) => {
|
||||||
|
if (api && result?.data?.AccessToken && result.data.User?.Name) {
|
||||||
|
setCheckForQuickConnect(false);
|
||||||
|
// saveUser({ username, password, rememberMe: rememberUser });
|
||||||
|
enqueueSnackbar(`Logged in as ${result.data.User?.Name}!`, {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
createApi(api.basePath, result.data.AccessToken);
|
||||||
|
if (rememberUser) {
|
||||||
|
saveUser(result.data.User?.Name, result.data.AccessToken);
|
||||||
|
}
|
||||||
|
navigate({ to: "/home", replace: true });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
enqueueSnackbar("Error authenticating user.", { variant: "error" });
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
const checkQuickConnectStatus = useMutation({
|
const checkQuickConnectStatus = useMutation({
|
||||||
mutationKey: ["quick-connect-button", "check-quick-connect-status"],
|
mutationKey: ["quick-connect-button", "check-quick-connect-status"],
|
||||||
mutationFn: async (secret: string) =>
|
mutationFn: async (secret: string) =>
|
||||||
api
|
api &&
|
||||||
? (
|
(
|
||||||
await getQuickConnectApi(api).getQuickConnectState(
|
await getQuickConnectApi(api).getQuickConnectState(
|
||||||
{ secret },
|
{ secret },
|
||||||
{ headers },
|
{ headers },
|
||||||
)
|
)
|
||||||
).data
|
).data,
|
||||||
: skipToken,
|
onSuccess: (result) => {
|
||||||
|
if (result?.Authenticated) {
|
||||||
|
setQuickConnectCode(null);
|
||||||
|
initQuickConnect.reset();
|
||||||
|
checkQuickConnectStatus.reset();
|
||||||
|
authenticateUser.mutate();
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const initQuickConnect = useMutation({
|
const initQuickConnect = useMutation({
|
||||||
mutationKey: ["quick-connect-button", "initiate-connection"],
|
mutationKey: ["quick-connect-button", "initiate-connection"],
|
||||||
@@ -81,6 +132,8 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
},
|
},
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
setQuickConnectCode(result?.data.Code);
|
setQuickConnectCode(result?.data.Code);
|
||||||
|
setQuickConnectSecret(result?.data.Secret);
|
||||||
|
setCheckForQuickConnect(true);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
||||||
@@ -88,17 +141,26 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleQuickConnectClose = useCallback(() => {
|
||||||
|
setQuickConnectCode(null);
|
||||||
|
setCheckForQuickConnect(false);
|
||||||
|
initQuickConnect.reset();
|
||||||
|
checkQuickConnectStatus.reset();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useInterval(
|
useInterval(
|
||||||
() => {
|
() => {
|
||||||
if (quickConnectCode) {
|
if (quickConnectSecret) {
|
||||||
checkQuickConnectStatus.mutate(quickConnectCode);
|
console.log(checkForQuickConnect);
|
||||||
|
checkQuickConnectStatus.mutate(quickConnectSecret);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
quickConnectCode ? 1000 : null,
|
checkForQuickConnect ? 1500 : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div style={{ marginLeft: "auto" }}>
|
||||||
|
{/* @ts-ignore */}
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
{...props}
|
{...props}
|
||||||
disabled={
|
disabled={
|
||||||
@@ -111,18 +173,15 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
(quickConnectCode && !checkQuickConnectStatus.data?.Authenticated),
|
(quickConnectCode && !checkQuickConnectStatus.data?.Authenticated),
|
||||||
)}
|
)}
|
||||||
variant={props.variant ?? "contained"}
|
variant={props.variant ?? "contained"}
|
||||||
style={{ flex: 1 }}
|
|
||||||
onClick={initQuickConnect.mutate}
|
onClick={initQuickConnect.mutate}
|
||||||
>
|
>
|
||||||
Quick Connect
|
{quickConnectEnabled.data?.data
|
||||||
|
? "Use Quick Connect"
|
||||||
|
: "Quick Connect Disabled"}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={Boolean(quickConnectCode)}
|
open={Boolean(quickConnectCode)}
|
||||||
onClose={() => {
|
onClose={handleQuickConnectClose}
|
||||||
setQuickConnectCode(null);
|
|
||||||
initQuickConnect.reset();
|
|
||||||
checkQuickConnectStatus.reset();
|
|
||||||
}}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="xs"
|
maxWidth="xs"
|
||||||
TransitionComponent={Transition}
|
TransitionComponent={Transition}
|
||||||
@@ -191,17 +250,12 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
}
|
}
|
||||||
label="Remember device"
|
label="Remember device"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button variant="contained" onClick={handleQuickConnectClose}>
|
||||||
variant="contained"
|
|
||||||
onClick={() => {
|
|
||||||
setQuickConnectCode(null);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ type TrailerButtonType = {
|
|||||||
const TrailerButton = (props: TrailerButtonType) => {
|
const TrailerButton = (props: TrailerButtonType) => {
|
||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<div>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={props.disabled ?? false}
|
disabled={props.disabled ?? false}
|
||||||
onClick={() => setDialog(true)}
|
onClick={() => setDialog(true)}
|
||||||
@@ -29,18 +29,20 @@ const TrailerButton = (props: TrailerButtonType) => {
|
|||||||
}}
|
}}
|
||||||
onClose={() => setDialog(false)}
|
onClose={() => setDialog(false)}
|
||||||
>
|
>
|
||||||
<ReactPlayer
|
{props.trailerItem[0]?.Url && (
|
||||||
playing={false}
|
<ReactPlayer
|
||||||
url={props.trailerItem[0]?.Url}
|
playing={false}
|
||||||
width="100%"
|
url={props.trailerItem[0]?.Url}
|
||||||
height="auto"
|
width="100%"
|
||||||
style={{
|
height="auto"
|
||||||
aspectRatio: "16/9",
|
style={{
|
||||||
}}
|
aspectRatio: "16/9",
|
||||||
controls
|
}}
|
||||||
/>
|
controls
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
|
|
||||||
import MuiCard from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
|
||||||
import { useApi } from "../../utils/store/api";
|
|
||||||
import "./card.scss";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {string} cardTitle
|
|
||||||
* @property {string | number} cardCaption
|
|
||||||
* @property {string} imageBlurhash
|
|
||||||
* @property {string} seriesId
|
|
||||||
* @property {boolean} hideText
|
|
||||||
* @property {() => {}} onClick
|
|
||||||
* @property {boolean} disablePadding
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Hero section for item pages
|
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const ActorCard = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageBlurhash,
|
|
||||||
seriesId,
|
|
||||||
hideText,
|
|
||||||
onClick,
|
|
||||||
disablePadding,
|
|
||||||
}) => {
|
|
||||||
const [api] = useApi((state) => [state.api]);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const defaultOnClick = () => {
|
|
||||||
navigate(`/person/${item.Id}`);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="card card-actor"
|
|
||||||
elevation={0}
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
|
||||||
>
|
|
||||||
<div className="card-box">
|
|
||||||
<div
|
|
||||||
className="card-image-container"
|
|
||||||
style={{
|
|
||||||
aspectRatio: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!imageBlurhash && (
|
|
||||||
<Blurhash
|
|
||||||
hash={imageBlurhash}
|
|
||||||
width={128}
|
|
||||||
height={128}
|
|
||||||
resolutionX={24}
|
|
||||||
resolutionY={24}
|
|
||||||
className="card-image-blurhash"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="card-image-icon-container">
|
|
||||||
<div className="material-symbols-rounded">person</div>
|
|
||||||
</div>
|
|
||||||
<img
|
|
||||||
alt={item.Name}
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
seriesId ? item.SeriesId : item.Id,
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
quality: 80,
|
|
||||||
fillHeight: 448,
|
|
||||||
fillWidth: 448,
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.target.style.opacity = 1;
|
|
||||||
}}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="card-text-container"
|
|
||||||
style={{ display: hideText ? "none" : "block" }}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
style={{ opacity: 0.9 }}
|
|
||||||
>
|
|
||||||
{cardTitle}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
style={{ opacity: 0.6 }}
|
|
||||||
lineHeight="auto"
|
|
||||||
>
|
|
||||||
{cardCaption}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -11,15 +11,17 @@ import {
|
|||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
type ImageType,
|
type ImageType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import ErrorBoundary from "../errorBoundary";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
import "./card.scss";
|
import "./card.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
|
import { useInView } from "react-intersection-observer";
|
||||||
|
|
||||||
const CardComponent = ({
|
const CardComponent = ({
|
||||||
item,
|
item,
|
||||||
cardTitle,
|
cardTitle,
|
||||||
@@ -37,8 +39,8 @@ const CardComponent = ({
|
|||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
cardTitle: string | undefined | null;
|
cardTitle: string | undefined | null;
|
||||||
cardCaption?: string | null | number;
|
cardCaption?: string | null | number;
|
||||||
imageType: ImageType;
|
imageType?: ImageType;
|
||||||
cardType: string;
|
cardType: "square" | "thumb" | "portrait";
|
||||||
queryKey?: string[];
|
queryKey?: string[];
|
||||||
userId?: string;
|
userId?: string;
|
||||||
seriesId?: string | null;
|
seriesId?: string | null;
|
||||||
@@ -80,8 +82,16 @@ const CardComponent = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { ref, inView } = useInView({
|
||||||
|
threshold: 0,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card" onClick={onClick ? onClick : defaultOnClick}>
|
<div
|
||||||
|
className="card"
|
||||||
|
ref={ref}
|
||||||
|
onClick={onClick ? onClick : defaultOnClick}
|
||||||
|
>
|
||||||
<div className={`card-image-container ${cardType}`}>
|
<div className={`card-image-container ${cardType}`}>
|
||||||
<ErrorBoundary fallback>
|
<ErrorBoundary fallback>
|
||||||
<div
|
<div
|
||||||
@@ -112,77 +122,74 @@ const CardComponent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
<img
|
{inView && (
|
||||||
alt={item.Name ?? "blink"}
|
<img
|
||||||
src={
|
alt={item.Name ?? "blink"}
|
||||||
api
|
src={
|
||||||
? overrideIcon === "User"
|
api
|
||||||
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
? overrideIcon === "User"
|
||||||
: getImageUrlsApi(api).getItemImageUrlById(
|
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
||||||
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ??
|
: getImageUrlsApi(api).getItemImageUrlById(
|
||||||
"",
|
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ??
|
||||||
imageType,
|
"",
|
||||||
{
|
imageType,
|
||||||
quality: 90,
|
{
|
||||||
fillWidth: cardType === "thumb" ? 560 : 280,
|
quality: 90,
|
||||||
},
|
fillWidth: cardType === "thumb" ? 560 : 320,
|
||||||
)
|
},
|
||||||
: ""
|
)
|
||||||
}
|
: ""
|
||||||
style={{
|
}
|
||||||
height: "100%",
|
style={{
|
||||||
width: "100%",
|
height: "100%",
|
||||||
opacity: 0,
|
width: "100%",
|
||||||
}}
|
opacity: 0,
|
||||||
loading="lazy"
|
}}
|
||||||
onLoad={(e) => {
|
loading="lazy"
|
||||||
e.currentTarget.style.setProperty("opacity", "1");
|
onLoad={(e) => {
|
||||||
}}
|
e.currentTarget.style.setProperty("opacity", "1");
|
||||||
onLoadStart={(e) => console.log(e)}
|
}}
|
||||||
className="card-image"
|
onLoadStart={(e) => console.log(e)}
|
||||||
/>
|
className="card-image"
|
||||||
<div className="card-overlay">
|
/>
|
||||||
{!disableOverlay && (
|
)}
|
||||||
<>
|
|
||||||
<PlayButton
|
{inView && !disableOverlay && (
|
||||||
itemId={item.Id}
|
<div className="card-overlay">
|
||||||
item={item}
|
<PlayButton
|
||||||
userId={userId}
|
item={item}
|
||||||
itemType={item.Type}
|
userId={userId}
|
||||||
currentAudioTrack={0}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentSubTrack="nosub"
|
currentAudioTrack="auto"
|
||||||
currentVideoTrack={0}
|
currentSubTrack={-1}
|
||||||
className="card-play-button"
|
currentVideoTrack={0}
|
||||||
iconProps={{
|
className="card-play-button"
|
||||||
style: { fontSize: "2.5em" },
|
iconOnly
|
||||||
}}
|
audio={
|
||||||
iconOnly
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
audio={
|
item.Type === BaseItemKind.Audio ||
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
item.Type === BaseItemKind.AudioBook ||
|
||||||
item.Type === BaseItemKind.Audio ||
|
item.Type === BaseItemKind.Playlist
|
||||||
item.Type === BaseItemKind.AudioBook ||
|
}
|
||||||
item.Type === BaseItemKind.Playlist
|
playlistItem={item.Type === BaseItemKind.Playlist}
|
||||||
}
|
playlistItemId={item.Id}
|
||||||
playlistItem={item.Type === BaseItemKind.Playlist}
|
/>
|
||||||
playlistItemId={item.Id}
|
<LikeButton
|
||||||
/>
|
itemId={item.Id}
|
||||||
<LikeButton
|
itemName={item.Name ?? ""}
|
||||||
itemId={item.Id}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
itemName={item.Name}
|
queryKey={queryKey}
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
userId={userId}
|
||||||
queryKey={queryKey}
|
/>
|
||||||
userId={userId}
|
<MarkPlayedButton
|
||||||
/>
|
itemId={item.Id}
|
||||||
<MarkPlayedButton
|
itemName={item.Name ?? ""}
|
||||||
itemId={item.Id}
|
isPlayed={item.UserData?.Played}
|
||||||
itemName={item.Name}
|
queryKey={queryKey}
|
||||||
isPlayed={item.UserData?.Played}
|
userId={userId}
|
||||||
queryKey={queryKey}
|
/>
|
||||||
userId={userId}
|
</div>
|
||||||
/>
|
)}
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{(item.UserData?.PlaybackPositionTicks ?? -1) > 0 && (
|
{(item.UserData?.PlaybackPositionTicks ?? -1) > 0 && (
|
||||||
<div className="card-progress-container">
|
<div className="card-progress-container">
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,209 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import MuiCard from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
|
||||||
|
|
||||||
import "./card.scss";
|
|
||||||
|
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|
||||||
import LikeButton from "../buttons/likeButton";
|
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
|
||||||
import PlayButton from "../buttons/playButton";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {string} cardTitle
|
|
||||||
* @property {string | number} cardCaption
|
|
||||||
* @property {string} imageBlurhash
|
|
||||||
* @property {Array} queryKey
|
|
||||||
* @property {string} userId
|
|
||||||
* @property {boolean} disableRunTime
|
|
||||||
* @property {() => {}} onClick
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Hero section for item pages
|
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const EpisodeCard = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageBlurhash,
|
|
||||||
queryKey,
|
|
||||||
userId,
|
|
||||||
disableRunTime = false,
|
|
||||||
onClick,
|
|
||||||
}) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const defaultOnClick = () => {
|
|
||||||
navigate({ to: `/episode/${item.Id}` });
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="card card-episode"
|
|
||||||
elevation={0}
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
|
||||||
>
|
|
||||||
<div className="card-box">
|
|
||||||
<div
|
|
||||||
className="card-image-container"
|
|
||||||
style={{
|
|
||||||
aspectRatio: 1.777,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!item.UserData && (
|
|
||||||
<div
|
|
||||||
className="card-indicator check"
|
|
||||||
style={{
|
|
||||||
opacity: item.UserData?.Played ? 1 : 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">done</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!!imageBlurhash && (
|
|
||||||
<Blurhash
|
|
||||||
hash={imageBlurhash}
|
|
||||||
width={128}
|
|
||||||
height={128}
|
|
||||||
resolutionX={24}
|
|
||||||
resolutionY={24}
|
|
||||||
className="card-image-blurhash"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="card-image-icon-container">
|
|
||||||
<div className="material-symbols-rounded">tv_gen</div>
|
|
||||||
</div>
|
|
||||||
<img
|
|
||||||
alt={item.Name}
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
|
||||||
quality: 90,
|
|
||||||
fillHeight: 512,
|
|
||||||
fillWidth: 512,
|
|
||||||
})}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.target.style.opacity = 1;
|
|
||||||
}}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="card-overlay">
|
|
||||||
<PlayButton
|
|
||||||
itemId={item.Id}
|
|
||||||
userId={userId}
|
|
||||||
itemType={item.Type}
|
|
||||||
currentAudioTrack={0}
|
|
||||||
currentSubTrack={0}
|
|
||||||
currentVideoTrack={0}
|
|
||||||
className="card-play-button"
|
|
||||||
iconProps={{
|
|
||||||
style: { fontSize: "2.5em" },
|
|
||||||
}}
|
|
||||||
iconOnly
|
|
||||||
/>
|
|
||||||
<LikeButton
|
|
||||||
itemId={item.Id}
|
|
||||||
itemName={item.Name}
|
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={userId}
|
|
||||||
/>
|
|
||||||
<MarkPlayedButton
|
|
||||||
itemId={item.Id}
|
|
||||||
itemName={item.Name}
|
|
||||||
isPlayed={item.UserData?.Played}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={userId}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{100 > item.UserData?.PlayedPercentage > 0 && (
|
|
||||||
<LinearProgress
|
|
||||||
variant="determinate"
|
|
||||||
value={item.UserData.PlayedPercentage}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
zIndex: 2,
|
|
||||||
height: "6px",
|
|
||||||
background: "rgb(5 5 5 / 0.5) !important",
|
|
||||||
backdropFilter: "blur(5px)",
|
|
||||||
}}
|
|
||||||
color="primary"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="card-text-container"
|
|
||||||
style={{ display: "block", marginTop: "0.5em" }}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
gap: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
textAlign="start"
|
|
||||||
noWrap
|
|
||||||
style={{
|
|
||||||
opacity: 0.9,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{cardTitle}
|
|
||||||
</Typography>
|
|
||||||
{!disableRunTime && (
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
noWrap
|
|
||||||
textAlign="start"
|
|
||||||
style={{ opacity: 0.8, flexShrink: 0 }}
|
|
||||||
>
|
|
||||||
{getRuntimeCompact(item.RunTimeTicks)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
textAlign="start"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "-webkit-box",
|
|
||||||
overflow: "hidden",
|
|
||||||
WebkitBoxOrient: "vertical",
|
|
||||||
WebkitLineClamp: 3,
|
|
||||||
}}
|
|
||||||
lineHeight="auto"
|
|
||||||
>
|
|
||||||
{cardCaption}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
+22
-18
@@ -1,11 +1,8 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { type ReactNode } from "react";
|
||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import Carousel from "react-multi-carousel";
|
import Carousel from "react-multi-carousel";
|
||||||
import "react-multi-carousel/lib/styles.css";
|
import "react-multi-carousel/lib/styles.css";
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
@@ -30,14 +27,23 @@ function LeftButton(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CardScroller = ({
|
type CardScrollerProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
displayCards: number;
|
||||||
|
title: string;
|
||||||
|
headingProps?: object;
|
||||||
|
disableDecoration?: boolean;
|
||||||
|
boxProps?: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function CardScroller({
|
||||||
children,
|
children,
|
||||||
displayCards,
|
displayCards,
|
||||||
title,
|
title,
|
||||||
headingProps,
|
headingProps,
|
||||||
disableDecoration = false,
|
disableDecoration = false,
|
||||||
boxProps,
|
boxProps,
|
||||||
}) => {
|
}: CardScrollerProps) {
|
||||||
const responsive = {
|
const responsive = {
|
||||||
superLargeDesktop: {
|
superLargeDesktop: {
|
||||||
// the naming can be any, depends on you.
|
// the naming can be any, depends on you.
|
||||||
@@ -73,9 +79,13 @@ export const CardScroller = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box {...boxProps} className="card-scroller-container" mb={1}>
|
<div
|
||||||
<Box
|
{...boxProps}
|
||||||
sx={{ mb: 1 }}
|
className="card-scroller-container"
|
||||||
|
style={{ marginBottom: "1.2em" }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "1.2em" }}
|
||||||
className={
|
className={
|
||||||
disableDecoration
|
disableDecoration
|
||||||
? "card-scroller-header-container hidden-decoration"
|
? "card-scroller-header-container hidden-decoration"
|
||||||
@@ -90,7 +100,7 @@ export const CardScroller = ({
|
|||||||
>
|
>
|
||||||
<div className="card-scroller-heading-decoration" /> {title}
|
<div className="card-scroller-heading-decoration" /> {title}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</div>
|
||||||
<Carousel
|
<Carousel
|
||||||
swipeable
|
swipeable
|
||||||
draggable
|
draggable
|
||||||
@@ -104,12 +114,6 @@ export const CardScroller = ({
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</Box>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
CardScroller.propTypes = {
|
|
||||||
displayCards: PropTypes.number.isRequired,
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
headingProps: PropTypes.any,
|
|
||||||
};
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
|
import type { PanInfo } from "framer-motion";
|
||||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
|
import type { MouseEvent, PointerEvent } from "react";
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
|
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
import "./carousel.scss";
|
import "./carousel.scss";
|
||||||
@@ -10,12 +10,11 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
import CarouselSlide from "../carouselSlide";
|
import CarouselSlide from "../carouselSlide";
|
||||||
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import ReactMultiCarousel from "react-multi-carousel";
|
|
||||||
import Slider from "../Slider";
|
import Slider from "../Slider";
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
const swipeConfidenceThreshold = 8000;
|
const swipeConfidenceThreshold = 8000;
|
||||||
const swipePower = (offset, velocity) => {
|
const swipePower = (offset: number, velocity: number) => {
|
||||||
return Math.abs(offset) * velocity;
|
return Math.abs(offset) * velocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,14 +29,11 @@ const Carousel = ({
|
|||||||
onChange,
|
onChange,
|
||||||
}: {
|
}: {
|
||||||
content: BaseItemDto[];
|
content: BaseItemDto[];
|
||||||
onChange: () => void;
|
onChange: (currentSlide: number) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
|
|
||||||
const [setDirection, dir] = useCarouselStore((state) => [
|
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||||
state.setDirection,
|
|
||||||
state.direction,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onChange(currentSlide);
|
onChange(currentSlide);
|
||||||
@@ -45,27 +41,6 @@ const Carousel = ({
|
|||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const responsive = {
|
|
||||||
superLargeDesktop: {
|
|
||||||
breakpoint: { max: 4000, min: 3000 },
|
|
||||||
items: 6,
|
|
||||||
},
|
|
||||||
desktop: {
|
|
||||||
breakpoint: { max: 3000, min: 1024 },
|
|
||||||
items: 6,
|
|
||||||
},
|
|
||||||
tablet: {
|
|
||||||
breakpoint: { max: 1024, min: 464 },
|
|
||||||
items: 4,
|
|
||||||
},
|
|
||||||
mobile: {
|
|
||||||
breakpoint: { max: 464, min: 0 },
|
|
||||||
items: 1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Memoize the content mapping
|
// Memoize the content mapping
|
||||||
const sliderContent = useMemo(() => {
|
const sliderContent = useMemo(() => {
|
||||||
return content.map((item, index) => {
|
return content.map((item, index) => {
|
||||||
@@ -98,16 +73,23 @@ const Carousel = ({
|
|||||||
>
|
>
|
||||||
{item.ImageTags?.Thumb ? (
|
{item.ImageTags?.Thumb ? (
|
||||||
<img
|
<img
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Thumb", {
|
src={
|
||||||
tag: item.ImageTags.Primary,
|
api &&
|
||||||
fillWidth: 300,
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
})}
|
item.Id ?? "",
|
||||||
|
"Thumb",
|
||||||
|
{
|
||||||
|
tag: item.ImageTags.Primary,
|
||||||
|
fillWidth: 300,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "item-image"}
|
alt={item.Name ?? "item-image"}
|
||||||
className="carousel-indicator-image"
|
className="carousel-indicator-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="carousel-indicator-icon">
|
<div className="carousel-indicator-icon">
|
||||||
{getTypeIcon(item.Type)}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@@ -116,7 +98,10 @@ const Carousel = ({
|
|||||||
}, [content, currentSlide, api, setDirection]);
|
}, [content, currentSlide, api, setDirection]);
|
||||||
|
|
||||||
const handleDragEnd = useCallback(
|
const handleDragEnd = useCallback(
|
||||||
(e, { offset, velocity }) => {
|
(
|
||||||
|
_: MouseEvent | TouchEvent | PointerEvent,
|
||||||
|
{ offset, velocity }: PanInfo,
|
||||||
|
) => {
|
||||||
const swipe = swipePower(offset.x, velocity.x);
|
const swipe = swipePower(offset.x, velocity.x);
|
||||||
if (
|
if (
|
||||||
currentSlide !== content.length - 1 &&
|
currentSlide !== content.length - 1 &&
|
||||||
@@ -147,6 +132,7 @@ const Carousel = ({
|
|||||||
drag={"x"}
|
drag={"x"}
|
||||||
dragConstraints={{ left: 0, right: 0 }}
|
dragConstraints={{ left: 0, right: 0 }}
|
||||||
dragElastic={1}
|
dragElastic={1}
|
||||||
|
//@ts-ignore
|
||||||
onDragEnd={handleDragEnd}
|
onDragEnd={handleDragEnd}
|
||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { motion } from "framer-motion";
|
|||||||
|
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
@@ -17,6 +16,7 @@ import { getTypeIcon } from "../utils/iconsCollection";
|
|||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCarouselStore } from "@/utils/store/carousel";
|
import { useCarouselStore } from "@/utils/store/carousel";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -74,20 +73,20 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
className="hero-carousel-background-image"
|
className="hero-carousel-background-image"
|
||||||
src={
|
src={
|
||||||
item.ParentBackdropItemId
|
item.ParentBackdropItemId
|
||||||
? `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
||||||
: `${api.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
: `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
loading="eager"
|
loading="eager"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="hero-carousel-background-icon-container">
|
<div className="hero-carousel-background-icon-container">
|
||||||
{getTypeIcon(item.Type)}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -129,16 +128,16 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
item.Name
|
item.Name
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
alt={item.Name}
|
alt={item.Name ?? "Item"}
|
||||||
className="hero-carousel-text-logo"
|
className="hero-carousel-text-logo"
|
||||||
src={`${api.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
src={`${api?.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
||||||
style={{
|
style={{
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
transition: "opacity 0.2s",
|
transition: "opacity 0.2s",
|
||||||
objectFit: "contain",
|
objectFit: "contain",
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -177,7 +176,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
>
|
>
|
||||||
{item.PremiereDate && (
|
{item.PremiereDate && (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{item.ProductionYear ?? ""}
|
{item.ProductionYear}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{item.OfficialRating && (
|
{item.OfficialRating && (
|
||||||
@@ -240,15 +239,21 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{item.RunTimeTicks && (
|
{item.RunTimeTicks ? (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{getRuntime(item.RunTimeTicks)}
|
{getRuntime(item.RunTimeTicks)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
)}
|
)}
|
||||||
{item.RunTimeTicks && (
|
{item.RunTimeTicks ? (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{endsAt(item.RunTimeTicks - item.UserData.PlaybackPositionTicks)}
|
{endsAt(
|
||||||
|
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
)}
|
)}
|
||||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||||
{item.Genres?.slice(0, 4).join(" / ")}
|
{item.Genres?.slice(0, 4).join(" / ")}
|
||||||
@@ -305,16 +310,14 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
>
|
>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
itemId={item.Id}
|
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
itemType={item.Type}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentSubTrack={0}
|
currentSubTrack={0}
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
size: "large",
|
size: "large",
|
||||||
}}
|
}}
|
||||||
itemUserData={item.UserData}
|
|
||||||
audio={
|
audio={
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
item.Type === BaseItemKind.Audio ||
|
item.Type === BaseItemKind.Audio ||
|
||||||
@@ -327,6 +330,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="large"
|
size="large"
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
endIcon={
|
endIcon={
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
class ErrorBoundary extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = { hasError: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
static getDerivedStateFromError(error) {
|
|
||||||
// Update state so the next render will show the fallback UI.
|
|
||||||
return { hasError: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error, info) {
|
|
||||||
// Example "componentStack":
|
|
||||||
// in ComponentThatThrows (created by App)
|
|
||||||
// in ErrorBoundary (created by App)
|
|
||||||
// in div (created by App)
|
|
||||||
// in App
|
|
||||||
this.setState;
|
|
||||||
console.error(`Err in ${info} - ${error}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.state.hasError) {
|
|
||||||
// You can render any custom fallback UI
|
|
||||||
return this.props.fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.props.children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default ErrorBoundary;
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Link, Typography } from "@mui/material";
|
import { Link, Typography } from "@mui/material";
|
||||||
import React from "react";
|
import React, { memo } from "react";
|
||||||
|
|
||||||
import anidbIcon from "../../assets/icons/anidb.png";
|
import anidbIcon from "../../assets/icons/anidb.png";
|
||||||
import anilistIcon from "../../assets/icons/anilist.svg";
|
import anilistIcon from "../../assets/icons/anilist.svg";
|
||||||
@@ -25,7 +25,7 @@ const knownIcons = [
|
|||||||
"kitsu",
|
"kitsu",
|
||||||
];
|
];
|
||||||
|
|
||||||
const IconLink = ({ name, url }: { name: string; url: string }) => {
|
const IconLink = memo(({ name, url }: { name: string; url: string }) => {
|
||||||
return (
|
return (
|
||||||
<Link target="_blank" href={url} className="item-detail-link">
|
<Link target="_blank" href={url} className="item-detail-link">
|
||||||
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
||||||
@@ -61,6 +61,6 @@ const IconLink = ({ name, url }: { name: string; url: string }) => {
|
|||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export default IconLink;
|
export default IconLink;
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
height: 16em;
|
height: 16em;
|
||||||
box-shadow: $shadow-card-image;
|
box-shadow: $shadow-card-image;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
&-icon {
|
&-icon {
|
||||||
color: rgb(255 255 255 / 0.5);
|
color: rgb(255 255 255 / 0.5);
|
||||||
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
||||||
|
|||||||
@@ -1,274 +0,0 @@
|
|||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import MuiLink from "@mui/material/Link";
|
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
|
||||||
|
|
||||||
import { SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
|
||||||
import LikeButton from "../../buttons/likeButton";
|
|
||||||
import PlayButton from "../../buttons/playButton";
|
|
||||||
|
|
||||||
import TrackList from "../tracksList/index";
|
|
||||||
import "./albumArtist.scss";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { Link, useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export const ArtistAlbum = ({ user, album, boxProps }) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const albumTracks = useQuery({
|
|
||||||
queryKey: ["artist", "album", album.Id],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getItemsApi(api).getItems({
|
|
||||||
userId: user.Id,
|
|
||||||
parentId: album.Id,
|
|
||||||
sortOrder: SortOrder.Ascending,
|
|
||||||
sortBy: "IndexNumber",
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [
|
|
||||||
currentTrackItem,
|
|
||||||
setCurrentAudioTrack,
|
|
||||||
setAudioUrl,
|
|
||||||
setAudioDisplay,
|
|
||||||
setAudioItem,
|
|
||||||
setAudioTracks,
|
|
||||||
] = useAudioPlayback((state) => [
|
|
||||||
state.item,
|
|
||||||
state.setCurrentTrack,
|
|
||||||
state.setUrl,
|
|
||||||
state.setDisplay,
|
|
||||||
state.setItem,
|
|
||||||
state.setTracks,
|
|
||||||
]);
|
|
||||||
const playTrack = (index) => {
|
|
||||||
setAudioTracks(albumTracks.data.Items);
|
|
||||||
setCurrentAudioTrack(index);
|
|
||||||
setAudioUrl(
|
|
||||||
`${api.basePath}/Audio/${albumTracks.data.Items[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
setAudioItem(albumTracks.data.Items[index]);
|
|
||||||
setAudioDisplay(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
gap: "1em",
|
|
||||||
marginBottom: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!album.ImageTags?.Primary && (
|
|
||||||
<div className="album-image">
|
|
||||||
<img
|
|
||||||
alt={album.Name}
|
|
||||||
src={`${api.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
height: "100%",
|
|
||||||
objectFit: "cover",
|
|
||||||
opacity: 0,
|
|
||||||
transition: "opacity 250ms",
|
|
||||||
position: "relative",
|
|
||||||
zIndex: 2,
|
|
||||||
}}
|
|
||||||
onLoad={(e) => (e.currentTarget.style.opacity = 1)}
|
|
||||||
/>
|
|
||||||
<div className="album-image-icon-container">
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded album-image-icon"
|
|
||||||
style={{ fontSize: "8em" }}
|
|
||||||
>
|
|
||||||
album
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
className="flex flex-column"
|
|
||||||
style={{
|
|
||||||
alignItems: "flex-start",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
padding: "1em 0",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex flex-column">
|
|
||||||
<Typography
|
|
||||||
variant="h4"
|
|
||||||
fontWeight={300}
|
|
||||||
style={{ opacity: "0.6", mb: 1 }}
|
|
||||||
>
|
|
||||||
{album.ProductionYear}
|
|
||||||
</Typography>
|
|
||||||
<MuiLink
|
|
||||||
component={Link}
|
|
||||||
to="/album/$Id"
|
|
||||||
variant="h2"
|
|
||||||
color="inherit"
|
|
||||||
underline="hover"
|
|
||||||
>
|
|
||||||
{album.Name}
|
|
||||||
</MuiLink>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className=" flex flex-row"
|
|
||||||
style={{
|
|
||||||
gap: "1em",
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PlayButton
|
|
||||||
audio
|
|
||||||
itemId={album.Id}
|
|
||||||
itemType={album.Type}
|
|
||||||
itemUserData={album.UserData}
|
|
||||||
userId={user.Id}
|
|
||||||
buttonProps={{
|
|
||||||
color: "white",
|
|
||||||
style: {
|
|
||||||
color: "black ",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LikeButton
|
|
||||||
itemName={album.Name}
|
|
||||||
key={album.Id}
|
|
||||||
queryKey={[
|
|
||||||
"item",
|
|
||||||
album.ParentBackdropItemId,
|
|
||||||
"artist",
|
|
||||||
"discography",
|
|
||||||
]}
|
|
||||||
isFavorite={album.UserData.IsFavorite}
|
|
||||||
itemId={album.Id}
|
|
||||||
itemType={album.Type}
|
|
||||||
itemUserData={album.UserData}
|
|
||||||
userId={user.Id}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{albumTracks.isSuccess && (
|
|
||||||
<TrackList user={user} tracks={albumTracks.data.Items} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
|
||||||
/* <div
|
|
||||||
key={0}
|
|
||||||
className="item-detail-album-track"
|
|
||||||
style={{
|
|
||||||
padding: "0.75em 0 ",
|
|
||||||
background: "rgb(0 0 0 / 0.6)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
fontWeight={400}
|
|
||||||
style={{
|
|
||||||
justifySelf: "end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
#
|
|
||||||
</Typography>
|
|
||||||
<div />
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
justifySelf: "start",
|
|
||||||
}}
|
|
||||||
fontWeight={400}
|
|
||||||
>
|
|
||||||
Name
|
|
||||||
</Typography>
|
|
||||||
<span className="material-symbols-rounded">schedule</span>
|
|
||||||
</div>
|
|
||||||
{/*albumTracks.data.Items.map((track, index) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={track.Id}
|
|
||||||
className={
|
|
||||||
currentTrackItem.Id === track.Id &&
|
|
||||||
currentTrackItem.ParentId === track.ParentId
|
|
||||||
? "item-detail-album-track playing"
|
|
||||||
: "item-detail-album-track"
|
|
||||||
}
|
|
||||||
onClick={() => playTrack(index)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
style={{
|
|
||||||
justifySelf: "end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.IndexNumber ? track.IndexNumber : "-"}
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["artist", "album", album.Id]}
|
|
||||||
userId={user.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
color={
|
|
||||||
currentTrackItem.Id === track.Id &&
|
|
||||||
currentTrackItem.ParentId === track.ParentId
|
|
||||||
? "hsl(337, 96%, 56%)"
|
|
||||||
: "white"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
style={{
|
|
||||||
justifySelf: "start",
|
|
||||||
}}
|
|
||||||
fontWeight={500}
|
|
||||||
>
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
{track.AlbumArtist === "Various Artists" && (
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.ArtistItems.map((artist) => artist.Name).join(
|
|
||||||
", ",
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Typography variant="subtitle1">
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})*/
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
SortOrder,
|
||||||
|
type UserDto,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import LikeButton from "../../buttons/likeButton";
|
||||||
|
import PlayButton from "../../buttons/playButton";
|
||||||
|
|
||||||
|
import "./albumArtist.scss";
|
||||||
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
type ArtistAlbumProps = {
|
||||||
|
user: UserDto;
|
||||||
|
album: BaseItemDto;
|
||||||
|
boxProps?: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const albumTracks = useQuery({
|
||||||
|
queryKey: ["artist", "album", album.Id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
const result = await getItemsApi(api).getItems({
|
||||||
|
userId: user.Id,
|
||||||
|
parentId: album.Id,
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
sortBy: ["IndexNumber"],
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: "1em",
|
||||||
|
marginBottom: "1em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{!!album.ImageTags?.Primary && (
|
||||||
|
<div className="album-image">
|
||||||
|
<img
|
||||||
|
alt={album.Name ?? "Album Image"}
|
||||||
|
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
objectFit: "cover",
|
||||||
|
opacity: 0,
|
||||||
|
transition: "opacity 250ms",
|
||||||
|
position: "relative",
|
||||||
|
zIndex: 2,
|
||||||
|
}}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="album-image-icon-container">
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded album-image-icon"
|
||||||
|
style={{ fontSize: "8em" }}
|
||||||
|
>
|
||||||
|
album
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className="flex flex-column"
|
||||||
|
style={{
|
||||||
|
alignItems: "flex-start",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
padding: "1em 0",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex flex-column">
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
|
fontWeight={300}
|
||||||
|
style={{ opacity: "0.6" }}
|
||||||
|
>
|
||||||
|
{album.ProductionYear}
|
||||||
|
</Typography>
|
||||||
|
<Link
|
||||||
|
to="/album/$id"
|
||||||
|
params={{ id: album.Id ?? "" }}
|
||||||
|
style={{ color: "white", textDecoration: "none" }}
|
||||||
|
>
|
||||||
|
<Typography variant="h4" color="white">
|
||||||
|
{album.Name}
|
||||||
|
</Typography>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className=" flex flex-row"
|
||||||
|
style={{
|
||||||
|
gap: "1em",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlayButton
|
||||||
|
audio
|
||||||
|
item={album}
|
||||||
|
itemType={album.Type ?? "MusicAlbum"}
|
||||||
|
userId={user.Id}
|
||||||
|
buttonProps={{
|
||||||
|
//@ts-ignore
|
||||||
|
color: "white",
|
||||||
|
style: {
|
||||||
|
color: "black ",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LikeButton
|
||||||
|
itemName={album.Name}
|
||||||
|
key={album.Id}
|
||||||
|
queryKey={[
|
||||||
|
"item",
|
||||||
|
album.ParentBackdropItemId ?? "",
|
||||||
|
"artist",
|
||||||
|
"discography",
|
||||||
|
]}
|
||||||
|
isFavorite={album.UserData?.IsFavorite}
|
||||||
|
itemId={album.Id}
|
||||||
|
userId={user.Id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{albumTracks.isSuccess && (albumTracks.data?.Items?.length ?? 0) > 0 && (
|
||||||
|
<div>
|
||||||
|
<div className="item-info-track header">
|
||||||
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
|
</div>
|
||||||
|
{albumTracks.data?.Items?.map((track, index) => (
|
||||||
|
<AlbumMusicTrack
|
||||||
|
track={track}
|
||||||
|
trackIndex={index}
|
||||||
|
musicTracks={albumTracks.data}
|
||||||
|
key={track.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Card } from "../../card/card";
|
import { Card } from "../../card/card";
|
||||||
import { CardScroller } from "../../cardScroller/cardScroller";
|
import CardScroller from "../../cardScroller/cardScroller";
|
||||||
import { CardsSkeleton } from "../../skeleton/cards";
|
import { CardsSkeleton } from "../../skeleton/cards";
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +21,9 @@ export const LatestMediaSection = ({
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
const fetchLatestMedia = async (library: BaseItemDto) => {
|
const fetchLatestMedia = async (library: BaseItemDto) => {
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
parentId: library.Id,
|
parentId: library.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
||||||
@@ -39,10 +39,10 @@ export const LatestMediaSection = ({
|
|||||||
if (data.isPending) {
|
if (data.isPending) {
|
||||||
return <CardsSkeleton />;
|
return <CardsSkeleton />;
|
||||||
}
|
}
|
||||||
if (data.isSuccess && data.data.length >= 1) {
|
if (data.isSuccess && (data.data?.length ?? 0) >= 1) {
|
||||||
return (
|
return (
|
||||||
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
||||||
{data.data.map((item) => {
|
{data.data?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
@@ -73,14 +73,8 @@ export const LatestMediaSection = ({
|
|||||||
? "square"
|
? "square"
|
||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["home", "latestMedia", latestMediaLib.Id]}
|
queryKey={["home", "latestMedia", latestMediaLib.Id ?? ""]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
|
||||||
import { Card } from "../../../card/card";
|
|
||||||
import { CardScroller } from "../../../cardScroller/cardScroller";
|
|
||||||
|
|
||||||
const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const items = useQuery({
|
|
||||||
queryKey: ["library", "genreItem", genreId],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getItemsApi(api).getItems({
|
|
||||||
genreIds: [genreId],
|
|
||||||
parentId: libraryId,
|
|
||||||
userId: userId,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (items.isSuccess && items.data.Items.length > 0) {
|
|
||||||
return (
|
|
||||||
<div className="library-genre">
|
|
||||||
<CardScroller title={genreName} displayCards={8} disableDecoration>
|
|
||||||
{items.data.Items.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
seriesId={item.SeriesId}
|
|
||||||
cardTitle={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? item.SeriesName
|
|
||||||
: item.Name
|
|
||||||
}
|
|
||||||
imageType={"Primary"}
|
|
||||||
cardCaption={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
|
||||||
: item.Type === BaseItemKind.Series
|
|
||||||
? `${item.ProductionYear} - ${
|
|
||||||
item.EndDate
|
|
||||||
? new Date(item.EndDate).toLocaleString([], {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "Present"
|
|
||||||
}`
|
|
||||||
: item.ProductionYear
|
|
||||||
}
|
|
||||||
disableOverlay={
|
|
||||||
item.Type === BaseItemKind.Person ||
|
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
item.Type === BaseItemKind.Genre ||
|
|
||||||
item.Type === BaseItemKind.MusicGenre ||
|
|
||||||
item.Type === BaseItemKind.Studio
|
|
||||||
}
|
|
||||||
cardType={
|
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
item.Type === BaseItemKind.Audio ||
|
|
||||||
item.Type === BaseItemKind.Genre ||
|
|
||||||
item.Type === BaseItemKind.MusicGenre ||
|
|
||||||
item.Type === BaseItemKind.Studio ||
|
|
||||||
item.Type === BaseItemKind.Playlist
|
|
||||||
? "square"
|
|
||||||
: "portrait"
|
|
||||||
}
|
|
||||||
queryKey={["library", "genreItem", genreId]}
|
|
||||||
userId={userId}
|
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default GenreView;
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
// Types
|
|
||||||
import type { BaseItemDto, UserDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
|
||||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
|
||||||
import LikeButton from "../../buttons/likeButton";
|
|
||||||
import "./tracksList.scss";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export default function TracksList({
|
|
||||||
tracks,
|
|
||||||
user,
|
|
||||||
queryKey,
|
|
||||||
}: { tracks: BaseItemDto[]; user: UserDto; queryKey: [] }) {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const [
|
|
||||||
currentItem,
|
|
||||||
setCurrentAudioTrack,
|
|
||||||
setAudioUrl,
|
|
||||||
setAudioDisplay,
|
|
||||||
setAudioItem,
|
|
||||||
setAudioTracks,
|
|
||||||
] = useAudioPlayback((state) => [
|
|
||||||
state.item,
|
|
||||||
state.setCurrentTrack,
|
|
||||||
state.setUrl,
|
|
||||||
state.setDisplay,
|
|
||||||
state.setItem,
|
|
||||||
state.setTracks,
|
|
||||||
]);
|
|
||||||
const playTrack = (index: number) => {
|
|
||||||
setAudioTracks(tracks);
|
|
||||||
setCurrentAudioTrack(index);
|
|
||||||
setAudioUrl(
|
|
||||||
`${api.basePath}/Audio/${tracks[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
setAudioItem(tracks[index]);
|
|
||||||
setAudioDisplay(true);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div className="track-list">
|
|
||||||
<div className="track track-header">
|
|
||||||
<Typography variant="h6">#</Typography>
|
|
||||||
<div>{""}</div>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Name
|
|
||||||
</Typography>
|
|
||||||
<span className="material-symbols-rounded">schedule</span>
|
|
||||||
</div>
|
|
||||||
{tracks.map((track, index) => (
|
|
||||||
<div
|
|
||||||
className={currentItem?.Id === track.Id ? "track playing" : "track"}
|
|
||||||
key={track.Id}
|
|
||||||
onClick={() => playTrack(index)}
|
|
||||||
>
|
|
||||||
{currentItem?.Id === track.Id ? (
|
|
||||||
<span className="material-symbols-rounded ">equalizer</span>
|
|
||||||
) : (
|
|
||||||
<Typography>{track.IndexNumber ?? "-"}</Typography>
|
|
||||||
)}
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={user.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
|
||||||
<Typography
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography>{getRuntimeMusic(track?.RunTimeTicks)}</Typography>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
.track{
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 4% 1fr 80% 1fr;
|
|
||||||
align-items: center;
|
|
||||||
justify-items: center;
|
|
||||||
gap: 0.5em;
|
|
||||||
width: 100%;
|
|
||||||
transition: background $transition-time-default;
|
|
||||||
padding: 0.4em;
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
|
||||||
cursor: pointer;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
&:hover{
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
}
|
|
||||||
&.playing {
|
|
||||||
background: rgb(255 255 255 / 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
&-list {
|
|
||||||
background: rgb(0 0 0 / 0.4);
|
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
border-radius: 20px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.2);
|
|
||||||
margin-bottom: 2em;
|
|
||||||
}
|
|
||||||
&-header{
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
|
||||||
padding: 0.8em 0.4em;
|
|
||||||
}
|
|
||||||
> *:first-child {
|
|
||||||
justify-self: end;
|
|
||||||
}
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: 0px solid !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,30 +4,16 @@ import { getRuntimeMusic } from "../../utils/date/time";
|
|||||||
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import TextLink from "../textLink";
|
|
||||||
import "./musicTrack.scss";
|
import "./musicTrack.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import type { QueryKey } from "@tanstack/react-query";
|
import { Link } from "@tanstack/react-router";
|
||||||
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {Array} queryKey
|
|
||||||
* @property {string} userId
|
|
||||||
* @property {bool} playlistItem
|
|
||||||
* @property {number} trackIndex
|
|
||||||
* @property {string | undefined} playlistItemId
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Music Track element displayed in ArtistTitlePage and Songs library
|
* @description Music Track element displayed in ArtistTitlePage and Songs library
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MusicTrack = ({
|
const MusicTrack = ({
|
||||||
item,
|
item,
|
||||||
queryKey,
|
queryKey,
|
||||||
@@ -37,8 +23,8 @@ const MusicTrack = ({
|
|||||||
trackIndex,
|
trackIndex,
|
||||||
className = "",
|
className = "",
|
||||||
}: {
|
}: {
|
||||||
item?: BaseItemDto | null;
|
item: BaseItemDto;
|
||||||
queryKey?: QueryKey;
|
queryKey: string[];
|
||||||
userId?: string | undefined;
|
userId?: string | undefined;
|
||||||
playlistItem?: boolean;
|
playlistItem?: boolean;
|
||||||
playlistItemId?: string;
|
playlistItemId?: string;
|
||||||
@@ -60,16 +46,21 @@ const MusicTrack = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
alt={item.Name}
|
alt={item.Name ?? "Music Track"}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
Object.keys(item.ImageTags).length === 0 ? item.AlbumId : item.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
(Object.keys(item.ImageTags ?? {}).length === 0
|
||||||
quality: 70,
|
? item.AlbumId
|
||||||
fillHeight: 128,
|
: item.Id) ?? "",
|
||||||
fillWidth: 128,
|
"Primary",
|
||||||
},
|
{
|
||||||
)}
|
quality: 70,
|
||||||
|
fillHeight: 128,
|
||||||
|
fillWidth: 128,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
@@ -77,14 +68,14 @@ const MusicTrack = ({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="music-track-image-overlay">
|
<div className="music-track-image-overlay">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
itemId={item.Id}
|
item={item}
|
||||||
|
itemType="Audio"
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type}
|
|
||||||
size="small"
|
size="small"
|
||||||
iconOnly
|
iconOnly
|
||||||
audio
|
audio
|
||||||
@@ -119,21 +110,26 @@ const MusicTrack = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.ArtistItems?.map((artist, index) => (
|
{item.ArtistItems?.map((artist, index) => (
|
||||||
<>
|
<span
|
||||||
<TextLink
|
style={{ display: "inline-flex", alignItems: "center" }}
|
||||||
key={index}
|
key={artist.Id}
|
||||||
variant={"subtitle2"}
|
>
|
||||||
location={`/artist/${artist.Id}`}
|
<Typography
|
||||||
otherProps={{
|
variant="subtitle2"
|
||||||
fontWeight: 400,
|
fontWeight="400"
|
||||||
style: {
|
style={{
|
||||||
textDecoration: "none",
|
textDecoration: "none",
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{artist.Name}
|
<Link
|
||||||
</TextLink>
|
style={{ textDecoration: "none", color: "white" }}
|
||||||
{index !== item.ArtistItems.length - 1 && (
|
to="/artist/$id"
|
||||||
|
params={{ id: artist.Id ?? "" }}
|
||||||
|
>
|
||||||
|
{artist.Name}
|
||||||
|
</Link>
|
||||||
|
</Typography>
|
||||||
|
{index !== (item.ArtistItems?.length ?? 0) - 1 && (
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
whiteSpace: "pre",
|
whiteSpace: "pre",
|
||||||
@@ -142,12 +138,12 @@ const MusicTrack = ({
|
|||||||
,{" "}
|
,{" "}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="subtitl1">
|
<Typography variant="subtitle1">
|
||||||
{getRuntimeMusic(item.RunTimeTicks)}
|
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
|
|||||||
@@ -1,27 +1,40 @@
|
|||||||
import { LinearProgress } from "@mui/material";
|
import { LinearProgress } from "@mui/material";
|
||||||
import { useNProgress } from "@tanem/react-nprogress";
|
import { useNProgress } from "@tanem/react-nprogress";
|
||||||
import React from "react";
|
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
||||||
|
import { useRouterState } from "@tanstack/react-router";
|
||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
|
||||||
|
export default function NProgress() {
|
||||||
|
const isQueryFetching = useIsFetching();
|
||||||
|
const isMutating = useIsMutating();
|
||||||
|
const routeIsLoading = useRouterState().isLoading;
|
||||||
|
|
||||||
|
const isAnimating = useMemo(() => {
|
||||||
|
if (isQueryFetching || isMutating || routeIsLoading) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, [isQueryFetching, isMutating, routeIsLoading]);
|
||||||
|
|
||||||
const NProgress: React.FC<{ isAnimating: boolean | number }> = ({
|
|
||||||
isAnimating,
|
|
||||||
}) => {
|
|
||||||
const { animationDuration, isFinished, progress } = useNProgress({
|
const { animationDuration, isFinished, progress } = useNProgress({
|
||||||
isAnimating,
|
isAnimating,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isAnimating) {
|
return createPortal(
|
||||||
return (
|
<div
|
||||||
<div
|
style={{
|
||||||
style={{
|
pointerEvents: "none",
|
||||||
pointerEvents: "none",
|
transition: "opacity 250ms linear",
|
||||||
transition: `opacity ${animationDuration}ms linear`,
|
position: "fixed",
|
||||||
position: "fixed",
|
top: "0",
|
||||||
top: "0",
|
left: "0",
|
||||||
left: "0",
|
right: "0",
|
||||||
right: "0",
|
zIndex: "10001",
|
||||||
zIndex: "10001",
|
opacity: isFinished ? 0 : 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{isAnimating && (
|
||||||
<LinearProgress
|
<LinearProgress
|
||||||
sx={{
|
sx={{
|
||||||
height: 3,
|
height: 3,
|
||||||
@@ -30,9 +43,9 @@ const NProgress: React.FC<{ isAnimating: boolean | number }> = ({
|
|||||||
value={progress * 100}
|
value={progress * 100}
|
||||||
variant="determinate"
|
variant="determinate"
|
||||||
/>
|
/>
|
||||||
</div>
|
)}
|
||||||
);
|
</div>,
|
||||||
}
|
document.body,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NProgress;
|
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { yellow } from "@mui/material/colors";
|
import { yellow } from "@mui/material/colors";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const EmptyNotice = ({ extraMsg }) => {
|
export const EmptyNotice = ({ extraMsg }: { extraMsg?: string }) => {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -42,12 +42,14 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
|
|||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
border: "2px dashed rgb(255 255 255 / 0.5)",
|
border: "2px dashed rgb(255 255 255 / 0.5)",
|
||||||
maxWidth: "40em",
|
maxWidth: "40em",
|
||||||
|
maxHeight: "20em",
|
||||||
|
overflow: "auto",
|
||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
// opacity: 0.6,
|
// opacity: 0.6,
|
||||||
}}
|
}}
|
||||||
color="gray"
|
color="gray"
|
||||||
>
|
>
|
||||||
{JSON.stringify(error?.message)}
|
{JSON.stringify(error?.stack)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { playItemFromQueue, usePlaybackStore } from "@/utils/store/playback";
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
import { Button, Typography } from "@mui/material";
|
import { Button, Typography } from "@mui/material";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@@ -7,8 +7,8 @@ import { getTypeIcon } from "../utils/iconsCollection";
|
|||||||
|
|
||||||
import "./outroCard.scss";
|
import "./outroCard.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
|
||||||
const OutroCard = (props: { handleShowCredits: () => void }) => {
|
const OutroCard = (props: { handleShowCredits: () => void }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -16,19 +16,14 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
s.currentItemIndex,
|
s.currentItemIndex,
|
||||||
s.tracks,
|
s.tracks,
|
||||||
]);
|
]);
|
||||||
const item = queueItems[nextItemIndex + 1];
|
const item = queueItems?.[nextItemIndex + 1];
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
mutationFn: () => playItemFromQueue("next", user?.Id, api),
|
||||||
onError: (error) => [console.error(error)],
|
onError: (error) => [console.error(error)],
|
||||||
});
|
});
|
||||||
|
if (!item || !item.Type) return null;
|
||||||
return (
|
return (
|
||||||
<div className="outro-card">
|
<div className="outro-card">
|
||||||
<Typography variant="h4">Up Next</Typography>
|
<Typography variant="h4">Up Next</Typography>
|
||||||
@@ -37,14 +32,21 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
<img
|
<img
|
||||||
className="outro-card-content-image"
|
className="outro-card-content-image"
|
||||||
alt={item.Name ?? "Cover"}
|
alt={item.Name ?? "Cover"}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
src={
|
||||||
tag: item.ImageTags.Primary,
|
api &&
|
||||||
quality: 80,
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
})}
|
item.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
tag: item.ImageTags.Primary,
|
||||||
|
quality: 80,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="outro-card-content-image icon">
|
<div className="outro-card-content-image icon">
|
||||||
{getTypeIcon(item?.Type)}
|
{getTypeIcon(item.Type)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Typography variant="h5" className="outro-card-content-title">
|
<Typography variant="h5" className="outro-card-content-title">
|
||||||
@@ -56,6 +58,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
<div className="outro-card-content-buttons">
|
<div className="outro-card-content-buttons">
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePlayNext.mutate}
|
onClick={handlePlayNext.mutate}
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
startIcon={
|
startIcon={
|
||||||
@@ -74,6 +77,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={props.handleShowCredits}
|
onClick={props.handleShowCredits}
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
grid-area: img;
|
grid-area: img;
|
||||||
max-height: 14em;
|
aspect-ratio: 16/9;
|
||||||
width: 20em;
|
width: 20em;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
border-radius: $border-radius-default;
|
border-radius: $border-radius-default;
|
||||||
|
|||||||
@@ -22,13 +22,12 @@ import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
const AudioPlayer = () => {
|
const AudioPlayer = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const audioRef = useRef<HTMLAudioElement>(null!);
|
|
||||||
|
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||||
const [url, display, item] = useAudioPlayback((state) => [
|
const [url, display, item] = useAudioPlayback((state) => [
|
||||||
state.url,
|
state.url,
|
||||||
state.display,
|
state.display,
|
||||||
@@ -46,15 +45,12 @@ const AudioPlayer = () => {
|
|||||||
if (audioRef.current?.paused) return false;
|
if (audioRef.current?.paused) return false;
|
||||||
return true;
|
return true;
|
||||||
}, [audioRef.current?.paused]);
|
}, [audioRef.current?.paused]);
|
||||||
const [playerReady, setPlayerReady] = useState(false);
|
|
||||||
const [volume, setVolume] = useState(0.8);
|
const [volume, setVolume] = useState(0.8);
|
||||||
const [isMuted, setIsMuted] = useState(false);
|
const [isMuted, setIsMuted] = useState(false);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [isScrubbing, setIsScrubbing] = useState(false);
|
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||||
const [sliderProgress, setSliderProgress] = useState(0);
|
const [sliderProgress, setSliderProgress] = useState(0);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (display) {
|
if (display) {
|
||||||
// const audioUrlRequest = new Request(audioRef.current?.dataset.src, {
|
// const audioUrlRequest = new Request(audioRef.current?.dataset.src, {
|
||||||
@@ -82,7 +78,7 @@ const AudioPlayer = () => {
|
|||||||
|
|
||||||
const info = useMemo(
|
const info = useMemo(
|
||||||
() =>
|
() =>
|
||||||
!!api?.configuration && (
|
api && (
|
||||||
<div
|
<div
|
||||||
// initial={{
|
// initial={{
|
||||||
// filter: "opacity(0)",
|
// filter: "opacity(0)",
|
||||||
@@ -100,7 +96,7 @@ const AudioPlayer = () => {
|
|||||||
alt={tracks?.[currentTrack]?.Name ?? "track"}
|
alt={tracks?.[currentTrack]?.Name ?? "track"}
|
||||||
className="audio-player-image"
|
className="audio-player-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={getImageUrlsApi(api).getItemImageUrlById(
|
||||||
(!item?.ImageTags?.Primary ? item?.AlbumId : item?.Id) ?? "",
|
(!item?.ImageTags?.Primary ? item?.AlbumId : item.Id) ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
quality: 85,
|
quality: 85,
|
||||||
@@ -152,9 +148,9 @@ const AudioPlayer = () => {
|
|||||||
<Fab
|
<Fab
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
audioRef.current.paused
|
audioRef.current?.paused
|
||||||
? audioRef.current.play()
|
? audioRef.current.play()
|
||||||
: audioRef.current.pause()
|
: audioRef.current?.pause()
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -170,7 +166,7 @@ const AudioPlayer = () => {
|
|||||||
<PlayNextButton />
|
<PlayNextButton />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
[tracks?.[currentTrack]?.Id, loading, playing, tracks?.length],
|
[tracks?.[currentTrack]?.Id, playing, tracks?.length],
|
||||||
);
|
);
|
||||||
|
|
||||||
const buttons = useMemo(
|
const buttons = useMemo(
|
||||||
@@ -187,7 +183,7 @@ const AudioPlayer = () => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
<QueueButton />
|
<QueueButton />
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => {
|
onClick={() => {
|
||||||
setIsMuted(!isMuted);
|
setIsMuted(!isMuted);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -200,7 +196,13 @@ const AudioPlayer = () => {
|
|||||||
step={1}
|
step={1}
|
||||||
max={100}
|
max={100}
|
||||||
onChange={(_, newVal) => {
|
onChange={(_, newVal) => {
|
||||||
Array.isArray(newVal) ? setVolume(newVal[0] / 100) : setVolume(newVal / 100);
|
if (!audioRef.current) {
|
||||||
|
console.error("Audio ref not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Array.isArray(newVal)
|
||||||
|
? setVolume(newVal[0] / 100)
|
||||||
|
: setVolume(newVal / 100);
|
||||||
if (Array.isArray(newVal)) {
|
if (Array.isArray(newVal)) {
|
||||||
audioRef.current.volume = newVal[0] / 100;
|
audioRef.current.volume = newVal[0] / 100;
|
||||||
} else {
|
} else {
|
||||||
@@ -248,13 +250,14 @@ const AudioPlayer = () => {
|
|||||||
[volume, isMuted, currentTrack],
|
[volume, isMuted, currentTrack],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (audioRef.current) {
|
// if (audioRef.current) {
|
||||||
audioRef.current.addEventListener("ended", () => {
|
// audioRef.current.addEventListener("change", () => {
|
||||||
if (tracks?.[currentTrack + 1]?.Id) {
|
// console.log("Audio Player changed state : ", currentTrack);
|
||||||
playItemFromQueue("next", user?.Id, api);
|
// });
|
||||||
}
|
// audioRef.current.addEventListener("ended", () => {
|
||||||
});
|
|
||||||
}
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatePresence mode="sync">
|
<AnimatePresence mode="sync">
|
||||||
@@ -286,10 +289,15 @@ const AudioPlayer = () => {
|
|||||||
autoPlay
|
autoPlay
|
||||||
src={url}
|
src={url}
|
||||||
ref={audioRef}
|
ref={audioRef}
|
||||||
key={item?.Id}
|
key={item?.Id ?? "noItem"}
|
||||||
onTimeUpdate={(e) =>
|
onTimeUpdate={(e) =>
|
||||||
setProgress(secToTicks(e.currentTarget.currentTime))
|
setProgress(secToTicks(e.currentTarget.currentTime))
|
||||||
}
|
}
|
||||||
|
onEnded={() => {
|
||||||
|
if (tracks?.[currentTrack + 1]?.Id && api && user?.Id) {
|
||||||
|
playItemFromQueue("next", user.Id, api);
|
||||||
|
}
|
||||||
|
}}
|
||||||
id="audio-player"
|
id="audio-player"
|
||||||
/>
|
/>
|
||||||
<div className="audio-player-controls">
|
<div className="audio-player-controls">
|
||||||
@@ -324,8 +332,12 @@ const AudioPlayer = () => {
|
|||||||
: setSliderProgress(value);
|
: setSliderProgress(value);
|
||||||
}}
|
}}
|
||||||
onChangeCommitted={(_, value) => {
|
onChangeCommitted={(_, value) => {
|
||||||
|
if (!audioRef.current) {
|
||||||
|
console.error("Audio ref not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
setIsScrubbing(false);
|
setIsScrubbing(false);
|
||||||
// console.log(ticksToSec(value * item?.RunTimeTicks));
|
// console.log(ticksToSec(value * item.RunTimeTicks));
|
||||||
Array.isArray(value)
|
Array.isArray(value)
|
||||||
? setProgress(value[0])
|
? setProgress(value[0])
|
||||||
: setProgress(value);
|
: setProgress(value);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getRuntimeMusic } from "@/utils/date/time";
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
import useQueue, { setQueue } from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
|
|
||||||
import { useSortable } from "@dnd-kit/sortable";
|
import { useSortable } from "@dnd-kit/sortable";
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
@@ -7,9 +7,6 @@ import { CSS } from "@dnd-kit/utilities";
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { Typography } from "@mui/material";
|
import { Typography } from "@mui/material";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useCallback, useRef } from "react";
|
|
||||||
import { type XYCoord, useDrag, useDrop } from "react-dnd";
|
|
||||||
import type { Identifier } from "typescript";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,84 +16,13 @@ type Props = {
|
|||||||
};
|
};
|
||||||
const QueueTrack = (props: Props) => {
|
const QueueTrack = (props: Props) => {
|
||||||
const { track, index } = props;
|
const { track, index } = props;
|
||||||
const [queue, currentItemIndex] = useQueue((s) => [
|
const [currentItemIndex] = useQueue((s) => [s.currentItemIndex]);
|
||||||
s.tracks,
|
|
||||||
s.currentItemIndex,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const { attributes, listeners, setNodeRef, transform, transition } =
|
const { attributes, listeners, setNodeRef, transform, transition } =
|
||||||
useSortable({
|
useSortable({
|
||||||
id: track.Id,
|
id: track.Id ?? "",
|
||||||
});
|
});
|
||||||
|
|
||||||
// const trackRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
// const handleQueueUpdate = useCallback(
|
|
||||||
// (dragIndex: number, dropIndex: number) => {
|
|
||||||
// const prevState = queue;
|
|
||||||
// prevState.splice(dropIndex, 0, prevState.splice(dragIndex, 1)[0]);
|
|
||||||
// setQueue(prevState, dropIndex);
|
|
||||||
// },
|
|
||||||
// [queue],
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const [{ handlerId }, drop] = useDrop<
|
|
||||||
// {
|
|
||||||
// index: number;
|
|
||||||
// id: string;
|
|
||||||
// type: string;
|
|
||||||
// },
|
|
||||||
// void,
|
|
||||||
// { handlerId: Identifier | null }
|
|
||||||
// >({
|
|
||||||
// accept: "Row",
|
|
||||||
// collect(monitor) {
|
|
||||||
// return {
|
|
||||||
// handlerId: monitor.getHandlerId(),
|
|
||||||
// };
|
|
||||||
// },
|
|
||||||
// hover(hoverItem, monitor) {
|
|
||||||
// console.log(hoverItem);
|
|
||||||
// if (!trackRef.current) return;
|
|
||||||
|
|
||||||
// const dragIndex = hoverItem.index;
|
|
||||||
// const dropIndex = index;
|
|
||||||
|
|
||||||
// if (dragIndex === dropIndex) return;
|
|
||||||
|
|
||||||
// const hoverBoundingRect = trackRef.current?.getBoundingClientRect();
|
|
||||||
// const hoverMiddleY =
|
|
||||||
// (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
||||||
|
|
||||||
// const clientOffset = monitor.getClientOffset();
|
|
||||||
|
|
||||||
// const hoverClientY = (clientOffset as XYCoord).y - hoverBoundingRect.top;
|
|
||||||
|
|
||||||
// if (dragIndex < dropIndex && hoverClientY < hoverMiddleY) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (dragIndex > dropIndex && hoverClientY > hoverMiddleY) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// handleQueueUpdate(dragIndex, dropIndex);
|
|
||||||
// hoverItem.index = dropIndex;
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const [{ isDragging }, drag] = useDrag({
|
|
||||||
// type: "Row",
|
|
||||||
// item: () => {
|
|
||||||
// const id = track.Id;
|
|
||||||
// return { id, index };
|
|
||||||
// },
|
|
||||||
// collect: (monitor) => ({
|
|
||||||
// isDragging: monitor.isDragging(),
|
|
||||||
// }),
|
|
||||||
// });
|
|
||||||
|
|
||||||
// drag(drop(trackRef));
|
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
// opacity: isDragging ? 0.5 : 1,
|
// opacity: isDragging ? 0.5 : 1,
|
||||||
transform: CSS.Transform.toString(transform),
|
transform: CSS.Transform.toString(transform),
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { CircularProgress } from "@mui/material";
|
||||||
|
import { useRouterState } from "@tanstack/react-router";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function RouterLoading() {
|
||||||
|
const routeLoading = useRouterState().isLoading;
|
||||||
|
if (!routeLoading) return null;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: "100vw",
|
||||||
|
height: "100vh",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
background: "rgb(0 0 0 / 0.35)",
|
||||||
|
position: "fixed",
|
||||||
|
zIndex: 10000,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress size={72} thickness={2} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,23 +1,30 @@
|
|||||||
import { getSetting, setSetting } from "@/utils/storage/settings";
|
import { getSetting, setSetting } from "@/utils/storage/settings";
|
||||||
import { FormControlLabel, Switch, Typography } from "@mui/material";
|
import { FormControlLabel, Switch, Typography } from "@mui/material";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
const SettingOption = ({
|
const SettingOption = ({
|
||||||
setting,
|
setting,
|
||||||
}: { setting: { key: string; name: string; description: string } }) => {
|
}: { setting: { key: string; name: string; description: string } }) => {
|
||||||
const [settingVal, setSettingVal] = useState(
|
const initValue = useQuery({
|
||||||
async () => (await getSetting(setting.key)) ?? false,
|
queryKey: ["setting", setting.key],
|
||||||
);
|
queryFn: async () => {
|
||||||
|
const result = await getSetting(setting.key);
|
||||||
|
return Boolean(result);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const [settingVal, setSettingVal] = useState(initValue.data ?? false);
|
||||||
return (
|
return (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Switch
|
<Switch
|
||||||
color="primary"
|
color="primary"
|
||||||
checked={settingVal}
|
checked={Boolean(settingVal)}
|
||||||
onChange={(e) => {
|
onChange={(_, checked) => {
|
||||||
setSetting(setting.key, e.target.checked);
|
setSetting(setting.key, checked);
|
||||||
setSettingVal(e.target.checked);
|
setSettingVal(Boolean(checked));
|
||||||
}}
|
}}
|
||||||
|
disabled={initValue.isLoading}
|
||||||
name={setting.name}
|
name={setting.name}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ const Settings = () => {
|
|||||||
const systemInfo = useQuery({
|
const systemInfo = useQuery({
|
||||||
queryKey: ["about", "systemInfo"],
|
queryKey: ["about", "systemInfo"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getSystemApi(api).getSystemInfo();
|
const result = await getSystemApi(api).getSystemInfo();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -106,7 +107,7 @@ const Settings = () => {
|
|||||||
const handleServerChange = useMutation({
|
const handleServerChange = useMutation({
|
||||||
mutationFn: async (server: RecommendedServerInfo) => {
|
mutationFn: async (server: RecommendedServerInfo) => {
|
||||||
await delUser();
|
await delUser();
|
||||||
await setDefaultServer(server.id);
|
await setDefaultServer(server.systemInfo?.Id ?? "");
|
||||||
await defaultServer.refetch();
|
await defaultServer.refetch();
|
||||||
createApi(server.address, undefined);
|
createApi(server.address, undefined);
|
||||||
queryClient.removeQueries();
|
queryClient.removeQueries();
|
||||||
@@ -126,15 +127,15 @@ const Settings = () => {
|
|||||||
const handleDelete = useMutation({
|
const handleDelete = useMutation({
|
||||||
mutationKey: ["server-delete"],
|
mutationKey: ["server-delete"],
|
||||||
mutationFn: async (server: RecommendedServerInfo) => {
|
mutationFn: async (server: RecommendedServerInfo) => {
|
||||||
await delServer(server.id);
|
await delServer(server.systemInfo?.Id ?? "");
|
||||||
|
|
||||||
if (server.id === defaultServer.data) {
|
if (server.systemInfo?.Id === defaultServer.data) {
|
||||||
await delUser();
|
await delUser();
|
||||||
await serversOnDisk.refetch();
|
await serversOnDisk.refetch();
|
||||||
|
|
||||||
if (serversOnDisk.data.length > 0) {
|
if (serversOnDisk.data?.length) {
|
||||||
setDefaultServer(serversOnDisk.data[0].id);
|
setDefaultServer(serversOnDisk.data[0].id);
|
||||||
createApi(serversOnDisk.data[0].address, null);
|
createApi(serversOnDisk.data[0].address, undefined);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Reset api in context
|
// TODO: Reset api in context
|
||||||
// useApi.setState(useApi.getInitialState());
|
// useApi.setState(useApi.getInitialState());
|
||||||
@@ -158,7 +159,7 @@ const Settings = () => {
|
|||||||
},
|
},
|
||||||
onSuccess: async (bestServer) => {
|
onSuccess: async (bestServer) => {
|
||||||
if (bestServer) {
|
if (bestServer) {
|
||||||
await setServer(bestServer.systemInfo.Id, bestServer);
|
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||||
setAddServerDialog(false);
|
setAddServerDialog(false);
|
||||||
enqueueSnackbar(
|
enqueueSnackbar(
|
||||||
"Client added successfully. You might need to refresh client list.",
|
"Client added successfully. You might need to refresh client list.",
|
||||||
@@ -413,7 +414,7 @@ const Settings = () => {
|
|||||||
{/* About */}
|
{/* About */}
|
||||||
{tabValue === 10 && (
|
{tabValue === 10 && (
|
||||||
<div className="settings-container settings-about">
|
<div className="settings-container settings-about">
|
||||||
<img src={logo} className="settings-logo" alt="JellyPlayer" />
|
<img src={logo} className="settings-logo" alt="Blink" />
|
||||||
<div className="settings-grid">
|
<div className="settings-grid">
|
||||||
<div className="settings-info-container">
|
<div className="settings-info-container">
|
||||||
<div className="settings-info">
|
<div className="settings-info">
|
||||||
@@ -422,10 +423,10 @@ const Settings = () => {
|
|||||||
icon={
|
icon={
|
||||||
<span
|
<span
|
||||||
className="material-symbols-rounded"
|
className="material-symbols-rounded"
|
||||||
style={{ "--wght": 500 }}
|
// style={{ "--wght": 500 }}
|
||||||
>
|
>
|
||||||
{updateInfo.data?.available
|
{updateInfo.data?.available
|
||||||
? "new_release"
|
? "release_alert"
|
||||||
: "new_releases"}
|
: "new_releases"}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
@@ -484,7 +485,7 @@ const Settings = () => {
|
|||||||
setUpdating(true);
|
setUpdating(true);
|
||||||
await updateInfo.data?.downloadAndInstall();
|
await updateInfo.data?.downloadAndInstall();
|
||||||
enqueueSnackbar(
|
enqueueSnackbar(
|
||||||
"Update has been installed! You need to relaunch JellyPlayer.",
|
"Update has been installed! You need to relaunch Blink.",
|
||||||
{
|
{
|
||||||
variant: "success",
|
variant: "success",
|
||||||
},
|
},
|
||||||
@@ -620,6 +621,7 @@ const Settings = () => {
|
|||||||
>
|
>
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
|
{/* @ts-ignore */}
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
startIcon={
|
startIcon={
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
import React from "react";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
const ShowMoreText = ({
|
const ShowMoreText = ({
|
||||||
content,
|
content,
|
||||||
collapsedLines,
|
collapsedLines,
|
||||||
extraProps,
|
extraProps,
|
||||||
}: { content: string; collapsedLines: number; extraProps?: unknown }) => {
|
}: {
|
||||||
|
content: string;
|
||||||
|
collapsedLines: number;
|
||||||
|
extraProps?: Record<string, any>;
|
||||||
|
}) => {
|
||||||
const [displayFull, setDisplayFull] = useState(false);
|
const [displayFull, setDisplayFull] = useState(false);
|
||||||
const [isOverflowing, setIsOverflowing] = useState(false);
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
||||||
const textRef = useRef(null);
|
const textRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (textRef.current) {
|
if (textRef.current) {
|
||||||
@@ -33,7 +38,7 @@ const ShowMoreText = ({
|
|||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
ref={textRef}
|
ref={textRef}
|
||||||
key={displayFull}
|
key={displayFull ? "full" : "collapsed"}
|
||||||
style={{
|
style={{
|
||||||
display: "-webkit-box",
|
display: "-webkit-box",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
@@ -49,6 +54,7 @@ const ShowMoreText = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
{content.length > 0 && isOverflowing && (
|
{content.length > 0 && isOverflowing && (
|
||||||
<Button
|
<Button
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={() => setDisplayFull((state) => !state)}
|
onClick={() => setDisplayFull((state) => !state)}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import Box from "@mui/material/Box";
|
|
||||||
import Card from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import CardContent from "@mui/material/CardContent";
|
|
||||||
import CardMedia from "@mui/material/CardMedia";
|
|
||||||
import Skeleton from "@mui/material/Skeleton";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
export const CardsSkeleton = () => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexFlow: "column",
|
|
||||||
marginBottom: "2em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="h4" sx={{ mb: "0.15em" }}>
|
|
||||||
<Skeleton width="35%" animation="wave" />
|
|
||||||
</Typography>
|
|
||||||
<Skeleton width="100%" variant="rounded" animation="wave">
|
|
||||||
<div style={{ paddingTop: "20%" }} />
|
|
||||||
</Skeleton>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import Skeleton from "@mui/material/Skeleton";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const CardsSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexFlow: "column",
|
||||||
|
marginBottom: "2em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="h3" sx={{ mb: "0.15em" }}>
|
||||||
|
<Skeleton width="35%" />
|
||||||
|
</Typography>
|
||||||
|
<div className="flex flex-align-center" style={{ height: "17em" }}>
|
||||||
|
{Array.from({ length: 12 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
height="26em"
|
||||||
|
sx={{
|
||||||
|
flex: "1 0 12.45%",
|
||||||
|
marginRight: "1.5em",
|
||||||
|
borderRadius: "10px",
|
||||||
|
animationDelay: `${index * 0.25}s`,
|
||||||
|
}}
|
||||||
|
// biome-ignore lint/suspicious/noArrayIndexKey: This is a skeleton component
|
||||||
|
key={index}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,22 +1,15 @@
|
|||||||
import Box from "@mui/material/Box";
|
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Skeleton from "@mui/material/Skeleton";
|
import Skeleton from "@mui/material/Skeleton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { theme } from "../../theme";
|
|
||||||
export const CarouselSkeleton = () => {
|
export const CarouselSkeleton = () => {
|
||||||
return (
|
return (
|
||||||
<Paper
|
<div
|
||||||
className="hero-carousel-skeleton"
|
className="hero-carousel hero-carousel-skeleton"
|
||||||
elevation={0}
|
style={{
|
||||||
sx={{
|
|
||||||
height: "70vh",
|
height: "70vh",
|
||||||
marginBottom: "3.2em",
|
|
||||||
position: "relative",
|
position: "relative",
|
||||||
background: "black",
|
width: "100vw",
|
||||||
border: "1px solid rgb(255 255 255 / 0.2)",
|
marginLeft: "-4.4em",
|
||||||
borderRadius: "10px",
|
|
||||||
overflow: "hidden",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="hero-carousel-detail">
|
<div className="hero-carousel-detail">
|
||||||
@@ -29,9 +22,13 @@ export const CarouselSkeleton = () => {
|
|||||||
/>
|
/>
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="p"
|
variant="body1"
|
||||||
className="hero-carousel-text"
|
className="hero-carousel-text"
|
||||||
style={{ display: "flex", flexDirection: "column" }}
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
paddingBottom: "4.4em",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="text"
|
variant="text"
|
||||||
@@ -53,6 +50,6 @@ export const CarouselSkeleton = () => {
|
|||||||
/>
|
/>
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
</Paper>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -2,66 +2,96 @@ import { Divider, Skeleton, Typography } from "@mui/material";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const EpisodeSkeleton = () => {
|
const EpisodeSkeleton = () => {
|
||||||
return Array.from(new Array(8)).map((a, index) => {
|
return Array.from(new Array(8)).map((_, index) => {
|
||||||
return <>
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
// biome-ignore lint/suspicious/noArrayIndexKey: this is a skeleton
|
||||||
style={{
|
key={index}
|
||||||
width: "100%",
|
style={{
|
||||||
}}
|
width: "100%",
|
||||||
className="item-detail-episode"
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6"><Skeleton variant="circular" sx={{
|
<div className="item-detail-episode">
|
||||||
animationDelay: `${index * 0.2}s`,
|
<Typography variant="h6">
|
||||||
animationDuration: "1.4s",
|
<Skeleton
|
||||||
animationName: "pulse",
|
variant="circular"
|
||||||
opacity: 0.1,
|
sx={{
|
||||||
}} /></Typography>
|
animationDelay: `${index * 0.25}s`,
|
||||||
<div className="item-detail-episode-image-container">
|
animationDuration: "1.4s",
|
||||||
<Skeleton className="item-detail-episode-image" variant="rectangular" sx={{
|
animationName: "pulse",
|
||||||
animationDelay: `${index * 0.2}s`,
|
opacity: 0.1,
|
||||||
animationDuration: "1.4s",
|
aspectRatio: 1,
|
||||||
animationName: "pulse",
|
width: "3rem",
|
||||||
opacity: 0.1,
|
height: "3rem",
|
||||||
}} />
|
}}
|
||||||
</div>
|
/>
|
||||||
<div className="item-detail-episode-info">
|
</Typography>
|
||||||
<Typography variant="h4">
|
<div className="item-detail-episode-image-container">
|
||||||
<Skeleton variant="text" width="10em" sx={{
|
<Skeleton
|
||||||
animationDelay: `${index * 0.2}s`,
|
className="item-detail-episode-image"
|
||||||
animationDuration: "1.4s",
|
variant="rectangular"
|
||||||
animationName: "pulse",
|
sx={{
|
||||||
opacity: 0.1,
|
animationDelay: `${index * 0.2}s`,
|
||||||
}} />
|
animationDuration: "1.4s",
|
||||||
</Typography>
|
animationName: "pulse",
|
||||||
<Skeleton variant="rounded" width="5em" style={{ borderRadius: "100px" }} sx={{
|
opacity: 0.1,
|
||||||
animationDelay: `${index * 0.2}s`,
|
}}
|
||||||
animationDuration: "1.4s",
|
/>
|
||||||
animationName: "pulse",
|
</div>
|
||||||
opacity: 0.1,
|
<div className="item-detail-episode-info">
|
||||||
}} />
|
<Typography variant="h4">
|
||||||
<Typography style={{
|
<Skeleton
|
||||||
width: "100%"
|
variant="text"
|
||||||
}}>
|
width="10em"
|
||||||
<Skeleton width="100%" sx={{
|
sx={{
|
||||||
animationDelay: `${index * 0.2}s`,
|
animationDelay: `${index * 0.2}s`,
|
||||||
animationDuration: "1.4s",
|
animationDuration: "1.4s",
|
||||||
animationName: "pulse",
|
animationName: "pulse",
|
||||||
opacity: 0.1,
|
opacity: 0.1,
|
||||||
}} />
|
}}
|
||||||
<Skeleton width="100%" sx={{
|
/>
|
||||||
animationDelay: `${index * 0.2}s`,
|
</Typography>
|
||||||
animationDuration: "1.4s",
|
<Skeleton
|
||||||
animationName: "pulse",
|
variant="rounded"
|
||||||
opacity: 0.1,
|
width="5em"
|
||||||
}} />
|
style={{ borderRadius: "100px" }}
|
||||||
</Typography>
|
sx={{
|
||||||
</div>
|
animationDelay: `${index * 0.2}s`,
|
||||||
</div>
|
animationDuration: "1.4s",
|
||||||
{index !== 7 && <Divider orientation="horizontal" flexItem />}
|
animationName: "pulse",
|
||||||
|
opacity: 0.1,
|
||||||
</>
|
}}
|
||||||
})
|
/>
|
||||||
|
<Typography
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
width="100%"
|
||||||
|
sx={{
|
||||||
|
animationDelay: `${index * 0.2}s`,
|
||||||
|
animationDuration: "1.4s",
|
||||||
|
animationName: "pulse",
|
||||||
|
opacity: 0.1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
width="100%"
|
||||||
|
sx={{
|
||||||
|
animationDelay: `${index * 0.2}s`,
|
||||||
|
animationDuration: "1.4s",
|
||||||
|
animationName: "pulse",
|
||||||
|
opacity: 0.1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{index !== 7 && <Divider orientation="horizontal" flexItem />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EpisodeSkeleton
|
export default EpisodeSkeleton
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
import Card from "@mui/material/Card";
|
|
||||||
import CardContent from "@mui/material/CardContent";
|
|
||||||
import CardMedia from "@mui/material/CardMedia";
|
|
||||||
import Skeleton from "@mui/material/Skeleton";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import Grid from "@mui/material/Unstable_Grid2";
|
|
||||||
|
|
||||||
export const EpisodeCardsSkeleton = () => {
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
container
|
|
||||||
columns={{
|
|
||||||
xs: 2,
|
|
||||||
sm: 3,
|
|
||||||
md: 4,
|
|
||||||
}}
|
|
||||||
sx={{ width: "100%" }}
|
|
||||||
>
|
|
||||||
{Array.from(new Array(4)).map((a) => {
|
|
||||||
return (
|
|
||||||
<Grid xs={1} sm={1} md={1} key={a}>
|
|
||||||
<Card sx={{ background: "transparent" }} elevation={0}>
|
|
||||||
<CardMedia>
|
|
||||||
<Skeleton
|
|
||||||
animation="wave"
|
|
||||||
variant="rectangular"
|
|
||||||
sx={{
|
|
||||||
aspectRatio: "1.777",
|
|
||||||
height: "auto",
|
|
||||||
m: 1,
|
|
||||||
borderRadius: "8px",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</CardMedia>
|
|
||||||
<CardContent
|
|
||||||
sx={{
|
|
||||||
padding: "0 0.5em",
|
|
||||||
alignItems: "flex-start",
|
|
||||||
backgroundColor: "transparent",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="h6">
|
|
||||||
<Skeleton variant="text" animation="wave" />
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<Typography variant="body2">
|
|
||||||
<Skeleton variant="text" animation="wave" />
|
|
||||||
<Skeleton variant="text" animation="wave" />
|
|
||||||
|
|
||||||
<Skeleton variant="text" animation="wave" />
|
|
||||||
</Typography>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { Divider, LinearProgress, Skeleton } from "@mui/material";
|
import { Skeleton } from "@mui/material";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
const ItemSkeleton = () => {
|
const ItemSkeleton = () => {
|
||||||
|
|||||||
+5
-4
@@ -1,12 +1,13 @@
|
|||||||
import Divider from "@mui/material/Divider";
|
import Divider from "@mui/material/Divider";
|
||||||
import Grid from "@mui/material/Grid2";
|
import Grid2 from "@mui/material/Grid2";
|
||||||
import Skeleton from "@mui/material/Skeleton";
|
import Skeleton from "@mui/material/Skeleton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
import React from "react";
|
||||||
import EpisodeSkeleton from "./episode";
|
import EpisodeSkeleton from "./episode";
|
||||||
|
|
||||||
export const SeasonSelectorSkeleton = () => {
|
export const SeasonSelectorSkeleton = () => {
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid2
|
||||||
container
|
container
|
||||||
columns={{
|
columns={{
|
||||||
xs: 2,
|
xs: 2,
|
||||||
@@ -44,8 +45,8 @@ export const SeasonSelectorSkeleton = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="item-detail-episode-container">
|
<div className="item-detail-episode-container">
|
||||||
<EpisodeSkeleton/>
|
<EpisodeSkeleton />
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid2>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import "./textLink.scss";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
const TextLink = ({ children, location, variant, otherProps }) => {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Typography
|
|
||||||
variant={variant}
|
|
||||||
className="link flex"
|
|
||||||
onClick={() => navigate({ to: location })}
|
|
||||||
{...otherProps}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default TextLink;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
.link {
|
|
||||||
text-decoration: underline;
|
|
||||||
text-decoration-color: rgb(255 255 255 / 0.5);
|
|
||||||
white-space: pre-line;
|
|
||||||
width: fit-content;
|
|
||||||
&:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration-color: rgb(255 255 255 / 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
import { LoadingButton } from "@mui/lab";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Chip,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogContentText,
|
||||||
|
DialogTitle,
|
||||||
|
Link,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { relaunch } from "@tauri-apps/plugin-process";
|
||||||
|
import { type Update, check } from "@tauri-apps/plugin-updater";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { useLayoutEffect, useState } from "react";
|
||||||
|
|
||||||
|
export default function Updater() {
|
||||||
|
const [updateDialog, setUpdateDialog] = useState(false);
|
||||||
|
const [updateDialogButton, setUpdateDialogButton] = useState(false);
|
||||||
|
const [updateInfo, setUpdateInfo] = useState<Update | undefined>(undefined);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
async function checkForUpdates() {
|
||||||
|
try {
|
||||||
|
const update = await check();
|
||||||
|
|
||||||
|
if (update?.available) {
|
||||||
|
setUpdateInfo(update);
|
||||||
|
setUpdateDialog(true);
|
||||||
|
|
||||||
|
console.info(`Update found : ${update.version}, ${update.date}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkForUpdates();
|
||||||
|
}, []);
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
if (!updateInfo) return null;
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={updateDialog}
|
||||||
|
maxWidth="xs"
|
||||||
|
PaperProps={{
|
||||||
|
style: {
|
||||||
|
borderRadius: "20px",
|
||||||
|
},
|
||||||
|
className: "glass",
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
"& img": {
|
||||||
|
width: "100%",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogTitle variant="h5" align="center" textAlign={"center"}>
|
||||||
|
Update Available!
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent
|
||||||
|
className="flex flex-center"
|
||||||
|
style={{ gap: "0.5em", padding: "0 2em 1em 2em", flexWrap: "wrap" }}
|
||||||
|
>
|
||||||
|
<Chip
|
||||||
|
icon={<span className="material-symbols-rounded">update</span>}
|
||||||
|
label={`v${updateInfo.currentVersion}`}
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
<span className="material-symbols-rounded">arrow_right_alt</span>
|
||||||
|
<Chip
|
||||||
|
icon={<span className="material-symbols-rounded">update</span>}
|
||||||
|
label={`v${updateInfo.version}`}
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
<DialogContentText sx={{ width: "100%" }}>
|
||||||
|
<Link
|
||||||
|
href={`https://github.com/prayag17/Blink/releases/v${updateInfo.version}`}
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
Open changelog
|
||||||
|
</Link>
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
|
||||||
|
<DialogActions
|
||||||
|
style={{
|
||||||
|
padding: "1em",
|
||||||
|
}}
|
||||||
|
className="flex flex-center"
|
||||||
|
>
|
||||||
|
{/* <Button
|
||||||
|
variant="outlined"
|
||||||
|
//@ts-ignore
|
||||||
|
color="white"
|
||||||
|
disabled={updateDialogButton}
|
||||||
|
onClick={() => setUpdateDialog(false)}
|
||||||
|
>
|
||||||
|
changelog
|
||||||
|
</Button> */}
|
||||||
|
<Button
|
||||||
|
color="error"
|
||||||
|
variant="contained"
|
||||||
|
disabled={updateDialogButton}
|
||||||
|
onClick={() => setUpdateDialog(false)}
|
||||||
|
style={{ borderRadius: "10px" }}
|
||||||
|
disableElevation
|
||||||
|
>
|
||||||
|
close
|
||||||
|
</Button>
|
||||||
|
<LoadingButton
|
||||||
|
style={{ borderRadius: "10px" }}
|
||||||
|
color="success"
|
||||||
|
variant="contained"
|
||||||
|
loading={updateDialogButton}
|
||||||
|
loadingIndicator="Updating..."
|
||||||
|
disableElevation
|
||||||
|
onClick={async () => {
|
||||||
|
setUpdateDialogButton(true);
|
||||||
|
await updateInfo.downloadAndInstall();
|
||||||
|
enqueueSnackbar("Update has been installed! You need to relaunch Blink.", {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
await relaunch();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</LoadingButton>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -49,6 +49,7 @@ export const queryClient = new QueryClient({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// biome-ignore lint/nursery/useComponentExportOnlyModules : This is a valid use case for a component export
|
||||||
function ProviderWrapper() {
|
function ProviderWrapper() {
|
||||||
const [api, createApi, jellyfinSDK] = useApiInContext((s) => [
|
const [api, createApi, jellyfinSDK] = useApiInContext((s) => [
|
||||||
s.api,
|
s.api,
|
||||||
|
|||||||
+14
-51
@@ -14,7 +14,6 @@ import { Route as rootRoute } from './routes/__root'
|
|||||||
import { Route as ApiImport } from './routes/_api'
|
import { Route as ApiImport } from './routes/_api'
|
||||||
import { Route as IndexImport } from './routes/index'
|
import { Route as IndexImport } from './routes/index'
|
||||||
import { Route as ErrorCodeImport } from './routes/error/$code'
|
import { Route as ErrorCodeImport } from './routes/error/$code'
|
||||||
import { Route as ApiSearchImport } from './routes/_api/search'
|
|
||||||
import { Route as ApiLoginImport } from './routes/_api/login'
|
import { Route as ApiLoginImport } from './routes/_api/login'
|
||||||
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
||||||
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
||||||
@@ -57,12 +56,6 @@ const ErrorCodeRoute = ErrorCodeImport.update({
|
|||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiSearchRoute = ApiSearchImport.update({
|
|
||||||
id: '/search',
|
|
||||||
path: '/search',
|
|
||||||
getParentRoute: () => ApiRoute,
|
|
||||||
} as any)
|
|
||||||
|
|
||||||
const ApiLoginRoute = ApiLoginImport.update({
|
const ApiLoginRoute = ApiLoginImport.update({
|
||||||
id: '/login',
|
id: '/login',
|
||||||
path: '/login',
|
path: '/login',
|
||||||
@@ -70,9 +63,9 @@ const ApiLoginRoute = ApiLoginImport.update({
|
|||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiSearchIndexRoute = ApiSearchIndexImport.update({
|
const ApiSearchIndexRoute = ApiSearchIndexImport.update({
|
||||||
id: '/',
|
id: '/search/',
|
||||||
path: '/',
|
path: '/search/',
|
||||||
getParentRoute: () => ApiSearchRoute,
|
getParentRoute: () => ApiRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiPlayerIndexRoute = ApiPlayerIndexImport.update({
|
const ApiPlayerIndexRoute = ApiPlayerIndexImport.update({
|
||||||
@@ -220,13 +213,6 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof ApiLoginImport
|
preLoaderRoute: typeof ApiLoginImport
|
||||||
parentRoute: typeof ApiImport
|
parentRoute: typeof ApiImport
|
||||||
}
|
}
|
||||||
'/_api/search': {
|
|
||||||
id: '/_api/search'
|
|
||||||
path: '/search'
|
|
||||||
fullPath: '/search'
|
|
||||||
preLoaderRoute: typeof ApiSearchImport
|
|
||||||
parentRoute: typeof ApiImport
|
|
||||||
}
|
|
||||||
'/error/$code': {
|
'/error/$code': {
|
||||||
id: '/error/$code'
|
id: '/error/$code'
|
||||||
path: '/error/$code'
|
path: '/error/$code'
|
||||||
@@ -369,10 +355,10 @@ declare module '@tanstack/react-router' {
|
|||||||
}
|
}
|
||||||
'/_api/search/': {
|
'/_api/search/': {
|
||||||
id: '/_api/search/'
|
id: '/_api/search/'
|
||||||
path: '/'
|
path: '/search'
|
||||||
fullPath: '/search/'
|
fullPath: '/search'
|
||||||
preLoaderRoute: typeof ApiSearchIndexImport
|
preLoaderRoute: typeof ApiSearchIndexImport
|
||||||
parentRoute: typeof ApiSearchImport
|
parentRoute: typeof ApiImport
|
||||||
}
|
}
|
||||||
'/_api/login/$userId/$userName': {
|
'/_api/login/$userId/$userName': {
|
||||||
id: '/_api/login/$userId/$userName'
|
id: '/_api/login/$userId/$userName'
|
||||||
@@ -402,21 +388,8 @@ const ApiLoginRouteWithChildren = ApiLoginRoute._addFileChildren(
|
|||||||
ApiLoginRouteChildren,
|
ApiLoginRouteChildren,
|
||||||
)
|
)
|
||||||
|
|
||||||
interface ApiSearchRouteChildren {
|
|
||||||
ApiSearchIndexRoute: typeof ApiSearchIndexRoute
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApiSearchRouteChildren: ApiSearchRouteChildren = {
|
|
||||||
ApiSearchIndexRoute: ApiSearchIndexRoute,
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApiSearchRouteWithChildren = ApiSearchRoute._addFileChildren(
|
|
||||||
ApiSearchRouteChildren,
|
|
||||||
)
|
|
||||||
|
|
||||||
interface ApiRouteChildren {
|
interface ApiRouteChildren {
|
||||||
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
||||||
ApiSearchRoute: typeof ApiSearchRouteWithChildren
|
|
||||||
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
||||||
ApiArtistIdRoute: typeof ApiArtistIdRoute
|
ApiArtistIdRoute: typeof ApiArtistIdRoute
|
||||||
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
||||||
@@ -431,11 +404,11 @@ interface ApiRouteChildren {
|
|||||||
ApiFavoriteIndexRoute: typeof ApiFavoriteIndexRoute
|
ApiFavoriteIndexRoute: typeof ApiFavoriteIndexRoute
|
||||||
ApiHomeIndexRoute: typeof ApiHomeIndexRoute
|
ApiHomeIndexRoute: typeof ApiHomeIndexRoute
|
||||||
ApiPlayerIndexRoute: typeof ApiPlayerIndexRoute
|
ApiPlayerIndexRoute: typeof ApiPlayerIndexRoute
|
||||||
|
ApiSearchIndexRoute: typeof ApiSearchIndexRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiRouteChildren: ApiRouteChildren = {
|
const ApiRouteChildren: ApiRouteChildren = {
|
||||||
ApiLoginRoute: ApiLoginRouteWithChildren,
|
ApiLoginRoute: ApiLoginRouteWithChildren,
|
||||||
ApiSearchRoute: ApiSearchRouteWithChildren,
|
|
||||||
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
||||||
ApiArtistIdRoute: ApiArtistIdRoute,
|
ApiArtistIdRoute: ApiArtistIdRoute,
|
||||||
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
||||||
@@ -450,6 +423,7 @@ const ApiRouteChildren: ApiRouteChildren = {
|
|||||||
ApiFavoriteIndexRoute: ApiFavoriteIndexRoute,
|
ApiFavoriteIndexRoute: ApiFavoriteIndexRoute,
|
||||||
ApiHomeIndexRoute: ApiHomeIndexRoute,
|
ApiHomeIndexRoute: ApiHomeIndexRoute,
|
||||||
ApiPlayerIndexRoute: ApiPlayerIndexRoute,
|
ApiPlayerIndexRoute: ApiPlayerIndexRoute,
|
||||||
|
ApiSearchIndexRoute: ApiSearchIndexRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiRouteWithChildren = ApiRoute._addFileChildren(ApiRouteChildren)
|
const ApiRouteWithChildren = ApiRoute._addFileChildren(ApiRouteChildren)
|
||||||
@@ -458,7 +432,6 @@ export interface FileRoutesByFullPath {
|
|||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'': typeof ApiRouteWithChildren
|
'': typeof ApiRouteWithChildren
|
||||||
'/login': typeof ApiLoginRouteWithChildren
|
'/login': typeof ApiLoginRouteWithChildren
|
||||||
'/search': typeof ApiSearchRouteWithChildren
|
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
'/album/$id': typeof ApiAlbumIdRoute
|
'/album/$id': typeof ApiAlbumIdRoute
|
||||||
'/artist/$id': typeof ApiArtistIdRoute
|
'/artist/$id': typeof ApiArtistIdRoute
|
||||||
@@ -479,7 +452,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/favorite': typeof ApiFavoriteIndexRoute
|
'/favorite': typeof ApiFavoriteIndexRoute
|
||||||
'/home': typeof ApiHomeIndexRoute
|
'/home': typeof ApiHomeIndexRoute
|
||||||
'/player': typeof ApiPlayerIndexRoute
|
'/player': typeof ApiPlayerIndexRoute
|
||||||
'/search/': typeof ApiSearchIndexRoute
|
'/search': typeof ApiSearchIndexRoute
|
||||||
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +489,6 @@ export interface FileRoutesById {
|
|||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/_api': typeof ApiRouteWithChildren
|
'/_api': typeof ApiRouteWithChildren
|
||||||
'/_api/login': typeof ApiLoginRouteWithChildren
|
'/_api/login': typeof ApiLoginRouteWithChildren
|
||||||
'/_api/search': typeof ApiSearchRouteWithChildren
|
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
'/_api/album/$id': typeof ApiAlbumIdRoute
|
'/_api/album/$id': typeof ApiAlbumIdRoute
|
||||||
'/_api/artist/$id': typeof ApiArtistIdRoute
|
'/_api/artist/$id': typeof ApiArtistIdRoute
|
||||||
@@ -547,7 +519,6 @@ export interface FileRouteTypes {
|
|||||||
| '/'
|
| '/'
|
||||||
| ''
|
| ''
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/search'
|
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
| '/album/$id'
|
| '/album/$id'
|
||||||
| '/artist/$id'
|
| '/artist/$id'
|
||||||
@@ -568,7 +539,7 @@ export interface FileRouteTypes {
|
|||||||
| '/favorite'
|
| '/favorite'
|
||||||
| '/home'
|
| '/home'
|
||||||
| '/player'
|
| '/player'
|
||||||
| '/search/'
|
| '/search'
|
||||||
| '/login/$userId/$userName'
|
| '/login/$userId/$userName'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to:
|
to:
|
||||||
@@ -602,7 +573,6 @@ export interface FileRouteTypes {
|
|||||||
| '/'
|
| '/'
|
||||||
| '/_api'
|
| '/_api'
|
||||||
| '/_api/login'
|
| '/_api/login'
|
||||||
| '/_api/search'
|
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
| '/_api/album/$id'
|
| '/_api/album/$id'
|
||||||
| '/_api/artist/$id'
|
| '/_api/artist/$id'
|
||||||
@@ -671,7 +641,6 @@ export const routeTree = rootRoute
|
|||||||
"filePath": "_api.tsx",
|
"filePath": "_api.tsx",
|
||||||
"children": [
|
"children": [
|
||||||
"/_api/login",
|
"/_api/login",
|
||||||
"/_api/search",
|
|
||||||
"/_api/album/$id",
|
"/_api/album/$id",
|
||||||
"/_api/artist/$id",
|
"/_api/artist/$id",
|
||||||
"/_api/boxset/$id",
|
"/_api/boxset/$id",
|
||||||
@@ -685,7 +654,8 @@ export const routeTree = rootRoute
|
|||||||
"/_api/series/$id",
|
"/_api/series/$id",
|
||||||
"/_api/favorite/",
|
"/_api/favorite/",
|
||||||
"/_api/home/",
|
"/_api/home/",
|
||||||
"/_api/player/"
|
"/_api/player/",
|
||||||
|
"/_api/search/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/_api/login": {
|
"/_api/login": {
|
||||||
@@ -697,13 +667,6 @@ export const routeTree = rootRoute
|
|||||||
"/_api/login/$userId/$userName"
|
"/_api/login/$userId/$userName"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/_api/search": {
|
|
||||||
"filePath": "_api/search.tsx",
|
|
||||||
"parent": "/_api",
|
|
||||||
"children": [
|
|
||||||
"/_api/search/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"/error/$code": {
|
"/error/$code": {
|
||||||
"filePath": "error/$code.tsx"
|
"filePath": "error/$code.tsx"
|
||||||
},
|
},
|
||||||
@@ -752,7 +715,7 @@ export const routeTree = rootRoute
|
|||||||
"parent": "/_api"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/playlist/$id": {
|
"/_api/playlist/$id": {
|
||||||
"filePath": "_api/playlist/$id.jsx",
|
"filePath": "_api/playlist/$id.tsx",
|
||||||
"parent": "/_api"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/series/$id": {
|
"/_api/series/$id": {
|
||||||
@@ -782,7 +745,7 @@ export const routeTree = rootRoute
|
|||||||
},
|
},
|
||||||
"/_api/search/": {
|
"/_api/search/": {
|
||||||
"filePath": "_api/search/index.tsx",
|
"filePath": "_api/search/index.tsx",
|
||||||
"parent": "/_api/search"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/login/$userId/$userName": {
|
"/_api/login/$userId/$userName": {
|
||||||
"filePath": "_api/login/$userId.$userName.tsx",
|
"filePath": "_api/login/$userId.$userName.tsx",
|
||||||
|
|||||||
+24
-229
@@ -3,37 +3,14 @@ import NProgress from "@/components/nProgress";
|
|||||||
import AudioPlayer from "@/components/playback/audioPlayer";
|
import AudioPlayer from "@/components/playback/audioPlayer";
|
||||||
import Settings from "@/components/settings";
|
import Settings from "@/components/settings";
|
||||||
import { EasterEgg } from "@/components/utils/easterEgg";
|
import { EasterEgg } from "@/components/utils/easterEgg";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { CssBaseline, ThemeProvider } from "@mui/material";
|
||||||
import { LoadingButton } from "@mui/lab";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Chip,
|
|
||||||
CircularProgress,
|
|
||||||
CssBaseline,
|
|
||||||
Dialog,
|
|
||||||
DialogActions,
|
|
||||||
DialogContent,
|
|
||||||
DialogContentText,
|
|
||||||
DialogTitle,
|
|
||||||
IconButton,
|
|
||||||
SvgIcon,
|
|
||||||
ThemeProvider,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
|
||||||
import {
|
import {
|
||||||
Outlet,
|
Outlet,
|
||||||
ScrollRestoration,
|
ScrollRestoration,
|
||||||
createRootRouteWithContext,
|
createRootRouteWithContext,
|
||||||
useRouterState,
|
|
||||||
} from "@tanstack/react-router";
|
} from "@tanstack/react-router";
|
||||||
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
|
import { SnackbarProvider } from "notistack";
|
||||||
import { relaunch } from "@tauri-apps/plugin-process";
|
import React from "react";
|
||||||
import { type Update, check } from "@tauri-apps/plugin-updater";
|
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
|
||||||
import { SnackbarProvider, useSnackbar } from "notistack";
|
|
||||||
import React, { Suspense, useEffect, useLayoutEffect, useState } from "react";
|
|
||||||
import Markdown from "react-markdown";
|
|
||||||
import remarkGfm from "remark-gfm";
|
|
||||||
|
|
||||||
import "../styles/global.scss";
|
import "../styles/global.scss";
|
||||||
import { theme } from "@/theme";
|
import { theme } from "@/theme";
|
||||||
@@ -41,9 +18,13 @@ import { theme } from "@/theme";
|
|||||||
// Fonts
|
// Fonts
|
||||||
import "@fontsource-variable/jetbrains-mono";
|
import "@fontsource-variable/jetbrains-mono";
|
||||||
import "@fontsource-variable/noto-sans";
|
import "@fontsource-variable/noto-sans";
|
||||||
|
import "@fontsource-variable/plus-jakarta-sans";
|
||||||
|
|
||||||
import "material-symbols/rounded.scss";
|
import "material-symbols/rounded.scss";
|
||||||
|
import Backdrop from "@/components/backdrop";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
|
import RouterLoading from "@/components/routerLoading";
|
||||||
|
import Updater from "@/components/updater";
|
||||||
import type { Api, Jellyfin } from "@jellyfin/sdk";
|
import type { Api, Jellyfin } from "@jellyfin/sdk";
|
||||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||||
@@ -60,213 +41,27 @@ type ApiContext = {
|
|||||||
|
|
||||||
export const Route = createRootRouteWithContext<ApiContext>()({
|
export const Route = createRootRouteWithContext<ApiContext>()({
|
||||||
component: () => {
|
component: () => {
|
||||||
const isQueryFetching = useIsFetching();
|
|
||||||
const isMutating = useIsMutating();
|
|
||||||
const routeIsLoading = useRouterState().isLoading;
|
|
||||||
const [updateDialog, setUpdateDialog] = useState(false);
|
|
||||||
const [updateDialogButton, setUpdateDialogButton] = useState(false);
|
|
||||||
const [updateInfo, setUpdateInfo] = useState<Update | undefined>(undefined);
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
async function checkForUpdates() {
|
|
||||||
try {
|
|
||||||
const update = await check();
|
|
||||||
|
|
||||||
if (update?.available) {
|
|
||||||
setUpdateInfo(update);
|
|
||||||
setUpdateDialog(true);
|
|
||||||
|
|
||||||
console.log(`Update found : ${update.version}, ${update.date}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkForUpdates();
|
|
||||||
}, []);
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const [backdropUrl, backdropId] = useBackdropStore((state) => [
|
|
||||||
state.backdropUrl,
|
|
||||||
state.backdropId,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const [backdropLoading, setBackdropLoading] = useState(true);
|
|
||||||
// Reset BackdropImageLoading for every new image
|
|
||||||
useEffect(() => {
|
|
||||||
setBackdropLoading(true);
|
|
||||||
}, [backdropId]);
|
|
||||||
return (
|
return (
|
||||||
<DndProvider backend={HTML5Backend}>
|
<DndProvider backend={HTML5Backend}>
|
||||||
<Suspense fallback={<h1>Loading...</h1>}>
|
<ThemeProvider theme={theme}>
|
||||||
<ThemeProvider theme={theme}>
|
<SnackbarProvider maxSnack={5}>
|
||||||
<SnackbarProvider maxSnack={5}>
|
<CssBaseline />
|
||||||
<CssBaseline />
|
<ScrollRestoration />
|
||||||
<ScrollRestoration />
|
<Settings />
|
||||||
<Settings />
|
<EasterEgg />
|
||||||
<EasterEgg />
|
<NProgress />
|
||||||
<NProgress
|
|
||||||
key={
|
|
||||||
isQueryFetching || isMutating || routeIsLoading
|
|
||||||
? `show${(isQueryFetching ?? 1) * (isMutating ?? 1) * (routeIsLoading ? 1 : 2)}`
|
|
||||||
: "hide"
|
|
||||||
}
|
|
||||||
isAnimating={isQueryFetching && isMutating && routeIsLoading}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{routeIsLoading && (
|
<RouterLoading />
|
||||||
<motion.div
|
|
||||||
initial={{ opacity: 0 }}
|
|
||||||
animate={{ opacity: 1 }}
|
|
||||||
style={{
|
|
||||||
width: "100vw",
|
|
||||||
height: "100vh",
|
|
||||||
display: "flex",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
background: "rgb(0 0 0 / 0.35)",
|
|
||||||
position: "fixed",
|
|
||||||
zIndex: 10000,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CircularProgress size={72} thickness={2} />
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Dialog
|
<Updater />
|
||||||
open={updateDialog}
|
<Backdrop />
|
||||||
fullWidth
|
<AppBar />
|
||||||
PaperProps={{
|
<AudioPlayer />
|
||||||
style: {
|
<Outlet />
|
||||||
borderRadius: "14px",
|
<ReactQueryDevtools />
|
||||||
background: "rgb(0 0 0 / 0.5)",
|
{/* <TanStackRouterDevtools /> */}
|
||||||
backdropFilter: "blur(10px)",
|
</SnackbarProvider>
|
||||||
border: "1px solid rgb(255 255 255 / 0.2)",
|
</ThemeProvider>
|
||||||
},
|
|
||||||
}}
|
|
||||||
sx={{
|
|
||||||
"& img": {
|
|
||||||
width: "100%",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{updateInfo !== undefined && (
|
|
||||||
<>
|
|
||||||
<DialogTitle
|
|
||||||
variant="h5"
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "flex-start",
|
|
||||||
gap: "0.4em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Update Available!
|
|
||||||
<Chip
|
|
||||||
icon={
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
update
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
label={`v${updateInfo.version}`}
|
|
||||||
color="success"
|
|
||||||
/>
|
|
||||||
</DialogTitle>
|
|
||||||
<DialogContent dividers>
|
|
||||||
<DialogContentText>
|
|
||||||
<Markdown remarkPlugins={[remarkGfm]}>
|
|
||||||
{updateInfo.body}
|
|
||||||
</Markdown>
|
|
||||||
</DialogContentText>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions
|
|
||||||
style={{
|
|
||||||
padding: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
disabled={updateDialogButton}
|
|
||||||
target="_blank"
|
|
||||||
href={`https://github.com/prayag17/JellyPlayer/releases/${updateInfo.version}`}
|
|
||||||
>
|
|
||||||
<SvgIcon>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="16"
|
|
||||||
height="16"
|
|
||||||
fill="currentColor"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
>
|
|
||||||
<title>Update</title>
|
|
||||||
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8" />
|
|
||||||
</svg>
|
|
||||||
</SvgIcon>
|
|
||||||
</IconButton>
|
|
||||||
<Button
|
|
||||||
size="large"
|
|
||||||
color="error"
|
|
||||||
variant="outlined"
|
|
||||||
disabled={updateDialogButton}
|
|
||||||
onClick={() => setUpdateDialog(false)}
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</Button>
|
|
||||||
<LoadingButton
|
|
||||||
size="large"
|
|
||||||
color="success"
|
|
||||||
variant="contained"
|
|
||||||
loading={updateDialogButton}
|
|
||||||
loadingIndicator="Updating..."
|
|
||||||
onClick={async () => {
|
|
||||||
setUpdateDialogButton(true);
|
|
||||||
await updateInfo.downloadAndInstall();
|
|
||||||
enqueueSnackbar(
|
|
||||||
"Update has been installed! You need to relaunch JellyPlayer.",
|
|
||||||
{
|
|
||||||
variant: "success",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
await relaunch();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Update
|
|
||||||
</LoadingButton>
|
|
||||||
</DialogActions>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Dialog>
|
|
||||||
<div className="app-backdrop-container">
|
|
||||||
<AnimatePresence>
|
|
||||||
<motion.img
|
|
||||||
key={backdropId}
|
|
||||||
src={backdropUrl}
|
|
||||||
alt=""
|
|
||||||
className="app-backdrop"
|
|
||||||
initial={{
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
animate={{
|
|
||||||
opacity: backdropLoading ? 0 : 1,
|
|
||||||
}}
|
|
||||||
exit={{
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
transition={{
|
|
||||||
opacity: {
|
|
||||||
duration: 1.2,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
onLoad={() => setBackdropLoading(false)}
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
|
||||||
</AnimatePresence>
|
|
||||||
</div>
|
|
||||||
<AppBar />
|
|
||||||
<AudioPlayer />
|
|
||||||
<Outlet />
|
|
||||||
{/* <ReactQueryDevtools /> */}
|
|
||||||
{/* <TanStackRouterDevtools /> */}
|
|
||||||
</SnackbarProvider>
|
|
||||||
</ThemeProvider>
|
|
||||||
</Suspense>
|
|
||||||
</DndProvider>
|
</DndProvider>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,6 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
|||||||
|
|
||||||
export const Route = createFileRoute("/_api")({
|
export const Route = createFileRoute("/_api")({
|
||||||
beforeLoad: async ({ context, location }) => {
|
beforeLoad: async ({ context, location }) => {
|
||||||
// console.log(context.api);
|
|
||||||
console.log(context.user);
|
|
||||||
if (!context.api) {
|
if (!context.api) {
|
||||||
const currentServerId = await getDefaultServer();
|
const currentServerId = await getDefaultServer();
|
||||||
if (currentServerId) {
|
if (currentServerId) {
|
||||||
@@ -59,6 +57,7 @@ export const Route = createFileRoute("/_api")({
|
|||||||
} else if (context.api) {
|
} else if (context.api) {
|
||||||
if (context.api.accessToken && location.pathname !== "/login/manual") {
|
if (context.api.accessToken && location.pathname !== "/login/manual") {
|
||||||
try {
|
try {
|
||||||
|
console.info("AccessToken", context.api.accessToken);
|
||||||
await getUserApi(context.api).getCurrentUser(); // Verify user is able to authenticate
|
await getUserApi(context.api).getCurrentUser(); // Verify user is able to authenticate
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
+134
-270
@@ -1,14 +1,10 @@
|
|||||||
import React, { useLayoutEffect, useMemo, useRef } from "react";
|
import React, { useLayoutEffect, useMemo } from "react";
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import {
|
import { BaseItemKind, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||||
type BaseItemDto,
|
|
||||||
BaseItemKind,
|
|
||||||
SortOrder,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
@@ -16,30 +12,28 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
|||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { getRuntimeCompact, getRuntimeMusic } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import PlayButton from "@/components/buttons/playButton";
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
|
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import {
|
|
||||||
generateAudioStreamUrl,
|
|
||||||
playAudio,
|
|
||||||
useAudioPlayback,
|
|
||||||
} from "@/utils/store/audioPlayback";
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import "./album.scss";
|
import "./album.scss";
|
||||||
|
|
||||||
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
import TagChip from "@/components/tagChip";
|
import TagChip from "@/components/tagChip";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { playItem } from "@/utils/store/playback";
|
import { Chip } from "@mui/material";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
import lyricsIcon from "../../../assets/icons/lyrics.svg";
|
import { createPortal } from "react-dom";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/album/$id")({
|
export const Route = createFileRoute("/_api/album/$id")({
|
||||||
component: MusicAlbumTitlePage,
|
component: MusicAlbumTitlePage,
|
||||||
@@ -47,13 +41,14 @@ export const Route = createFileRoute("/_api/album/$id")({
|
|||||||
|
|
||||||
function MusicAlbumTitlePage() {
|
function MusicAlbumTitlePage() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
@@ -68,7 +63,7 @@ function MusicAlbumTitlePage() {
|
|||||||
const similarItems = useQuery({
|
const similarItems = useQuery({
|
||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (item.data?.Id) {
|
if (api && item.data?.Id) {
|
||||||
const result = await getLibraryApi(api).getSimilarAlbums({
|
const result = await getLibraryApi(api).getSimilarAlbums({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data?.Id,
|
itemId: item.data?.Id,
|
||||||
@@ -76,6 +71,7 @@ function MusicAlbumTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess,
|
enabled: item.isSuccess,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
@@ -85,16 +81,17 @@ function MusicAlbumTitlePage() {
|
|||||||
const musicTracks = useQuery({
|
const musicTracks = useQuery({
|
||||||
queryKey: ["item", "musicTracks", id],
|
queryKey: ["item", "musicTracks", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
parentId: item.data?.Id,
|
parentId: item.data?.Id,
|
||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
sortBy: ["IndexNumber"],
|
sortBy: ["IndexNumber", "ParentIndexNumber"],
|
||||||
fields: ["MediaSources"],
|
fields: ["MediaSources"],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicAlbum,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicAlbum,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -118,33 +115,12 @@ function MusicAlbumTitlePage() {
|
|||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (item.isSuccess) {
|
if (item.isSuccess) {
|
||||||
setAppBackdrop(
|
setAppBackdrop(
|
||||||
`${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`,
|
`${api?.basePath}/Items/${item.data?.ParentBackdropItemId}/Images/Backdrop`,
|
||||||
item.data.Id,
|
item.data?.Id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [item.isSuccess]);
|
}, [item.isSuccess]);
|
||||||
|
|
||||||
const pageRef = useRef(null);
|
|
||||||
|
|
||||||
const handlePlayback = (
|
|
||||||
index: number,
|
|
||||||
item: BaseItemDto,
|
|
||||||
queue: BaseItemDto[],
|
|
||||||
) => {
|
|
||||||
if (item.Id && user?.Id) {
|
|
||||||
const url = generateAudioStreamUrl(
|
|
||||||
item.Id,
|
|
||||||
user?.Id,
|
|
||||||
api.deviceInfo.id,
|
|
||||||
api.basePath,
|
|
||||||
api.accessToken,
|
|
||||||
);
|
|
||||||
playAudio(url, item, undefined);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const currentPlayingItem = useAudioPlayback((s) => s.item);
|
|
||||||
|
|
||||||
if (item.isPending || similarItems.isPending) {
|
if (item.isPending || similarItems.isPending) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -160,210 +136,120 @@ function MusicAlbumTitlePage() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (item.isSuccess && similarItems.isSuccess) {
|
if (item.isSuccess && item.data && similarItems.isSuccess) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={id} className="scrollY padded-top item item-album">
|
||||||
key={id}
|
<div className="item-info">
|
||||||
className="scrollY padded-top item item-album"
|
<Typography className="item-info-name" variant="h3">
|
||||||
ref={pageRef}
|
{item.data?.Name}
|
||||||
>
|
</Typography>
|
||||||
<div className="item-info-container">
|
<div className="flex flex-align-center item-info-album-info">
|
||||||
<div className="item-info">
|
{/* @ts-ignore - Using Link as component */}
|
||||||
<Typography className="item-info-name" variant="h3">
|
<Link
|
||||||
{item.data.Name}
|
to="/artist/$id"
|
||||||
|
params={{ id: item.data.AlbumArtists?.[0].Id ?? "" }}
|
||||||
|
>
|
||||||
|
<Chip
|
||||||
|
// component={Link}
|
||||||
|
className="flex flex-align-center"
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
textDecoration: "none",
|
||||||
|
}}
|
||||||
|
icon={
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded fill"
|
||||||
|
style={{
|
||||||
|
paddingLeft: "0.25em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
artist
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
label={item.data.AlbumArtist}
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
<Typography className="opacity-07">
|
||||||
|
{item.data.ProductionYear}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div className="flex flex-align-center item-info-album-info">
|
<Typography className="opacity-07">
|
||||||
<div className="flex flex-align-center">
|
{(musicTracks.data?.TotalRecordCount ?? 0) > 1
|
||||||
<span
|
? `${musicTracks.data?.TotalRecordCount} songs`
|
||||||
className="material-symbols-rounded"
|
: "Single"}
|
||||||
style={{
|
</Typography>
|
||||||
opacity: 0.7,
|
<Typography className="opacity-07">
|
||||||
}}
|
{getRuntimeCompact(item.data.CumulativeRunTimeTicks ?? 0)}
|
||||||
>
|
</Typography>
|
||||||
artist
|
</div>
|
||||||
</span>
|
<div className="item-info-buttons">
|
||||||
<Typography ml={1}>{item.data.AlbumArtist}</Typography>
|
<PlayButton
|
||||||
</div>
|
item={item.data}
|
||||||
<Typography className="opacity-07">
|
audio
|
||||||
{item.data.ProductionYear}
|
itemType={item.data.Type ?? "Audio"}
|
||||||
</Typography>
|
userId={user?.Id}
|
||||||
<Typography className="opacity-07">
|
/>
|
||||||
{(musicTracks.data?.TotalRecordCount ?? 0) > 1
|
<LikeButton
|
||||||
? `${musicTracks.data?.TotalRecordCount} songs`
|
itemId={item.data.Id}
|
||||||
: "1 song"}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
</Typography>
|
queryKey={["item", "musicTracks"]}
|
||||||
<Typography className="opacity-07">
|
userId={user?.Id}
|
||||||
{getRuntimeCompact(item.data.CumulativeRunTimeTicks ?? 0)}
|
itemName={item.data.Name}
|
||||||
</Typography>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="item-info-buttons">
|
<div className="item-info-track-container ">
|
||||||
<PlayButton
|
{allDiscs.length > 1 ? (
|
||||||
item={item.data}
|
allDiscs.map((disc) => (
|
||||||
audio
|
<div className="item-info-disc-container" key={disc}>
|
||||||
itemType={item.data.Type ?? "Audio"}
|
<div
|
||||||
userId={user?.Id}
|
className="item-info-disc-header flex flex-row flex-align-center"
|
||||||
/>
|
style={{ marginBottom: "1em" }}
|
||||||
<LikeButton
|
>
|
||||||
itemId={item.data.Id}
|
<span
|
||||||
isFavorite={item.data.UserData?.IsFavorite}
|
className="material-symbols-rounded"
|
||||||
queryKey={["item", "musicTracks"]}
|
style={{ fontSize: "2em" }}
|
||||||
userId={user?.Id}
|
|
||||||
itemName={item.data.Name}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="item-info-track-container ">
|
|
||||||
{allDiscs.length > 1 ? (
|
|
||||||
allDiscs.map((disc) => (
|
|
||||||
<>
|
|
||||||
<div
|
|
||||||
className="item-info-disc-header flex flex-row flex-align-center"
|
|
||||||
key={disc}
|
|
||||||
>
|
>
|
||||||
<span
|
album
|
||||||
className="material-symbols-rounded"
|
</span>
|
||||||
style={{ fontSize: "2em" }}
|
<Typography variant="h5">Disc {disc}</Typography>
|
||||||
>
|
</div>
|
||||||
album
|
|
||||||
</span>
|
|
||||||
<Typography variant="h5">Disc {disc}</Typography>
|
|
||||||
</div>
|
|
||||||
<div key={disc} className="item-info-track header">
|
|
||||||
<span className="material-symbols-rounded index">
|
|
||||||
tag
|
|
||||||
</span>
|
|
||||||
<Typography variant="subtitle1">Title</Typography>
|
|
||||||
<Typography variant="subtitle1">Duration</Typography>
|
|
||||||
</div>
|
|
||||||
{musicTracks.data?.Items?.map(
|
|
||||||
(track, index) =>
|
|
||||||
track.ParentIndexNumber === disc && (
|
|
||||||
<div
|
|
||||||
className={
|
|
||||||
currentPlayingItem?.Id === track.Id
|
|
||||||
? "item-info-track playing"
|
|
||||||
: "item-info-track"
|
|
||||||
}
|
|
||||||
key={track.Id}
|
|
||||||
onClick={() =>
|
|
||||||
musicTracks.data.Items &&
|
|
||||||
handlePlayback(
|
|
||||||
index,
|
|
||||||
track,
|
|
||||||
musicTracks.data.Items,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="index-container">
|
|
||||||
<span className="material-symbols-rounded fill ">
|
|
||||||
play_arrow
|
|
||||||
</span>
|
|
||||||
<Typography className="index">
|
|
||||||
{track.IndexNumber ?? "-"}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<div className="item-info-track-info">
|
|
||||||
<Typography className="item-info-track-info-name">
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "0.6em",
|
|
||||||
}}
|
|
||||||
fontWeight={300}
|
|
||||||
>
|
|
||||||
{track.HasLyrics && (
|
|
||||||
<img src={lyricsIcon} alt="lyrics" />
|
|
||||||
)}
|
|
||||||
{track.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<Typography>
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
|
||||||
</Typography>
|
|
||||||
<div className="flex flex-align-center">
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["item", "musicTracks"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="item-info-track header">
|
<div className="item-info-track header">
|
||||||
<span className="material-symbols-rounded index">tag</span>
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
<Typography variant="subtitle1">Title</Typography>
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
<Typography variant="subtitle1">Duration</Typography>
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
</div>
|
</div>
|
||||||
{musicTracks.data?.Items?.map((track, index) => (
|
{musicTracks.data?.Items?.map(
|
||||||
<div
|
(track, index) =>
|
||||||
className={
|
track.ParentIndexNumber === disc && (
|
||||||
currentPlayingItem?.Id === track.Id
|
<AlbumMusicTrack
|
||||||
? "item-info-track playing"
|
key={track.Id}
|
||||||
: "item-info-track"
|
track={track}
|
||||||
}
|
trackIndex={index}
|
||||||
key={track.Id}
|
musicTracks={musicTracks.data}
|
||||||
onClick={() =>
|
|
||||||
musicTracks.data.Items &&
|
|
||||||
handlePlayback(index, track, musicTracks.data.Items)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="index-container">
|
|
||||||
<span className="material-symbols-rounded fill ">
|
|
||||||
play_arrow
|
|
||||||
</span>
|
|
||||||
<Typography className="index">
|
|
||||||
{track.IndexNumber ?? "-"}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<div className="item-info-track-info">
|
|
||||||
<Typography className="item-info-track-info-name">
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "0.6em",
|
|
||||||
}}
|
|
||||||
fontWeight={300}
|
|
||||||
>
|
|
||||||
{track.HasLyrics && (
|
|
||||||
<img src={lyricsIcon} alt="lyrics" />
|
|
||||||
)}
|
|
||||||
{track.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<Typography>
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
|
||||||
</Typography>
|
|
||||||
<div className="flex flex-align-center">
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["item", "musicTracks"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
),
|
||||||
</div>
|
)}
|
||||||
))}
|
</div>
|
||||||
</>
|
))
|
||||||
)}
|
) : (
|
||||||
</div>
|
<div>
|
||||||
|
<div className="item-info-track header">
|
||||||
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
|
</div>
|
||||||
|
{musicTracks.data?.Items?.map((track, index) => (
|
||||||
|
<AlbumMusicTrack
|
||||||
|
key={track.Id}
|
||||||
|
track={track}
|
||||||
|
trackIndex={index}
|
||||||
|
musicTracks={musicTracks.data}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{createPortal(
|
||||||
<div className="item-info-sidebar">
|
<div className="item-info-sidebar">
|
||||||
<div className="item-info-sidebar-image-container">
|
<div className="item-info-sidebar-image-container">
|
||||||
{item.data.ImageTags?.Primary ? (
|
{item.data.ImageTags?.Primary ? (
|
||||||
@@ -371,9 +257,9 @@ function MusicAlbumTitlePage() {
|
|||||||
className="item-info-sidebar-image"
|
className="item-info-sidebar-image"
|
||||||
alt={item.data.Name ?? "Album"}
|
alt={item.data.Name ?? "Album"}
|
||||||
src={
|
src={
|
||||||
item.data.Id &&
|
api &&
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
item.data.Id,
|
item.data.Id ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
tag: item.data.ImageTags.Primary,
|
tag: item.data.ImageTags.Primary,
|
||||||
@@ -396,41 +282,19 @@ function MusicAlbumTitlePage() {
|
|||||||
<TagChip label={genre.Name ?? "genre"} key={genre.Id} />
|
<TagChip label={genre.Name ?? "genre"} key={genre.Id} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-column item-info-sidebar-artist-container">
|
<div className="item-info-sidebar-overview">
|
||||||
{item.data.ArtistItems?.map((artist) => (
|
<ShowMoreText
|
||||||
<Link
|
content={item.data.Overview ?? ""}
|
||||||
to="/artist/$id"
|
collapsedLines={4}
|
||||||
params={{ id: artist.Id ?? "" }}
|
/>
|
||||||
className="item-info-sidebar-artist"
|
|
||||||
key={artist.Id}
|
|
||||||
>
|
|
||||||
<div className="item-info-sidebar-artist-image-container">
|
|
||||||
<img
|
|
||||||
className="item-info-sidebar-artist-image"
|
|
||||||
alt={artist.Name ?? "Artist"}
|
|
||||||
src={
|
|
||||||
artist.Id &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
artist.Id,
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
quality: 90,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<span className="material-symbols-rounded">artist</span>
|
|
||||||
</div>
|
|
||||||
<Typography>{artist.Name}</Typography>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>,
|
||||||
</div>
|
document.body,
|
||||||
{(similarItems.data?.TotalRecordCount ?? -1) > 0 && (
|
)}
|
||||||
|
{(similarItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="You might also like"
|
title="You might also like"
|
||||||
displayCards={7}
|
displayCards={5}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
{similarItems.data?.Items?.map((similar) => {
|
{similarItems.data?.Items?.map((similar) => {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
$border-radius: 20px;
|
$border-radius: 20px;
|
||||||
.item-album {
|
.item-album {
|
||||||
|
width: 70vw;
|
||||||
|
padding-right: 2.2em;
|
||||||
.item-info {
|
.item-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -9,123 +11,7 @@ $border-radius: 20px;
|
|||||||
display: grid;
|
display: grid;
|
||||||
gap: 3em;
|
gap: 3em;
|
||||||
}
|
}
|
||||||
&-sidebar {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1em;
|
|
||||||
position: sticky;
|
|
||||||
max-height: 100vh;
|
|
||||||
top: 0;
|
|
||||||
&-image {
|
|
||||||
width: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
border-radius: $border-radius-default;
|
|
||||||
}
|
|
||||||
&-artist {
|
|
||||||
display: flex;
|
|
||||||
gap: 1em;
|
|
||||||
align-items: center;
|
|
||||||
padding: 1em 0;
|
|
||||||
color: rgb(255 255 255 / 0.7);
|
|
||||||
transition: $transition-time-default;
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: none;
|
|
||||||
&:hover {
|
|
||||||
color: rgb(255 255 255)
|
|
||||||
}
|
|
||||||
&-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
z-index: 1;
|
|
||||||
position: relative;
|
|
||||||
&-container {
|
|
||||||
width: 3em;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
border-radius: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
.material-symbols-rounded {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-container {
|
|
||||||
// max-height: 20em;/
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-track {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 3em 60% 6em 1fr;
|
|
||||||
gap: 1em;
|
|
||||||
padding: 1em;
|
|
||||||
align-items: center;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: $border-radius-default;
|
|
||||||
transition: background $transition-time-fast;
|
|
||||||
&.header {
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
|
||||||
color: rgb(255 255 255 / 0.7);
|
|
||||||
border-radius: 0 !important;
|
|
||||||
}
|
|
||||||
.index-container {
|
|
||||||
justify-self: center;
|
|
||||||
position: relative;
|
|
||||||
.material-symbols-rounded {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
font-size: 2em !important;
|
|
||||||
opacity: 0;
|
|
||||||
transition: none !important;
|
|
||||||
color: $clr-accent-default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.1em
|
|
||||||
}
|
|
||||||
&:hover {
|
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
|
||||||
.index-container {
|
|
||||||
// font-size: 0em;
|
|
||||||
.index {
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0;
|
|
||||||
}
|
|
||||||
.material-symbols-rounded {
|
|
||||||
opacity: 1;
|
|
||||||
font-size: 2.2em !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.playing {
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
|
||||||
.item-info-track-info-name, .index {
|
|
||||||
color: $clr-accent-default;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.4em
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-album-info {
|
&-album-info {
|
||||||
gap: 1.2em;
|
gap: 1.2em;
|
||||||
}
|
}
|
||||||
@@ -142,6 +28,74 @@ $border-radius: 20px;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item-info-sidebar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1em;
|
||||||
|
position: fixed;
|
||||||
|
// max-height: 100vh;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 30vw;
|
||||||
|
padding: 4.4em;
|
||||||
|
padding-left: 2.2em;
|
||||||
|
&-image {
|
||||||
|
width: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
}
|
||||||
|
&-artist {
|
||||||
|
display: flex;
|
||||||
|
gap: 1em;
|
||||||
|
align-items: center;
|
||||||
|
padding: 1em 0;
|
||||||
|
color: rgb(255 255 255 / 0.7);
|
||||||
|
transition: $transition-time-default;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
&:hover {
|
||||||
|
color: rgb(255 255 255)
|
||||||
|
}
|
||||||
|
&-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
z-index: 1;
|
||||||
|
position: relative;
|
||||||
|
&-container {
|
||||||
|
width: 3em;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
border-radius: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-container {
|
||||||
|
// max-height: 20em;/
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-overview {
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: 28vh;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.item-detail-album {
|
.item-detail-album {
|
||||||
&-track {
|
&-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, {
|
||||||
import React, { useState, useEffect, useLayoutEffect, useRef } from "react";
|
useState,
|
||||||
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
|
useRef,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
@@ -17,7 +22,6 @@ import {
|
|||||||
SortOrder,
|
SortOrder,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
@@ -26,12 +30,11 @@ import LikeButton from "@/components/buttons/likeButton";
|
|||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
|
|
||||||
import meshBg from "@/assets/herobg.png";
|
|
||||||
import { ArtistAlbum } from "@/components/layouts/artist/artistAlbum";
|
import { ArtistAlbum } from "@/components/layouts/artist/artistAlbum";
|
||||||
import MusicTrack from "@/components/musicTrack";
|
import MusicTrack from "@/components/musicTrack";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import "./artist.scss";
|
import "./artist.scss";
|
||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
@@ -40,7 +43,14 @@ import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
function TabPanel(props) {
|
|
||||||
|
type TabPanelProp = {
|
||||||
|
children: ReactNode;
|
||||||
|
index: number;
|
||||||
|
value: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
function TabPanel(props: TabPanelProp) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -57,12 +67,6 @@ function TabPanel(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/artist/$id")({
|
export const Route = createFileRoute("/_api/artist/$id")({
|
||||||
component: ArtistTitlePage,
|
component: ArtistTitlePage,
|
||||||
});
|
});
|
||||||
@@ -76,10 +80,10 @@ function ArtistTitlePage() {
|
|||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -91,8 +95,9 @@ function ArtistTitlePage() {
|
|||||||
const artistDiscography = useQuery({
|
const artistDiscography = useQuery({
|
||||||
queryKey: ["item", id, "artist", "discography"],
|
queryKey: ["item", id, "artist", "discography"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
albumArtistIds: [item.data.Id],
|
albumArtistIds: [item.data?.Id ?? ""],
|
||||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||||
sortOrder: [SortOrder.Descending],
|
sortOrder: [SortOrder.Descending],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -102,14 +107,16 @@ function ArtistTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicArtist,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicArtist,
|
||||||
});
|
});
|
||||||
|
|
||||||
const artistSongs = useQuery({
|
const artistSongs = useQuery({
|
||||||
queryKey: ["item", id, "artist", "songs"],
|
queryKey: ["item", id, "artist", "songs"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
artistIds: [item.data.Id],
|
artistIds: [item.data?.Id ?? ""],
|
||||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -119,15 +126,16 @@ function ArtistTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicArtist,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicArtist,
|
||||||
});
|
});
|
||||||
|
|
||||||
const artistAppearances = useQuery({
|
const artistAppearances = useQuery({
|
||||||
queryKey: ["item", id, "artist", "appearences"],
|
queryKey: ["item", id, "artist", "appearences"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
contributingArtistIds: [item.data.Id],
|
contributingArtistIds: [item.data?.Id ?? ""],
|
||||||
excludeItemIds: [item.data.Id],
|
excludeItemIds: [item.data?.Id ?? ""],
|
||||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||||
sortOrder: [SortOrder.Descending],
|
sortOrder: [SortOrder.Descending],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -136,7 +144,7 @@ function ArtistTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicArtist,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicArtist,
|
||||||
});
|
});
|
||||||
|
|
||||||
const artistTabs = [
|
const artistTabs = [
|
||||||
@@ -150,7 +158,10 @@ function ArtistTitlePage() {
|
|||||||
if (
|
if (
|
||||||
artistDiscography.isSuccess &&
|
artistDiscography.isSuccess &&
|
||||||
artistSongs.isSuccess &&
|
artistSongs.isSuccess &&
|
||||||
artistAppearances.isSuccess
|
artistAppearances.isSuccess &&
|
||||||
|
artistDiscography.data &&
|
||||||
|
artistSongs.data &&
|
||||||
|
artistAppearances.data
|
||||||
) {
|
) {
|
||||||
if (artistDiscography.data.TotalRecordCount !== 0) {
|
if (artistDiscography.data.TotalRecordCount !== 0) {
|
||||||
setActiveArtistTab(0);
|
setActiveArtistTab(0);
|
||||||
@@ -168,10 +179,11 @@ function ArtistTitlePage() {
|
|||||||
|
|
||||||
const [animationDirection, setAnimationDirection] = useState("forward");
|
const [animationDirection, setAnimationDirection] = useState("forward");
|
||||||
|
|
||||||
|
const { setBackdrop } = useBackdropStore();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (item.isSuccess) {
|
if (item.isSuccess && item.data) {
|
||||||
setBackdrop(
|
setBackdrop(
|
||||||
`${api.basePath}/Items/${item.data.Id}/Images/Backdrop`,
|
`${api?.basePath}/Items/${item.data.Id}/Images/Backdrop`,
|
||||||
item.data.Id,
|
item.data.Id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -199,7 +211,7 @@ function ArtistTitlePage() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (item.isSuccess) {
|
if (item.isSuccess && item.data) {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={id}
|
key={id}
|
||||||
@@ -219,17 +231,20 @@ function ArtistTitlePage() {
|
|||||||
<div className="item-hero flex flex-row">
|
<div className="item-hero flex flex-row">
|
||||||
<div className="item-hero-backdrop-container">
|
<div className="item-hero-backdrop-container">
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data?.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Backdrop",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data?.Id ?? "",
|
||||||
tag: item.data.BackdropImageTags[0],
|
"Backdrop",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.data.BackdropImageTags?.[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -242,53 +257,59 @@ function ArtistTitlePage() {
|
|||||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.keys(item.data.ImageTags).includes("Primary") ? (
|
{item.data.ImageTags?.Primary ? (
|
||||||
<>
|
<div>
|
||||||
<Blurhash
|
<Blurhash
|
||||||
hash={
|
hash={
|
||||||
item.data.ImageBlurHashes.Primary[
|
item.data.ImageBlurHashes?.Primary?.[
|
||||||
item.data.ImageTags.Primary
|
item.data.ImageTags.Primary
|
||||||
]
|
] ?? ""
|
||||||
}
|
}
|
||||||
className="item-hero-image-blurhash"
|
className="item-hero-image-blurhash"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Primary",
|
||||||
tag: item.data.ImageTags.Primary,
|
{
|
||||||
},
|
quality: 90,
|
||||||
)}
|
tag: item.data.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-image"
|
className="item-hero-image"
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="item-hero-image-icon">
|
<div className="item-hero-image-icon">
|
||||||
{getTypeIcon(item.data.Type)}
|
{getTypeIcon(item.data.Type ?? "MusicArtist")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="item-hero-detail flex flex-column">
|
<div className="item-hero-detail flex flex-column">
|
||||||
{Object.keys(item.data.ImageTags).includes("Logo") ? (
|
{item.data.ImageTags?.Logo ? (
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Logo",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Logo",
|
||||||
fillWidth: 592,
|
{
|
||||||
fillHeight: 592,
|
quality: 90,
|
||||||
},
|
fillWidth: 592,
|
||||||
)}
|
fillHeight: 592,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-logo"
|
className="item-hero-logo"
|
||||||
/>
|
/>
|
||||||
@@ -322,7 +343,11 @@ function ArtistTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.ExternalUrls?.map((url) => (
|
{item.data.ExternalUrls?.map((url) => (
|
||||||
<IconLink url={url.Url} name={url.Name} />
|
<IconLink
|
||||||
|
url={url.Url ?? ""}
|
||||||
|
name={url.Name ?? ""}
|
||||||
|
key={url.Url}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -332,22 +357,22 @@ function ArtistTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.PremiereDate && (
|
{item.data.PremiereDate && (
|
||||||
<>
|
<div>
|
||||||
<Typography variant="h5">Born</Typography>
|
<Typography variant="h5">Born</Typography>
|
||||||
<Typography sx={{ opacity: 0.8 }}>
|
<Typography sx={{ opacity: 0.8 }}>
|
||||||
{new Date(item.data.PremiereDate).toDateString()}
|
{new Date(item.data.PremiereDate).toDateString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
{item.data.EndDate && (
|
{item.data.EndDate && (
|
||||||
<>
|
<div>
|
||||||
<Typography variant="h5" mt={2}>
|
<Typography variant="h5" mt={2}>
|
||||||
Death
|
Death
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography sx={{ opacity: 0.8 }}>
|
<Typography sx={{ opacity: 0.8 }}>
|
||||||
{new Date(item.data.EndDate).toDateString()}
|
{new Date(item.data.EndDate).toDateString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -356,7 +381,7 @@ function ArtistTitlePage() {
|
|||||||
<Tabs
|
<Tabs
|
||||||
variant="scrollable"
|
variant="scrollable"
|
||||||
value={activeArtistTab}
|
value={activeArtistTab}
|
||||||
onChange={(e, newVal) => {
|
onChange={(_, newVal) => {
|
||||||
if (newVal > activeArtistTab) {
|
if (newVal > activeArtistTab) {
|
||||||
setAnimationDirection("forward");
|
setAnimationDirection("forward");
|
||||||
} else if (newVal < activeArtistTab) {
|
} else if (newVal < activeArtistTab) {
|
||||||
@@ -397,8 +422,8 @@ function ArtistTitlePage() {
|
|||||||
ease: "anticipate",
|
ease: "anticipate",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{artistDiscography.isSuccess &&
|
{user &&
|
||||||
artistDiscography.data.Items?.map((tabitem) => {
|
artistDiscography.data?.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<ArtistAlbum
|
<ArtistAlbum
|
||||||
key={tabitem.Id}
|
key={tabitem.Id}
|
||||||
@@ -429,7 +454,7 @@ function ArtistTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{artistSongs.isSuccess &&
|
{artistSongs.isSuccess &&
|
||||||
artistSongs.data.Items?.map((tabitem) => {
|
artistSongs.data?.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<MusicTrack
|
<MusicTrack
|
||||||
item={tabitem}
|
item={tabitem}
|
||||||
@@ -462,7 +487,7 @@ function ArtistTitlePage() {
|
|||||||
className="grid"
|
className="grid"
|
||||||
>
|
>
|
||||||
{artistAppearances.isSuccess &&
|
{artistAppearances.isSuccess &&
|
||||||
artistAppearances.data.Items?.map((tabitem) => {
|
artistAppearances.data?.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={tabitem.Id}
|
key={tabitem.Id}
|
||||||
|
|||||||
+86
-100
@@ -1,5 +1,4 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { useLayoutEffect, useRef } from "react";
|
||||||
import React, { useEffect, useRef } from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
@@ -17,17 +16,16 @@ import {
|
|||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
@@ -41,31 +39,9 @@ import IconLink from "@/components/iconLink";
|
|||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { green, red, yellow } from "@mui/material/colors";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
function TabPanel(props) {
|
|
||||||
const { children, value, index, ...other } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role="tabpanel"
|
|
||||||
hidden={value !== index}
|
|
||||||
id={`full-width-tabpanel-${index}`}
|
|
||||||
aria-labelledby={`full-width-tab-${index}`}
|
|
||||||
{...other}
|
|
||||||
style={{ marginTop: "1em" }}
|
|
||||||
>
|
|
||||||
{value === index && <Box>{children}</Box>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/boxset/$id")({
|
export const Route = createFileRoute("/_api/boxset/$id")({
|
||||||
component: BoxSetTitlePage,
|
component: BoxSetTitlePage,
|
||||||
});
|
});
|
||||||
@@ -79,6 +55,7 @@ function BoxSetTitlePage() {
|
|||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
@@ -93,9 +70,10 @@ function BoxSetTitlePage() {
|
|||||||
const collectionItems = useQuery({
|
const collectionItems = useQuery({
|
||||||
queryKey: ["item", id, "collection"],
|
queryKey: ["item", id, "collection"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
parentId: item.data.Id,
|
parentId: item.data?.Id,
|
||||||
fields: [ItemFields.SeasonUserData, ItemFields.Overview],
|
fields: [ItemFields.SeasonUserData, ItemFields.Overview],
|
||||||
excludeLocationTypes: [LocationType.Virtual],
|
excludeLocationTypes: [LocationType.Virtual],
|
||||||
});
|
});
|
||||||
@@ -107,8 +85,9 @@ function BoxSetTitlePage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const similarItems = useQuery({
|
const similarItems = useQuery({
|
||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", "similarItem", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api || !item.data?.Id) return null;
|
||||||
const result = await getLibraryApi(api).getSimilarItems({
|
const result = await getLibraryApi(api).getSimilarItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data?.Id,
|
itemId: item.data?.Id,
|
||||||
@@ -121,13 +100,19 @@ function BoxSetTitlePage() {
|
|||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
if (item.isSuccess) {
|
|
||||||
if (item.data.BackdropImageTags?.length > 0) {
|
useLayoutEffect(() => {
|
||||||
|
if (api && item.isSuccess) {
|
||||||
|
if (item.data?.BackdropImageTags?.length) {
|
||||||
setBackdrop(
|
setBackdrop(
|
||||||
api?.getItemImageUrl(item.data.Id, "Backdrop", {
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
tag: item.data.BackdropImageTags[0],
|
item.data.Id ?? "",
|
||||||
}),
|
"Backdrop",
|
||||||
|
{
|
||||||
|
tag: item.data.BackdropImageTags[0],
|
||||||
|
},
|
||||||
|
),
|
||||||
item.data.Id,
|
item.data.Id,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -140,6 +125,7 @@ function BoxSetTitlePage() {
|
|||||||
const { scrollYProgress } = useScroll({
|
const { scrollYProgress } = useScroll({
|
||||||
target: pageRef,
|
target: pageRef,
|
||||||
offset: ["start start", "60vh start"],
|
offset: ["start start", "60vh start"],
|
||||||
|
layoutEffect: false,
|
||||||
});
|
});
|
||||||
const parallax = useParallax(scrollYProgress, 50);
|
const parallax = useParallax(scrollYProgress, 50);
|
||||||
|
|
||||||
@@ -158,7 +144,7 @@ function BoxSetTitlePage() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (item.isSuccess && similarItems.isSuccess) {
|
if (item.isSuccess && item.data && similarItems.isSuccess) {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={id}
|
key={id}
|
||||||
@@ -179,17 +165,20 @@ function BoxSetTitlePage() {
|
|||||||
<div className="item-hero-backdrop-container">
|
<div className="item-hero-backdrop-container">
|
||||||
{item.data.BackdropImageTags?.length ? (
|
{item.data.BackdropImageTags?.length ? (
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Backdrop",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
tag: item.data.BackdropImageTags[0],
|
"Backdrop",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.data.BackdropImageTags[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -197,11 +186,11 @@ function BoxSetTitlePage() {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={heroBg}
|
src={heroBg}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -215,53 +204,60 @@ function BoxSetTitlePage() {
|
|||||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.keys(item.data.ImageTags).includes("Primary") ? (
|
{item.data.ImageTags?.Primary &&
|
||||||
<>
|
item.data.ImageBlurHashes?.Primary ? (
|
||||||
|
<div>
|
||||||
<Blurhash
|
<Blurhash
|
||||||
hash={
|
hash={
|
||||||
item.data.ImageBlurHashes.Primary[
|
item.data.ImageBlurHashes?.Primary?.[
|
||||||
item.data.ImageTags.Primary
|
item.data.ImageTags.Primary
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
className="item-hero-image-blurhash"
|
className="item-hero-image-blurhash"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Primary",
|
||||||
tag: item.data.ImageTags.Primary,
|
{
|
||||||
},
|
quality: 90,
|
||||||
)}
|
tag: item.data.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-image"
|
className="item-hero-image"
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="item-hero-image-icon">
|
<div className="item-hero-image-icon">
|
||||||
{getTypeIcon(item.data.Type)}
|
{getTypeIcon(item.data.Type ?? "BoxSet")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="item-hero-detail">
|
<div className="item-hero-detail">
|
||||||
{Object.keys(item.data.ImageTags).includes("Logo") ? (
|
{item.data.ImageTags?.Logo ? (
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Logo",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Logo",
|
||||||
fillWidth: 592,
|
{
|
||||||
fillHeight: 592,
|
quality: 90,
|
||||||
},
|
fillWidth: 592,
|
||||||
)}
|
fillHeight: 592,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-logo"
|
className="item-hero-logo"
|
||||||
/>
|
/>
|
||||||
@@ -356,7 +352,7 @@ function BoxSetTitlePage() {
|
|||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{endsAt(
|
{endsAt(
|
||||||
item.data.RunTimeTicks -
|
item.data.RunTimeTicks -
|
||||||
item.data.UserData.PlaybackPositionTicks,
|
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
@@ -369,9 +365,7 @@ function BoxSetTitlePage() {
|
|||||||
<div className="flex flex-row fullWidth">
|
<div className="flex flex-row fullWidth">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item.data}
|
item={item.data}
|
||||||
itemId={item.data.Id}
|
itemType={item.data.Type ?? "BoxSet"}
|
||||||
itemType={item.data.Type}
|
|
||||||
itemUserData={item.data.UserData}
|
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentSubTrack={0}
|
currentSubTrack={0}
|
||||||
@@ -386,14 +380,14 @@ function BoxSetTitlePage() {
|
|||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData?.Played}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -419,15 +413,19 @@ function BoxSetTitlePage() {
|
|||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.ExternalUrls.map((url) => (
|
{item.data.ExternalUrls?.map((url) => (
|
||||||
<IconLink url={url.Url} name={url.Name} />
|
<IconLink
|
||||||
|
url={url.Url ?? ""}
|
||||||
|
name={url.Name ?? ""}
|
||||||
|
key={url.Url}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{collectionItems.data.TotalRecordCount > 0 && (
|
{(collectionItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
<CardScroller title="" displayCards={7} disableDecoration>
|
<CardScroller title="" displayCards={7} disableDecoration>
|
||||||
{collectionItems.data.Items.map((similar, index) => {
|
{collectionItems.data?.Items?.map((similar) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={similar.Id}
|
key={similar.Id}
|
||||||
@@ -441,26 +439,20 @@ function BoxSetTitlePage() {
|
|||||||
imageType={"Primary"}
|
imageType={"Primary"}
|
||||||
cardCaption={similar.ProductionYear}
|
cardCaption={similar.ProductionYear}
|
||||||
cardType={"portrait"}
|
cardType={"portrait"}
|
||||||
queryKey={["item", id, "collection"]}
|
queryKey={["item", id]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
|
||||||
similar.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(similar.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{similarItems.data.TotalRecordCount > 0 && (
|
{similarItems.data?.TotalRecordCount && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="You might also like"
|
title="You might also like"
|
||||||
displayCards={7}
|
displayCards={7}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
{similarItems.data.Items.map((similar, index) => {
|
{similarItems.data?.Items?.map((similar) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={similar.Id}
|
key={similar.Id}
|
||||||
@@ -493,12 +485,6 @@ function BoxSetTitlePage() {
|
|||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
|
||||||
similar.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(similar.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
+334
-354
@@ -1,11 +1,8 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { useState, useRef, useMemo, useEffect } from "react";
|
||||||
import React, { useState, useLayoutEffect, useRef } from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
import Divider from "@mui/material/Divider";
|
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
@@ -19,18 +16,13 @@ import { motion, useScroll } from "framer-motion";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
ItemFields,
|
|
||||||
MediaStreamType,
|
MediaStreamType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import heroBg from "@/assets/herobg.png";
|
import heroBg from "@/assets/herobg.png";
|
||||||
import { Card } from "@/components/card/card";
|
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
|
||||||
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||||
@@ -38,7 +30,6 @@ import PlayButton from "@/components/buttons/playButton";
|
|||||||
import TrailerButton from "@/components/buttons/trailerButton";
|
import TrailerButton from "@/components/buttons/trailerButton";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
import TextLink from "@/components/textLink";
|
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
@@ -63,34 +54,14 @@ import sdrIcon from "@/assets/icons/sdr.svg";
|
|||||||
|
|
||||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
function TabPanel(props) {
|
|
||||||
const { children, value, index, ...other } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role="tabpanel"
|
|
||||||
hidden={value !== index}
|
|
||||||
id={`full-width-tabpanel-${index}`}
|
|
||||||
aria-labelledby={`full-width-tab-${index}`}
|
|
||||||
{...other}
|
|
||||||
style={{ marginTop: "1em" }}
|
|
||||||
>
|
|
||||||
{value === index && <Box>{children}</Box>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/episode/$id")({
|
export const Route = createFileRoute("/_api/episode/$id")({
|
||||||
component: EpisodeTitlePage,
|
component: EpisodeTitlePage,
|
||||||
});
|
});
|
||||||
@@ -104,10 +75,10 @@ function EpisodeTitlePage() {
|
|||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -119,191 +90,174 @@ function EpisodeTitlePage() {
|
|||||||
const upcomingEpisodes = useQuery({
|
const upcomingEpisodes = useQuery({
|
||||||
queryKey: ["item", id, "episode", "upcomingEpisodes"],
|
queryKey: ["item", id, "episode", "upcomingEpisodes"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
parentId: item.data?.ParentId ?? "",
|
parentId: item.data?.ParentId ?? "",
|
||||||
startIndex: item.data?.IndexNumber ?? 0,
|
startIndex: item.data?.IndexNumber ?? 0,
|
||||||
|
excludeLocationTypes: ["Virtual"],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.Episode,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Episode,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||||
|
|
||||||
const [videoTracks, setVideoTracks] = useState([]);
|
const [selectedVideoTrack, setSelectedVideoTrack] = useState(0);
|
||||||
const [audioTracks, setAudioTracks] = useState([]);
|
const [selectedAudioTrack, setSelectedAudioTrack] = useState(0);
|
||||||
const [subtitleTracks, setSubtitleTracks] = useState([]);
|
const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(0);
|
||||||
|
|
||||||
const filterMediaStreamVideo = (source) => {
|
const videoTracks = useMemo(() => {
|
||||||
if (source.Type === MediaStreamType.Video) {
|
const result = item.data?.MediaStreams?.filter((source) => {
|
||||||
return true;
|
if (source.Type === MediaStreamType.Video) {
|
||||||
}
|
return true;
|
||||||
return false;
|
}
|
||||||
};
|
return false;
|
||||||
const filterMediaStreamAudio = (source) => {
|
});
|
||||||
if (source.Type === MediaStreamType.Audio) {
|
setSelectedVideoTrack(result?.find((track) => track.IsDefault)?.Index ?? 0);
|
||||||
return true;
|
return result ?? [];
|
||||||
}
|
}, [item.data?.Id]);
|
||||||
return false;
|
const audioTracks = useMemo(() => {
|
||||||
};
|
const result = item.data?.MediaStreams?.filter((source) => {
|
||||||
const filterMediaStreamSubtitle = (source) => {
|
if (source.Type === MediaStreamType.Audio) {
|
||||||
if (source.Type === MediaStreamType.Subtitle) {
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
});
|
||||||
};
|
setSelectedAudioTrack(result?.find((track) => track.IsDefault)?.Index ?? 0);
|
||||||
|
return result ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
const subtitleTracks = useMemo(() => {
|
||||||
|
const result = item.data?.MediaStreams?.filter((source) => {
|
||||||
|
if (source.Type === MediaStreamType.Subtitle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
setSelectedSubtitleTrack(
|
||||||
|
result?.find((track) => track.IsDefault)?.Index ?? -1,
|
||||||
|
);
|
||||||
|
return result ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
|
||||||
const [selectedVideoTrack, setSelectedVideoTrack] = useState(null);
|
const directors = useMemo(() => {
|
||||||
const [selectedAudioTrack, setSelectedAudioTrack] = useState(null);
|
return item.data?.People?.filter((itm) => itm.Type === "Director") ?? [];
|
||||||
const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(null);
|
}, [item.data?.Id]);
|
||||||
|
const writers = useMemo(() => {
|
||||||
|
return item.data?.People?.filter((itm) => itm.Type === "Writer") ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
const actors = useMemo(() => {
|
||||||
|
return item.data?.People?.filter((itm) => itm.Type === "Actor") ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
const producers = useMemo(() => {
|
||||||
|
return item.data?.People?.filter((itm) => itm.Type === "Producer") ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
|
||||||
const [directors, setDirectors] = useState([]);
|
|
||||||
const [writers, setWriters] = useState([]);
|
|
||||||
const [actors, setActors] = useState([]);
|
|
||||||
const [producers, setProducers] = useState([]);
|
|
||||||
|
|
||||||
const [mediaQualityInfo, setMediaQualityInfo] = useState<MediaQualityInfo>();
|
const mediaQualityInfo = useMemo<MediaQualityInfo>(() => {
|
||||||
|
const checkAtmos = audioTracks.filter((audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("atmos"),
|
||||||
|
);
|
||||||
|
const checkDolbyVision = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("dv") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("dolby vision") ||
|
||||||
|
!!video.VideoDoViTitle ||
|
||||||
|
video.VideoRangeType === "DOVI",
|
||||||
|
);
|
||||||
|
const checkDD = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
(audio.DisplayTitle?.toLocaleLowerCase().includes("dd") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("ddp")) ||
|
||||||
|
(audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital+")),
|
||||||
|
);
|
||||||
|
const checkDDP = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("ddp") ||
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital+"),
|
||||||
|
);
|
||||||
|
const checkDts = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dts") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
||||||
|
);
|
||||||
|
const checkDtsHDMA = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") ||
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
||||||
|
);
|
||||||
|
const checkUHD = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("4k") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("2160p") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("uhd"),
|
||||||
|
);
|
||||||
|
const checkHD = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
(video.DisplayTitle?.toLocaleLowerCase().includes("hd") &&
|
||||||
|
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr")) ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("1080p") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("fhd"),
|
||||||
|
);
|
||||||
|
const checkSD = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
(video.DisplayTitle?.toLocaleLowerCase().includes("sd") &&
|
||||||
|
!video.DisplayTitle?.toLocaleLowerCase().includes("sdr")) ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("720p"),
|
||||||
|
);
|
||||||
|
const checkSDR = videoTracks.filter(
|
||||||
|
(video) => video.VideoRangeType === "SDR",
|
||||||
|
);
|
||||||
|
const checkHDR = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.VideoRange === "HDR" ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("dv"),
|
||||||
|
);
|
||||||
|
const checkHDR10 = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.VideoRangeType === "HDR10" &&
|
||||||
|
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
||||||
|
);
|
||||||
|
const checkHDR10Plus = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.VideoRangeType === "HDR10Plus" ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
||||||
|
);
|
||||||
|
const checkTrueHD = audioTracks.filter((audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("truehd"),
|
||||||
|
);
|
||||||
|
const checkIMAX = videoTracks.filter((video) =>
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("imax"),
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
isAtmos: checkAtmos.length > 0,
|
||||||
|
isDolbyVision: checkDolbyVision.length > 0,
|
||||||
|
isDts: checkDts.length > 0,
|
||||||
|
isDtsHDMA: checkDtsHDMA.length > 0,
|
||||||
|
isDD: checkDD.length > 0,
|
||||||
|
isDDP: checkDDP.length > 0,
|
||||||
|
isUHD: checkUHD.length > 0,
|
||||||
|
isHD: checkHD.length > 0,
|
||||||
|
isSD: checkSD.length > 0,
|
||||||
|
isSDR: checkSDR.length > 0,
|
||||||
|
isHDR: checkHDR.length > 0,
|
||||||
|
isHDR10: checkHDR10.length > 0,
|
||||||
|
isHDR10Plus: checkHDR10Plus.length > 0,
|
||||||
|
isTrueHD: checkTrueHD.length > 0,
|
||||||
|
isIMAX: checkIMAX.length > 0,
|
||||||
|
};
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useEffect(() => {
|
||||||
if (item.isSuccess) {
|
if (api && item.isSuccess && item.data) {
|
||||||
setAppBackdrop(
|
setAppBackdrop(
|
||||||
item.data.Type === BaseItemKind.MusicAlbum ||
|
`${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`,
|
||||||
item.data.Type === BaseItemKind.Episode
|
|
||||||
? `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
|
|
||||||
: `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`,
|
|
||||||
item.data.Id,
|
item.data.Id,
|
||||||
);
|
);
|
||||||
const direTp = item.data.People.filter((itm) => itm.Type === "Director");
|
|
||||||
setDirectors(direTp);
|
|
||||||
const writeTp = item.data.People.filter((itm) => itm.Type === "Writer");
|
|
||||||
setWriters(writeTp);
|
|
||||||
const producerTp = item.data.People.filter(
|
|
||||||
(itm) => itm.Type === "Producer",
|
|
||||||
);
|
|
||||||
setProducers(producerTp);
|
|
||||||
const actorTp = item.data.People.filter((itm) => itm.Type === "Actor");
|
|
||||||
setActors(actorTp);
|
|
||||||
if (item.data.MediaStreams && item.data.MediaSources) {
|
|
||||||
const videos = item.data.MediaStreams.filter(filterMediaStreamVideo);
|
|
||||||
const audios = item.data.MediaStreams.filter(filterMediaStreamAudio);
|
|
||||||
const subs = item.data.MediaStreams.filter(filterMediaStreamSubtitle);
|
|
||||||
|
|
||||||
setSelectedVideoTrack(videos[0]?.Index ?? null);
|
|
||||||
setSelectedAudioTrack(
|
|
||||||
item.data.MediaSources[0].DefaultAudioStreamIndex ?? null,
|
|
||||||
);
|
|
||||||
setSelectedSubtitleTrack(
|
|
||||||
item.data.MediaSources[0].DefaultSubtitleStreamIndex === -1 ||
|
|
||||||
!item.data.MediaSources[0].DefaultSubtitleStreamIndex
|
|
||||||
? "nosub"
|
|
||||||
: item.data.MediaSources[0].DefaultSubtitleStreamIndex,
|
|
||||||
);
|
|
||||||
|
|
||||||
setVideoTracks(videos);
|
|
||||||
setAudioTracks(audios);
|
|
||||||
setSubtitleTracks(subs);
|
|
||||||
|
|
||||||
// Analyze item for QualityInfo
|
|
||||||
const checkAtmos = audios.filter((audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("atmos"),
|
|
||||||
);
|
|
||||||
const checkDolbyVision = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("dv") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("dolby vision") ||
|
|
||||||
!!video.VideoDoViTitle ||
|
|
||||||
video.VideoRangeType === "DOVI",
|
|
||||||
);
|
|
||||||
const checkDD = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
(audio.DisplayTitle?.toLocaleLowerCase().includes("dd") &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes("ddp")) ||
|
|
||||||
(audio.DisplayTitle?.toLocaleLowerCase().includes(
|
|
||||||
"dolby digital",
|
|
||||||
) &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes(
|
|
||||||
"dolby digital+",
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
const checkDDP = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("ddp") ||
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital+"),
|
|
||||||
);
|
|
||||||
const checkDts = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dts") &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
|
||||||
);
|
|
||||||
const checkDtsHDMA = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") ||
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
|
||||||
);
|
|
||||||
const checkUHD = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("4k") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("2160p") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("uhd"),
|
|
||||||
);
|
|
||||||
const checkHD = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
(video.DisplayTitle?.toLocaleLowerCase().includes("hd") &&
|
|
||||||
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr")) ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("1080p") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("fhd"),
|
|
||||||
);
|
|
||||||
const checkSD = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
(video.DisplayTitle?.toLocaleLowerCase().includes("sd") &&
|
|
||||||
!video.DisplayTitle?.toLocaleLowerCase().includes("sdr")) ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("720p"),
|
|
||||||
);
|
|
||||||
const checkSDR = videos.filter(
|
|
||||||
(video) => video.VideoRangeType === "SDR",
|
|
||||||
);
|
|
||||||
const checkHDR = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.VideoRange === "HDR" ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("dv"),
|
|
||||||
);
|
|
||||||
const checkHDR10 = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.VideoRangeType === "HDR10" &&
|
|
||||||
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
|
||||||
);
|
|
||||||
const checkHDR10Plus = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.VideoRangeType === "HDR10+" ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
|
||||||
);
|
|
||||||
const checkTrueHD = audios.filter((audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("truehd"),
|
|
||||||
);
|
|
||||||
const checkIMAX = videos.filter((video) =>
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("imax"),
|
|
||||||
);
|
|
||||||
setMediaQualityInfo({
|
|
||||||
isAtmos: checkAtmos.length > 0,
|
|
||||||
isDolbyVision: checkDolbyVision.length > 0,
|
|
||||||
isDts: checkDts.length > 0,
|
|
||||||
isDtsHDMA: checkDtsHDMA.length > 0,
|
|
||||||
isDD: checkDD.length > 0,
|
|
||||||
isDDP: checkDDP.length > 0,
|
|
||||||
isUHD: checkUHD.length > 0,
|
|
||||||
isHD: checkHD.length > 0,
|
|
||||||
isSD: checkSD.length > 0,
|
|
||||||
isSDR: checkSDR.length > 0,
|
|
||||||
isHDR: checkHDR.length > 0,
|
|
||||||
isHDR10: checkHDR10.length > 0,
|
|
||||||
isHDR10Plus: checkHDR10Plus.length > 0,
|
|
||||||
isTrueHD: checkTrueHD.length > 0,
|
|
||||||
isIMAX: checkIMAX.length > 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [item.isSuccess]);
|
}, [item.isSuccess]);
|
||||||
|
|
||||||
@@ -311,6 +265,7 @@ function EpisodeTitlePage() {
|
|||||||
const { scrollYProgress } = useScroll({
|
const { scrollYProgress } = useScroll({
|
||||||
target: pageRef,
|
target: pageRef,
|
||||||
offset: ["start start", "60vh start"],
|
offset: ["start start", "60vh start"],
|
||||||
|
layoutEffect: false,
|
||||||
});
|
});
|
||||||
const parallax = useParallax(scrollYProgress, 50);
|
const parallax = useParallax(scrollYProgress, 50);
|
||||||
|
|
||||||
@@ -329,7 +284,7 @@ function EpisodeTitlePage() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (item.isSuccess) {
|
if (item.isSuccess && item.data) {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={id}
|
key={id}
|
||||||
@@ -350,17 +305,20 @@ function EpisodeTitlePage() {
|
|||||||
<div className="item-hero-backdrop-container">
|
<div className="item-hero-backdrop-container">
|
||||||
{item.data.ParentBackdropImageTags?.length ? (
|
{item.data.ParentBackdropImageTags?.length ? (
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.ParentBackdropItemId,
|
api &&
|
||||||
"Backdrop",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.ParentBackdropItemId ?? "",
|
||||||
tag: item.data.ParentBackdropImageTags[0],
|
"Backdrop",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.data.ParentBackdropImageTags[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -368,11 +326,11 @@ function EpisodeTitlePage() {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={heroBg}
|
src={heroBg}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -386,71 +344,80 @@ function EpisodeTitlePage() {
|
|||||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.keys(item.data.ImageTags).includes("Primary") ? (
|
{item.data.ImageTags?.Primary ? (
|
||||||
<>
|
<div>
|
||||||
<Blurhash
|
<Blurhash
|
||||||
hash={
|
hash={
|
||||||
item.data.ImageBlurHashes.Primary[
|
item.data.ImageBlurHashes?.Primary?.[
|
||||||
item.data.ImageTags.Primary
|
item.data.ImageTags.Primary
|
||||||
]
|
] ?? ""
|
||||||
}
|
}
|
||||||
className="item-hero-image-blurhash"
|
className="item-hero-image-blurhash"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Primary",
|
||||||
tag: item.data.ImageTags.Primary,
|
{
|
||||||
},
|
quality: 90,
|
||||||
)}
|
tag: item.data.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-image"
|
className="item-hero-image"
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="item-hero-image-icon">
|
<div className="item-hero-image-icon">
|
||||||
{getTypeIcon(item.data.Type)}
|
{getTypeIcon(item.data.Type ?? "Episode")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="item-hero-detail">
|
<div className="item-hero-detail">
|
||||||
<TextLink
|
<Typography
|
||||||
otherProps={{
|
variant="h2"
|
||||||
fontWeight: 200,
|
fontWeight="200"
|
||||||
mb: 2,
|
mb={2}
|
||||||
style: {
|
style={{
|
||||||
textDecoration: "none",
|
textDecoration: "none",
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
variant={"h2"}
|
|
||||||
location={`/series/${item.data.SeriesId}`}
|
|
||||||
>
|
>
|
||||||
{item.data.ParentLogoItemId?.length > 0 ? (
|
<Link
|
||||||
<img
|
style={{ textDecoration: "none", color: "white" }}
|
||||||
alt={item.data.SeriesName}
|
to="/series/$id"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
params={{ id: item.data.SeriesId ?? "" }}
|
||||||
item.data.ParentLogoItemId,
|
>
|
||||||
"Logo",
|
{item.data.ParentLogoItemId ? (
|
||||||
{
|
<img
|
||||||
quality: 90,
|
alt={item.data.SeriesName ?? ""}
|
||||||
fillWidth: 592,
|
src={
|
||||||
fillHeight: 592,
|
api &&
|
||||||
},
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
)}
|
item.data.ParentLogoItemId,
|
||||||
onLoad={(e) => {
|
"Logo",
|
||||||
e.currentTarget.style.opacity = 1;
|
{
|
||||||
}}
|
quality: 90,
|
||||||
className="item-hero-logo"
|
fillWidth: 592,
|
||||||
/>
|
fillHeight: 592,
|
||||||
) : (
|
},
|
||||||
item.data.SeriesName
|
)
|
||||||
)}
|
}
|
||||||
</TextLink>
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
className="item-hero-logo"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
item.data.SeriesName
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
</Typography>
|
||||||
<Typography variant="h4" fontWeight={300} mb={2}>
|
<Typography variant="h4" fontWeight={300} mb={2}>
|
||||||
S{item.data.ParentIndexNumber ?? 0}:E
|
S{item.data.ParentIndexNumber ?? 0}:E
|
||||||
{item.data.IndexNumberEnd
|
{item.data.IndexNumberEnd
|
||||||
@@ -590,7 +557,7 @@ function EpisodeTitlePage() {
|
|||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{endsAt(
|
{endsAt(
|
||||||
item.data.RunTimeTicks -
|
item.data.RunTimeTicks -
|
||||||
item.data.UserData.PlaybackPositionTicks,
|
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
@@ -684,32 +651,32 @@ function EpisodeTitlePage() {
|
|||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item.data}
|
item={item.data}
|
||||||
itemId={item.data.Id}
|
itemType="Episode"
|
||||||
itemType={item.data.Type}
|
currentVideoTrack={selectedVideoTrack ?? 0}
|
||||||
itemUserData={item.data.UserData}
|
currentAudioTrack={selectedAudioTrack ?? 0}
|
||||||
currentVideoTrack={selectedVideoTrack}
|
currentSubTrack={selectedSubtitleTrack ?? "nosub"}
|
||||||
currentAudioTrack={selectedAudioTrack}
|
|
||||||
currentSubTrack={selectedSubtitleTrack}
|
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row" style={{ gap: "1em" }}>
|
<div className="flex flex-row" style={{ gap: "1em" }}>
|
||||||
<TrailerButton
|
{item.data.RemoteTrailers && (
|
||||||
trailerItem={item.data.RemoteTrailers}
|
<TrailerButton
|
||||||
disabled={item.data.RemoteTrailers?.length === 0}
|
trailerItem={item.data.RemoteTrailers}
|
||||||
/>
|
disabled={item.data.RemoteTrailers?.length === 0}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData?.Played}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -733,7 +700,7 @@ function EpisodeTitlePage() {
|
|||||||
}}
|
}}
|
||||||
value={selectedVideoTrack}
|
value={selectedVideoTrack}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={(e) => setSelectedVideoTrack(e.target.value)}
|
onChange={(e) => setSelectedVideoTrack(Number(e.target.value))}
|
||||||
>
|
>
|
||||||
{videoTracks.map((track) => (
|
{videoTracks.map((track) => (
|
||||||
<MenuItem key={track.Index} value={track.Index}>
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
@@ -752,7 +719,7 @@ function EpisodeTitlePage() {
|
|||||||
}}
|
}}
|
||||||
value={selectedAudioTrack}
|
value={selectedAudioTrack}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={(e) => setSelectedAudioTrack(e.target.value)}
|
onChange={(e) => setSelectedAudioTrack(Number(e.target.value))}
|
||||||
>
|
>
|
||||||
{audioTracks.map((track) => (
|
{audioTracks.map((track) => (
|
||||||
<MenuItem key={track.Index} value={track.Index}>
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
@@ -770,9 +737,11 @@ function EpisodeTitlePage() {
|
|||||||
}}
|
}}
|
||||||
value={selectedSubtitleTrack}
|
value={selectedSubtitleTrack}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={(e) => setSelectedSubtitleTrack(e.target.value)}
|
onChange={(e) =>
|
||||||
|
setSelectedSubtitleTrack(Number(e.target.value))
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<MenuItem key={-1} value={"nosub"}>
|
<MenuItem key={-1} value={-1}>
|
||||||
No Subtitle
|
No Subtitle
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{subtitleTracks.map((track) => (
|
{subtitleTracks.map((track) => (
|
||||||
@@ -790,43 +759,18 @@ function EpisodeTitlePage() {
|
|||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.ExternalUrls.map((url) => (
|
{item.data.ExternalUrls?.map((url) => (
|
||||||
<IconLink url={url.Url} name={url.Name} />
|
<IconLink
|
||||||
|
key={url.Url}
|
||||||
|
url={url.Url ?? ""}
|
||||||
|
name={url.Name ?? ""}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{upcomingEpisodes.isSuccess &&
|
{(item.data.People?.length ?? 0) > 0 && (
|
||||||
upcomingEpisodes.data.Items?.length > 0 && (
|
|
||||||
<CardScroller
|
|
||||||
title="Upcoming Episodes"
|
|
||||||
displayCards={4}
|
|
||||||
disableDecoration
|
|
||||||
>
|
|
||||||
{upcomingEpisodes.data.Items?.map((episode) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={episode.Id}
|
|
||||||
item={episode}
|
|
||||||
cardTitle={episode.SeriesName}
|
|
||||||
imageType="Primary"
|
|
||||||
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
|
||||||
cardType="thumb"
|
|
||||||
queryKey={["item", id, "episode", "upcomingEpisodes"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
imageBlurhash={
|
|
||||||
!!episode.ImageBlurHashes?.Primary &&
|
|
||||||
episode.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(episode.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
{item.data.People?.length > 0 && (
|
|
||||||
<div className="item-detail-cast">
|
<div className="item-detail-cast">
|
||||||
<Typography variant="h5" mb={2}>
|
<Typography variant="h5" mb={2}>
|
||||||
Cast & Crew
|
Cast & Crew
|
||||||
@@ -839,23 +783,26 @@ function EpisodeTitlePage() {
|
|||||||
<Link
|
<Link
|
||||||
className="item-detail-cast-card"
|
className="item-detail-cast-card"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to={`/person/$id`}
|
to="/person/$id"
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -889,23 +836,26 @@ function EpisodeTitlePage() {
|
|||||||
<Link
|
<Link
|
||||||
className="item-detail-cast-card"
|
className="item-detail-cast-card"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to={`/person/$id`}
|
to="/person/$id"
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -939,23 +889,26 @@ function EpisodeTitlePage() {
|
|||||||
<Link
|
<Link
|
||||||
className="item-detail-cast-card"
|
className="item-detail-cast-card"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to={`/person/$id`}
|
to="/person/$id"
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -989,23 +942,26 @@ function EpisodeTitlePage() {
|
|||||||
<Link
|
<Link
|
||||||
className="item-detail-cast-card"
|
className="item-detail-cast-card"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to={`/person/$id`}
|
to="/person/$id"
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -1033,6 +989,30 @@ function EpisodeTitlePage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{upcomingEpisodes.isSuccess &&
|
||||||
|
(upcomingEpisodes.data?.Items?.length ?? 0) > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Upcoming Episodes"
|
||||||
|
displayCards={4}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{upcomingEpisodes.data?.Items?.map((episode) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={episode.Id}
|
||||||
|
item={episode}
|
||||||
|
cardTitle={episode.SeriesName}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["item", id, "episode", "upcomingEpisodes"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,15 @@ import React, { useEffect } from "react";
|
|||||||
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import "./favorite.scss";
|
import "./favorite.scss";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/favorite/")({
|
export const Route = createFileRoute("/_api/favorite/")({
|
||||||
component: FavoritePage,
|
component: FavoritePage,
|
||||||
@@ -27,6 +25,7 @@ function FavoritePage() {
|
|||||||
const movies = useQuery({
|
const movies = useQuery({
|
||||||
queryKey: ["favorite", "movies"],
|
queryKey: ["favorite", "movies"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -40,6 +39,7 @@ function FavoritePage() {
|
|||||||
const series = useQuery({
|
const series = useQuery({
|
||||||
queryKey: ["favorite", "series"],
|
queryKey: ["favorite", "series"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -53,6 +53,7 @@ function FavoritePage() {
|
|||||||
const musicAlbum = useQuery({
|
const musicAlbum = useQuery({
|
||||||
queryKey: ["favorite", "musicAlbum"],
|
queryKey: ["favorite", "musicAlbum"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -66,6 +67,7 @@ function FavoritePage() {
|
|||||||
const audio = useQuery({
|
const audio = useQuery({
|
||||||
queryKey: ["favorite", "audio"],
|
queryKey: ["favorite", "audio"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -79,6 +81,7 @@ function FavoritePage() {
|
|||||||
const book = useQuery({
|
const book = useQuery({
|
||||||
queryKey: ["favorite", "book"],
|
queryKey: ["favorite", "book"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -92,6 +95,7 @@ function FavoritePage() {
|
|||||||
const musicArtists = useQuery({
|
const musicArtists = useQuery({
|
||||||
queryKey: ["favorite", "musicArtist"],
|
queryKey: ["favorite", "musicArtist"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -105,6 +109,7 @@ function FavoritePage() {
|
|||||||
const person = useQuery({
|
const person = useQuery({
|
||||||
queryKey: ["favorite", "person"],
|
queryKey: ["favorite", "person"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
@@ -120,7 +125,7 @@ function FavoritePage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main
|
<div
|
||||||
className="scrollY"
|
className="scrollY"
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@@ -130,9 +135,9 @@ function FavoritePage() {
|
|||||||
paddingTop: "4.2em",
|
paddingTop: "4.2em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{movies.isSuccess && movies.data.Items.length > 0 && (
|
{movies.isSuccess && (movies.data?.Items?.length ?? 0) > 0 && (
|
||||||
<CardScroller displayCards={8} title="Movies">
|
<CardScroller displayCards={8} title="Movies">
|
||||||
{movies.data.Items.map((item) => (
|
{movies.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -142,19 +147,13 @@ function FavoritePage() {
|
|||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["favorite", "movies"]}
|
queryKey={["favorite", "movies"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{series.isSuccess && series.data.Items.length > 0 && (
|
{series.isSuccess && (series.data?.Items?.length ?? 0) > 0 && (
|
||||||
<CardScroller title="TV Shows" displayCards={8} disableDecoration>
|
<CardScroller title="TV Shows" displayCards={8} disableDecoration>
|
||||||
{series.data.Items.map((item) => (
|
{series.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -170,19 +169,13 @@ function FavoritePage() {
|
|||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["favorite", "series"]}
|
queryKey={["favorite", "series"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{audio.isSuccess && audio.data.Items.length > 0 && (
|
{audio.isSuccess && (audio.data?.Items?.length ?? 0) > 0 && (
|
||||||
<CardScroller title="Audio" displayCards={8} disableDecoration>
|
<CardScroller title="Audio" displayCards={8} disableDecoration>
|
||||||
{audio.data.Items.map((item) => (
|
{audio.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -192,19 +185,13 @@ function FavoritePage() {
|
|||||||
cardType="square"
|
cardType="square"
|
||||||
queryKey={["favorite", "audio"]}
|
queryKey={["favorite", "audio"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{musicAlbum.isSuccess && musicAlbum.data.Items.length > 0 && (
|
{musicAlbum.isSuccess && (musicAlbum.data?.Items?.length ?? 0) > 0 && (
|
||||||
<CardScroller title="Albums" displayCards={8} disableDecoration>
|
<CardScroller title="Albums" displayCards={8} disableDecoration>
|
||||||
{musicAlbum.data.Items.map((item) => (
|
{musicAlbum.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -215,19 +202,13 @@ function FavoritePage() {
|
|||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["favorite", "musicAlbum"]}
|
queryKey={["favorite", "musicAlbum"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{book.isSuccess && book.data.Items.length > 0 && (
|
{book.isSuccess && (book.data?.Items?.length ?? 0) > 0 && (
|
||||||
<CardScroller title="Books" displayCards={8} disableDecoration>
|
<CardScroller title="Books" displayCards={8} disableDecoration>
|
||||||
{book.data.Items.map((item) => (
|
{book.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -238,41 +219,30 @@ function FavoritePage() {
|
|||||||
cardType={"portrait"}
|
cardType={"portrait"}
|
||||||
queryKey={["favorite", "book"]}
|
queryKey={["favorite", "book"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{musicArtists.isSuccess && musicArtists.data.Items.length > 0 && (
|
{musicArtists.isSuccess &&
|
||||||
<CardScroller title="Artists" displayCards={8} disableDecoration>
|
(musicArtists.data?.Items?.length ?? 0) > 0 && (
|
||||||
{musicArtists.data.Items.map((item) => (
|
<CardScroller title="Artists" displayCards={8} disableDecoration>
|
||||||
<Card
|
{musicArtists.data?.Items?.map((item) => (
|
||||||
key={item.Id}
|
<Card
|
||||||
item={item}
|
key={item.Id}
|
||||||
cardTitle={item.Name}
|
item={item}
|
||||||
imageType={"Primary"}
|
cardTitle={item.Name}
|
||||||
disableOverlay
|
imageType={"Primary"}
|
||||||
cardType={"square"}
|
disableOverlay
|
||||||
queryKey={["favorite", "musicArtist"]}
|
cardType={"square"}
|
||||||
userId={user?.Id}
|
queryKey={["favorite", "musicArtist"]}
|
||||||
imageBlurhash={
|
userId={user?.Id}
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
/>
|
||||||
item.ImageBlurHashes?.Primary[
|
))}
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
</CardScroller>
|
||||||
]
|
)}
|
||||||
}
|
{person.isSuccess && (person.data?.Items?.length ?? 0) > 0 && (
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
{person.isSuccess && person.data.Items.length > 0 && (
|
|
||||||
<CardScroller title="People" displayCards={8} disableDecoration>
|
<CardScroller title="People" displayCards={8} disableDecoration>
|
||||||
{person.data.Items.map((item) => (
|
{person.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -282,17 +252,11 @@ function FavoritePage() {
|
|||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["favorite", "person"]}
|
queryKey={["favorite", "person"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
</main>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+249
-250
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useCallback, useMemo } from "react";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import Carousel from "@/components/carousel";
|
|||||||
|
|
||||||
// Custom Components
|
// Custom Components
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
||||||
import { CardsSkeleton } from "@/components/skeleton/cards";
|
import { CardsSkeleton } from "@/components/skeleton/cards";
|
||||||
import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
||||||
@@ -45,18 +45,20 @@ function Home() {
|
|||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
});
|
});
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id && !!api.accessToken,
|
enabled: !!user?.Id && !!api?.accessToken,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const latestMedia = useQuery({
|
const latestMedia = useQuery({
|
||||||
queryKey: ["home", "latestMedia"],
|
queryKey: ["home", "latestMedia"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
fields: [
|
fields: [
|
||||||
@@ -83,6 +85,7 @@ function Home() {
|
|||||||
const resumeItemsVideo = useQuery({
|
const resumeItemsVideo = useQuery({
|
||||||
queryKey: ["home", "resume", "video"],
|
queryKey: ["home", "resume", "video"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -99,6 +102,7 @@ function Home() {
|
|||||||
const resumeItemsAudio = useQuery({
|
const resumeItemsAudio = useQuery({
|
||||||
queryKey: ["home", "resume", "audio"],
|
queryKey: ["home", "resume", "audio"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -114,6 +118,7 @@ function Home() {
|
|||||||
const upNextItems = useQuery({
|
const upNextItems = useQuery({
|
||||||
queryKey: ["home", "upNext"],
|
queryKey: ["home", "upNext"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const upNext = await getTvShowsApi(api).getNextUp({
|
const upNext = await getTvShowsApi(api).getNextUp({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
fields: [
|
fields: [
|
||||||
@@ -130,274 +135,268 @@ function Home() {
|
|||||||
refetchOnMount: true,
|
refetchOnMount: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [latestMediaLibs, setLatestMediaLibs] = useState<
|
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
|
||||||
BaseItemDto[] | undefined
|
const latestMediaLibs = useMemo(() => {
|
||||||
>([]);
|
if (libraries.data?.Items?.length) {
|
||||||
|
return libraries.data?.Items?.reduce(
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
|
||||||
|
|
||||||
const [excludeTypes] = useState(
|
|
||||||
() => new Set(["boxsets", "playlists", "livetv", "channels"]),
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (libraries.isSuccess) {
|
|
||||||
const latestMediaLibsTemp = libraries.data.Items?.reduce(
|
|
||||||
(filteredItems: BaseItemDto[], currentItem) => {
|
(filteredItems: BaseItemDto[], currentItem) => {
|
||||||
if (currentItem.Type && !excludeTypes.has(currentItem.Type)) {
|
if (currentItem.Type && !excludeTypes.includes(currentItem.Type)) {
|
||||||
filteredItems.push(currentItem);
|
filteredItems.push(currentItem);
|
||||||
}
|
}
|
||||||
return filteredItems;
|
return filteredItems;
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
setLatestMediaLibs(latestMediaLibsTemp);
|
|
||||||
}
|
}
|
||||||
}, [libraries.isSuccess]);
|
}, [libraries.data?.Items?.length]);
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
|
|
||||||
|
const handleOnChangeCarousel = useCallback(
|
||||||
|
(now: number) => {
|
||||||
|
if (api && latestMedia.isSuccess && (latestMedia.data?.length ?? 0) > 0) {
|
||||||
|
if (latestMedia.data?.[now]?.ParentBackdropImageTags) {
|
||||||
|
setBackdrop(
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
latestMedia.data[now].Id ?? "",
|
||||||
|
"Backdrop",
|
||||||
|
{
|
||||||
|
tag: latestMedia.data[now].ParentBackdropImageTags[0],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
latestMedia.data[now]?.ParentBackdropImageTags[0] ??
|
||||||
|
latestMedia.data[now].Id,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setBackdrop(
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
latestMedia.data?.[now].Id ?? "",
|
||||||
|
"Backdrop",
|
||||||
|
{
|
||||||
|
tag: latestMedia.data?.[now].BackdropImageTags?.[0],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
latestMedia.data?.[now]?.BackdropImageTags?.[0] ??
|
||||||
|
latestMedia.data?.[now].Id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[latestMedia.data?.map((item) => item.Id).join("")],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<main
|
||||||
<main
|
className="scrollY home padded-top"
|
||||||
className="scrollY home padded-top"
|
style={{
|
||||||
style={{
|
flexGrow: 1,
|
||||||
flexGrow: 1,
|
position: "relative",
|
||||||
position: "relative",
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
{latestMedia.isPending ? (
|
||||||
{latestMedia.isPending ? (
|
<CarouselSkeleton />
|
||||||
<CarouselSkeleton />
|
) : (
|
||||||
) : (
|
latestMedia.data?.length && (
|
||||||
latestMedia.data?.length && (
|
<Carousel
|
||||||
<Carousel
|
content={latestMedia.data}
|
||||||
content={latestMedia.data}
|
onChange={handleOnChangeCarousel}
|
||||||
onChange={(now: number) => {
|
/>
|
||||||
if (latestMedia.isSuccess && latestMedia.data.length > 0) {
|
)
|
||||||
if (latestMedia.data[now]?.ParentBackdropImageTags) {
|
)}
|
||||||
setBackdrop(
|
</ErrorBoundary>
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
latestMedia.data[now].Id,
|
|
||||||
"Backdrop",
|
|
||||||
{
|
|
||||||
tag: latestMedia.data[now]
|
|
||||||
.ParentBackdropImageTags[0],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
latestMedia.data[now]?.ParentBackdropImageTags[0] ??
|
|
||||||
latestMedia.data[now].Id,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
setBackdrop(
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
latestMedia.data[now].Id,
|
|
||||||
"Backdrop",
|
|
||||||
{
|
|
||||||
tag: latestMedia.data[now].BackdropImageTags[0],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
latestMedia.data[now]?.BackdropImageTags[0] ??
|
|
||||||
latestMedia.data[now].Id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
|
|
||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
fallback={
|
fallback={
|
||||||
<div className="error">
|
<div className="error">
|
||||||
<Typography>Error with Carousel</Typography>
|
<Typography>Error with Carousel</Typography>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{libraries.isPending ? (
|
{libraries.isPending ? (
|
||||||
<CardsSkeleton />
|
<CardsSkeleton />
|
||||||
) : (
|
) : (
|
||||||
<CardScroller displayCards={4} title="Libraries">
|
<CardScroller displayCards={4} title="Libraries">
|
||||||
{libraries.status === "success" &&
|
{libraries.status === "success" &&
|
||||||
libraries.data.Items?.map((item) => {
|
libraries.data?.Items?.map((item) => {
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
cardTitle={item.Name}
|
|
||||||
imageType="Primary"
|
|
||||||
cardType="thumb"
|
|
||||||
disableOverlay
|
|
||||||
onClick={() => {
|
|
||||||
if (item.Id) {
|
|
||||||
navigate({
|
|
||||||
to: "/library/$id",
|
|
||||||
params: { id: item.Id },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
overrideIcon={item.CollectionType}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
<ErrorBoundary
|
|
||||||
fallback={
|
|
||||||
<div className="error">
|
|
||||||
<Typography>Error with Libraries</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{upNextItems.isPending ? (
|
|
||||||
<CardsSkeleton />
|
|
||||||
) : upNextItems.isSuccess && !upNextItems.data.TotalRecordCount ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<CardScroller displayCards={4} title="Up Next">
|
|
||||||
{upNextItems.data?.Items?.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
cardTitle={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? item.SeriesName
|
|
||||||
: item.Name
|
|
||||||
}
|
|
||||||
imageType={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? "Primary"
|
|
||||||
: item.ImageTags?.Thumb
|
|
||||||
? "Thumb"
|
|
||||||
: "Backdrop"
|
|
||||||
}
|
|
||||||
cardCaption={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? item.ParentIndexNumber === 0
|
|
||||||
? `${item.SeasonName} - ${item.Name}`
|
|
||||||
: item.IndexNumberEnd
|
|
||||||
? `${item.IndexNumber}-${item.IndexNumberEnd}. ${item.Name}`
|
|
||||||
: `${item.IndexNumber}. ${item.Name}`
|
|
||||||
: item.Type === BaseItemKind.Series
|
|
||||||
? `${item.ProductionYear} - ${
|
|
||||||
item.EndDate
|
|
||||||
? new Date(item.EndDate).toLocaleString([], {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "Present"
|
|
||||||
}`
|
|
||||||
: item.ProductionYear
|
|
||||||
}
|
|
||||||
cardType="thumb"
|
|
||||||
queryKey={["home", "upNext"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
<ErrorBoundary
|
|
||||||
fallback={
|
|
||||||
<div className="error">
|
|
||||||
<Typography>Error with resumeItemsVideo</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{resumeItemsVideo.isPending ? (
|
|
||||||
<CardsSkeleton />
|
|
||||||
) : resumeItemsVideo.isSuccess &&
|
|
||||||
!resumeItemsVideo.data.TotalRecordCount ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<CardScroller displayCards={4} title="Continue Watching">
|
|
||||||
{resumeItemsVideo.data?.Items?.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
cardTitle={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? item.SeriesName
|
|
||||||
: item.Name
|
|
||||||
}
|
|
||||||
imageType={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? "Primary"
|
|
||||||
: item.ImageTags?.Thumb
|
|
||||||
? "Thumb"
|
|
||||||
: "Backdrop"
|
|
||||||
}
|
|
||||||
cardCaption={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
|
||||||
: item.Type === BaseItemKind.Series
|
|
||||||
? `${item.ProductionYear} - ${
|
|
||||||
item.EndDate
|
|
||||||
? new Date(item.EndDate).toLocaleString([], {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "Present"
|
|
||||||
}`
|
|
||||||
: item.ProductionYear
|
|
||||||
}
|
|
||||||
cardType="thumb"
|
|
||||||
queryKey={["home", "resume", "video"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
<ErrorBoundary
|
|
||||||
fallback={
|
|
||||||
<div className="error">
|
|
||||||
<Typography>Error with resumeItemsAudio</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{resumeItemsAudio.isPending ? (
|
|
||||||
<CardsSkeleton />
|
|
||||||
) : resumeItemsAudio.isSuccess &&
|
|
||||||
!resumeItemsAudio.data.TotalRecordCount ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<CardScroller displayCards={4} title="Continue Listening">
|
|
||||||
{resumeItemsAudio.data?.Items?.map((item) => {
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
cardTitle={item.Name}
|
cardTitle={item.Name}
|
||||||
imageType="Primary"
|
imageType="Primary"
|
||||||
cardCaption={item.ProductionYear}
|
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
queryKey={["home", "resume", "audio"]}
|
disableOverlay
|
||||||
userId={user?.Id}
|
onClick={() => {
|
||||||
|
if (item.Id) {
|
||||||
|
navigate({
|
||||||
|
to: "/library/$id",
|
||||||
|
params: { id: item.Id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
overrideIcon={item.CollectionType}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
fallback={
|
fallback={
|
||||||
<div className="error">
|
<div className="error">
|
||||||
<Typography>Error with LatestMediaSections</Typography>
|
<Typography>Error with Libraries</Typography>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{latestMediaLibs?.map((lib) => {
|
{upNextItems.isPending ? (
|
||||||
return <LatestMediaSection key={lib.Id} latestMediaLib={lib} />;
|
<CardsSkeleton />
|
||||||
})}
|
) : upNextItems.isSuccess && !upNextItems.data?.TotalRecordCount ? (
|
||||||
</ErrorBoundary>
|
<></>
|
||||||
</main>
|
) : (
|
||||||
</>
|
<CardScroller displayCards={4} title="Up Next">
|
||||||
|
{upNextItems.data?.Items?.map((item) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={item.Id}
|
||||||
|
item={item}
|
||||||
|
cardTitle={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? "Primary"
|
||||||
|
: item.ImageTags?.Thumb
|
||||||
|
? "Thumb"
|
||||||
|
: "Backdrop"
|
||||||
|
}
|
||||||
|
cardCaption={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? item.ParentIndexNumber === 0
|
||||||
|
? `${item.SeasonName} - ${item.Name}`
|
||||||
|
: item.IndexNumberEnd
|
||||||
|
? `${item.IndexNumber}-${item.IndexNumberEnd}. ${item.Name}`
|
||||||
|
: `${item.IndexNumber}. ${item.Name}`
|
||||||
|
: item.Type === BaseItemKind.Series
|
||||||
|
? `${item.ProductionYear} - ${
|
||||||
|
item.EndDate
|
||||||
|
? new Date(item.EndDate).toLocaleString([], {
|
||||||
|
year: "numeric",
|
||||||
|
})
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["home", "upNext"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<div className="error">
|
||||||
|
<Typography>Error with resumeItemsVideo</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{resumeItemsVideo.isPending ? (
|
||||||
|
<CardsSkeleton />
|
||||||
|
) : resumeItemsVideo.isSuccess &&
|
||||||
|
!resumeItemsVideo.data?.TotalRecordCount ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<CardScroller displayCards={4} title="Continue Watching">
|
||||||
|
{resumeItemsVideo.data?.Items?.map((item) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={item.Id}
|
||||||
|
item={item}
|
||||||
|
cardTitle={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? "Primary"
|
||||||
|
: item.ImageTags?.Thumb
|
||||||
|
? "Thumb"
|
||||||
|
: "Backdrop"
|
||||||
|
}
|
||||||
|
cardCaption={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type === BaseItemKind.Series
|
||||||
|
? `${item.ProductionYear} - ${
|
||||||
|
item.EndDate
|
||||||
|
? new Date(item.EndDate).toLocaleString([], {
|
||||||
|
year: "numeric",
|
||||||
|
})
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["home", "resume", "video"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<div className="error">
|
||||||
|
<Typography>Error with resumeItemsAudio</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{resumeItemsAudio.isPending ? (
|
||||||
|
<CardsSkeleton />
|
||||||
|
) : resumeItemsAudio.isSuccess &&
|
||||||
|
!resumeItemsAudio.data?.TotalRecordCount ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<CardScroller displayCards={4} title="Continue Listening">
|
||||||
|
{resumeItemsAudio.data?.Items?.map((item) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={item.Id}
|
||||||
|
item={item}
|
||||||
|
cardTitle={item.Name}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={item.ProductionYear}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["home", "resume", "audio"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<div className="error">
|
||||||
|
<Typography>Error with LatestMediaSections</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{latestMediaLibs?.map((lib) => {
|
||||||
|
return <LatestMediaSection key={lib.Id} latestMediaLib={lib} />;
|
||||||
|
})}
|
||||||
|
</ErrorBoundary>
|
||||||
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default React.memo(Home);
|
export default Home;
|
||||||
+336
-342
@@ -1,11 +1,6 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { useState, useLayoutEffect, useRef, useMemo } from "react";
|
||||||
import React, { useState, useLayoutEffect, useRef } from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import Divider from "@mui/material/Divider";
|
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
@@ -19,18 +14,16 @@ import { motion, useScroll } from "framer-motion";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
ItemFields,
|
|
||||||
MediaStreamType,
|
MediaStreamType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import heroBg from "@/assets/herobg.png";
|
import heroBg from "@/assets/herobg.png";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import "./item.scss";
|
import "./item.scss";
|
||||||
|
|
||||||
@@ -67,34 +60,10 @@ import sdrIcon from "@/assets/icons/sdr.svg";
|
|||||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { queryClient } from "@/main";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
function TabPanel(props) {
|
|
||||||
const { children, value, index, ...other } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role="tabpanel"
|
|
||||||
hidden={value !== index}
|
|
||||||
id={`full-width-tabpanel-${index}`}
|
|
||||||
aria-labelledby={`full-width-tab-${index}`}
|
|
||||||
{...other}
|
|
||||||
style={{ marginTop: "1em" }}
|
|
||||||
>
|
|
||||||
{value === index && <Box>{children}</Box>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/item/$id")({
|
export const Route = createFileRoute("/_api/item/$id")({
|
||||||
component: ItemDetail,
|
component: ItemDetail,
|
||||||
});
|
});
|
||||||
@@ -109,6 +78,7 @@ function ItemDetail() {
|
|||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
@@ -120,224 +90,226 @@ function ItemDetail() {
|
|||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// const item = useSuspenseQuery({ queryKey: ["item", id] });
|
|
||||||
|
|
||||||
const similarItems = useQuery({
|
const similarItems = useQuery({
|
||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let result;
|
if (!api) return null;
|
||||||
if (item.data.Type === "Movie") {
|
if (!item.data?.Id) return null;
|
||||||
result = await getLibraryApi(api).getSimilarMovies({
|
if (item.data?.Type === "Movie") {
|
||||||
userId: user?.Id,
|
return (
|
||||||
itemId: item.data.Id,
|
await getLibraryApi(api).getSimilarMovies({
|
||||||
limit: 16,
|
userId: user?.Id,
|
||||||
});
|
itemId: item.data.Id,
|
||||||
} else if (item.data.Type === "Series") {
|
limit: 16,
|
||||||
result = await getLibraryApi(api).getSimilarShows({
|
})
|
||||||
userId: user?.Id,
|
).data;
|
||||||
itemId: item.data.Id,
|
|
||||||
});
|
|
||||||
} else if (item.data.Type === "MusicAlbum") {
|
|
||||||
result = await getLibraryApi(api).getSimilarAlbums({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: item.data.Id,
|
|
||||||
});
|
|
||||||
} else if (item.data.Type === "MusicArtist") {
|
|
||||||
result = await getLibraryApi(api).getSimilarArtists({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: item.data.Id,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
result = await getLibraryApi(api).getSimilarItems({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: item.data.Id,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return result.data;
|
if (item.data?.Type === "Series") {
|
||||||
|
return (
|
||||||
|
await getLibraryApi(api).getSimilarShows({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: item.data.Id,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
}
|
||||||
|
if (item.data?.Type === "MusicAlbum") {
|
||||||
|
return (
|
||||||
|
await getLibraryApi(api).getSimilarAlbums({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: item.data.Id,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
}
|
||||||
|
if (item.data?.Type === "MusicArtist") {
|
||||||
|
return (
|
||||||
|
await getLibraryApi(api).getSimilarArtists({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: item.data.Id,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
await getLibraryApi(api).getSimilarItems({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: item.data.Id,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess,
|
enabled: item.isSuccess,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [videoTracks, setVideoTracks] = useState([]);
|
const [selectedVideoTrack, setSelectedVideoTrack] = useState(0);
|
||||||
const [audioTracks, setAudioTracks] = useState([]);
|
const [selectedAudioTrack, setSelectedAudioTrack] = useState(0);
|
||||||
const [subtitleTracks, setSubtitleTracks] = useState([]);
|
const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(0);
|
||||||
|
|
||||||
const filterMediaStreamVideo = (source) => {
|
const videoTracks = useMemo(() => {
|
||||||
if (source.Type === MediaStreamType.Video) {
|
const result = item.data?.MediaStreams?.filter((source) => {
|
||||||
return true;
|
if (source.Type === MediaStreamType.Video) {
|
||||||
}
|
return true;
|
||||||
return false;
|
}
|
||||||
};
|
return false;
|
||||||
const filterMediaStreamAudio = (source) => {
|
});
|
||||||
if (source.Type === MediaStreamType.Audio) {
|
setSelectedVideoTrack(
|
||||||
return true;
|
result?.find((track) => track.IsDefault)?.Index ??
|
||||||
}
|
result?.[0]?.Index ??
|
||||||
return false;
|
0,
|
||||||
};
|
);
|
||||||
const filterMediaStreamSubtitle = (source) => {
|
return result ?? [];
|
||||||
if (source.Type === MediaStreamType.Subtitle) {
|
}, [item.data?.Id]);
|
||||||
return true;
|
const audioTracks = useMemo(() => {
|
||||||
}
|
const result = item.data?.MediaStreams?.filter((source) => {
|
||||||
return false;
|
if (source.Type === MediaStreamType.Audio) {
|
||||||
};
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
setSelectedAudioTrack(
|
||||||
|
result?.find((track) => track.IsDefault)?.Index ??
|
||||||
|
result?.[0]?.Index ??
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
return result ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
const subtitleTracks = useMemo(() => {
|
||||||
|
const result = item.data?.MediaStreams?.filter((source) => {
|
||||||
|
if (source.Type === MediaStreamType.Subtitle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
setSelectedSubtitleTrack(result?.find((track) => track.IsDefault)?.Index ?? -1);
|
||||||
|
return result ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
|
||||||
const [selectedVideoTrack, setSelectedVideoTrack] = useState(null);
|
const directors = useMemo(() => {
|
||||||
const [selectedAudioTrack, setSelectedAudioTrack] = useState(null);
|
return item.data?.People?.filter((itm) => itm.Type === "Director") ?? [];
|
||||||
const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(null);
|
}, [item.data?.Id]);
|
||||||
|
const writers = useMemo(() => {
|
||||||
|
return item.data?.People?.filter((itm) => itm.Type === "Writer") ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
const actors = useMemo(() => {
|
||||||
|
return item.data?.People?.filter((itm) => itm.Type === "Actor") ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
const producers = useMemo(() => {
|
||||||
|
return item.data?.People?.filter((itm) => itm.Type === "Producer") ?? [];
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
|
||||||
const [directors, setDirectors] = useState([]);
|
const mediaQualityInfo = useMemo<MediaQualityInfo>(() => {
|
||||||
const [writers, setWriters] = useState([]);
|
const checkAtmos = audioTracks.filter((audio) =>
|
||||||
const [actors, setActors] = useState([]);
|
audio.DisplayTitle?.toLocaleLowerCase().includes("atmos"),
|
||||||
const [producers, setProducers] = useState([]);
|
);
|
||||||
|
const checkDolbyVision = videoTracks.filter(
|
||||||
const [mediaQualityInfo, setMediaQualityInfo] = useState<MediaQualityInfo>();
|
(video) =>
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("dv") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("dolby vision") ||
|
||||||
|
!!video.VideoDoViTitle ||
|
||||||
|
video.VideoRangeType === "DOVI",
|
||||||
|
);
|
||||||
|
const checkDD = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
(audio.DisplayTitle?.toLocaleLowerCase().includes("dd") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("ddp")) ||
|
||||||
|
(audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital+")),
|
||||||
|
);
|
||||||
|
const checkDDP = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("ddp") ||
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital+"),
|
||||||
|
);
|
||||||
|
const checkDts = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dts") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") &&
|
||||||
|
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
||||||
|
);
|
||||||
|
const checkDtsHDMA = audioTracks.filter(
|
||||||
|
(audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") ||
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
||||||
|
);
|
||||||
|
const checkUHD = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("4k") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("2160p") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("uhd"),
|
||||||
|
);
|
||||||
|
const checkHD = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
(video.DisplayTitle?.toLocaleLowerCase().includes("hd") &&
|
||||||
|
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr")) ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("1080p") ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("fhd"),
|
||||||
|
);
|
||||||
|
const checkSD = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
(video.DisplayTitle?.toLocaleLowerCase().includes("sd") &&
|
||||||
|
!video.DisplayTitle?.toLocaleLowerCase().includes("sdr")) ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("720p"),
|
||||||
|
);
|
||||||
|
const checkSDR = videoTracks.filter(
|
||||||
|
(video) => video.VideoRangeType === "SDR",
|
||||||
|
);
|
||||||
|
const checkHDR = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.VideoRange === "HDR" ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("dv"),
|
||||||
|
);
|
||||||
|
const checkHDR10 = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.VideoRangeType === "HDR10" &&
|
||||||
|
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
||||||
|
);
|
||||||
|
const checkHDR10Plus = videoTracks.filter(
|
||||||
|
(video) =>
|
||||||
|
video.VideoRangeType === "HDR10Plus" ||
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
||||||
|
);
|
||||||
|
const checkTrueHD = audioTracks.filter((audio) =>
|
||||||
|
audio.DisplayTitle?.toLocaleLowerCase().includes("truehd"),
|
||||||
|
);
|
||||||
|
const checkIMAX = videoTracks.filter((video) =>
|
||||||
|
video.DisplayTitle?.toLocaleLowerCase().includes("imax"),
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
isAtmos: checkAtmos.length > 0,
|
||||||
|
isDolbyVision: checkDolbyVision.length > 0,
|
||||||
|
isDts: checkDts.length > 0,
|
||||||
|
isDtsHDMA: checkDtsHDMA.length > 0,
|
||||||
|
isDD: checkDD.length > 0,
|
||||||
|
isDDP: checkDDP.length > 0,
|
||||||
|
isUHD: checkUHD.length > 0,
|
||||||
|
isHD: checkHD.length > 0,
|
||||||
|
isSD: checkSD.length > 0,
|
||||||
|
isSDR: checkSDR.length > 0,
|
||||||
|
isHDR: checkHDR.length > 0,
|
||||||
|
isHDR10: checkHDR10.length > 0,
|
||||||
|
isHDR10Plus: checkHDR10Plus.length > 0,
|
||||||
|
isTrueHD: checkTrueHD.length > 0,
|
||||||
|
isIMAX: checkIMAX.length > 0,
|
||||||
|
};
|
||||||
|
}, [item.data?.Id]);
|
||||||
|
|
||||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (item.isSuccess) {
|
if (api && item.isSuccess && item.data) {
|
||||||
if (item.data.BackdropImageTags?.length > 0) {
|
if ((item.data?.BackdropImageTags?.length ?? 0) > 0) {
|
||||||
setBackdrop(
|
setBackdrop(
|
||||||
getImageUrlsApi(api).getItemImageUrlById(item.data.Id, "Backdrop", {
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
tag: item.data.BackdropImageTags[0],
|
item.data.Id ?? "",
|
||||||
}),
|
"Backdrop",
|
||||||
item.data.BackdropImageTags[0],
|
{
|
||||||
|
tag: item.data.BackdropImageTags?.[0],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
item.data.BackdropImageTags?.[0],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}
|
}
|
||||||
const direTp = item.data.People.filter((itm) => itm.Type === "Director");
|
|
||||||
setDirectors(direTp);
|
|
||||||
const writeTp = item.data.People.filter((itm) => itm.Type === "Writer");
|
|
||||||
setWriters(writeTp);
|
|
||||||
const producerTp = item.data.People.filter(
|
|
||||||
(itm) => itm.Type === "Producer",
|
|
||||||
);
|
|
||||||
setProducers(producerTp);
|
|
||||||
const actorTp = item.data.People.filter((itm) => itm.Type === "Actor");
|
|
||||||
setActors(actorTp);
|
|
||||||
|
|
||||||
if (item.data.MediaStreams && item.data.MediaSources?.length > 0) {
|
|
||||||
const videos = item.data.MediaStreams.filter(filterMediaStreamVideo);
|
|
||||||
const audios = item.data.MediaStreams.filter(filterMediaStreamAudio);
|
|
||||||
const subs = item.data.MediaStreams.filter(filterMediaStreamSubtitle);
|
|
||||||
|
|
||||||
setSelectedVideoTrack(videos[0]?.Index ?? null);
|
|
||||||
setSelectedAudioTrack(
|
|
||||||
item.data.MediaSources[0].DefaultAudioStreamIndex ?? null,
|
|
||||||
);
|
|
||||||
setSelectedSubtitleTrack(
|
|
||||||
item.data.MediaSources[0].DefaultSubtitleStreamIndex === -1 ||
|
|
||||||
!item.data.MediaSources[0].DefaultSubtitleStreamIndex
|
|
||||||
? "nosub"
|
|
||||||
: item.data.MediaSources[0].DefaultSubtitleStreamIndex,
|
|
||||||
);
|
|
||||||
|
|
||||||
setVideoTracks(videos);
|
|
||||||
setAudioTracks(audios);
|
|
||||||
setSubtitleTracks(subs);
|
|
||||||
|
|
||||||
// Analyze item for QualityInfo
|
|
||||||
const checkAtmos = audios.filter((audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("atmos"),
|
|
||||||
);
|
|
||||||
const checkDolbyVision = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("dv") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("dolby vision") ||
|
|
||||||
!!video.VideoDoViTitle ||
|
|
||||||
video.VideoRangeType === "DOVI",
|
|
||||||
);
|
|
||||||
const checkDD = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
(audio.DisplayTitle?.toLocaleLowerCase().includes("dd") &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes("ddp")) ||
|
|
||||||
(audio.DisplayTitle?.toLocaleLowerCase().includes(
|
|
||||||
"dolby digital",
|
|
||||||
) &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes(
|
|
||||||
"dolby digital+",
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
const checkDDP = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("ddp") ||
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dolby digital+"),
|
|
||||||
);
|
|
||||||
const checkDts = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dts") &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") &&
|
|
||||||
!audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
|
||||||
);
|
|
||||||
const checkDtsHDMA = audios.filter(
|
|
||||||
(audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd ma") ||
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("dts-hd.ma"),
|
|
||||||
);
|
|
||||||
const checkUHD = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("4k") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("2160p") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("uhd"),
|
|
||||||
);
|
|
||||||
const checkHD = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
(video.DisplayTitle?.toLocaleLowerCase().includes("hd") &&
|
|
||||||
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr")) ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("1080p") ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("fhd"),
|
|
||||||
);
|
|
||||||
const checkSD = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
(video.DisplayTitle?.toLocaleLowerCase().includes("sd") &&
|
|
||||||
!video.DisplayTitle?.toLocaleLowerCase().includes("sdr")) ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("720p"),
|
|
||||||
);
|
|
||||||
const checkSDR = videos.filter(
|
|
||||||
(video) => video.VideoRangeType === "SDR",
|
|
||||||
);
|
|
||||||
const checkHDR = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.VideoRange === "HDR" ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("dv"),
|
|
||||||
);
|
|
||||||
const checkHDR10 = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.VideoRangeType === "HDR10" &&
|
|
||||||
!video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
|
||||||
);
|
|
||||||
const checkHDR10Plus = videos.filter(
|
|
||||||
(video) =>
|
|
||||||
video.VideoRangeType === "HDR10+" ||
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("hdr10+"),
|
|
||||||
);
|
|
||||||
const checkTrueHD = audios.filter((audio) =>
|
|
||||||
audio.DisplayTitle?.toLocaleLowerCase().includes("truehd"),
|
|
||||||
);
|
|
||||||
const checkIMAX = videos.filter((video) =>
|
|
||||||
video.DisplayTitle?.toLocaleLowerCase().includes("imax"),
|
|
||||||
);
|
|
||||||
setMediaQualityInfo({
|
|
||||||
isAtmos: checkAtmos.length > 0,
|
|
||||||
isDolbyVision: checkDolbyVision.length > 0,
|
|
||||||
isDts: checkDts.length > 0,
|
|
||||||
isDtsHDMA: checkDtsHDMA.length > 0,
|
|
||||||
isDD: checkDD.length > 0,
|
|
||||||
isDDP: checkDDP.length > 0,
|
|
||||||
isUHD: checkUHD.length > 0,
|
|
||||||
isHD: checkHD.length > 0,
|
|
||||||
isSD: checkSD.length > 0,
|
|
||||||
isSDR: checkSDR.length > 0,
|
|
||||||
isHDR: checkHDR.length > 0,
|
|
||||||
isHDR10: checkHDR10.length > 0,
|
|
||||||
isHDR10Plus: checkHDR10Plus.length > 0,
|
|
||||||
isTrueHD: checkTrueHD.length > 0,
|
|
||||||
isIMAX: checkIMAX.length > 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [item.isSuccess]);
|
}, [item.isSuccess]);
|
||||||
|
|
||||||
@@ -353,7 +325,7 @@ function ItemDetail() {
|
|||||||
return <ItemSkeleton />;
|
return <ItemSkeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.isSuccess && similarItems.isSuccess) {
|
if (item.isSuccess && item.data) {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={id}
|
key={id}
|
||||||
@@ -374,17 +346,20 @@ function ItemDetail() {
|
|||||||
<div className="item-hero-backdrop-container">
|
<div className="item-hero-backdrop-container">
|
||||||
{item.data.BackdropImageTags?.length ? (
|
{item.data.BackdropImageTags?.length ? (
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Backdrop",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
tag: item.data.BackdropImageTags[0],
|
"Backdrop",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.data.BackdropImageTags[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -392,11 +367,11 @@ function ItemDetail() {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<motion.img
|
<motion.img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={heroBg}
|
src={heroBg}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
y: parallax,
|
y: parallax,
|
||||||
@@ -410,54 +385,60 @@ function ItemDetail() {
|
|||||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.keys(item.data.ImageTags).includes("Primary") ? (
|
{item.data.ImageTags?.Primary ? (
|
||||||
<>
|
<div>
|
||||||
<Blurhash
|
<Blurhash
|
||||||
hash={
|
hash={
|
||||||
item.data.ImageBlurHashes.Primary[
|
item.data.ImageBlurHashes?.Primary?.[
|
||||||
item.data.ImageTags.Primary
|
item.data.ImageTags.Primary
|
||||||
]
|
] ?? ""
|
||||||
}
|
}
|
||||||
className="item-hero-image-blurhash"
|
className="item-hero-image-blurhash"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Primary",
|
||||||
tag: item.data.ImageTags.Primary,
|
{
|
||||||
},
|
quality: 90,
|
||||||
)}
|
tag: item.data.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-image"
|
className="item-hero-image"
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="item-hero-image-icon">
|
<div className="item-hero-image-icon">
|
||||||
{getTypeIcon(item.data.Type)}
|
{getTypeIcon(item.data.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="item-hero-detail flex flex-column">
|
<div className="item-hero-detail flex flex-column">
|
||||||
{item.data.ImageTags?.Logo ? (
|
{item.data.ImageTags?.Logo ? (
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Logo",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Logo",
|
||||||
fillWidth: 592,
|
{
|
||||||
fillHeight: 592,
|
quality: 90,
|
||||||
tag: item.data.ImageTags.Logo,
|
fillWidth: 592,
|
||||||
},
|
fillHeight: 592,
|
||||||
)}
|
tag: item.data.ImageTags.Logo,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-logo"
|
className="item-hero-logo"
|
||||||
/>
|
/>
|
||||||
@@ -595,7 +576,7 @@ function ItemDetail() {
|
|||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{endsAt(
|
{endsAt(
|
||||||
item.data.RunTimeTicks -
|
item.data.RunTimeTicks -
|
||||||
item.data.UserData.PlaybackPositionTicks,
|
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
@@ -694,9 +675,8 @@ function ItemDetail() {
|
|||||||
>
|
>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item.data}
|
item={item.data}
|
||||||
itemId={item.data.Id}
|
itemType={item.data.Type ?? "Movie"}
|
||||||
itemType={item.data.Type}
|
audio={item.data.Type === "Audio"}
|
||||||
itemUserData={item.data.UserData}
|
|
||||||
currentVideoTrack={selectedVideoTrack}
|
currentVideoTrack={selectedVideoTrack}
|
||||||
currentAudioTrack={selectedAudioTrack}
|
currentAudioTrack={selectedAudioTrack}
|
||||||
currentSubTrack={selectedSubtitleTrack}
|
currentSubTrack={selectedSubtitleTrack}
|
||||||
@@ -707,22 +687,24 @@ function ItemDetail() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row" style={{ gap: "1em" }}>
|
<div className="flex flex-row" style={{ gap: "1em" }}>
|
||||||
<TrailerButton
|
{item.data.RemoteTrailers && (
|
||||||
trailerItem={item.data.RemoteTrailers}
|
<TrailerButton
|
||||||
disabled={item.data.RemoteTrailers?.length === 0}
|
trailerItem={item.data.RemoteTrailers}
|
||||||
/>
|
disabled={item.data.RemoteTrailers?.length === 0}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData?.Played}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -730,9 +712,9 @@ function ItemDetail() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="item-detail">
|
<div className="item-detail">
|
||||||
<div style={{ width: "100%" }}>
|
<div style={{ width: "100%" }}>
|
||||||
{item.data.Taglines?.length > 0 && (
|
{(item.data.Taglines?.length ?? 0) > 0 && (
|
||||||
<Typography variant="h5" mb={2} fontWeight={300}>
|
<Typography variant="h5" mb={2} fontWeight={300}>
|
||||||
{item.data.Taglines[0]}
|
{item.data.Taglines?.[0]}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
<ShowMoreText
|
<ShowMoreText
|
||||||
@@ -755,7 +737,7 @@ function ItemDetail() {
|
|||||||
}}
|
}}
|
||||||
value={selectedVideoTrack}
|
value={selectedVideoTrack}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={(e) => setSelectedVideoTrack(e.target.value)}
|
onChange={(e) => setSelectedVideoTrack(Number(e.target.value))}
|
||||||
>
|
>
|
||||||
{videoTracks.map((track) => (
|
{videoTracks.map((track) => (
|
||||||
<MenuItem key={track.Index} value={track.Index}>
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
@@ -774,7 +756,7 @@ function ItemDetail() {
|
|||||||
}}
|
}}
|
||||||
value={selectedAudioTrack}
|
value={selectedAudioTrack}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={(e) => setSelectedAudioTrack(e.target.value)}
|
onChange={(e) => setSelectedAudioTrack(Number(e.target.value))}
|
||||||
>
|
>
|
||||||
{audioTracks.map((track) => (
|
{audioTracks.map((track) => (
|
||||||
<MenuItem key={track.Index} value={track.Index}>
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
@@ -797,9 +779,11 @@ function ItemDetail() {
|
|||||||
disablePortal: true,
|
disablePortal: true,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onChange={(e) => setSelectedSubtitleTrack(e.target.value)}
|
onChange={(e) =>
|
||||||
|
setSelectedSubtitleTrack(Number(e.target.value))
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<MenuItem key={-1} value={"nosub"}>
|
<MenuItem key={-1} value={-1}>
|
||||||
No Subtitle
|
No Subtitle
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{subtitleTracks.map((track) => (
|
{subtitleTracks.map((track) => (
|
||||||
@@ -817,13 +801,17 @@ function ItemDetail() {
|
|||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.ExternalUrls.map((url) => (
|
{item.data.ExternalUrls?.map(
|
||||||
<IconLink url={url.Url} name={url.Name} />
|
(url) =>
|
||||||
))}
|
url.Url &&
|
||||||
|
url.Name && (
|
||||||
|
<IconLink key={url.Name} url={url.Url} name={url.Name} />
|
||||||
|
),
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{item.data.People.length > 0 && (
|
{(item.data.People?.length ?? 0) > 0 && (
|
||||||
<div className="item-detail-cast">
|
<div className="item-detail-cast">
|
||||||
<Typography variant="h5" mb={2}>
|
<Typography variant="h5" mb={2}>
|
||||||
Cast & Crew
|
Cast & Crew
|
||||||
@@ -838,21 +826,24 @@ function ItemDetail() {
|
|||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to="/person/$id"
|
to="/person/$id"
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -890,16 +881,19 @@ function ItemDetail() {
|
|||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -935,21 +929,24 @@ function ItemDetail() {
|
|||||||
to="/person/$id"
|
to="/person/$id"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -983,23 +980,26 @@ function ItemDetail() {
|
|||||||
<Link
|
<Link
|
||||||
className="item-detail-cast-card"
|
className="item-detail-cast-card"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to={`/person/$id`}
|
to="/person/$id"
|
||||||
params={{
|
params={{
|
||||||
id: actor.Id,
|
id: actor.Id ?? "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
alt={actor.Name}
|
alt={actor.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
actor.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
actor.Id ?? "",
|
||||||
quality: 80,
|
"Primary",
|
||||||
fillWidth: 200,
|
{
|
||||||
fillHeight: 200,
|
quality: 80,
|
||||||
},
|
fillWidth: 200,
|
||||||
)}
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="item-detail-cast-card-image"
|
className="item-detail-cast-card-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -1027,13 +1027,13 @@ function ItemDetail() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{similarItems.data.TotalRecordCount > 0 && (
|
{(similarItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="You might also like"
|
title="You might also like"
|
||||||
displayCards={7}
|
displayCards={7}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
{similarItems.data.Items.map((similar) => {
|
{similarItems.data?.Items?.map((similar) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={similar.Id}
|
key={similar.Id}
|
||||||
@@ -1066,12 +1066,6 @@ function ItemDetail() {
|
|||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
|
||||||
similar.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(similar.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
+437
-314
@@ -28,11 +28,11 @@ import { getMusicGenresApi } from "@jellyfin/sdk/lib/utils/api/music-genres-api"
|
|||||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||||
|
|
||||||
import GenreView from "@/components/layouts/library/genreView";
|
|
||||||
import MusicTrack from "@/components/musicTrack";
|
import MusicTrack from "@/components/musicTrack";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import {
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
type BaseItemDtoQueryResult,
|
type BaseItemDtoQueryResult,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
CollectionType,
|
CollectionType,
|
||||||
@@ -43,13 +43,7 @@ import {
|
|||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import {
|
import { FormControl, Menu, Stack, useScrollTrigger } from "@mui/material";
|
||||||
FormControl,
|
|
||||||
Menu,
|
|
||||||
Select,
|
|
||||||
Stack,
|
|
||||||
useScrollTrigger,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
import "./library.scss";
|
import "./library.scss";
|
||||||
@@ -59,7 +53,7 @@ import { useApiInContext } from "@/utils/store/api";
|
|||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
type SortByObject = { title: string; value: ItemSortBy };
|
type SortByObject = { title: string; value: string };
|
||||||
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
||||||
// type allowedFilters = ["movies", "tvshows", "music", "books"];
|
// type allowedFilters = ["movies", "tvshows", "music", "books"];
|
||||||
|
|
||||||
@@ -83,10 +77,10 @@ const useWindowWidth = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/library/$id")({
|
export const Route = createFileRoute("/_api/library/$id")({
|
||||||
component: LibraryView,
|
component: Library,
|
||||||
});
|
});
|
||||||
|
|
||||||
function LibraryView() {
|
function Library() {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
@@ -94,8 +88,9 @@ function LibraryView() {
|
|||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const currentLib = useQuery({
|
const currentLib = useQuery({
|
||||||
queryKey: ["libraryView", "currentLib", id],
|
queryKey: ["library", "currentLib", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
@@ -107,9 +102,58 @@ function LibraryView() {
|
|||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [currentViewType, setCurrentViewType] = useState<BaseItemKind | "Artist">(
|
const genres = useQuery({
|
||||||
undefined!,
|
queryKey: ["library", "genreItem", id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
if (currentLib.data?.CollectionType === "music") {
|
||||||
|
const result = await getMusicGenresApi(api).getMusicGenres({
|
||||||
|
parentId: id,
|
||||||
|
userId: user?.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
const result = await getGenresApi(api).getGenres({
|
||||||
|
parentId: id,
|
||||||
|
userId: user?.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [genreFilter, setGenreFilter] = useState<string[]>(() => {
|
||||||
|
const cachedVal = sessionStorage.getItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_genreFilter`,
|
||||||
|
);
|
||||||
|
if (cachedVal) {
|
||||||
|
return JSON.parse(cachedVal);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
const handleGenreFilter = useCallback(
|
||||||
|
(e: ChangeEvent<HTMLInputElement>, genre: BaseItemDto) => {
|
||||||
|
if (e.target.checked) {
|
||||||
|
const genreFilterTemp = [...genreFilter, genre.Id];
|
||||||
|
setGenreFilter((s) => (genre.Id ? [...s, genre.Id] : s));
|
||||||
|
sessionStorage.setItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_genreFilter`,
|
||||||
|
JSON.stringify(genreFilterTemp),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const genreFilterTemp = genreFilter.filter((id) => id !== genre.Id);
|
||||||
|
setGenreFilter((s) => s.filter((id) => id !== genre.Id));
|
||||||
|
sessionStorage.setItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_genreFilter`,
|
||||||
|
JSON.stringify(genreFilterTemp),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[genres.data?.Items?.length, id],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [currentViewType, setCurrentViewType] = useState<
|
||||||
|
BaseItemKind | "Artist"
|
||||||
|
>(undefined!);
|
||||||
const availableViewTypes: ViewObject[] = useMemo(() => {
|
const availableViewTypes: ViewObject[] = useMemo(() => {
|
||||||
let result: ViewObject[] = undefined!;
|
let result: ViewObject[] = undefined!;
|
||||||
switch (currentLib.data?.CollectionType) {
|
switch (currentLib.data?.CollectionType) {
|
||||||
@@ -171,6 +215,9 @@ function LibraryView() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case CollectionType.Playlists:
|
||||||
|
result = [{ title: "Playlist", value: BaseItemKind.Playlist }];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = [];
|
result = [];
|
||||||
}
|
}
|
||||||
@@ -199,7 +246,7 @@ function LibraryView() {
|
|||||||
Dvd: undefined,
|
Dvd: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [sortBy, setSortBy] = useState<ItemSortBy>("Name");
|
const [sortBy, setSortBy] = useState<string>("Name");
|
||||||
const [sortAscending, setSortAscending] = useState(
|
const [sortAscending, setSortAscending] = useState(
|
||||||
() =>
|
() =>
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
@@ -300,6 +347,47 @@ function LibraryView() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case BaseItemKind.Playlist:
|
||||||
|
result = [
|
||||||
|
{
|
||||||
|
title: "Name",
|
||||||
|
value: ItemSortBy.SortName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Community Rating",
|
||||||
|
value: ItemSortBy.CommunityRating,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Critics Rating",
|
||||||
|
value: ItemSortBy.CriticRating,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Date Added",
|
||||||
|
value: ItemSortBy.DateCreated,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Date Played",
|
||||||
|
value: ItemSortBy.DatePlayed,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Folder",
|
||||||
|
value: `${ItemSortBy.IsFolder},${ItemSortBy.SortName}`,
|
||||||
|
},
|
||||||
|
{ title: "Parenal Rating", value: ItemSortBy.OfficialRating },
|
||||||
|
{
|
||||||
|
title: "Play Count",
|
||||||
|
value: ItemSortBy.PlayCount,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Release Date",
|
||||||
|
value: `${ItemSortBy.ProductionYear},${ItemSortBy.PremiereDate},${ItemSortBy.SortName}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Random",
|
||||||
|
value: ItemSortBy.Random,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = [];
|
result = [];
|
||||||
break;
|
break;
|
||||||
@@ -486,7 +574,7 @@ function LibraryView() {
|
|||||||
|
|
||||||
const items = useQuery({
|
const items = useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
"libraryView",
|
"library",
|
||||||
"currentLibItems",
|
"currentLibItems",
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
@@ -495,9 +583,11 @@ function LibraryView() {
|
|||||||
sortBy: sortBy,
|
sortBy: sortBy,
|
||||||
filters,
|
filters,
|
||||||
videoTypesState,
|
videoTypesState,
|
||||||
|
genreFilter,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||||
if (currentViewType === "MusicArtist") {
|
if (currentViewType === "MusicArtist") {
|
||||||
result = await getArtistsApi(api).getAlbumArtists({
|
result = await getArtistsApi(api).getAlbumArtists({
|
||||||
@@ -514,16 +604,6 @@ function LibraryView() {
|
|||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personTypes: ["Actor"],
|
personTypes: ["Actor"],
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "Genre") {
|
|
||||||
result = await getGenresApi(api).getGenres({
|
|
||||||
userId: user?.Id,
|
|
||||||
parentId: id,
|
|
||||||
});
|
|
||||||
} else if (currentViewType === "MusicGenre") {
|
|
||||||
result = await getMusicGenresApi(api).getMusicGenres({
|
|
||||||
userId: user?.Id,
|
|
||||||
parentId: id,
|
|
||||||
});
|
|
||||||
} else if (currentViewType === "Studio") {
|
} else if (currentViewType === "Studio") {
|
||||||
result = await getStudiosApi(api).getStudios({
|
result = await getStudiosApi(api).getStudios({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
@@ -551,7 +631,7 @@ function LibraryView() {
|
|||||||
sortOrder: [
|
sortOrder: [
|
||||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||||
],
|
],
|
||||||
sortBy: [sortBy],
|
sortBy: sortBy.split(",") as ItemSortBy[],
|
||||||
filters: filtersArray,
|
filters: filtersArray,
|
||||||
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
||||||
hasTrailer: filters.hasTrailer ? true : undefined,
|
hasTrailer: filters.hasTrailer ? true : undefined,
|
||||||
@@ -563,6 +643,7 @@ function LibraryView() {
|
|||||||
is4K: filters.is4K || undefined,
|
is4K: filters.is4K || undefined,
|
||||||
is3D: filters.is3D || undefined,
|
is3D: filters.is3D || undefined,
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
|
genreIds: genreFilter,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const videoTypes: VideoType[] = [];
|
const videoTypes: VideoType[] = [];
|
||||||
@@ -586,7 +667,7 @@ function LibraryView() {
|
|||||||
sortOrder: [
|
sortOrder: [
|
||||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||||
],
|
],
|
||||||
sortBy: [sortBy],
|
sortBy: sortBy.split(",") as ItemSortBy[],
|
||||||
filters: filtersArray,
|
filters: filtersArray,
|
||||||
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
||||||
hasTrailer: filters.hasTrailer ? true : undefined,
|
hasTrailer: filters.hasTrailer ? true : undefined,
|
||||||
@@ -598,14 +679,13 @@ function LibraryView() {
|
|||||||
is4K: filters.is4K || undefined,
|
is4K: filters.is4K || undefined,
|
||||||
is3D: filters.is3D || undefined,
|
is3D: filters.is3D || undefined,
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
|
genreIds: genreFilter,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
// enabled: false,
|
|
||||||
enabled: !!user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
enabled: !!user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
// gcTime: 0,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const disableSort = useMemo(() => {
|
const disableSort = useMemo(() => {
|
||||||
@@ -646,7 +726,7 @@ function LibraryView() {
|
|||||||
? 260
|
? 260
|
||||||
: 356,
|
: 356,
|
||||||
[items.dataUpdatedAt],
|
[items.dataUpdatedAt],
|
||||||
); // This sets the approx height of each card in libraryView to estimate no of virtual rows to render
|
); // This sets the approx height of each card in library to estimate no of virtual rows to render
|
||||||
const windowWidth = useWindowWidth();
|
const windowWidth = useWindowWidth();
|
||||||
const itemsPerRow = useMemo(
|
const itemsPerRow = useMemo(
|
||||||
() => Math.max(1, Math.floor(windowWidth / 200)),
|
() => Math.max(1, Math.floor(windowWidth / 200)),
|
||||||
@@ -694,10 +774,10 @@ function LibraryView() {
|
|||||||
|
|
||||||
const backdropItems = useMemo(() => {
|
const backdropItems = useMemo(() => {
|
||||||
if (items.isSuccess) {
|
if (items.isSuccess) {
|
||||||
const temp = items.data.Items?.filter(
|
const temp = items.data?.Items?.filter(
|
||||||
(item) => item.BackdropImageTags?.length,
|
(item) => item.BackdropImageTags?.length,
|
||||||
);
|
);
|
||||||
if (temp?.[0]?.Id) {
|
if (temp?.[0]?.Id && api) {
|
||||||
setBackdrop(
|
setBackdrop(
|
||||||
getImageUrlsApi(api).getItemImageUrlById(temp?.[0]?.Id, "Backdrop", {
|
getImageUrlsApi(api).getItemImageUrlById(temp?.[0]?.Id, "Backdrop", {
|
||||||
tag: temp?.[0]?.BackdropImageTags?.[0],
|
tag: temp?.[0]?.BackdropImageTags?.[0],
|
||||||
@@ -710,7 +790,7 @@ function LibraryView() {
|
|||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (backdropItems?.length) {
|
if (backdropItems?.length && api) {
|
||||||
const intervalId = setInterval(() => {
|
const intervalId = setInterval(() => {
|
||||||
const itemIndex = Math.floor(Math.random() * backdropItems?.length);
|
const itemIndex = Math.floor(Math.random() * backdropItems?.length);
|
||||||
const backdropItem = backdropItems[itemIndex];
|
const backdropItem = backdropItems[itemIndex];
|
||||||
@@ -730,8 +810,6 @@ function LibraryView() {
|
|||||||
}
|
}
|
||||||
}, [backdropItems]);
|
}, [backdropItems]);
|
||||||
|
|
||||||
const [test, setTest] = useState(1);
|
|
||||||
|
|
||||||
if (items.isError) {
|
if (items.isError) {
|
||||||
console.error(items.error);
|
console.error(items.error);
|
||||||
}
|
}
|
||||||
@@ -778,7 +856,7 @@ function LibraryView() {
|
|||||||
{currentLib.isPending ? (
|
{currentLib.isPending ? (
|
||||||
<CircularProgress sx={{ p: 1 }} />
|
<CircularProgress sx={{ p: 1 }} />
|
||||||
) : (
|
) : (
|
||||||
currentLib.data.Name
|
currentLib.data?.Name
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Chip
|
<Chip
|
||||||
@@ -786,7 +864,7 @@ function LibraryView() {
|
|||||||
!items.isSuccess ? (
|
!items.isSuccess ? (
|
||||||
<CircularProgress sx={{ p: 1.5 }} />
|
<CircularProgress sx={{ p: 1.5 }} />
|
||||||
) : (
|
) : (
|
||||||
items.data.TotalRecordCount
|
items.data?.TotalRecordCount
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -810,7 +888,7 @@ function LibraryView() {
|
|||||||
gap={1.2}
|
gap={1.2}
|
||||||
className="library-items-options"
|
className="library-items-options"
|
||||||
>
|
>
|
||||||
{!disableSort && (
|
{!disableSort && sortBy && (
|
||||||
<div className="flex flex-row flex-center">
|
<div className="flex flex-row flex-center">
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -840,7 +918,7 @@ function LibraryView() {
|
|||||||
value={sortBy ?? "Name"}
|
value={sortBy ?? "Name"}
|
||||||
size="small"
|
size="small"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSortBy(e.target.value as ItemSortBy);
|
setSortBy(e.target.value);
|
||||||
console.info(e);
|
console.info(e);
|
||||||
sessionStorage.setItem(
|
sessionStorage.setItem(
|
||||||
`library-${currentLib.data?.Id}-config_sort`,
|
`library-${currentLib.data?.Id}-config_sort`,
|
||||||
@@ -852,7 +930,7 @@ function LibraryView() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{sortByOptions.map((item) => (
|
{sortByOptions.map((item) => (
|
||||||
<MenuItem key={item.value} value={item.value}>
|
<MenuItem key={item.title} value={item.value}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
@@ -880,7 +958,7 @@ function LibraryView() {
|
|||||||
</TextField>
|
</TextField>
|
||||||
)}
|
)}
|
||||||
{!disableFilters && (
|
{!disableFilters && (
|
||||||
<>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
startIcon={
|
startIcon={
|
||||||
<span className="material-symbols-rounded">
|
<span className="material-symbols-rounded">
|
||||||
@@ -907,260 +985,339 @@ function LibraryView() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
{currentViewType !== "Audio" && (
|
||||||
variant="h6"
|
<div>
|
||||||
fontWeight={600}
|
<Typography
|
||||||
mx="0.4em"
|
variant="h6"
|
||||||
mb={0.5}
|
fontWeight={600}
|
||||||
>
|
mx="0.4em"
|
||||||
Filters
|
mb={0.5}
|
||||||
</Typography>
|
>
|
||||||
<FormControl
|
Filters
|
||||||
style={{
|
</Typography>
|
||||||
background: "rgb(0 0 0 / 0.4)",
|
<FormControl
|
||||||
width: "100%",
|
style={{
|
||||||
padding: "0.4em 1em",
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
borderRadius: "6px",
|
width: "100%",
|
||||||
}}
|
padding: "0.4em 1em",
|
||||||
>
|
borderRadius: "6px",
|
||||||
<FormControlLabel
|
}}
|
||||||
control={
|
>
|
||||||
<Checkbox
|
<FormControlLabel
|
||||||
checked={filters.isPlayed}
|
control={
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
<Checkbox
|
||||||
setFilters((s) => ({
|
checked={filters.isPlayed}
|
||||||
...s,
|
onChange={(
|
||||||
isPlayed: e.target.checked,
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
}))
|
) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
isPlayed: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Played"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Played"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.isUnPlayed}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.isUnPlayed}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
isUnPlayed: e.target.checked,
|
||||||
isUnPlayed: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Unplayed"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Unplayed"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.isResumable}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.isResumable}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
isResumable: e.target.checked,
|
||||||
isResumable: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Resumable"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Resumable"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.isFavorite}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.isFavorite}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
isFavorite: e.target.checked,
|
||||||
isFavorite: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Favorites"
|
||||||
/>
|
/>
|
||||||
}
|
</FormControl>
|
||||||
label="Favorites"
|
</div>
|
||||||
/>
|
)}
|
||||||
</FormControl>
|
{currentViewType !== "Audio" && (
|
||||||
<Typography
|
<div>
|
||||||
variant="h6"
|
<Typography
|
||||||
fontWeight={600}
|
variant="h6"
|
||||||
mx="0.4em"
|
fontWeight={600}
|
||||||
mb={0.5}
|
mx="0.4em"
|
||||||
>
|
mb={0.5}
|
||||||
Features
|
>
|
||||||
</Typography>
|
Features
|
||||||
<FormControl
|
</Typography>
|
||||||
style={{
|
<FormControl
|
||||||
background: "rgb(0 0 0 / 0.4)",
|
style={{
|
||||||
width: "100%",
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
padding: "0.4em 1em",
|
width: "100%",
|
||||||
borderRadius: "6px",
|
padding: "0.4em 1em",
|
||||||
}}
|
borderRadius: "6px",
|
||||||
>
|
}}
|
||||||
<FormControlLabel
|
>
|
||||||
control={
|
<FormControlLabel
|
||||||
<Checkbox
|
control={
|
||||||
checked={filters.hasSubtitles}
|
<Checkbox
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
checked={filters.hasSubtitles}
|
||||||
setFilters((s) => ({
|
onChange={(
|
||||||
...s,
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
hasSubtitles: e.target.checked,
|
) =>
|
||||||
}))
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
hasSubtitles: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Subtitles"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Subtitles"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.hasTrailer}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.hasTrailer}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
hasTrailer: e.target.checked,
|
||||||
hasTrailer: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Trailer"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Trailer"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.hasSpecialFeature}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.hasSpecialFeature}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
hasSpecialFeature: e.target.checked,
|
||||||
hasSpecialFeature: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Special Features"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Special Features"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.hasThemeSong}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.hasThemeSong}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
hasThemeSong: e.target.checked,
|
||||||
hasThemeSong: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Theme Song"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="Theme Song"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.hasThemeVideo}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.hasThemeVideo}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
hasThemeVideo: e.target.checked,
|
||||||
hasThemeVideo: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="Theme Video"
|
||||||
/>
|
/>
|
||||||
}
|
</FormControl>
|
||||||
label="Theme Video"
|
</div>
|
||||||
/>
|
)}
|
||||||
</FormControl>
|
{currentViewType !== "Audio" && (
|
||||||
<Typography
|
<div>
|
||||||
variant="h6"
|
<Typography
|
||||||
fontWeight={600}
|
variant="h6"
|
||||||
mx="0.4em"
|
fontWeight={600}
|
||||||
mb={0.5}
|
mx="0.4em"
|
||||||
>
|
mb={0.5}
|
||||||
Video Types
|
>
|
||||||
</Typography>
|
Video Types
|
||||||
<FormControl
|
</Typography>
|
||||||
style={{
|
<FormControl
|
||||||
background: "rgb(0 0 0 / 0.4)",
|
style={{
|
||||||
width: "100%",
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
padding: "0.4em 1em",
|
width: "100%",
|
||||||
borderRadius: "6px",
|
padding: "0.4em 1em",
|
||||||
}}
|
borderRadius: "6px",
|
||||||
>
|
}}
|
||||||
<FormControlLabel
|
>
|
||||||
control={
|
<FormControlLabel
|
||||||
<Checkbox
|
control={
|
||||||
checked={videoTypesState.BluRay}
|
<Checkbox
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
checked={videoTypesState.BluRay}
|
||||||
setVideoTypesState((s) => ({
|
onChange={(
|
||||||
...s,
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
BluRay: e.target.checked,
|
) =>
|
||||||
}))
|
setVideoTypesState((s) => ({
|
||||||
|
...s,
|
||||||
|
BluRay: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="BluRay"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="BluRay"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={videoTypesState.Dvd}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={videoTypesState.Dvd}
|
) =>
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
setVideoTypesState((s) => ({
|
||||||
setVideoTypesState((s) => ({
|
...s,
|
||||||
...s,
|
Dvd: e.target.checked,
|
||||||
Dvd: e.target.checked,
|
}))
|
||||||
}))
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
label="DVD"
|
||||||
/>
|
/>
|
||||||
}
|
<FormControlLabel
|
||||||
label="DVD"
|
control={
|
||||||
/>
|
<Checkbox
|
||||||
<FormControlLabel
|
checked={filters.isHD}
|
||||||
control={
|
onChange={(
|
||||||
<Checkbox
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
checked={filters.isHD}
|
) => {
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
setFilters((s) => ({
|
||||||
setFilters((s) => ({
|
...s,
|
||||||
...s,
|
isHD: e.target.checked,
|
||||||
isHD: e.target.checked,
|
}));
|
||||||
}));
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="HD"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.is4K}
|
||||||
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
is4K: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="4k"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={<Checkbox checked={false} />}
|
||||||
|
label="SD"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
value={filters.is3D}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
is3D: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="3D"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{genres.isSuccess &&
|
||||||
|
(genres.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
|
<div>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
fontWeight={600}
|
||||||
|
mx="0.4em"
|
||||||
|
mb={0.5}
|
||||||
|
>
|
||||||
|
Genres
|
||||||
|
</Typography>
|
||||||
|
<FormControl
|
||||||
|
style={{
|
||||||
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.4em 1em",
|
||||||
|
borderRadius: "6px",
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
}
|
{genres.data?.Items?.map(
|
||||||
label="HD"
|
(genre) =>
|
||||||
/>
|
genre.Id && (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
key={genre.Id}
|
||||||
<Checkbox
|
control={
|
||||||
checked={filters.is4K}
|
<Checkbox
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
checked={genreFilter.includes(
|
||||||
setFilters((s) => ({
|
genre.Id,
|
||||||
...s,
|
)}
|
||||||
is4K: e.target.checked,
|
onChange={(e) =>
|
||||||
}))
|
handleGenreFilter(e, genre)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="4k"
|
label={genre.Name}
|
||||||
/>
|
/>
|
||||||
<FormControlLabel
|
),
|
||||||
control={<Checkbox checked={false} />}
|
)}
|
||||||
label="SD"
|
</FormControl>
|
||||||
disabled
|
</div>
|
||||||
/>
|
)}
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
value={filters.is3D}
|
|
||||||
onChange={(e) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
is3D: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="3D"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</Menu>
|
</Menu>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -1170,22 +1327,11 @@ function LibraryView() {
|
|||||||
) : items.data?.TotalRecordCount === 0 ? (
|
) : items.data?.TotalRecordCount === 0 ? (
|
||||||
<EmptyNotice
|
<EmptyNotice
|
||||||
extraMsg={
|
extraMsg={
|
||||||
currentViewType === BaseItemKind.Trailer &&
|
currentViewType === BaseItemKind.Trailer
|
||||||
"Install the trailers channel to enhance your movie experience by adding a library of internet trailers."
|
? "Install the trailers channel to enhance your movie experience by adding a library of internet trailers."
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : currentViewType === BaseItemKind.Genre ? (
|
|
||||||
items.data?.Items?.map((item) => {
|
|
||||||
return (
|
|
||||||
<GenreView
|
|
||||||
key={item.Id}
|
|
||||||
libraryId={currentLib.data.Id}
|
|
||||||
genreId={item.Id}
|
|
||||||
genreName={item.Name}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
) : currentViewType !== BaseItemKind.Audio ? (
|
) : currentViewType !== BaseItemKind.Audio ? (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -1204,6 +1350,7 @@ function LibraryView() {
|
|||||||
);
|
);
|
||||||
for (let i = fromIndex; i < toIndex; i++) {
|
for (let i = fromIndex; i < toIndex; i++) {
|
||||||
const item = items.data?.Items?.[i];
|
const item = items.data?.Items?.[i];
|
||||||
|
if (!item) return null;
|
||||||
displayItems.push(
|
displayItems.push(
|
||||||
<div
|
<div
|
||||||
className="library-virtual-item"
|
className="library-virtual-item"
|
||||||
@@ -1212,7 +1359,7 @@ function LibraryView() {
|
|||||||
ref={virtualizer.measureElement}
|
ref={virtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<Card
|
<Card
|
||||||
item={item ?? null}
|
item={item}
|
||||||
seriesId={item?.SeriesId}
|
seriesId={item?.SeriesId}
|
||||||
cardTitle={
|
cardTitle={
|
||||||
item?.Type === BaseItemKind.Episode
|
item?.Type === BaseItemKind.Episode
|
||||||
@@ -1286,6 +1433,7 @@ function LibraryView() {
|
|||||||
>
|
>
|
||||||
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
||||||
const item = items.data?.Items?.[virtualRow.index];
|
const item = items.data?.Items?.[virtualRow.index];
|
||||||
|
if (!item) return null;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item?.Id}
|
key={item?.Id}
|
||||||
@@ -1299,31 +1447,8 @@ function LibraryView() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MusicTrack
|
<MusicTrack
|
||||||
item={item ?? null}
|
item={item}
|
||||||
// queryKey={[
|
queryKey={["library"]}
|
||||||
// "libraryView",
|
|
||||||
// "currentLibItems",
|
|
||||||
// id,
|
|
||||||
// {
|
|
||||||
// currentViewType: currentViewType,
|
|
||||||
// sortAscending: sortAscending,
|
|
||||||
// sortBy: sortBy,
|
|
||||||
// extraFilters: {
|
|
||||||
// hasSubtitles: hasSubtitles,
|
|
||||||
// hasTrailer: hasTrailer,
|
|
||||||
// hasSpecialFeature: hasSpecialFeature,
|
|
||||||
// hasThemeSong: hasThemeSong,
|
|
||||||
// hasThemeVideo: hasThemeVideo,
|
|
||||||
// },
|
|
||||||
// qualityFilters: {
|
|
||||||
// isBluRay: isBluRay,
|
|
||||||
// isDVD: isDVD,
|
|
||||||
// isHD: isHD,
|
|
||||||
// is4K: is4K,
|
|
||||||
// is3D: is3D,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ]}
|
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -1341,5 +1466,3 @@ function LibraryView() {
|
|||||||
return <ErrorNotice error={currentLib.error} />;
|
return <ErrorNotice error={currentLib.error} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LibraryView;
|
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
&-icon {
|
&-icon {
|
||||||
font-size: 3em;
|
font-size: 3em;
|
||||||
fill: url(#clr-gradient-default) !important;
|
fill: url(#clr-gradient-default) !important;
|
||||||
|
|
||||||
&-container {
|
&-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -33,7 +32,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.library {
|
.library {
|
||||||
padding-left: 0 !important;
|
padding-left: 0 !important;
|
||||||
padding-right: 0 !important;
|
padding-right: 0 !important;
|
||||||
@@ -42,7 +40,7 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
&-grid {
|
&-grid {
|
||||||
--number-of-cols:8;
|
--number-of-cols: 8;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(var(--number-of-cols), minmax(0, 1fr));
|
grid-template-columns: repeat(var(--number-of-cols), minmax(0, 1fr));
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
@@ -85,8 +83,8 @@
|
|||||||
}
|
}
|
||||||
&-filter {
|
&-filter {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 0 0.5em !important;
|
margin: 0 0.5em !important;
|
||||||
&-container {
|
&-container {
|
||||||
margin-top: 0.75em;
|
margin-top: 0.75em;
|
||||||
width: 22em;
|
width: 22em;
|
||||||
@@ -95,7 +93,7 @@
|
|||||||
border-radius: $border-radius-default;
|
border-radius: $border-radius-default;
|
||||||
backdrop-filter: blur(10px);
|
backdrop-filter: blur(10px);
|
||||||
overflow-y: overlay;
|
overflow-y: overlay;
|
||||||
}
|
}
|
||||||
&-title {
|
&-title {
|
||||||
justify-self: start;
|
justify-self: start;
|
||||||
}
|
}
|
||||||
@@ -120,7 +118,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix card width with virtual rows
|
// Fix card width with virtual rows
|
||||||
.card {
|
.card {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -128,21 +125,22 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
// Layout css for dynamic virtual rows
|
// Layout css for dynamic virtual rows
|
||||||
&-virtual-item{
|
&-virtual-item {
|
||||||
width: 14%;
|
width: 14%;
|
||||||
flex-basis: 14%;
|
min-width: 0;
|
||||||
height: fit-content;
|
// flex: 0 0 0;
|
||||||
display: inline-flex;
|
height: fit-content;
|
||||||
flex-direction: row;
|
display: inline-flex;
|
||||||
justify-content: center;
|
flex-direction: row;
|
||||||
align-items: center;
|
justify-content: center;
|
||||||
padding: 0.75em;
|
align-items: center;
|
||||||
&-row{
|
padding: 0.75em;
|
||||||
|
&-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
flex-basis: 14%;
|
flex-basis: 14%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-14
@@ -1,6 +1,6 @@
|
|||||||
|
import AppBarBackOnly from "@/components/appBar/backOnly";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { CircularProgress, Typography } from "@mui/material";
|
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/login")({
|
export const Route = createFileRoute("/_api/login")({
|
||||||
@@ -19,16 +19,12 @@ export const Route = createFileRoute("/_api/login")({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// component: () => {
|
component: () => {
|
||||||
// const data = Route.useRouteContext();
|
return (
|
||||||
// console.log(data);
|
<>
|
||||||
// return (
|
<AppBarBackOnly />
|
||||||
// <div style={{ height: "100vh" }} className="flex flex-column flex-center">
|
<Outlet />
|
||||||
// <CircularProgress size={86} thickness={2} />
|
</>
|
||||||
// <Typography mt={4} align="center">
|
);
|
||||||
// Fetching users...
|
},
|
||||||
// </Typography>
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
@@ -1,51 +1,68 @@
|
|||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import { OutlinedInput, Paper, Typography } from "@mui/material";
|
import { OutlinedInput, Typography } from "@mui/material";
|
||||||
import Checkbox from "@mui/material/Checkbox";
|
import Checkbox from "@mui/material/Checkbox";
|
||||||
import FormControl from "@mui/material/FormControl";
|
import FormControl from "@mui/material/FormControl";
|
||||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||||
import FormGroup from "@mui/material/FormGroup";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import InputAdornment from "@mui/material/InputAdornment";
|
import InputAdornment from "@mui/material/InputAdornment";
|
||||||
import InputLabel from "@mui/material/InputLabel";
|
import InputLabel from "@mui/material/InputLabel";
|
||||||
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
|
||||||
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
||||||
import "./login.scss";
|
import "./login.scss";
|
||||||
|
|
||||||
import { saveUser } from "@/utils/storage/user";
|
import { saveUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import React, { useLayoutEffect, useState } from "react";
|
import {
|
||||||
|
createFileRoute,
|
||||||
|
useNavigate,
|
||||||
|
useRouter,
|
||||||
|
} from "@tanstack/react-router";
|
||||||
|
import React, {
|
||||||
|
type ChangeEvent,
|
||||||
|
type FormEvent,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
||||||
component: LoginUser,
|
component: LoginUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type PasswordState = {
|
||||||
|
showpass: boolean;
|
||||||
|
password: string | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
function LoginUser() {
|
function LoginUser() {
|
||||||
const { userName, userId } = Route.useParams();
|
const { userName, userId } = Route.useParams();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const createApi = useApiInContext((s) => s.createApi);
|
const createApi = useApiInContext((s) => s.createApi);
|
||||||
|
|
||||||
const [password, setPassword] = useState({
|
const [password, setPassword] = useState<PasswordState>({
|
||||||
showpass: false,
|
showpass: false,
|
||||||
|
password: undefined,
|
||||||
});
|
});
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [rememberMe, setRememberMe] = useState(true);
|
const [rememberMe, setRememberMe] = useState(true);
|
||||||
|
|
||||||
const navigate = useNavigate({ from: "/login/$userId/$userName" });
|
const navigate = useNavigate({ from: "/login/$userId/$userName" });
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const handlePassword = (prop) => (event) => {
|
const handlePassword =
|
||||||
setPassword({
|
(prop: "password" | "showPassord") =>
|
||||||
...password,
|
(event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||||
[prop]: event.target.value,
|
setPassword({
|
||||||
});
|
...password,
|
||||||
};
|
[prop]: event.target.value,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleShowPassword = () => {
|
const handleShowPassword = () => {
|
||||||
setPassword({
|
setPassword({
|
||||||
@@ -54,159 +71,134 @@ function LoginUser() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const authUser = async () => {
|
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||||
try {
|
|
||||||
const auth = await api.authenticateUserByName(
|
|
||||||
userName,
|
|
||||||
password.password,
|
|
||||||
);
|
|
||||||
return auth;
|
|
||||||
} catch (error) {
|
|
||||||
if (error.response?.status === 500) {
|
|
||||||
enqueueSnackbar(
|
|
||||||
"Unable to connect to server. Please try again after some time.",
|
|
||||||
{ variant: "error" },
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
enqueueSnackbar("Incorrect Password.", { variant: "error" });
|
|
||||||
}
|
|
||||||
setLoading(false);
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleLogin = async () => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
if (!api) {
|
||||||
const user = await authUser();
|
return;
|
||||||
sessionStorage.setItem("accessToken", user.data.AccessToken);
|
|
||||||
createApi(api.basePath, user.data.AccessToken);
|
|
||||||
if (rememberMe === true) {
|
|
||||||
await saveUser(userName, user.data.AccessToken);
|
|
||||||
}
|
}
|
||||||
setLoading(false);
|
|
||||||
navigate({ to: "/home" });
|
|
||||||
};
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCheckRememberMe = (event) => {
|
const handleCheckRememberMe = (
|
||||||
setRememberMe(event.target.checked);
|
_: ChangeEvent<HTMLInputElement>,
|
||||||
|
checked: boolean,
|
||||||
|
) => {
|
||||||
|
setRememberMe(checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLoginFn = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
|
event.preventDefault();
|
||||||
|
try {
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("API not initialized");
|
||||||
|
}
|
||||||
|
const authenticate = await api.authenticateUserByName(
|
||||||
|
userName,
|
||||||
|
password.password,
|
||||||
|
);
|
||||||
|
if (!authenticate.data.AccessToken) {
|
||||||
|
throw new Error("No access token received");
|
||||||
|
}
|
||||||
|
createApi(api.basePath, authenticate.data?.AccessToken);
|
||||||
|
|
||||||
|
if (rememberMe) await saveUser(userName, authenticate.data.AccessToken);
|
||||||
|
|
||||||
|
router.invalidate().finally(() => {
|
||||||
|
navigate({ to: "/home", replace: true });
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
enqueueSnackbar("Unable to authenticate! Please check your password", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLogin = useMutation({
|
||||||
|
mutationKey: ["login", "authenticate"],
|
||||||
|
mutationFn: handleLoginFn,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div
|
||||||
<AppBarBackOnly />
|
style={{
|
||||||
<div
|
height: "100vh",
|
||||||
style={{
|
display: "flex",
|
||||||
height: "100vh",
|
justifyContent: "center",
|
||||||
display: "flex",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
flexDirection: "column",
|
||||||
alignItems: "center",
|
width: "30vw",
|
||||||
flexDirection: "column",
|
margin: "auto",
|
||||||
width: "30vw",
|
}}
|
||||||
margin: "auto",
|
>
|
||||||
}}
|
<AvatarImage userId={userId} />
|
||||||
>
|
<div style={{ display: "inline-flex", margin: "1em 0" }}>
|
||||||
<div
|
<Typography variant="h5">Login as</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
style={{
|
style={{
|
||||||
marginBottom: "-4em",
|
display: "inline",
|
||||||
boxShadow: "1em 0 hsl(256, 100%, 6%)",
|
|
||||||
}}
|
}}
|
||||||
|
ml={0.5}
|
||||||
|
fontWeight={700}
|
||||||
|
className="gradient-text"
|
||||||
>
|
>
|
||||||
<AvatarImage userId={userId} />
|
{userName}
|
||||||
</div>
|
</Typography>
|
||||||
<Paper
|
|
||||||
sx={{
|
|
||||||
width: "100%",
|
|
||||||
padding: "1em",
|
|
||||||
paddingTop: "5em",
|
|
||||||
borderRadius: "10px",
|
|
||||||
}}
|
|
||||||
elevation={2}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
textAlign="center"
|
|
||||||
variant="h5"
|
|
||||||
sx={{ opacity: 0.8 }}
|
|
||||||
mb={2}
|
|
||||||
>
|
|
||||||
Login as{" "}
|
|
||||||
<Typography
|
|
||||||
variant="h5"
|
|
||||||
style={{
|
|
||||||
display: "inline",
|
|
||||||
}}
|
|
||||||
fontWeight={700}
|
|
||||||
className="gradient-text"
|
|
||||||
>
|
|
||||||
{userName}
|
|
||||||
</Typography>
|
|
||||||
</Typography>
|
|
||||||
<FormGroup
|
|
||||||
sx={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<FormControl
|
|
||||||
variant="outlined"
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
|
||||||
<OutlinedInput
|
|
||||||
id="user-password"
|
|
||||||
type={password.showpass ? "text" : "password"}
|
|
||||||
variant="outlined"
|
|
||||||
onChange={handlePassword("password")}
|
|
||||||
label="Password:"
|
|
||||||
endAdornment={
|
|
||||||
<InputAdornment position="end">
|
|
||||||
<IconButton
|
|
||||||
onClick={handleShowPassword}
|
|
||||||
aria-label="toggle password visibility"
|
|
||||||
>
|
|
||||||
{password.showpass ? (
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
visibility
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
visibility_off
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</IconButton>
|
|
||||||
</InputAdornment>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={rememberMe}
|
|
||||||
onChange={handleCheckRememberMe}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Remember me"
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
<LoadingButton
|
|
||||||
variant="contained"
|
|
||||||
endIcon={
|
|
||||||
<span className="material-symbols-rounded">chevron_right</span>
|
|
||||||
}
|
|
||||||
onClick={handleLogin}
|
|
||||||
loading={loading}
|
|
||||||
loadingPosition="end"
|
|
||||||
size="large"
|
|
||||||
fullWidth
|
|
||||||
>
|
|
||||||
Login
|
|
||||||
</LoadingButton>
|
|
||||||
</Paper>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
<form onSubmit={(e) => handleLogin.mutate(e)}>
|
||||||
|
<FormControl
|
||||||
|
variant="outlined"
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||||
|
<OutlinedInput
|
||||||
|
id="user-password"
|
||||||
|
type={password.showpass ? "text" : "password"}
|
||||||
|
onChange={handlePassword("password")}
|
||||||
|
label="Password:"
|
||||||
|
endAdornment={
|
||||||
|
<InputAdornment position="end">
|
||||||
|
<IconButton
|
||||||
|
onClick={handleShowPassword}
|
||||||
|
aria-label="toggle password visibility"
|
||||||
|
>
|
||||||
|
{password.showpass ? (
|
||||||
|
<span className="material-symbols-rounded">visibility</span>
|
||||||
|
) : (
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
visibility_off
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</IconButton>
|
||||||
|
</InputAdornment>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox checked={rememberMe} onChange={handleCheckRememberMe} />
|
||||||
|
}
|
||||||
|
label="Remember me"
|
||||||
|
/>
|
||||||
|
<LoadingButton
|
||||||
|
variant="contained"
|
||||||
|
endIcon={
|
||||||
|
<span className="material-symbols-rounded">chevron_right</span>
|
||||||
|
}
|
||||||
|
type="submit"
|
||||||
|
loading={handleLogin.isPending}
|
||||||
|
loadingPosition="end"
|
||||||
|
size="large"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</LoadingButton>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,18 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React, { useLayoutEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
|
|
||||||
import { Chip, IconButton, Typography } from "@mui/material";
|
import { Chip, Typography } from "@mui/material";
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
|
|
||||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
|
||||||
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx";
|
||||||
import "./login.scss";
|
import "./login.scss";
|
||||||
|
|
||||||
import QuickConnectButton from "@/components/buttons/quickConnectButton";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { Link, createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
import avatar from "../../../assets/icons/avatar.png";
|
import avatar from "../../../assets/icons/avatar.png";
|
||||||
|
|
||||||
@@ -36,7 +33,7 @@ const UserCard = ({ user }: { user: UserDto }) => {
|
|||||||
<img
|
<img
|
||||||
className="user-card-image"
|
className="user-card-image"
|
||||||
alt={"user"}
|
alt={"user"}
|
||||||
src={`${api.basePath}/Users/${user.Id}/Images/Primary?quality=80&tag=${user.PrimaryImageTag}`}
|
src={`${api?.basePath}/Users/${user.Id}/Images/Primary?quality=80&tag=${user.PrimaryImageTag}`}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<img className="user-card-image" alt="user" src={avatar} />
|
<img className="user-card-image" alt="user" src={avatar} />
|
||||||
@@ -50,13 +47,8 @@ const UserCard = ({ user }: { user: UserDto }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function LoginPublicUsersList() {
|
function LoginPublicUsersList() {
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const handleChangeServer = () => {
|
|
||||||
navigate({ to: "/setup/server/list" });
|
|
||||||
};
|
|
||||||
const users = useQuery({
|
const users = useQuery({
|
||||||
queryKey: ["login", "public-users"],
|
queryKey: ["login", "public-users"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
@@ -67,49 +59,35 @@ function LoginPublicUsersList() {
|
|||||||
enabled: Boolean(api),
|
enabled: Boolean(api),
|
||||||
});
|
});
|
||||||
|
|
||||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||||
|
useEffect(() => {
|
||||||
useLayoutEffect(() => {
|
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (users.isSuccess) {
|
if (users.isSuccess) {
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="login-container scrollY">
|
||||||
<AppBarBackOnly />
|
<Typography variant="h4" align="center">
|
||||||
<div className="login-container">
|
Users
|
||||||
<Typography variant="h4" align="center">
|
</Typography>
|
||||||
Users
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<div className="user-list-container roundedScrollbar">
|
<div className="user-list-container roundedScrollbar">
|
||||||
{users.data.map((item) => {
|
{users.data.map((item) => {
|
||||||
return <UserCard user={item} key={item.Id} />;
|
return <UserCard user={item} key={item.Id} />;
|
||||||
})}
|
})}
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* <div className="buttons">
|
|
||||||
<Button
|
|
||||||
color="secondary"
|
|
||||||
variant="contained"
|
|
||||||
className="userEventButton"
|
|
||||||
onClick={handleChangeServer}
|
|
||||||
>
|
|
||||||
Change Server
|
|
||||||
</Button>
|
|
||||||
<QuickConnectButton />
|
|
||||||
</div> */}
|
|
||||||
<Chip
|
|
||||||
style={{ marginLeft: "50%", transform: "translateX(-50%)" }}
|
|
||||||
label={
|
|
||||||
<Typography variant="body2" align="center">
|
|
||||||
Don't see your user? Try using{" "}
|
|
||||||
<Link to="/login/manual">Manual Login</Link> or{" "}
|
|
||||||
<Link to="/setup/server/list">Changing Server</Link>
|
|
||||||
</Typography>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
|
<Chip
|
||||||
|
style={{ marginLeft: "50%", transform: "translateX(-50%)" }}
|
||||||
|
label={
|
||||||
|
<Typography variant="body2" align="center">
|
||||||
|
Don't see your user? Try using{" "}
|
||||||
|
<Link to="/login/manual">Manual Login</Link> or{" "}
|
||||||
|
<Link to="/setup/server/list">Changing Server</Link>
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (users.isError) {
|
if (users.isError) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
&-container{
|
&-container{
|
||||||
width: min(40em,80vw);
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding-top: 4em;
|
padding-top: 4em;
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-form {
|
&-form {
|
||||||
width: 28em;
|
width: 24em;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
background: rgb(255 255 255 / 0.05);
|
background: rgb(255 255 255 / 0.05);
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
border: 1px solid rgb(255 255 255 / 0.1);
|
// border: 1px solid rgb(255 255 255 / 0.1);
|
||||||
&.padded-top {
|
&.padded-top {
|
||||||
margin-top: 25vh;
|
margin-top: 25vh;
|
||||||
}
|
}
|
||||||
|
|||||||
+135
-134
@@ -1,5 +1,10 @@
|
|||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import React, { type FormEvent, useLayoutEffect, useState } from "react";
|
import React, {
|
||||||
|
type ChangeEvent,
|
||||||
|
type FormEvent,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
import { saveUser } from "@/utils/storage/user.js";
|
import { saveUser } from "@/utils/storage/user.js";
|
||||||
|
|
||||||
@@ -15,13 +20,11 @@ import InputLabel from "@mui/material/InputLabel";
|
|||||||
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
import { useApiInContext } from "@/utils/store/api.js";
|
||||||
import { axiosClient, useApiInContext } from "@/utils/store/api.js";
|
|
||||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||||
import "./login.scss";
|
import "./login.scss";
|
||||||
|
|
||||||
import QuickConnectButton from "@/components/buttons/quickConnectButton";
|
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
|
||||||
import { blue } from "@mui/material/colors";
|
import { blue } from "@mui/material/colors";
|
||||||
import {
|
import {
|
||||||
createFileRoute,
|
createFileRoute,
|
||||||
@@ -31,6 +34,9 @@ import {
|
|||||||
|
|
||||||
export const Route = createFileRoute("/_api/login/manual")({
|
export const Route = createFileRoute("/_api/login/manual")({
|
||||||
component: UserLoginManual,
|
component: UserLoginManual,
|
||||||
|
validateSearch: (search): { redirect?: string } => {
|
||||||
|
return { redirect: String(search.redirect) };
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function UserLoginManual() {
|
function UserLoginManual() {
|
||||||
@@ -43,18 +49,8 @@ function UserLoginManual() {
|
|||||||
|
|
||||||
const server = useQuery({
|
const server = useQuery({
|
||||||
queryKey: ["login", "manual", "serverInfo"],
|
queryKey: ["login", "manual", "serverInfo"],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
return (await getBrandingApi(api).getBrandingOptions()).data;
|
api ? (await getBrandingApi(api).getBrandingOptions()).data : null,
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const ssoProviders = useQuery({
|
|
||||||
queryKey: ["login", "manual", "ssoProviders"],
|
|
||||||
queryFn: async () => {
|
|
||||||
return axiosClient.get(
|
|
||||||
`${api.basePath}/sso/SAML/Get?api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -69,12 +65,14 @@ function UserLoginManual() {
|
|||||||
password: "",
|
password: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
const handlePassword = (prop) => (event) => {
|
const handlePassword =
|
||||||
setPassword({
|
(prop: "password" | "showpass") =>
|
||||||
...password,
|
(event: ChangeEvent<HTMLInputElement>) => {
|
||||||
[prop]: event.target.value,
|
setPassword({
|
||||||
});
|
...password,
|
||||||
};
|
[prop]: event.target.value,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleShowPassword = () => {
|
const handleShowPassword = () => {
|
||||||
setPassword({
|
setPassword({
|
||||||
@@ -86,14 +84,19 @@ function UserLoginManual() {
|
|||||||
const handleLoginFn = async (event: FormEvent<HTMLFormElement>) => {
|
const handleLoginFn = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
try {
|
try {
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("Api is not available");
|
||||||
|
}
|
||||||
const authenticate = await api.authenticateUserByName(
|
const authenticate = await api.authenticateUserByName(
|
||||||
username,
|
username,
|
||||||
password.password,
|
password.password,
|
||||||
);
|
);
|
||||||
|
if (!authenticate.data?.AccessToken) {
|
||||||
|
throw new Error("Access token not available");
|
||||||
|
}
|
||||||
createApi(api.basePath, authenticate.data?.AccessToken);
|
createApi(api.basePath, authenticate.data?.AccessToken);
|
||||||
|
|
||||||
if (rememberMe) await saveUser(username, authenticate.data.AccessToken);
|
if (rememberMe) await saveUser(username, authenticate.data.AccessToken);
|
||||||
|
|
||||||
router.invalidate().finally(() => {
|
router.invalidate().finally(() => {
|
||||||
navigate({ to: searchParams.redirect || "/home", replace: true });
|
navigate({ to: searchParams.redirect || "/home", replace: true });
|
||||||
});
|
});
|
||||||
@@ -112,126 +115,124 @@ function UserLoginManual() {
|
|||||||
mutationFn: handleLoginFn,
|
mutationFn: handleLoginFn,
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleCheckRememberMe = (event) => {
|
const handleCheckRememberMe = (
|
||||||
setRememberMe(event.target.checked);
|
_: ChangeEvent<HTMLInputElement>,
|
||||||
|
checked: boolean,
|
||||||
|
) => {
|
||||||
|
setRememberMe(checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||||
|
useEffect(() => {
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="login scrollY">
|
||||||
<AppBarBackOnly />
|
<div
|
||||||
<div className="login scrollY">
|
className={`login-form-container ${
|
||||||
<div
|
server.data?.LoginDisclaimer && "padded-top"
|
||||||
className={`login-form-container ${
|
}`}
|
||||||
server.data?.LoginDisclaimer && "padded-top"
|
>
|
||||||
}`}
|
<Typography variant="h4" color="textPrimary">
|
||||||
>
|
Login
|
||||||
<Typography variant="h3" color="textPrimary">
|
</Typography>
|
||||||
Login
|
<form className="login-form" onSubmit={(e) => handleLogin.mutate(e)}>
|
||||||
</Typography>
|
<TextField
|
||||||
<form className="login-form" onSubmit={(e) => handleLogin.mutate(e)}>
|
variant="outlined"
|
||||||
<TextField
|
label="Username"
|
||||||
variant="outlined"
|
onChange={(e) => setUsername(e.currentTarget.value)}
|
||||||
label="Username"
|
/>
|
||||||
onChange={(e) => setUsername(e.currentTarget.value)}
|
<FormControl sx={{ width: "100%" }} variant="outlined">
|
||||||
/>
|
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||||
<FormControl sx={{ width: "100%" }} variant="outlined">
|
<OutlinedInput
|
||||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
fullWidth
|
||||||
<OutlinedInput
|
id="user-password"
|
||||||
fullWidth
|
type={password.showpass ? "text" : "password"}
|
||||||
id="user-password"
|
onChange={handlePassword("password")}
|
||||||
type={password.showpass ? "text" : "password"}
|
label="Password:"
|
||||||
onChange={handlePassword("password")}
|
endAdornment={
|
||||||
label="Password:"
|
<InputAdornment position="end">
|
||||||
endAdornment={
|
<IconButton
|
||||||
<InputAdornment position="end">
|
onClick={handleShowPassword}
|
||||||
<IconButton
|
aria-label="toggle password visibility"
|
||||||
onClick={handleShowPassword}
|
>
|
||||||
aria-label="toggle password visibility"
|
{password.showpass ? (
|
||||||
>
|
<span className="material-symbols-rounded">
|
||||||
{password.showpass ? (
|
visibility
|
||||||
<span className="material-symbols-rounded">
|
</span>
|
||||||
visibility
|
) : (
|
||||||
</span>
|
<span className="material-symbols-rounded">
|
||||||
) : (
|
visibility_off
|
||||||
<span className="material-symbols-rounded">
|
</span>
|
||||||
visibility_off
|
)}
|
||||||
</span>
|
</IconButton>
|
||||||
)}
|
</InputAdornment>
|
||||||
</IconButton>
|
|
||||||
</InputAdornment>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={rememberMe}
|
|
||||||
onChange={handleCheckRememberMe}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
label="Remember me"
|
|
||||||
/>
|
/>
|
||||||
<div
|
</FormControl>
|
||||||
className="flex flex-row"
|
<FormControlLabel
|
||||||
style={{ width: "100%", gap: "0.8em", flexWrap: "wrap" }}
|
control={
|
||||||
>
|
<Checkbox checked={rememberMe} onChange={handleCheckRememberMe} />
|
||||||
<LoadingButton
|
}
|
||||||
variant="contained"
|
label="Remember me"
|
||||||
type="submit"
|
/>
|
||||||
loading={handleLogin.isPending}
|
<div
|
||||||
sx={{ width: "100%" }}
|
className="flex flex-row"
|
||||||
>
|
style={{ width: "100%", gap: "0.8em", flexWrap: "wrap" }}
|
||||||
Login
|
|
||||||
</LoadingButton>
|
|
||||||
<QuickConnectButton />
|
|
||||||
<Button
|
|
||||||
color="secondary"
|
|
||||||
variant="contained"
|
|
||||||
className="userEventButton"
|
|
||||||
// size="large"
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
onClick={() => navigate({ to: "/setup/server/list" })}
|
|
||||||
>
|
|
||||||
Change Server
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{server.isSuccess && server.data.LoginDisclaimer && (
|
|
||||||
<Paper
|
|
||||||
elevation={5}
|
|
||||||
style={{
|
|
||||||
marginTop: "1em",
|
|
||||||
padding: "1em",
|
|
||||||
borderRadius: "15px",
|
|
||||||
width: "32em",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div
|
<LoadingButton
|
||||||
className="flex flex-row flex-align-center"
|
variant="contained"
|
||||||
style={{ gap: "0.5em", marginBottom: "0.5em" }}
|
type="submit"
|
||||||
|
loading={handleLogin.isPending}
|
||||||
|
sx={{ width: "100%" }}
|
||||||
>
|
>
|
||||||
<span
|
Login
|
||||||
className="material-symbols-rounded"
|
</LoadingButton>
|
||||||
style={{
|
<Button
|
||||||
color: blue[700],
|
color="secondary"
|
||||||
"--fill": 1,
|
variant="contained"
|
||||||
}}
|
className="userEventButton"
|
||||||
>
|
// size="large"
|
||||||
info
|
style={{ flex: 1 }}
|
||||||
</span>
|
onClick={() => navigate({ to: "/setup/server/list" })}
|
||||||
Notice
|
>
|
||||||
</div>
|
Change Server
|
||||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
</Button>
|
||||||
{server.data.LoginDisclaimer}
|
</div>
|
||||||
</Typography>
|
</form>
|
||||||
</Paper>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
{server.isSuccess && server.data?.LoginDisclaimer && (
|
||||||
|
<Paper
|
||||||
|
elevation={0}
|
||||||
|
style={{
|
||||||
|
marginTop: "1em",
|
||||||
|
padding: "1em",
|
||||||
|
borderRadius: "15px",
|
||||||
|
width: "28em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="flex flex-row flex-align-center"
|
||||||
|
style={{ gap: "0.5em", marginBottom: "0.5em" }}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
color: blue[700],
|
||||||
|
//@ts-ignore
|
||||||
|
"--fill": 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
info
|
||||||
|
</span>
|
||||||
|
Notice
|
||||||
|
</div>
|
||||||
|
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||||
|
{server.data.LoginDisclaimer}
|
||||||
|
</Typography>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, {
|
||||||
import React, { useState, useLayoutEffect, useRef } from "react";
|
useState,
|
||||||
|
useLayoutEffect,
|
||||||
|
useRef,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
@@ -8,16 +12,10 @@ import Tab from "@mui/material/Tab";
|
|||||||
import Tabs from "@mui/material/Tabs";
|
import Tabs from "@mui/material/Tabs";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import useParallax from "@/utils/hooks/useParallax";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
import { AnimatePresence, motion, useScroll } from "framer-motion";
|
|
||||||
|
|
||||||
import {
|
import { BaseItemKind, LocationType } from "@jellyfin/sdk/lib/generated-client";
|
||||||
BaseItemKind,
|
|
||||||
ItemFields,
|
|
||||||
LocationType,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
@@ -27,7 +25,7 @@ import { Blurhash } from "react-blurhash";
|
|||||||
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import { setBackdrop } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import meshBg from "@/assets/herobg.png";
|
import meshBg from "@/assets/herobg.png";
|
||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
@@ -35,10 +33,17 @@ import "./person.scss";
|
|||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
function TabPanel(props) {
|
type TabPanelProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
index: number;
|
||||||
|
value: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
function TabPanel(props: TabPanelProps) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -55,32 +60,20 @@ function TabPanel(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
function a11yProps(index) {
|
|
||||||
return {
|
|
||||||
id: `full-width-tab-${index}`,
|
|
||||||
"aria-controls": `full-width-tabpanel-${index}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/person/$id")({
|
export const Route = createFileRoute("/_api/person/$id")({
|
||||||
component: PersonTitlePage,
|
component: PersonTitlePage,
|
||||||
});
|
});
|
||||||
|
|
||||||
function PersonTitlePage() {
|
function PersonTitlePage() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
@@ -95,6 +88,7 @@ function PersonTitlePage() {
|
|||||||
const personMovies = useQuery({
|
const personMovies = useQuery({
|
||||||
queryKey: ["item", id, "personMovies"],
|
queryKey: ["item", id, "personMovies"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
@@ -106,12 +100,13 @@ function PersonTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.Person,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
const personShows = useQuery({
|
const personShows = useQuery({
|
||||||
queryKey: ["item", id, "personShows"],
|
queryKey: ["item", id, "personShows"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
@@ -123,13 +118,13 @@ function PersonTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.Person,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const personBooks = useQuery({
|
const personBooks = useQuery({
|
||||||
queryKey: ["item", id, "personBooks"],
|
queryKey: ["item", id, "personBooks"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
@@ -141,12 +136,13 @@ function PersonTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.Person,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
const personPhotos = useQuery({
|
const personPhotos = useQuery({
|
||||||
queryKey: ["item", id, "personPhotos"],
|
queryKey: ["item", id, "personPhotos"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
@@ -157,12 +153,13 @@ function PersonTitlePage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.Person,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
const personEpisodes = useQuery({
|
const personEpisodes = useQuery({
|
||||||
queryKey: ["item", id, "personEpisodes"],
|
queryKey: ["item", id, "personEpisodes"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
@@ -171,11 +168,10 @@ function PersonTitlePage() {
|
|||||||
fields: ["SeasonUserData", "Overview"],
|
fields: ["SeasonUserData", "Overview"],
|
||||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||||
excludeLocationTypes: [LocationType.Virtual],
|
excludeLocationTypes: [LocationType.Virtual],
|
||||||
limit: 24,
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess && item.data.Type === BaseItemKind.Person,
|
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -209,6 +205,8 @@ function PersonTitlePage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (
|
if (
|
||||||
personMovies.isSuccess &&
|
personMovies.isSuccess &&
|
||||||
@@ -217,15 +215,15 @@ function PersonTitlePage() {
|
|||||||
personPhotos.isSuccess &&
|
personPhotos.isSuccess &&
|
||||||
personEpisodes.isSuccess
|
personEpisodes.isSuccess
|
||||||
) {
|
) {
|
||||||
if (personMovies.data.TotalRecordCount !== 0) {
|
if (personMovies.data?.TotalRecordCount !== 0) {
|
||||||
setActivePersonTab(0);
|
setActivePersonTab(0);
|
||||||
} else if (personShows.data.TotalRecordCount !== 0) {
|
} else if (personShows.data?.TotalRecordCount !== 0) {
|
||||||
setActivePersonTab(1);
|
setActivePersonTab(1);
|
||||||
} else if (personBooks.data.TotalRecordCount !== 0) {
|
} else if (personBooks.data?.TotalRecordCount !== 0) {
|
||||||
setActivePersonTab(2);
|
setActivePersonTab(2);
|
||||||
} else if (personPhotos.data.TotalRecordCount !== 0) {
|
} else if (personPhotos.data?.TotalRecordCount !== 0) {
|
||||||
setActivePersonTab(3);
|
setActivePersonTab(3);
|
||||||
} else if (personEpisodes.data.TotalRecordCount !== 0) {
|
} else if (personEpisodes.data?.TotalRecordCount !== 0) {
|
||||||
setActivePersonTab(4);
|
setActivePersonTab(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,11 +239,6 @@ function PersonTitlePage() {
|
|||||||
const [animationDirection, setAnimationDirection] = useState("forward");
|
const [animationDirection, setAnimationDirection] = useState("forward");
|
||||||
|
|
||||||
const pageRef = useRef(null);
|
const pageRef = useRef(null);
|
||||||
const { scrollYProgress } = useScroll({
|
|
||||||
target: pageRef,
|
|
||||||
offset: ["start start", "60vh start"],
|
|
||||||
});
|
|
||||||
const parallax = useParallax(scrollYProgress, 50);
|
|
||||||
|
|
||||||
if (item.isPending) {
|
if (item.isPending) {
|
||||||
return (
|
return (
|
||||||
@@ -263,7 +256,7 @@ function PersonTitlePage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.isSuccess) {
|
if (item.isSuccess && item.data) {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={id}
|
key={id}
|
||||||
@@ -282,15 +275,12 @@ function PersonTitlePage() {
|
|||||||
>
|
>
|
||||||
<div className="item-hero">
|
<div className="item-hero">
|
||||||
<div className="item-hero-backdrop-container">
|
<div className="item-hero-backdrop-container">
|
||||||
<motion.img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={meshBg}
|
src={meshBg}
|
||||||
className="item-hero-backdrop"
|
className="item-hero-backdrop"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
y: parallax,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -300,34 +290,35 @@ function PersonTitlePage() {
|
|||||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.keys(item.data.ImageTags).includes("Primary") ? (
|
{item.data.ImageTags?.Primary && (
|
||||||
<>
|
<div>
|
||||||
<Blurhash
|
<Blurhash
|
||||||
hash={
|
hash={
|
||||||
item.data.ImageBlurHashes.Primary[
|
item.data.ImageBlurHashes?.Primary?.[
|
||||||
item.data.ImageTags.Primary
|
item.data.ImageTags.Primary
|
||||||
]
|
] ?? ""
|
||||||
}
|
}
|
||||||
className="item-hero-image-blurhash"
|
className="item-hero-image-blurhash"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
alt={item.data.Name}
|
alt={item.data.Name ?? ""}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.data.Id,
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.data.Id ?? "",
|
||||||
quality: 90,
|
"Primary",
|
||||||
tag: item.data.ImageTags.Primary,
|
{
|
||||||
},
|
quality: 90,
|
||||||
)}
|
tag: item.data.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
className="item-hero-image"
|
className="item-hero-image"
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="item-hero-detail flex flex-column">
|
<div className="item-hero-detail flex flex-column">
|
||||||
@@ -339,7 +330,7 @@ function PersonTitlePage() {
|
|||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -358,9 +349,11 @@ function PersonTitlePage() {
|
|||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.ExternalUrls.map((url) => (
|
{item.data.ExternalUrls?.map(
|
||||||
<IconLink url={url.Url} name={url.Name} />
|
(url) =>
|
||||||
))}
|
url.Name &&
|
||||||
|
url.Url && <IconLink url={url.Url} name={url.Name} />,
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -369,22 +362,22 @@ function PersonTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.PremiereDate && (
|
{item.data.PremiereDate && (
|
||||||
<>
|
<div>
|
||||||
<Typography variant="h6">Birth</Typography>
|
<Typography variant="h6">Birth</Typography>
|
||||||
<Typography variant="subtitle1" sx={{ opacity: 0.8 }}>
|
<Typography variant="subtitle1" sx={{ opacity: 0.8 }}>
|
||||||
{new Date(item.data.PremiereDate).toDateString()}
|
{new Date(item.data.PremiereDate).toDateString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
{item.data.EndDate && (
|
{item.data.EndDate && (
|
||||||
<>
|
<div>
|
||||||
<Typography variant="h6" mt={2}>
|
<Typography variant="h6" mt={2}>
|
||||||
Death
|
Death
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle2" sx={{ opacity: 0.8 }}>
|
<Typography variant="subtitle2" sx={{ opacity: 0.8 }}>
|
||||||
{new Date(item.data.EndDate).toDateString()}
|
{new Date(item.data.EndDate).toDateString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -394,7 +387,7 @@ function PersonTitlePage() {
|
|||||||
<Tabs
|
<Tabs
|
||||||
variant="scrollable"
|
variant="scrollable"
|
||||||
value={activePersonTab}
|
value={activePersonTab}
|
||||||
onChange={(e, newVal) => {
|
onChange={(_, newVal) => {
|
||||||
if (newVal > activePersonTab) {
|
if (newVal > activePersonTab) {
|
||||||
setAnimationDirection("forward");
|
setAnimationDirection("forward");
|
||||||
} else if (newVal < activePersonTab) {
|
} else if (newVal < activePersonTab) {
|
||||||
@@ -427,7 +420,7 @@ function PersonTitlePage() {
|
|||||||
? "col-7"
|
? "col-7"
|
||||||
: "col-4"
|
: "col-4"
|
||||||
}`}
|
}`}
|
||||||
key={tab.queryKey}
|
key={tab.queryKey.join("")}
|
||||||
initial={{
|
initial={{
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
transform:
|
transform:
|
||||||
@@ -445,7 +438,7 @@ function PersonTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{tab.data.isSuccess &&
|
{tab.data.isSuccess &&
|
||||||
tab.data.data.Items.map((tabitem, index) => {
|
tab.data.data?.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={tabitem.Id}
|
key={tabitem.Id}
|
||||||
@@ -478,27 +471,10 @@ function PersonTitlePage() {
|
|||||||
}
|
}
|
||||||
queryKey={tab.queryKey}
|
queryKey={tab.queryKey}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!tabitem.ImageBlurHashes?.Primary &&
|
|
||||||
tabitem.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(tabitem.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
{tab.data.isSuccess &&
|
|
||||||
tab.data.data.TotalRecordCount > 24 && (
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
opacity: 0.8,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
And more...
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ $cardWidth: 18%;
|
|||||||
}
|
}
|
||||||
&-backdrop {
|
&-backdrop {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: top;
|
object-position: top;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
@@ -103,7 +103,7 @@ $cardWidth: 18%;
|
|||||||
top: -4.4em;
|
top: -4.4em;
|
||||||
left: -$page-margin;
|
left: -$page-margin;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: calc(44vh + 4.4em);
|
height: 100vh;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
mask-image: linear-gradient(to top, transparent, black);
|
mask-image: linear-gradient(to top, transparent, black);
|
||||||
-webkit-mask-image: linear-gradient(
|
-webkit-mask-image: linear-gradient(
|
||||||
|
|||||||
@@ -87,6 +87,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
|
overscroll-behavior: contain;
|
||||||
&-line {
|
&-line {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
white-space: wrap;
|
white-space: wrap;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
|||||||
import useQueue, { setQueue } from "@/utils/store/queue";
|
import useQueue, { setQueue } from "@/utils/store/queue";
|
||||||
import { Fab, IconButton, Slider, Typography } from "@mui/material";
|
import { Fab, IconButton, Slider, Typography } from "@mui/material";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
import "./audio.scss";
|
import "./audio.scss";
|
||||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||||
@@ -49,11 +49,12 @@ function AudioPlayerRoute() {
|
|||||||
s.player.ref,
|
s.player.ref,
|
||||||
]);
|
]);
|
||||||
const [audioPlayer, setAudioPlayer] = useState<HTMLAudioElement | null>(
|
const [audioPlayer, setAudioPlayer] = useState<HTMLAudioElement | null>(
|
||||||
audioPlayerRef?.current,
|
audioPlayerRef?.current ? audioPlayerRef?.current : null,
|
||||||
);
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(audioPlayerRef);
|
if (audioPlayerRef?.current) {
|
||||||
setAudioPlayer(audioPlayerRef.current);
|
setAudioPlayer(audioPlayerRef?.current);
|
||||||
|
}
|
||||||
}, [audioPlayerRef?.current]);
|
}, [audioPlayerRef?.current]);
|
||||||
|
|
||||||
console.log(audioPlayer?.paused);
|
console.log(audioPlayer?.paused);
|
||||||
@@ -68,12 +69,16 @@ function AudioPlayerRoute() {
|
|||||||
|
|
||||||
const lyrics = useQuery({
|
const lyrics = useQuery({
|
||||||
queryKey: ["player", "audio", item?.Id, "lyrics"],
|
queryKey: ["player", "audio", item?.Id, "lyrics"],
|
||||||
queryFn: async () =>
|
queryFn: async () => {
|
||||||
(
|
if (!item?.Id || !api) {
|
||||||
await getLyricsApi(api).searchRemoteLyrics({
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
await getLyricsApi(api).getLyrics({
|
||||||
itemId: item?.Id,
|
itemId: item?.Id,
|
||||||
})
|
})
|
||||||
).data,
|
).data;
|
||||||
|
},
|
||||||
enabled: Boolean(item?.Id),
|
enabled: Boolean(item?.Id),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,15 +115,31 @@ function AudioPlayerRoute() {
|
|||||||
const { active, over } = event;
|
const { active, over } = event;
|
||||||
if (active.id !== over?.id) {
|
if (active.id !== over?.id) {
|
||||||
const prevState = queue;
|
const prevState = queue;
|
||||||
const oldIndex = prevState?.map((item) => item.Id).indexOf(active.id);
|
const oldIndex = prevState
|
||||||
const newIndex = prevState?.map((item) => item.Id).indexOf(over.id);
|
?.map((item) => item.Id)
|
||||||
|
.indexOf(String(active.id));
|
||||||
|
const newIndex = prevState
|
||||||
|
?.map((item) => item.Id)
|
||||||
|
.indexOf(String(over?.id));
|
||||||
|
|
||||||
|
if (oldIndex === newIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!oldIndex || !newIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (oldIndex === -1 || newIndex === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const newState = prevState
|
const newState = prevState
|
||||||
? arrayMove(prevState, oldIndex, newIndex)
|
? arrayMove(prevState, oldIndex, newIndex)
|
||||||
: prevState;
|
: prevState;
|
||||||
|
|
||||||
const currentTrack = newState?.map((item) => item.Id).indexOf(item?.Id);
|
const currentTrack = newState?.map((item) => item.Id).indexOf(item?.Id);
|
||||||
|
|
||||||
|
if (!currentTrack) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setQueue(newState, currentTrack);
|
setQueue(newState, currentTrack);
|
||||||
// setQueue(newState);
|
// setQueue(newState);
|
||||||
}
|
}
|
||||||
@@ -139,13 +160,16 @@ function AudioPlayerRoute() {
|
|||||||
{item?.ImageTags?.Primary ? (
|
{item?.ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "Music"}
|
alt={item.Name ?? "Music"}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item.Id ?? "",
|
api &&
|
||||||
"Primary",
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
{
|
item.Id ?? "",
|
||||||
tag: item.ImageTags.Primary,
|
"Primary",
|
||||||
},
|
{
|
||||||
)}
|
tag: item.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
className="audio-info-image"
|
className="audio-info-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -170,10 +194,12 @@ function AudioPlayerRoute() {
|
|||||||
style={{ gap: "1em", alignItems: "center" }}
|
style={{ gap: "1em", alignItems: "center" }}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2" className="opacity-07">
|
<Typography variant="subtitle2" className="opacity-07">
|
||||||
{getRuntimeMusic(secToTicks(audioPlayer?.currentTime) ?? 0)}
|
{getRuntimeMusic(secToTicks(audioPlayer?.currentTime ?? 0) ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Slider
|
<Slider
|
||||||
value={isScrubbing ? sliderProgress : secToTicks(progress)}
|
value={
|
||||||
|
isScrubbing ? sliderProgress : secToTicks(Number(progress))
|
||||||
|
}
|
||||||
max={item?.RunTimeTicks ?? 1}
|
max={item?.RunTimeTicks ?? 1}
|
||||||
step={1}
|
step={1}
|
||||||
key={item?.Id}
|
key={item?.Id}
|
||||||
@@ -285,25 +311,26 @@ function AudioPlayerRoute() {
|
|||||||
<div
|
<div
|
||||||
className="audio-lyrics"
|
className="audio-lyrics"
|
||||||
data-has-synced-lyrics={Boolean(
|
data-has-synced-lyrics={Boolean(
|
||||||
lyrics.data?.[0]?.Lyrics?.Metadata?.IsSynced,
|
(lyrics.data?.Lyrics?.[0].Start ?? -1) >= 0,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="audio-lyrics-container" ref={lyricsContainer}>
|
<div className="audio-lyrics-container" ref={lyricsContainer}>
|
||||||
{lyrics.data?.[1]?.Lyrics?.Lyrics?.map((lyric, index) => (
|
{lyrics.data?.Lyrics?.map((lyric, index) => (
|
||||||
<div
|
<div
|
||||||
className="audio-lyrics-line"
|
className="audio-lyrics-line"
|
||||||
key={`${lyric.Text}${index}`}
|
key={`${lyric.Text}${index}`}
|
||||||
data-active-lyric={
|
data-active-lyric={
|
||||||
secToTicks(audioPlayer?.currentTime) >= (lyric.Start ?? 0) &&
|
secToTicks(audioPlayer?.currentTime ?? 0) >=
|
||||||
secToTicks(audioPlayer?.currentTime) <
|
(lyric.Start ?? 0) &&
|
||||||
(lyrics.data?.[0]?.Lyrics?.Lyrics?.[index + 1]?.Start ?? 0)
|
secToTicks(audioPlayer?.currentTime ?? 0) <
|
||||||
|
(lyrics.data?.Lyrics?.[index + 1]?.Start ?? 0)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{lyric.Text}
|
{lyric.Text}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{!lyrics.data?.[0]?.Lyrics?.Metadata?.IsSynced && (
|
{!((lyrics.data?.Lyrics?.[0].Start ?? -1) >= 0) && (
|
||||||
<Typography
|
<Typography
|
||||||
className="flex flex-align-center"
|
className="flex flex-align-center"
|
||||||
style={{
|
style={{
|
||||||
@@ -326,7 +353,7 @@ function AudioPlayerRoute() {
|
|||||||
onDragStart={(event) => {
|
onDragStart={(event) => {
|
||||||
const { active } = event;
|
const { active } = event;
|
||||||
setCurrentDraggingIndex(
|
setCurrentDraggingIndex(
|
||||||
queue?.map((item) => item.Id).indexOf(active.id),
|
queue?.map((item) => item.Id).indexOf(String(active.id) ?? "") ?? 0,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
modifiers={[restrictToVerticalAxis]}
|
modifiers={[restrictToVerticalAxis]}
|
||||||
@@ -335,6 +362,7 @@ function AudioPlayerRoute() {
|
|||||||
<div className="audio-queue-container">
|
<div className="audio-queue-container">
|
||||||
<Typography variant="h5">Queue:</Typography>
|
<Typography variant="h5">Queue:</Typography>
|
||||||
<SortableContext
|
<SortableContext
|
||||||
|
//@ts-ignore
|
||||||
items={queue?.map((track) => track.Id)}
|
items={queue?.map((track) => track.Id)}
|
||||||
strategy={verticalListSortingStrategy}
|
strategy={verticalListSortingStrategy}
|
||||||
>
|
>
|
||||||
@@ -350,19 +378,19 @@ function AudioPlayerRoute() {
|
|||||||
<span className="material-symbols-rounded">drag_handle</span>
|
<span className="material-symbols-rounded">drag_handle</span>
|
||||||
<div className="audio-queue-track-info">
|
<div className="audio-queue-track-info">
|
||||||
<Typography className="audio-queue-track-info-name">
|
<Typography className="audio-queue-track-info-name">
|
||||||
{queue[currentDraggingIndex].Name}
|
{queue[currentDraggingIndex ?? 0].Name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
fontWeight={300}
|
fontWeight={300}
|
||||||
className="opacity-07"
|
className="opacity-07"
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
>
|
>
|
||||||
{queue[currentDraggingIndex].Artists?.join(", ")}
|
{queue[currentDraggingIndex ?? 0].Artists?.join(", ")}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<Typography className="opacity-07">
|
<Typography className="opacity-07">
|
||||||
{getRuntimeMusic(
|
{getRuntimeMusic(
|
||||||
queue[currentDraggingIndex].RunTimeTicks ?? 0,
|
queue[currentDraggingIndex ?? 0].RunTimeTicks ?? 0,
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+384
-132
@@ -1,5 +1,9 @@
|
|||||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import React, { type ChangeEventHandler, useTransition } from "react";
|
import React, {
|
||||||
|
type ChangeEventHandler,
|
||||||
|
type MouseEventHandler,
|
||||||
|
useTransition,
|
||||||
|
} from "react";
|
||||||
import { useLayoutEffect, useMemo } from "react";
|
import { useLayoutEffect, useMemo } from "react";
|
||||||
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
@@ -12,6 +16,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import ReactPlayer from "react-player";
|
import ReactPlayer from "react-player";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
changeAudioTrack,
|
||||||
changeSubtitleTrack,
|
changeSubtitleTrack,
|
||||||
playItemFromQueue,
|
playItemFromQueue,
|
||||||
toggleSubtitleTrack,
|
toggleSubtitleTrack,
|
||||||
@@ -36,7 +41,13 @@ import { AnimatePresence, motion } from "framer-motion";
|
|||||||
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import { Button, LinearProgress, TextField } from "@mui/material";
|
import {
|
||||||
|
Button,
|
||||||
|
LinearProgress,
|
||||||
|
Popover,
|
||||||
|
TextField,
|
||||||
|
Tooltip,
|
||||||
|
} from "@mui/material";
|
||||||
import JASSUB from "jassub";
|
import JASSUB from "jassub";
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import workerUrl from "jassub/dist/jassub-worker.js?url";
|
import workerUrl from "jassub/dist/jassub-worker.js?url";
|
||||||
@@ -53,8 +64,10 @@ import useQueue, { clearQueue } from "@/utils/store/queue";
|
|||||||
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
||||||
import { toNumber } from "lodash";
|
import { toNumber } from "lodash";
|
||||||
import type { OnProgressProps } from "react-player/base";
|
import type { OnProgressProps } from "react-player/base";
|
||||||
import type { TrackProps } from "react-player/file";
|
|
||||||
|
|
||||||
|
import type subtitlePlaybackInfo from "@/utils/types/subtitlePlaybackInfo";
|
||||||
|
import type { Instance } from "@popperjs/core";
|
||||||
|
//@ts-ignore
|
||||||
import font from "./Noto-Sans-Indosphere.ttf?url";
|
import font from "./Noto-Sans-Indosphere.ttf?url";
|
||||||
|
|
||||||
const ticksDisplay = (ticks: number) => {
|
const ticksDisplay = (ticks: number) => {
|
||||||
@@ -85,7 +98,7 @@ const VOLUME_SCROLL_INTERVAL = 0.02;
|
|||||||
*/
|
*/
|
||||||
function addSubtitleTrackToReactPlayer(
|
function addSubtitleTrackToReactPlayer(
|
||||||
videoElem: HTMLMediaElement,
|
videoElem: HTMLMediaElement,
|
||||||
subtitleTracks,
|
subtitleTracks: subtitlePlaybackInfo,
|
||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
) {
|
) {
|
||||||
if (subtitleTracks.url && subtitleTracks.allTracks) {
|
if (subtitleTracks.url && subtitleTracks.allTracks) {
|
||||||
@@ -98,9 +111,9 @@ function addSubtitleTrackToReactPlayer(
|
|||||||
track.srclang = reqSubTrack[0].Language ?? "en";
|
track.srclang = reqSubTrack[0].Language ?? "en";
|
||||||
track.label = reqSubTrack[0].DisplayTitle ?? "Subtitle";
|
track.label = reqSubTrack[0].DisplayTitle ?? "Subtitle";
|
||||||
track.default = true;
|
track.default = true;
|
||||||
|
track.id = subtitleTracks.url;
|
||||||
|
|
||||||
track.addEventListener("load", () => {
|
track.addEventListener("load", () => {
|
||||||
console.log("Track loaded");
|
|
||||||
const a = track.track;
|
const a = track.track;
|
||||||
a.mode = "showing";
|
a.mode = "showing";
|
||||||
});
|
});
|
||||||
@@ -108,7 +121,14 @@ function addSubtitleTrackToReactPlayer(
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
videoElem.appendChild(track);
|
const trackAlreadyExists = videoElem.textTracks.getTrackById(
|
||||||
|
subtitleTracks.url,
|
||||||
|
);
|
||||||
|
if (!trackAlreadyExists?.id) {
|
||||||
|
// console.log(trackAlreadyExists.getTrackById(reqSubTrack[0].Index));
|
||||||
|
videoElem.appendChild(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const i of videoElem.textTracks) {
|
for (const i of videoElem.textTracks) {
|
||||||
if (i.label === reqSubTrack[0].DisplayTitle) {
|
if (i.label === reqSubTrack[0].DisplayTitle) {
|
||||||
@@ -141,7 +161,7 @@ function VideoPlayer() {
|
|||||||
episodeTitle,
|
episodeTitle,
|
||||||
mediaSource,
|
mediaSource,
|
||||||
playsessionId,
|
playsessionId,
|
||||||
introInfo,
|
mediaSegments,
|
||||||
] = usePlaybackStore((state) => [
|
] = usePlaybackStore((state) => [
|
||||||
state.playbackStream,
|
state.playbackStream,
|
||||||
state.item,
|
state.item,
|
||||||
@@ -153,6 +173,19 @@ function VideoPlayer() {
|
|||||||
state.playsessionId,
|
state.playsessionId,
|
||||||
state.intro,
|
state.intro,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const introInfo = mediaSegments?.Items?.find(
|
||||||
|
(segment) => segment.Type === "Intro",
|
||||||
|
);
|
||||||
|
|
||||||
|
const creditInfo = mediaSegments?.Items?.find(
|
||||||
|
(segment) => segment.Type === "Outro",
|
||||||
|
);
|
||||||
|
|
||||||
|
const recapInfo = mediaSegments?.Items?.find(
|
||||||
|
(segment) => segment.Type === "Recap",
|
||||||
|
);
|
||||||
|
|
||||||
const [currentQueueItemIndex, queue] = useQueue((s) => [
|
const [currentQueueItemIndex, queue] = useQueue((s) => [
|
||||||
s.currentItemIndex,
|
s.currentItemIndex,
|
||||||
s.tracks,
|
s.tracks,
|
||||||
@@ -182,7 +215,7 @@ function VideoPlayer() {
|
|||||||
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout>(null!);
|
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout>(null!);
|
||||||
|
|
||||||
const handleReady = async () => {
|
const handleReady = async () => {
|
||||||
if (!isReady) {
|
if (api && !isReady) {
|
||||||
player.current?.seekTo(ticksToSec(startPosition), "seconds");
|
player.current?.seekTo(ticksToSec(startPosition), "seconds");
|
||||||
setIsReady(true);
|
setIsReady(true);
|
||||||
// Report Jellyfin server: Playback has begin
|
// Report Jellyfin server: Playback has begin
|
||||||
@@ -207,6 +240,7 @@ function VideoPlayer() {
|
|||||||
|
|
||||||
const handleProgress = async (event: OnProgressProps) => {
|
const handleProgress = async (event: OnProgressProps) => {
|
||||||
setProgress(secToTicks(event.playedSeconds));
|
setProgress(secToTicks(event.playedSeconds));
|
||||||
|
if (!api) return null;
|
||||||
// Report Jellyfin server: Playback progress
|
// Report Jellyfin server: Playback progress
|
||||||
getPlaystateApi(api).reportPlaybackProgress({
|
getPlaystateApi(api).reportPlaybackProgress({
|
||||||
playbackProgressInfo: {
|
playbackProgressInfo: {
|
||||||
@@ -230,6 +264,7 @@ function VideoPlayer() {
|
|||||||
appWindow.getCurrent().setFullscreen(false);
|
appWindow.getCurrent().setFullscreen(false);
|
||||||
|
|
||||||
history.back();
|
history.back();
|
||||||
|
if (!api) return null;
|
||||||
// Report Jellyfin server: Playback has ended/stopped
|
// Report Jellyfin server: Playback has ended/stopped
|
||||||
getPlaystateApi(api).reportPlaybackStopped({
|
getPlaystateApi(api).reportPlaybackStopped({
|
||||||
playbackStopInfo: {
|
playbackStopInfo: {
|
||||||
@@ -258,6 +293,7 @@ function VideoPlayer() {
|
|||||||
|
|
||||||
const handleKeyPress = useCallback((event: KeyboardEvent) => {
|
const handleKeyPress = useCallback((event: KeyboardEvent) => {
|
||||||
if (player.current) {
|
if (player.current) {
|
||||||
|
event.preventDefault();
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
player.current.seekTo(player.current.getCurrentTime() + 10);
|
player.current.seekTo(player.current.getCurrentTime() + 10);
|
||||||
@@ -265,6 +301,7 @@ function VideoPlayer() {
|
|||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
player.current.seekTo(player.current.getCurrentTime() - 10);
|
player.current.seekTo(player.current.getCurrentTime() - 10);
|
||||||
break;
|
break;
|
||||||
|
case "F8":
|
||||||
case " ":
|
case " ":
|
||||||
setPlaying((state) => !state);
|
setPlaying((state) => !state);
|
||||||
break;
|
break;
|
||||||
@@ -289,8 +326,13 @@ function VideoPlayer() {
|
|||||||
case "m":
|
case "m":
|
||||||
// setIsMuted((state) => !state);
|
// setIsMuted((state) => !state);
|
||||||
break;
|
break;
|
||||||
|
case "F7":
|
||||||
|
playItemFromQueue("previous", user?.Id, api);
|
||||||
|
break;
|
||||||
|
case "F9":
|
||||||
|
playItemFromQueue("next", user?.Id, api);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(event.key);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,6 +347,7 @@ function VideoPlayer() {
|
|||||||
};
|
};
|
||||||
}, [handleKeyPress]);
|
}, [handleKeyPress]);
|
||||||
|
|
||||||
|
const playerOSDRef = useRef<HTMLDivElement>(null);
|
||||||
// Volume control with mouse wheel
|
// Volume control with mouse wheel
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleMouseWheel = (event: WheelEvent) => {
|
const handleMouseWheel = (event: WheelEvent) => {
|
||||||
@@ -318,11 +361,11 @@ function VideoPlayer() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// attach the event listener
|
// attach the event listener
|
||||||
document.addEventListener("wheel", handleMouseWheel);
|
playerOSDRef.current?.addEventListener("wheel", handleMouseWheel);
|
||||||
|
|
||||||
// remove the event listener
|
// remove the event listener
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener("wheel", handleMouseWheel);
|
playerOSDRef.current?.removeEventListener("wheel", handleMouseWheel);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -333,8 +376,6 @@ function VideoPlayer() {
|
|||||||
}, [item?.Id]);
|
}, [item?.Id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(mediaSource.subtitle.enable);
|
|
||||||
|
|
||||||
if (player.current?.getInternalPlayer() && mediaSource.subtitle.enable) {
|
if (player.current?.getInternalPlayer() && mediaSource.subtitle.enable) {
|
||||||
let jassubRenderer: JASSUB | undefined;
|
let jassubRenderer: JASSUB | undefined;
|
||||||
if (
|
if (
|
||||||
@@ -346,7 +387,7 @@ function VideoPlayer() {
|
|||||||
video: player.current?.getInternalPlayer(),
|
video: player.current?.getInternalPlayer(),
|
||||||
workerUrl,
|
workerUrl,
|
||||||
wasmUrl,
|
wasmUrl,
|
||||||
subUrl: `${api.basePath}${mediaSource.subtitle.url}`,
|
subUrl: `${api?.basePath}${mediaSource.subtitle.url}`,
|
||||||
availableFonts: { "noto sans": font },
|
availableFonts: { "noto sans": font },
|
||||||
fallbackFont: "noto sans",
|
fallbackFont: "noto sans",
|
||||||
});
|
});
|
||||||
@@ -360,9 +401,8 @@ function VideoPlayer() {
|
|||||||
addSubtitleTrackToReactPlayer(
|
addSubtitleTrackToReactPlayer(
|
||||||
player.current.getInternalPlayer() as HTMLMediaElement,
|
player.current.getInternalPlayer() as HTMLMediaElement,
|
||||||
mediaSource.subtitle,
|
mediaSource.subtitle,
|
||||||
api.basePath,
|
api?.basePath ?? "",
|
||||||
);
|
);
|
||||||
console.log(videoElem.textTracks);
|
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
if (jassubRenderer) {
|
if (jassubRenderer) {
|
||||||
@@ -389,22 +429,22 @@ function VideoPlayer() {
|
|||||||
|
|
||||||
const showSkipIntroButton = useMemo(() => {
|
const showSkipIntroButton = useMemo(() => {
|
||||||
if (
|
if (
|
||||||
ticksToSec(progress) >=
|
progress >= (introInfo?.StartTicks ?? 0) &&
|
||||||
(introInfo?.Introduction?.ShowSkipPromptAt ?? 0) &&
|
progress < (introInfo?.EndTicks ?? 0)
|
||||||
ticksToSec(progress) < (introInfo?.Introduction?.HideSkipPromptAt ?? 0)
|
) {
|
||||||
)
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}, [progress]);
|
}, [progress]);
|
||||||
|
|
||||||
const showUpNextCard = useMemo(() => {
|
const showUpNextCard = useMemo(() => {
|
||||||
if (queue[currentQueueItemIndex]?.Id === queue[queue.length - 1]?.Id) {
|
if (queue?.[currentQueueItemIndex]?.Id === queue?.[queue.length - 1]?.Id) {
|
||||||
return false; // Check if the current playing episode is last episode in queue
|
return false; // Check if the current playing episode is last episode in queue
|
||||||
}
|
}
|
||||||
if (introInfo?.Credits) {
|
if (creditInfo) {
|
||||||
if (
|
if (
|
||||||
ticksToSec(progress) >= introInfo?.Credits.ShowSkipPromptAt &&
|
progress >= (creditInfo.StartTicks ?? progress + 1) &&
|
||||||
ticksToSec(progress) < introInfo?.Credits.HideSkipPromptAt
|
progress < (creditInfo.EndTicks ?? 0)
|
||||||
)
|
)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -417,9 +457,28 @@ function VideoPlayer() {
|
|||||||
return false;
|
return false;
|
||||||
}, [progress, item?.Id]);
|
}, [progress, item?.Id]);
|
||||||
|
|
||||||
|
const showSkipRecap = useMemo(() => {
|
||||||
|
if (
|
||||||
|
recapInfo &&
|
||||||
|
progress >= (recapInfo?.StartTicks ?? 0) &&
|
||||||
|
progress < (recapInfo?.EndTicks ?? 0)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, [progress, item?.Id]);
|
||||||
|
|
||||||
const handleSkipIntro = useCallback(() => {
|
const handleSkipIntro = useCallback(() => {
|
||||||
player.current?.seekTo(
|
player.current?.seekTo(
|
||||||
introInfo?.Introduction.IntroEnd ?? player.current?.getCurrentTime(),
|
ticksToSec(Number(introInfo?.EndTicks)) ??
|
||||||
|
player.current?.getCurrentTime(),
|
||||||
|
);
|
||||||
|
}, [item?.Id]);
|
||||||
|
|
||||||
|
const handleSkipRecap = useCallback(() => {
|
||||||
|
player.current?.seekTo(
|
||||||
|
ticksToSec(Number(recapInfo?.EndTicks)) ??
|
||||||
|
player.current?.getCurrentTime(),
|
||||||
);
|
);
|
||||||
}, [item?.Id]);
|
}, [item?.Id]);
|
||||||
|
|
||||||
@@ -437,29 +496,24 @@ function VideoPlayer() {
|
|||||||
return marks;
|
return marks;
|
||||||
}, [item?.Chapters]);
|
}, [item?.Chapters]);
|
||||||
|
|
||||||
|
const [showChapterList, setShowChapterList] =
|
||||||
|
useState<HTMLButtonElement | null>(null);
|
||||||
|
const handleShowChapterList: MouseEventHandler<HTMLButtonElement> =
|
||||||
|
useCallback((e) => {
|
||||||
|
setShowChapterList(e.currentTarget);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const sliderDisplayFormat = (value: number) => {
|
const sliderDisplayFormat = (value: number) => {
|
||||||
const currentChapter = item?.Chapters?.filter((chapter, index) => {
|
const currentChapter = item?.Chapters?.filter((chapter, index) => {
|
||||||
if (index + 1 === item.Chapters?.length) {
|
if (index + 1 === item.Chapters?.length) {
|
||||||
return chapter;
|
return chapter;
|
||||||
}
|
}
|
||||||
if (isSeeking) {
|
if (
|
||||||
if (
|
(item.Chapters?.[index + 1]?.StartPositionTicks ?? value) - value >=
|
||||||
(item.Chapters?.[index + 1]?.StartPositionTicks ?? sliderProgress) -
|
0 &&
|
||||||
sliderProgress >=
|
(chapter.StartPositionTicks ?? value) - value < 0
|
||||||
0 &&
|
) {
|
||||||
(chapter.StartPositionTicks ?? sliderProgress) - sliderProgress < 0
|
return chapter;
|
||||||
) {
|
|
||||||
return chapter;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (
|
|
||||||
(item.Chapters?.[index + 1]?.StartPositionTicks ?? progress) -
|
|
||||||
progress >=
|
|
||||||
0 &&
|
|
||||||
(chapter.StartPositionTicks ?? progress) - progress < 0
|
|
||||||
) {
|
|
||||||
return chapter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -508,55 +562,58 @@ function VideoPlayer() {
|
|||||||
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
||||||
|
|
||||||
const imgUrlParamsObject: Record<string, string> = {
|
const imgUrlParamsObject: Record<string, string> = {
|
||||||
api_key: api.accessToken,
|
api_key: String(api?.accessToken),
|
||||||
MediaSourceId: mediaSource.id ?? "",
|
MediaSourceId: mediaSource.id ?? "",
|
||||||
};
|
};
|
||||||
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
||||||
|
|
||||||
|
const imageAspectRatio = trickplayResolution.Width / trickplayResolution.Height;
|
||||||
|
|
||||||
if (currentChapter?.[0]?.Name) {
|
if (currentChapter?.[0]?.Name) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-column video-osb-bubble glass">
|
<div className="flex flex-column video-osb-bubble">
|
||||||
<div
|
<div
|
||||||
className="video-osd-trickplayBubble"
|
className="video-osd-trickplayBubble"
|
||||||
style={{
|
style={{
|
||||||
background: `url(${api.basePath}/Videos/${item?.Id}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
background: `url(${api?.basePath}/Videos/${item?.Id}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
backgroundPositionY: `${backgroundOffsetY}px`,
|
||||||
width: `${trickplayResolution.Width}px`,
|
width: "100%",
|
||||||
height: `${trickplayResolution.Height}px`,
|
aspectRatio: imageAspectRatio,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Typography variant="h6" px={2} pt={1}>
|
<Typography variant="h6" px="12px" pt={1}>
|
||||||
{currentChapter?.[0]?.Name}
|
{currentChapter?.[0]?.Name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography px={2} pb={1}>
|
<Typography px="12px" pb={1}>
|
||||||
{ticksDisplay(value)}
|
{ticksDisplay(value)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-column video-osb-bubble glass">
|
<div className="flex flex-column video-osb-bubble">
|
||||||
<div
|
<div
|
||||||
className="video-osd-trickplayBubble"
|
className="video-osd-trickplayBubble"
|
||||||
style={{
|
style={{
|
||||||
background: `url(${api.basePath}/Videos/${item?.Id}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
background: `url(${api?.basePath}/Videos/${item?.Id}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
backgroundPositionY: `${backgroundOffsetY}px`,
|
||||||
width: `${trickplayResolution.Width}px`,
|
width: "100%",
|
||||||
height: `${trickplayResolution.Height}px`,
|
aspectRatio: imageAspectRatio,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Typography variant="h6" px={2} py={1}>
|
<Typography variant="h6" px="12px" py={1}>
|
||||||
{ticksDisplay(value)}
|
{ticksDisplay(value)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentChapter?.[0]?.Name) {
|
if (currentChapter?.[0]?.Name) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-column video-osb-bubble glass">
|
<div className="flex flex-column video-osb-bubble">
|
||||||
<Typography variant="h6" px={2} pt={1}>
|
<Typography variant="h6" px="12px" pt={1}>
|
||||||
{currentChapter?.[0]?.Name}
|
{currentChapter?.[0]?.Name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography px={2} pb={1}>
|
<Typography px={2} pb={1}>
|
||||||
@@ -566,8 +623,8 @@ function VideoPlayer() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-column video-osb-bubble glass">
|
<div className="flex flex-column video-osb-bubble ">
|
||||||
<Typography variant="h6" px={2} py={1}>
|
<Typography variant="h6" px="12px" py={1}>
|
||||||
{ticksDisplay(value)}
|
{ticksDisplay(value)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
@@ -584,30 +641,99 @@ function VideoPlayer() {
|
|||||||
}, [volume]);
|
}, [volume]);
|
||||||
|
|
||||||
const handlePlaybackEnded = () => {
|
const handlePlaybackEnded = () => {
|
||||||
if (queue[currentQueueItemIndex + 1].Id) {
|
if (queue?.[currentQueueItemIndex + 1].Id) {
|
||||||
playItemFromQueue("next", user?.Id, api);
|
playItemFromQueue("next", user?.Id, api);
|
||||||
} else {
|
} else {
|
||||||
handleExitPlayer(); // Exit player if playback has finished and the queue is empty
|
handleExitPlayer(); // Exit player if playback has finished and the queue is empty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||||
const handleSubtitleChange = (
|
const handleSubtitleChange: ChangeEventHandler<
|
||||||
e: ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>,
|
HTMLInputElement | HTMLTextAreaElement
|
||||||
) => {
|
> = useCallback(
|
||||||
startSubtitleChange(() => {
|
(e) => {
|
||||||
if (mediaSource.subtitle.allTracks) {
|
startSubtitleChange(() => {
|
||||||
changeSubtitleTrack(toNumber(e.target.value), mediaSource.subtitle.allTracks);
|
if (mediaSource.subtitle.allTracks) {
|
||||||
console.log(mediaSource.subtitle);
|
changeSubtitleTrack(toNumber(e.target.value), mediaSource.subtitle.allTracks);
|
||||||
setSettingsMenu(null);
|
setSettingsMenu(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[mediaSource.subtitle.allTracks],
|
||||||
|
);
|
||||||
|
|
||||||
|
const [audioTackIsChanging, startAudioTrackChange] = useTransition();
|
||||||
|
const handleAudioTrackChange: ChangeEventHandler<
|
||||||
|
HTMLInputElement | HTMLTextAreaElement
|
||||||
|
> = (e) => {
|
||||||
|
// setPlaying(false);
|
||||||
|
startAudioTrackChange(() => {
|
||||||
|
if (api && mediaSource.audio.allTracks) {
|
||||||
|
changeAudioTrack(toNumber(e.target.value), api, progress);
|
||||||
|
setIsReady(false);
|
||||||
|
// setSettingsMenu(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// setPlaying(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrevChapter = useCallback(() => {
|
||||||
|
const chapters = item?.Chapters?.filter((chapter) => {
|
||||||
|
if ((chapter.StartPositionTicks ?? 0) <= progress) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!chapters?.length) {
|
||||||
|
player.current?.seekTo(0);
|
||||||
|
}
|
||||||
|
if (chapters?.length === 1) {
|
||||||
|
player.current?.seekTo(ticksToSec(chapters[0].StartPositionTicks ?? 0));
|
||||||
|
} else if ((chapters?.length ?? 0) > 1) {
|
||||||
|
player.current?.seekTo(
|
||||||
|
ticksToSec(chapters?.[chapters.length - 2].StartPositionTicks ?? 0),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const chapter = item?.Chapters?.[Number(currentChapterIndex) - 1];
|
||||||
|
// player.current?.seekTo(ticksToSec(currentChapter?.[0]?.StartPositionTicks ?? 0));
|
||||||
|
}, [progress, playsessionId]);
|
||||||
|
const handleNextChapter = useCallback(() => {
|
||||||
|
const next = item?.Chapters?.filter((chapter) => {
|
||||||
|
if ((chapter.StartPositionTicks ?? 0) > progress) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})[0];
|
||||||
|
console.log("Next Chapter", next);
|
||||||
|
player.current?.seekTo(ticksToSec(next?.StartPositionTicks ?? 0));
|
||||||
|
}, [progress, playsessionId]);
|
||||||
|
|
||||||
|
const positionRef = React.useRef<{ x: number; y: number }>({
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
});
|
||||||
|
const popperRef = React.useRef<Instance>(null);
|
||||||
|
const areaRef = React.useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const [hoverProgress, setHoverProgress] = useState(0);
|
||||||
|
|
||||||
|
const handleSliderHover = (event: React.MouseEvent) => {
|
||||||
|
positionRef.current = { x: event.clientX, y: event.clientY };
|
||||||
|
const rect = areaRef.current!.getBoundingClientRect();
|
||||||
|
const width = rect.width;
|
||||||
|
const distX = event.clientX - rect.left;
|
||||||
|
const percentageCovered = distX / width;
|
||||||
|
setHoverProgress(percentageCovered * itemDuration);
|
||||||
|
if (popperRef.current != null) {
|
||||||
|
popperRef.current.update();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="video-player">
|
<div className="video-player">
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{loading && (
|
{(loading || audioTackIsChanging) && (
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{
|
animate={{
|
||||||
@@ -647,6 +773,23 @@ function VideoPlayer() {
|
|||||||
Skip Intro
|
Skip Intro
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{showSkipRecap && (
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
size="large"
|
||||||
|
//@ts-ignore
|
||||||
|
color="white"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "18vh",
|
||||||
|
right: "2em",
|
||||||
|
zIndex: 10000,
|
||||||
|
}}
|
||||||
|
onClick={handleSkipRecap}
|
||||||
|
>
|
||||||
|
Skip Recap
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
{!forceShowCredits && showUpNextCard && (
|
{!forceShowCredits && showUpNextCard && (
|
||||||
<OutroCard handleShowCredits={handleShowCredits} />
|
<OutroCard handleShowCredits={handleShowCredits} />
|
||||||
)}
|
)}
|
||||||
@@ -676,6 +819,7 @@ function VideoPlayer() {
|
|||||||
: "video-player-osd"
|
: "video-player-osd"
|
||||||
}
|
}
|
||||||
onMouseMove={handleShowOsd}
|
onMouseMove={handleShowOsd}
|
||||||
|
ref={playerOSDRef}
|
||||||
initial={{
|
initial={{
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
@@ -712,7 +856,7 @@ function VideoPlayer() {
|
|||||||
<IconButton onClick={(e) => setSettingsMenu(e.currentTarget)}>
|
<IconButton onClick={(e) => setSettingsMenu(e.currentTarget)}>
|
||||||
<span className="material-symbols-rounded">settings</span>
|
<span className="material-symbols-rounded">settings</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Menu
|
<Popover
|
||||||
anchorEl={settingsMenu}
|
anchorEl={settingsMenu}
|
||||||
open={settingsMenuOpen}
|
open={settingsMenuOpen}
|
||||||
onClose={() => setSettingsMenu(null)}
|
onClose={() => setSettingsMenu(null)}
|
||||||
@@ -720,19 +864,40 @@ function VideoPlayer() {
|
|||||||
paper: {
|
paper: {
|
||||||
style: {
|
style: {
|
||||||
maxHeight: "20em",
|
maxHeight: "20em",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "1em",
|
||||||
|
width: "24em",
|
||||||
|
padding: "1em",
|
||||||
|
borderRadius: "12px",
|
||||||
},
|
},
|
||||||
|
className: "glass",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
MenuListProps={{
|
anchorOrigin={{
|
||||||
style: {
|
vertical: "bottom",
|
||||||
display: "flex",
|
horizontal: "right",
|
||||||
flexDirection: "column",
|
}}
|
||||||
gap: "1em",
|
transformOrigin={{
|
||||||
width: "24em",
|
vertical: "top",
|
||||||
},
|
horizontal: "right",
|
||||||
}}
|
}}
|
||||||
style={{}}
|
|
||||||
>
|
>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
label="Audio"
|
||||||
|
variant="outlined"
|
||||||
|
value={mediaSource.audio.track}
|
||||||
|
onChange={handleAudioTrackChange}
|
||||||
|
fullWidth
|
||||||
|
disabled={audioTackIsChanging}
|
||||||
|
>
|
||||||
|
{mediaSource.audio.allTracks?.map((sub) => (
|
||||||
|
<MenuItem key={sub.Index} value={sub.Index}>
|
||||||
|
{sub.DisplayTitle}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
<TextField
|
<TextField
|
||||||
select
|
select
|
||||||
label="Subtitles"
|
label="Subtitles"
|
||||||
@@ -751,68 +916,103 @@ function VideoPlayer() {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</TextField>
|
</TextField>
|
||||||
</Menu>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
{(forceShowCredits || !showUpNextCard) && (
|
{(forceShowCredits || !showUpNextCard) && (
|
||||||
<div className="video-player-osd-info">
|
<div className="video-player-osd-info">
|
||||||
<Typography variant="h4" fontWeight={500} mb={2}>
|
<Typography variant="h4" fontWeight={500} mb={2}>
|
||||||
{itemName}
|
{String(itemName)}
|
||||||
{episodeTitle && (
|
{episodeTitle && (
|
||||||
<Typography variant="h6" fontWeight={300} mt={1}>
|
<Typography variant="h6" fontWeight={300} mt={1}>
|
||||||
{episodeTitle}
|
{String(episodeTitle)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div className="video-player-osd-controls">
|
<div className="video-player-osd-controls">
|
||||||
<div className="video-player-osd-controls-progress">
|
<div className="video-player-osd-controls-progress">
|
||||||
<Slider
|
<Tooltip
|
||||||
value={isSeeking ? sliderProgress : progress}
|
// title={sliderDisplayFormat(
|
||||||
max={itemDuration}
|
// positionRef.current.x - areaRef.current!.getBoundingClientRect().x,
|
||||||
step={1}
|
// )}
|
||||||
onChange={(_, newValue) => {
|
key={`${positionRef.current}`}
|
||||||
setIsSeeking(true);
|
title={sliderDisplayFormat(hoverProgress)}
|
||||||
Array.isArray(newValue)
|
placement="top"
|
||||||
? setSliderProgress(newValue[0])
|
slotProps={{
|
||||||
: setSliderProgress(newValue);
|
popper: {
|
||||||
}}
|
popperRef,
|
||||||
onChangeCommitted={(_, newValue) => {
|
anchorEl: {
|
||||||
setIsSeeking(false);
|
getBoundingClientRect: () => {
|
||||||
Array.isArray(newValue)
|
return new DOMRect(
|
||||||
? setProgress(newValue[0])
|
positionRef.current.x,
|
||||||
: setProgress(newValue);
|
areaRef.current!.getBoundingClientRect().y,
|
||||||
if (Array.isArray(newValue)) {
|
0,
|
||||||
player.current?.seekTo(
|
0,
|
||||||
ticksToSec(newValue[0]),
|
);
|
||||||
"seconds",
|
},
|
||||||
);
|
},
|
||||||
} else {
|
disablePortal: true,
|
||||||
player.current?.seekTo(ticksToSec(newValue), "seconds");
|
},
|
||||||
}
|
tooltip: {
|
||||||
}}
|
className: "glass",
|
||||||
sx={{
|
style: {
|
||||||
"& .MuiSlider-thumb": {
|
width: "34em",
|
||||||
width: 14,
|
overflow: "hidden",
|
||||||
height: 14,
|
padding: "12px",
|
||||||
transition: "0.1s ease-in-out",
|
borderRadius: "20px",
|
||||||
opacity: 0,
|
|
||||||
"&.Mui-active": {
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
opacity: 1,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"&:hover .MuiSlider-thumb": {
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
"& .MuiSlider-rail": {
|
|
||||||
opacity: 0.28,
|
|
||||||
background: "white",
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
marks={chapterMarks}
|
>
|
||||||
valueLabelDisplay="auto"
|
<Slider
|
||||||
valueLabelFormat={sliderDisplayFormat}
|
value={isSeeking ? sliderProgress : progress}
|
||||||
/>
|
max={itemDuration}
|
||||||
|
step={1}
|
||||||
|
onChange={(_, newValue) => {
|
||||||
|
setIsSeeking(true);
|
||||||
|
Array.isArray(newValue)
|
||||||
|
? setSliderProgress(newValue[0])
|
||||||
|
: setSliderProgress(newValue);
|
||||||
|
}}
|
||||||
|
onChangeCommitted={(_, newValue) => {
|
||||||
|
setIsSeeking(false);
|
||||||
|
Array.isArray(newValue)
|
||||||
|
? setProgress(newValue[0])
|
||||||
|
: setProgress(newValue);
|
||||||
|
if (Array.isArray(newValue)) {
|
||||||
|
player.current?.seekTo(
|
||||||
|
ticksToSec(newValue[0]),
|
||||||
|
"seconds",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
player.current?.seekTo(ticksToSec(newValue), "seconds");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
"& .MuiSlider-thumb": {
|
||||||
|
width: 14,
|
||||||
|
height: 14,
|
||||||
|
transition: "0.1s ease-in-out",
|
||||||
|
opacity: 0,
|
||||||
|
"&.Mui-active": {
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"&:hover .MuiSlider-thumb": {
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
"& .MuiSlider-rail": {
|
||||||
|
opacity: 0.28,
|
||||||
|
background: "white",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
marks={chapterMarks}
|
||||||
|
valueLabelDisplay="off"
|
||||||
|
ref={areaRef}
|
||||||
|
onMouseMove={handleSliderHover}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
<div className="video-player-osd-controls-progress-text">
|
<div className="video-player-osd-controls-progress-text">
|
||||||
<Typography>
|
<Typography>
|
||||||
{ticksDisplay(isSeeking ? sliderProgress : progress)}
|
{ticksDisplay(isSeeking ? sliderProgress : progress)}
|
||||||
@@ -824,21 +1024,37 @@ function VideoPlayer() {
|
|||||||
<div className="video-player-osd-controls-buttons">
|
<div className="video-player-osd-controls-buttons">
|
||||||
<PlayPreviousButton />
|
<PlayPreviousButton />
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
player.current?.seekTo(
|
player.current?.seekTo(
|
||||||
player.current.getCurrentTime() - 15,
|
player.current.getCurrentTime() - 15,
|
||||||
)
|
);
|
||||||
}
|
}}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded fill">
|
<span className="material-symbols-rounded fill">
|
||||||
fast_rewind
|
fast_rewind
|
||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
<IconButton onClick={handlePrevChapter}>
|
||||||
|
<span className="material-symbols-rounded fill">
|
||||||
|
first_page
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
<IconButton onClick={() => setPlaying((state) => !state)}>
|
<IconButton onClick={() => setPlaying((state) => !state)}>
|
||||||
<span className="material-symbols-rounded fill">
|
<span className="material-symbols-rounded fill">
|
||||||
{playing ? "pause" : "play_arrow"}
|
{playing ? "pause" : "play_arrow"}
|
||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
disabled={
|
||||||
|
(item?.Chapters?.[item.Chapters?.length - 1]
|
||||||
|
?.StartPositionTicks ?? 0) <= progress
|
||||||
|
}
|
||||||
|
onClick={handleNextChapter}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded fill">
|
||||||
|
last_page
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
player.current?.seekTo(
|
player.current?.seekTo(
|
||||||
@@ -912,9 +1128,45 @@ function VideoPlayer() {
|
|||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<QueueButton />
|
<QueueButton />
|
||||||
|
<IconButton
|
||||||
|
disabled={item?.Chapters?.length === 0}
|
||||||
|
onClick={handleShowChapterList}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">list</span>
|
||||||
|
</IconButton>
|
||||||
|
<Menu
|
||||||
|
open={Boolean(showChapterList)}
|
||||||
|
anchorEl={showChapterList}
|
||||||
|
onClose={() => setShowChapterList(null)}
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "center",
|
||||||
|
}}
|
||||||
|
transformOrigin={{
|
||||||
|
vertical: "bottom",
|
||||||
|
horizontal: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{chapterMarks &&
|
||||||
|
item?.Chapters?.map((chapter) => (
|
||||||
|
<MenuItem
|
||||||
|
key={chapter.Name}
|
||||||
|
onClick={() => {
|
||||||
|
player.current?.seekTo(
|
||||||
|
ticksToSec(chapter.StartPositionTicks ?? 0),
|
||||||
|
"seconds",
|
||||||
|
);
|
||||||
|
setShowChapterList(null); // Close the chapter list menu
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{chapter.Name}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Menu>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={
|
disabled={
|
||||||
mediaSource.subtitle.track === -2 || subtitleIsChanging
|
mediaSource.subtitle.allTracks?.length === 0 ||
|
||||||
|
subtitleIsChanging
|
||||||
}
|
}
|
||||||
onClick={() => startSubtitleChange(toggleSubtitleTrack)}
|
onClick={() => startSubtitleChange(toggleSubtitleTrack)}
|
||||||
>
|
>
|
||||||
@@ -943,7 +1195,7 @@ function VideoPlayer() {
|
|||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
<ReactPlayer
|
<ReactPlayer
|
||||||
key={`${item?.Id}${mediaSource.id}`}
|
key={playsessionId}
|
||||||
playing={playing}
|
playing={playing}
|
||||||
url={playbackStream}
|
url={playbackStream}
|
||||||
ref={player}
|
ref={player}
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import { save } from "@tauri-apps/plugin-dialog";
|
|||||||
import "./photos.scss";
|
import "./photos.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import {
|
import {
|
||||||
Button,
|
|
||||||
CircularProgress,
|
|
||||||
IconButton,
|
IconButton,
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
@@ -48,12 +46,16 @@ function PhotosPlayer() {
|
|||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={
|
src={
|
||||||
item.Id
|
api
|
||||||
? getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
? getImageUrlsApi(api).getItemImageUrlById(
|
||||||
// width: 250,
|
item.Id ?? "",
|
||||||
fillWidth: 250,
|
"Primary",
|
||||||
quality: 70,
|
{
|
||||||
})
|
// width: 250,
|
||||||
|
fillWidth: 250,
|
||||||
|
quality: 70,
|
||||||
|
},
|
||||||
|
)
|
||||||
: brokenImage
|
: brokenImage
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
@@ -103,7 +105,7 @@ function PhotosPlayer() {
|
|||||||
|
|
||||||
if (pathToSave) {
|
if (pathToSave) {
|
||||||
download(
|
download(
|
||||||
`${api.basePath}/Items/${currentPhoto?.Id}/Download?api_key=${api.accessToken}`,
|
`${api?.basePath}/Items/${currentPhoto?.Id}/Download?api_key=${api?.accessToken}`,
|
||||||
pathToSave,
|
pathToSave,
|
||||||
);
|
);
|
||||||
enqueueSnackbar("Image download queued.", { variant: "info" });
|
enqueueSnackbar("Image download queued.", { variant: "info" });
|
||||||
@@ -120,7 +122,7 @@ function PhotosPlayer() {
|
|||||||
key={currentPhoto?.Id ?? "noPhoto"}
|
key={currentPhoto?.Id ?? "noPhoto"}
|
||||||
src={
|
src={
|
||||||
currentPhoto
|
currentPhoto
|
||||||
? `${api.basePath}/Items/${currentPhoto.Id}/Download?api_key=${api.accessToken}`
|
? `${api?.basePath}/Items/${currentPhoto.Id}/Download?api_key=${api?.accessToken}`
|
||||||
: brokenImage
|
: brokenImage
|
||||||
}
|
}
|
||||||
alt="Item"
|
alt="Item"
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
filter: drop-shadow(0 0 10px black);
|
filter: drop-shadow(0 0 10px black);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-trick-bubble {
|
&-trickplayBubble {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: $border-radius-default;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-osd-visible {
|
&-osd-visible {
|
||||||
@@ -98,11 +98,20 @@ video {
|
|||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
&-text {
|
&-text {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
&-bubble{
|
||||||
|
width: 14em;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
transform-origin:bottom center;
|
||||||
|
transform: translate(var(--left, 0), var(--top, 0));
|
||||||
|
position: fixed;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&-buttons {
|
&-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
import React, { useEffect } from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
|
|
||||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
|
||||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
|
||||||
|
|
||||||
import MusicTrack from "@/components/musicTrack";
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
|
||||||
import "./playlist.scss";
|
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
function TabPanel(props) {
|
|
||||||
const { children, value, index, ...other } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role="tabpanel"
|
|
||||||
hidden={value !== index}
|
|
||||||
id={`full-width-tabpanel-${index}`}
|
|
||||||
aria-labelledby={`full-width-tab-${index}`}
|
|
||||||
{...other}
|
|
||||||
style={{ marginTop: "1em" }}
|
|
||||||
>
|
|
||||||
{value === index && <Box>{children}</Box>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
function a11yProps(index) {
|
|
||||||
return {
|
|
||||||
id: `full-width-tab-${index}`,
|
|
||||||
"aria-controls": `full-width-tabpanel-${index}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/playlist/$id")({
|
|
||||||
component: PlaylistTitlePage,
|
|
||||||
});
|
|
||||||
|
|
||||||
function PlaylistTitlePage() {
|
|
||||||
const { id } = Route.useParams();
|
|
||||||
const api = Route.useRouteContext().api;
|
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
|
||||||
|
|
||||||
const item = useQuery({
|
|
||||||
queryKey: ["item", id],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: id,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id,
|
|
||||||
networkMode: "always",
|
|
||||||
refetchOnWindowFocus: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const similarItems = useQuery({
|
|
||||||
queryKey: ["item", id, "similarItem"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getLibraryApi(api).getSimilarAlbums({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: item.data.Id,
|
|
||||||
limit: 16,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: item.isSuccess,
|
|
||||||
networkMode: "always",
|
|
||||||
refetchOnWindowFocus: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const musicTracks = useQuery({
|
|
||||||
queryKey: ["item", id, "musicTracks"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getPlaylistsApi(api).getPlaylistItems({
|
|
||||||
userId: user?.Id,
|
|
||||||
playlistId: item.data.Id,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: item.isSuccess,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (item.isSuccess) {
|
|
||||||
setAppBackdrop(
|
|
||||||
item.data.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
item.data.Type === BaseItemKind.Episode
|
|
||||||
? `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
|
|
||||||
: `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`,
|
|
||||||
item.data.Id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (item.isPending || similarItems.isPending) {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: "100%",
|
|
||||||
height: "100vh",
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CircularProgress />
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (item.isSuccess && similarItems.isSuccess) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="scrollY padded-top item"
|
|
||||||
style={{
|
|
||||||
padding: "5em 2em 2em 1em",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
gap: "0.5em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{musicTracks.isPending ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
musicTracks.data.TotalRecordCount > 0 &&
|
|
||||||
musicTracks.data.Items.map((track, index) => {
|
|
||||||
return (
|
|
||||||
<MusicTrack
|
|
||||||
item={track}
|
|
||||||
key={track.Id}
|
|
||||||
queryKey={["item", id, "musicTracks"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
playlistItem
|
|
||||||
playlistItemId={item.data.Id}
|
|
||||||
trackIndex={index}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
|
|
||||||
{similarItems.data.TotalRecordCount > 0 && (
|
|
||||||
<CardScroller
|
|
||||||
title="You might also like"
|
|
||||||
displayCards={8}
|
|
||||||
disableDecoration
|
|
||||||
>
|
|
||||||
{similarItems.data.Items.map((similar, index) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={similar.Id}
|
|
||||||
item={similar}
|
|
||||||
seriesId={similar.SeriesId}
|
|
||||||
cardTitle={
|
|
||||||
similar.Type === BaseItemKind.Episode
|
|
||||||
? similar.SeriesName
|
|
||||||
: similar.Name
|
|
||||||
}
|
|
||||||
imageType={"Primary"}
|
|
||||||
cardCaption={
|
|
||||||
similar.Type === BaseItemKind.Episode
|
|
||||||
? `S${similar.ParentIndexNumber}:E${similar.IndexNumber} - ${similar.Name}`
|
|
||||||
: similar.Type === BaseItemKind.Series
|
|
||||||
? `${similar.ProductionYear} - ${
|
|
||||||
similar.EndDate
|
|
||||||
? new Date(similar.EndDate).toLocaleString([], {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "Present"
|
|
||||||
}`
|
|
||||||
: similar.ProductionYear
|
|
||||||
}
|
|
||||||
cardType={
|
|
||||||
similar.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
similar.Type === BaseItemKind.Audio
|
|
||||||
? "square"
|
|
||||||
: "portrait"
|
|
||||||
}
|
|
||||||
queryKey={["item", id, "similarItem"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
imageBlurhash={
|
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
|
||||||
similar.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(similar.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (item.isError || similarItems.isError) {
|
|
||||||
return <ErrorNotice />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default PlaylistTitlePage;
|
|
||||||
Loaded 100 of 137 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user