Compare commits
183
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04ab9f767b | ||
|
|
e93de2beea | ||
|
|
9f314582c0 | ||
|
|
fcf61012db | ||
|
|
d9bce4de04 | ||
|
|
5784036eb1 | ||
|
|
e89932fc7d | ||
|
|
31826f1098 | ||
|
|
5746bf35a5 | ||
|
|
cb5ee9b672 | ||
|
|
7c5fa8f869 | ||
|
|
b592680006 | ||
|
|
e5f1ff34ed | ||
|
|
6a1467e864 | ||
|
|
205b655d00 | ||
|
|
b1d9b40def | ||
|
|
610a7e4dbf | ||
|
|
0d2edcab3d | ||
|
|
5b4efd20c0 | ||
|
|
67c69208c4 | ||
|
|
23cdfb010d | ||
|
|
3cfa52ffc9 | ||
|
|
75b4ddd598 | ||
|
|
ae5a2133fa | ||
|
|
6675a55957 | ||
|
|
4bdd0139bf | ||
|
|
df392eb647 | ||
|
|
5aaa3435da | ||
|
|
0f80d4db4e | ||
|
|
4a0cb46734 | ||
|
|
d5c1bfac64 | ||
|
|
affbd00157 | ||
|
|
e39a5c70c0 | ||
|
|
c80d13744d | ||
|
|
5994b94406 | ||
|
|
a1af85dd72 | ||
|
|
ffdedc7b9b | ||
|
|
289ac4958d | ||
|
|
a07ae9b264 | ||
|
|
dd0bf8b493 | ||
|
|
5ca4694c2b | ||
|
|
89581e1ba8 | ||
|
|
2aa3e4106c | ||
|
|
08f0ca0df1 | ||
|
|
fa29331c1c | ||
|
|
a98663691d | ||
|
|
cc1391bb7d | ||
|
|
b00f93d262 | ||
|
|
4c9dd86962 | ||
|
|
3131c1f905 | ||
|
|
c560f8ae1b | ||
|
|
cf5fb43377 | ||
|
|
5a9b3ad273 | ||
|
|
1c499f42ec | ||
|
|
61ebc66127 | ||
|
|
c232c1bf12 | ||
|
|
2d5f49c32e | ||
|
|
0c50acddd9 | ||
|
|
56ba65d23e | ||
|
|
b8f544b483 | ||
|
|
690cfb398c | ||
|
|
45dbfbb7ec | ||
|
|
e5171b7bb8 | ||
|
|
9211faabf0 | ||
|
|
422b1d6aa4 | ||
|
|
7f7866b28d | ||
|
|
1defb53945 | ||
|
|
73e3b865ab | ||
|
|
691df70aff | ||
|
|
6f2d5a5627 | ||
|
|
7804ab2b86 | ||
|
|
4ade92bccc | ||
|
|
ab1aa23725 | ||
|
|
0131a23dc2 | ||
|
|
72ca2fb4f3 | ||
|
|
b39a15449d | ||
|
|
cb83b05c7a | ||
|
|
32f5b3b3cf | ||
|
|
94e6a03e87 | ||
|
|
690070207b | ||
|
|
79c70e6d46 | ||
|
|
cf1f3c772d | ||
|
|
b870a119e5 | ||
|
|
0883cb0fe1 | ||
|
|
8519c12c45 | ||
|
|
d6c1b0992e | ||
|
|
9c3cc53278 | ||
|
|
abc7d68016 | ||
|
|
ad8d8545e9 | ||
|
|
1c8c048df0 | ||
|
|
c0402fe8cf | ||
|
|
ce6e4b681b | ||
|
|
6bf7f434b5 | ||
|
|
4834a31cb5 | ||
|
|
b49f187098 | ||
|
|
e41b5b3085 | ||
|
|
c19198e706 | ||
|
|
78c4b7a206 | ||
|
|
5579d5e5e8 | ||
|
|
e50ae60216 | ||
|
|
4bc6044ca2 | ||
|
|
7d55810f08 | ||
|
|
40651fd3d6 | ||
|
|
fdf43aba18 | ||
|
|
03bd7c027b | ||
|
|
995d75dbec | ||
|
|
4952d8842b | ||
|
|
f527d97912 | ||
|
|
ef8dfbc23a | ||
|
|
6576bfe5f3 | ||
|
|
3000146e66 | ||
|
|
81e0c3b9a8 | ||
|
|
27d8e04b0f | ||
|
|
50de0b7b51 | ||
|
|
64c5b7570b | ||
|
|
d46e143262 | ||
|
|
6542ed9487 | ||
|
|
d39c064600 | ||
|
|
d254d3033d | ||
|
|
3abf27724f | ||
|
|
120e283e3d | ||
|
|
706fb7b890 | ||
|
|
11b4a878ac | ||
|
|
6695bdc6ee | ||
|
|
17922127dd | ||
|
|
a135d1be5f | ||
|
|
88c42d8110 | ||
|
|
8e667a2253 | ||
|
|
e08eaea1d1 | ||
|
|
937e9385f2 | ||
|
|
bb2c0272a2 | ||
|
|
6b4d6ed0d3 | ||
|
|
374cba8f63 | ||
|
|
07522b50c5 | ||
|
|
257ff8e552 | ||
|
|
37e898e4cf | ||
|
|
65e5370dbf | ||
|
|
2d4b0d66b4 | ||
|
|
54d0b07666 | ||
|
|
9ac556d001 | ||
|
|
333fe09f45 | ||
|
|
a8ee9c190c | ||
|
|
0cf87da218 | ||
|
|
f919162dfc | ||
|
|
c9d16f4669 | ||
|
|
53311a1728 | ||
|
|
c4073f1368 | ||
|
|
c69a547379 | ||
|
|
7b0b22b611 | ||
|
|
47a486a3ad | ||
|
|
0f5482627a | ||
|
|
4ca90e713d | ||
|
|
093e40a929 | ||
|
|
797d0600c3 | ||
|
|
18d55a4af6 | ||
|
|
d7f3317913 | ||
|
|
52b73f7475 | ||
|
|
0c8b282469 | ||
|
|
25479b2278 | ||
|
|
dfb8eeee12 | ||
|
|
790f3f163b | ||
|
|
db74b4f58b | ||
|
|
18ebe4ef1e | ||
|
|
f0c8458dc4 | ||
|
|
80080e841a | ||
|
|
d60cb2b5fb | ||
|
|
7086892843 | ||
|
|
951cf61a89 | ||
|
|
ceee9311aa | ||
|
|
21a6e492f4 | ||
|
|
b916560c6a | ||
|
|
d3d5c5ac54 | ||
|
|
3f5e764cd7 | ||
|
|
4381b6e28e | ||
|
|
83c96cf65c | ||
|
|
4ff422ae61 | ||
|
|
c0d7d4e03d | ||
|
|
cd768a088b | ||
|
|
2f12fe0862 | ||
|
|
f6c0963f48 | ||
|
|
4ae8a087ed | ||
|
|
412e54fd82 | ||
|
|
51848a39ae |
No files matched your search
@@ -0,0 +1,15 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: [prayag17] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
polar: # Replace with a single Polar username
|
||||||
|
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||||
|
thanks_dev: # Replace with a single thanks.dev username
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
changelog:
|
||||||
|
categories:
|
||||||
|
- title: 🏕 Features
|
||||||
|
labels:
|
||||||
|
- '*'
|
||||||
|
exclude:
|
||||||
|
labels:
|
||||||
|
- dependencies
|
||||||
|
- title: 👒 Dependencies
|
||||||
|
labels:
|
||||||
|
- dependencies
|
||||||
@@ -13,12 +13,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- name: Sync node version and setup cache
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "lts/*"
|
node-version: "lts/*"
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
@@ -56,12 +56,12 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [macos-latest, ubuntu-22.04, windows-latest]
|
platform: [macos-latest, ubuntu-22.04, windows-latest, windows-11-arm]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
environment: TAURI
|
environment: TAURI
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
@@ -78,10 +78,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
workspaces: "./src-tauri -> target"
|
workspaces: "./src-tauri -> target"
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
@@ -89,7 +89,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
@@ -98,7 +98,7 @@ jobs:
|
|||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- name: Sync node version and setup cache
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "lts/*"
|
node-version: "lts/*"
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
@@ -115,8 +115,59 @@ jobs:
|
|||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||||
|
|
||||||
|
# TODO: Remove the below command after upstream issue is fixed
|
||||||
|
# Related issue: https://github.com/tauri-apps/tauri/issues/10702
|
||||||
|
WEBKIT_DISABLE_DMABUF_RENDERER: 1 # Disable DMABUF renderer on Wayland
|
||||||
|
|
||||||
- name: Upload build Artifacts
|
- name: Upload build Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
||||||
path: src-tauri/target/debug/bundle/*
|
path: src-tauri/target/debug/bundle/*
|
||||||
|
|
||||||
|
# Create or update nightly release
|
||||||
|
nightly_release:
|
||||||
|
needs: build
|
||||||
|
if: github.repository == 'prayag17/Blink' && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write # Required for creating/updating releases
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6.0.1
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v7.0.0
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Prepare assets
|
||||||
|
run: |
|
||||||
|
mkdir -p release_assets
|
||||||
|
find artifacts -type f \( -name "*.exe" -o -name "*.msi" -o -name "*.dmg" -o -name "*.deb" -o -name "*.AppImage" -o -name "*.rpm" -o -name "*.tar.gz" \) | while read -r file; do
|
||||||
|
# Extract platform from artifact name (e.g. Blink-ubuntu-22.04-devSHA)
|
||||||
|
artifact_name=$(echo "$file" | cut -d'/' -f2)
|
||||||
|
platform=$(echo "$artifact_name" | sed -E 's/Blink-(.*)-dev.*/\1/' | sed 's/-/_/g')
|
||||||
|
filename=$(basename "$file")
|
||||||
|
cp "$file" "release_assets/${platform}-${filename}"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Delete old nightly release
|
||||||
|
run: gh release delete nightly --yes --repo ${{ github.repository }} || true
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Create nightly release
|
||||||
|
uses: softprops/action-gh-release@v2.5.0
|
||||||
|
with:
|
||||||
|
tag_name: nightly
|
||||||
|
name: Nightly Build (${{ github.sha }})
|
||||||
|
body: |
|
||||||
|
Nightly build from the latest main branch.
|
||||||
|
|
||||||
|
**Last commit:** ${{ github.event.head_commit.message }}
|
||||||
|
**SHA:** ${{ github.sha }}
|
||||||
|
prerelease: true
|
||||||
|
files: release_assets/*
|
||||||
|
fail_on_unmatched_files: true
|
||||||
|
|
||||||
@@ -12,12 +12,12 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [macos-latest, ubuntu-22.04, windows-latest]
|
platform: [macos-latest, ubuntu-22.04, windows-latest, windows-11-arm]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
environment: TAURI
|
environment: TAURI
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
@@ -37,10 +37,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
workspaces: "./src-tauri -> target"
|
workspaces: "./src-tauri -> target"
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
@@ -57,7 +57,7 @@ jobs:
|
|||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- name: Sync node version and setup cache
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "lts/*"
|
node-version: "lts/*"
|
||||||
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
run: pnpm install --no-frozen-lockfile && pnpm run build # Change this to npm, yarn or pnpm.
|
run: pnpm install --no-frozen-lockfile && pnpm run build # Change this to npm, yarn or pnpm.
|
||||||
|
|
||||||
- name: Build the app
|
- name: Build the app
|
||||||
uses: tauri-apps/tauri-action@dev
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
name: Publish Releases to WinGet
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
jobs:
|
||||||
|
publish-alpha:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: contains(github.event.release.tag_name, '-alpha')
|
||||||
|
steps:
|
||||||
|
- uses: vedantmgoyal9/winget-releaser@main
|
||||||
|
with:
|
||||||
|
identifier: prayag17.Blink.Alpha
|
||||||
|
version: ${{ github.event.release.tag_name }}
|
||||||
|
installers-regex: '\.exe$'
|
||||||
|
token: ${{ secrets.WINGET_TOKEN }}
|
||||||
|
|
||||||
|
publish-stable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: "!contains(github.event.release.tag_name, '-alpha')"
|
||||||
|
steps:
|
||||||
|
- uses: vedantmgoyal9/winget-releaser@main
|
||||||
|
with:
|
||||||
|
identifier: prayag17.Blink
|
||||||
|
version: ${{ github.event.release.tag_name }}
|
||||||
|
installers-regex: '\.exe$'
|
||||||
|
token: ${{ secrets.WINGET_TOKEN }}
|
||||||
@@ -40,3 +40,8 @@ target/
|
|||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
generateBanner
|
generateBanner
|
||||||
|
# Million Lint
|
||||||
|
.million
|
||||||
|
|
||||||
|
# TypeScript incremental build cache
|
||||||
|
*.tsbuildinfo
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"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
|
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
## 📝 Prerequisites
|
## 📝 Prerequisites
|
||||||
|
|
||||||
- Nodejs (≥19.1.0)
|
- Nodejs (22.14.0)
|
||||||
- Rust (≥1.76.0)
|
- Rust (>=1.85.0)
|
||||||
- Visual Studio C++ Build tools
|
- Visual Studio C++ Build tools
|
||||||
- [pnpm](https://pnpm.io/)
|
- [pnpm](https://pnpm.io/)
|
||||||
|
|
||||||
@@ -60,21 +60,25 @@
|
|||||||
- Sort/Filter library items
|
- Sort/Filter library items
|
||||||
- Queue playback support
|
- Queue playback support
|
||||||
- Intro Skip button using [jumoog/Intro-Skipper](https://github.com/jumoog/intro-skipper) plugin
|
- Intro Skip button using [jumoog/Intro-Skipper](https://github.com/jumoog/intro-skipper) plugin
|
||||||
|
- Mediasegment support
|
||||||
|
|
||||||
## 📷 Screenshots
|
## 📷 Screenshots
|
||||||
|
|
||||||
- Home
|
- Home
|
||||||

|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212208" src="https://github.com/user-attachments/assets/036c2339-e8f1-4c8d-a908-af0ece9bb1f3" />
|
||||||
- Title Page - Movie
|
- Library
|
||||||

|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212723" src="https://github.com/user-attachments/assets/6520a325-3cf3-47a0-9056-b27aded4bb8c" />
|
||||||
- Title Page - Show
|
- Music Player Detailed
|
||||||

|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 213017" src="https://github.com/user-attachments/assets/00a89efa-0a4c-4272-868e-f52c9fcfeaac" />
|
||||||
- Episode List
|
- Item Page
|
||||||

|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212653" src="https://github.com/user-attachments/assets/5d281f8c-48ba-4787-b8ca-a4b86ccab5c1" />
|
||||||
|
- Album / Music Player
|
||||||
|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212949" src="https://github.com/user-attachments/assets/d99aaea5-e242-4b3d-a5c5-d2868313728b" />
|
||||||
|
- Search Dialog
|
||||||
|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212749" src="https://github.com/user-attachments/assets/4ad87072-86ad-4510-95a4-567d6d11e997" />
|
||||||
- Video Player
|
- Video Player
|
||||||

|
<img width="2560" height="1600" alt="Screenshot 2026-02-10 213049" src="https://github.com/user-attachments/assets/effcca22-3650-46e1-9a86-b3b434851f2f" />
|
||||||
- About Dialog
|
|
||||||

|
|
||||||
|
|
||||||
## 📃 Roadmap
|
## 📃 Roadmap
|
||||||
|
|
||||||
@@ -86,3 +90,4 @@
|
|||||||
- [@ferferga](https://github.com/ferferga) for helping in development behind the scenes.
|
- [@ferferga](https://github.com/ferferga) for helping in development behind the scenes.
|
||||||
- All contributors of [jellyfin/jellyfin-vue](https://github.com/jellyfin/jellyfin-vue).
|
- All contributors of [jellyfin/jellyfin-vue](https://github.com/jellyfin/jellyfin-vue).
|
||||||
- And also [@jellyfin](https://github.com/jellyfin/) for creating the main service
|
- And also [@jellyfin](https://github.com/jellyfin/) for creating the main service
|
||||||
|
|
||||||
+22
-16
@@ -1,19 +1,27 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
|
||||||
"organizeImports": {
|
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"recommended": true,
|
"recommended": true,
|
||||||
"style": {
|
"style": {
|
||||||
"noNonNullAssertion": "off",
|
"noNonNullAssertion": "off",
|
||||||
"useEnumInitializers": "off"
|
"useEnumInitializers": "off",
|
||||||
|
"noParameterAssign": "error",
|
||||||
|
"useAsConstAssertion": "error",
|
||||||
|
"useDefaultParameterLast": "error",
|
||||||
|
"useSelfClosingElements": "error",
|
||||||
|
"useSingleVarDeclarator": "error",
|
||||||
|
"noUnusedTemplateLiteral": "error",
|
||||||
|
"useNumberNamespace": "error",
|
||||||
|
"noInferrableTypes": "error",
|
||||||
|
"noUselessElse": "error"
|
||||||
},
|
},
|
||||||
"a11y": {
|
"a11y": {
|
||||||
"useKeyWithClickEvents": "off",
|
"useKeyWithClickEvents": "off",
|
||||||
"useMediaCaption": "off"
|
"useMediaCaption": "off",
|
||||||
|
"noStaticElementInteractions": "off"
|
||||||
},
|
},
|
||||||
"correctness": {
|
"correctness": {
|
||||||
"useExhaustiveDependencies": "off",
|
"useExhaustiveDependencies": "off",
|
||||||
@@ -22,19 +30,17 @@
|
|||||||
"suspicious": {
|
"suspicious": {
|
||||||
"noExplicitAny": "off"
|
"noExplicitAny": "off"
|
||||||
},
|
},
|
||||||
"nursery": {
|
"nursery": {}
|
||||||
"useComponentExportOnlyModules": "error"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"include": [
|
"includes": [
|
||||||
"src/**/*.ts",
|
"**/src/**/*.ts",
|
||||||
"src/**/*.tsx",
|
"**/src/**/*.tsx",
|
||||||
"src/**/*.jsx",
|
"**/src/**/*.jsx",
|
||||||
"src/**/*.js",
|
"**/src/**/*.js",
|
||||||
"*.json",
|
"**/*.json",
|
||||||
"*.scss"
|
"**/*.scss"
|
||||||
],
|
],
|
||||||
"ignoreUnknown": true
|
"ignoreUnknown": true
|
||||||
},
|
},
|
||||||
|
|||||||
+40
-30
@@ -1,60 +1,70 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="ru">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<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>Blink</title>
|
<title>Blink</title>
|
||||||
<style>
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
background: #08001f;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.app-loading {
|
.app-loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%,-50%);
|
transform: translate(-50%, -50%);
|
||||||
width: 10em;
|
|
||||||
height: 10em;
|
|
||||||
background: rgb(180 180 180);
|
|
||||||
z-index: 100000;
|
z-index: 100000;
|
||||||
mask-image: url("./src/assets/icon-outline.png");
|
display: flex;
|
||||||
mask-size: contain;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-loading.hidden {
|
.app-loading.hidden {
|
||||||
display: none;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-loading-logo {
|
||||||
.app-loading-anim{
|
display: block;
|
||||||
width: 150%;
|
width: min(230px, 62vw);
|
||||||
height: 100%;
|
height: auto;
|
||||||
position: absolute;
|
filter: drop-shadow(0 10px 30px rgb(0 0 0 / 0.35));
|
||||||
top: 0;
|
animation: splashPulse 1.4s ease-in-out infinite;
|
||||||
left: 0;
|
|
||||||
background: linear-gradient(to right,transparent,rgb(255 255 255),transparent);
|
|
||||||
transform: scaleX(0);
|
|
||||||
animation: loading 0.75s linear infinite both;
|
|
||||||
transform-origin: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes loading {
|
@keyframes splashPulse {
|
||||||
0%{
|
0%,
|
||||||
transform: translate(-100%);
|
100% {
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
50%{
|
50% {
|
||||||
transform: translate(0%);
|
opacity: 0.62;
|
||||||
}
|
}
|
||||||
100%{
|
}
|
||||||
transform: translate(100%);
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.app-loading-logo {
|
||||||
|
animation: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="app-loading">
|
<div class="app-loading" role="status" aria-label="Загрузка Blink">
|
||||||
<!-- <img src="./src/assets/icon-outline.svg" class="app-loading-logo" /> -->
|
<img
|
||||||
<div class="app-loading-anim"></div>
|
class="app-loading-logo"
|
||||||
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAX8AAACqCAYAAABFwE9PAAAAAXNSR0IArs4c6QAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABf6ADAAQAAAABAAAAqgAAAAAX35FHAAA3E0lEQVR4Ae2dB/wcRfn/CSGEGgi9hNB7b9IhQAhFQHqTjhRFQRB/gAiIggIK/hWkozQhRIr03nsvIiWUQCD03kNJ/u9PuPt6ue/e3c7sM3u7d/O8Xs/3dmdnPk+Z2Wdnp+y3zySRGnpg/Pjxfbk4KzwQnq7C/fn9HP64wh/y+2afPn3G8RspeiB6IHqgFB7oUwotc1KSYD8Fos6BB8FzwXPCegC0orFkeBEeCT9fw8/xUHiD80jRA9ED0QOF8kBXBX+C+0J4fw14PlgBfnJYPXcF/QHwyvAcsCW9ANgN8I3wbTwMPrEEj1jRA9ED0QM+Hujo4E+w74dT1oO3rfzO7uMkwzJfg3UfrAfBCB4EekuIlMID1KXaKi6Lw2sp3BWzlNgDtHV1SteE1RmdDdbQ85Swhprfgx+Ab+ZeeJPfSFUP4LhJ4SHw6fC7cFFpHIpdDevhFKnGA/hkefhgeAT8CPwO/C38MjxPTdZ4GD3QMR6gbU8GHwZ/ArcixY/jYHVwu5twwvfgE+ExcNnovyi8NzxVt9Yitg+CFfBvhptRfAB0ayPpYLtp8Oq0XtWs4Te4diXpaeYlO8t7GD0APgB+Hu4Eeg8j9oQ7ejiuvhVi7+rw23Baig+AeifG81J7gIZ/fNrGn5Dv9FIb76o8DvgZrGDZiXQHRi3s6pMy5sfOGWCXwF+tbz0A5i6jzVHn6IFaD9CO14Y1jJOFtqrF7NhjPKTecafTlxh4BKzJn44l7MvS43mB8lqOGyl6oJQeoP1OA6sjk5XeAsBp/H/SUnpskkkGl1RvF7W1mewo+FEqtZN7uKu7OKUu7/yc34J/tBoiUvRAGT1wJEpb3N+zgLOMiwPKGvy1VLJbaHEM1TDQPB1qsOzLQhoe0yTxTFlAYtnogbw9QJtdApk/N5S7ggtWWYP/3Rj5uouhJc+rnoEeANqc1jFUsUeb67KSbqIzs4LE8tEDOXvgb8ibzFDmNy5YpQz+bG4Yj5FXuBjaAXk11HU7AVNDHZ1CQwwN2QzfrGuIF6GiB4J5gLaqjadrGgt4zgWvlMG/YuBx/L7rYmwH5NX3hvQAmL4DbJEJGxjbsb8xXoSLHjD3APevdusebwysXv9TLpilDf70/l/BUH03p9toEAYfUXajuQG0MmGYsR0a/okUPVB0DxyEgnqTt6QriYnvuwCWejMRAWQMxlp/iM3Ff+3Kq28ELUllO73mtUvZJLnU3VDSb0q6liFNw4FT4ZcvM2DEotEDwTxAu9fS5JGw9W7+YbR7p/uptD1/nKghkG4M/GqY6jWfqIMS02aBdNcDIFL0QFE98AcUsw78GgG52dXg0gZ/DF3f1dgOy78RD8ANy2gTeqvdbRFA99fo/YwNgBshowcye4B2vzwgO2YG6g3wO9q9c6enzMF/694+6LqUY0pq8WroPXsA3dUDihQ9UFQPnIBi1kPtj4F5vo/BlmtMfeR7leEJqt1seS3rew1Z+n62+GH4LVgTK+JxsHaXKpCJF4KHwFrCNQAOTcvii8E89UeHFmSMH+rBHYO/cUVFOBsPcJ9uCtJaNmgToRzk0+ufCKFMJzjyIDgkvQ/4ybBe05yJcn1hfWL6LPgrOCTt7axgGwvgiD7wa4Ec8n9tNC2Kjh5I9ABtXd/pfyZAm78mUWCnJuJABY+RARwpyG/gk2CzdfRgzVXBDPUQKNVmN3yxGhyKNu/Udh/tKq8HaOz7BGjw+udGi5XXKx6aY/A6ARxZhdzBQ6VURRCwPpzmP/RUdUn7+ykZS/PlT3T9S1rDHPPpK6h5DLWlqu+YKXpAHqBN6qudbzq25TTZR3Sdh/HKFWk845HHa9LEpQLQaXlYn161Jq2ZLzxhtP5b0evWxlfwLiu8A6KCXecB2uZvArX35bI6s1SrfXDi/Bi8cVajG5S/vkG6WTITM48ApiWO35qBfgc0xBgvFJz0DLHKR/oO159I0QNF8QDxSotBfhFAn5uIJY9mxS1V8MfYn8GhdH4yqzPTlKfS7iGf9RLNsmx22z6Njzzy6BtPpZr78LAxFimfB45E5WkCqK3/89E9xFNUY2cfwSFIkyf98/ImsjT7/x9DQ67KS3dfOdjaD9YqqhB0rK9esVz0QAgP0MgXhL8O0Ngvt9I3VC/aSr9anF04CTWh9yI98rG1wkIeI+sb8G80lDGzIVYoKO3IHhgAXHstTguAGyGjB7J4QG/31vuovgLz4CxK1Za1Vq4W2+yYp6d2xf3UDLA30Dm9k4Kn3G8ooQzBP9SQz7U8TF/29SVtSw+kTWHNJ+l+GA0/A99TeUhzGCl6IL0HaFMrknvr9CVS5zyONjkyde5OyIgzh8KhSMsvZ8jbT8hcwdCgj/PW30UedmrITktSQ5DXSicU6Q8fCzfS6x2unQ7P62JrzBs9QJu5FbYm7W3KbWi6MLWI0aGWd6qCNImcOyF3Twk3pMI2DGzcxdDOWqgnfCsOkHNqgZoca//A7+EQE3e+6sdyBfUA7UT7eUJQXp+zKY5n8eK8sCZkQ5D+L25b5j2Qe6GxQbMVp9Ym1gQ7Q/SE5D7NAzkT5bZQYUfS/oSdnYXFAl3jAdqHvj7wiGO7SpP9oq5xYq2heOaPabzjkWcMZdoSMJE7PfyZh87NirTFltq6SjpG4cHwuGaKe17T94H6JclslkaZaeE3PGWq2GHN8OO17vUAbWOrDO2qUVENS+ofwJhTW3q9aa3AaP3Tgz3S5nfM92cmT950LGOVfTeALP+hw0fg6WujRaSdUEoT9tb0/6i/rz1A96NMlgfl0bTLUG3Sw5xYpAgeoE30RY+jA+jye9r5mAC4xYbEodbj4kBOII3jzt0O65HbD35xghZ2f25phy1pZGLic3Zm9iB9yJHzsl/KqNf/Xg+K/4E+ALhJGvtjnu7wAO1hd//m1LDkK1yZIpQHC93zx+hQk7FH8TR9JZRTW+D+iOvztcjjevkh1wJ55Kfhrowc/Y8DazqV+vNZ4aT2ZLGyS728M7BPv5G63AO0Ay220G5ea/oV7fxLa9DC4+HQtWBrGg3glXBbHnrInQoO8WGzrYpYodh6CmxNemtzHrahjFWvv9Yer2WmRayrqJO/B2gQ+9U2CqPjB8EJMVzaY2hbgmCP9OYHIXr92lm7A09T7QptBx2AUOsPm30B5s3tMKaZTBquekPbNcvjee1c6s9nrsaq11+r9g61J/G4+zxAO9ewzCEBLD+Kdj4+AG6xIXHoXLDGVa3p1HZZjiFzw9YrfOSfv7fLpmZy0SvEyge1iQWayU26RpkQvX5gx8d/G5nk8C5Kow3sr4ZgTC+BF7xjHlyAZzv4CeWsx1P1XYzjPPWxKPYXQCxX+FR1Oq16ULDfEGvi/0VvyCfghuj1y92DuEmDvpoXrE6jOjUeoO7V6zf71k4N9MG083aNTtSokfOhHAq/C1vTCTmb0iMOQza2NqaC90iPkAIdoNsscIgvGi7taiZ6hOr1V6pgwjfbXdWK+TvAAzSAEGP9ub3JF7Hnrw+AzWjcNt4G77fGmKngaCAa+1avPwQVtdevsfDJjA3WB9ye8MAM1euvqmKxeqiKFX9L4gHua/3r1F8aq7srbXx3Y8zywOHUx2Br2q1dHsCQg62NqeDpw2NTt8uuZnLR69EANq/ZTGbSNXQI3euXmdYT+EmmxLSCeYB630uVb0jayWs91F0wrzVRB+NXN3RmFeoRDtoyLovcWeGPq4oY/+7fxJVtu4SNSxrbKbgHfQyi3DEBdKmF1GcrrN9wfEyNZXL0AHWujZqjYEsy+yctaV1RtGGfEN/s/wWvUu1aMvV7KmLatJXhkG8Uedu2cqmFnru2uO5z+U+uhbgr16JMiMm4WlWeoW1p+XCk7vKAFjPMY2zyxcZ45YHjZp0d/sryUQrWte3yALKXg0N9jbSQ68uxd3L4bdiStOzN6XWY/DPC+vBbaDq8Xe0rym2PB2hQk8HWn2d5C0zNIeRKRer5743lzl9pbOGto1tcD3KZipwS4PPgEP59FNyLgiieHVT/Ecv6v4rpA27fOqqmJb1BvoRYp8fwuvN42vke0MbF+YzNPJs2rqXo3UcES42hWX/24LZ2eRJbzoRD0dB22dVKLgZfb2y0/uG786Q2ZZ4w1iMJrpDfU2pVR/F6Ng/QEPTZBUvS6MDc2bTyKx2iZ+qjyZYUsl41cayPIlnLUJHbgvGjrDgNyl9ND6Fwn3KQrtg9mJ/1Gujtm3wa9n7mUVibb0LT+aEFRPxieYA2vgoarWis1XW08VeMMVPBFSX4W0/0Pof1N6bygGEmGodeB88whKyF+oiTfWoTCnas5bSW7UmvwSd52vi+Z7m0xZ4kY1En3NPaEPO5eyDECrvT3dWwKWF5s3ppRMBchoKreRVuXOhknqbjG1+2v4Id+r68lmvpNwQdiE2F/KcO2K52tLux0Rdg7xuemArOoUire7QZx+cfyYTSKeIG9gBtXHNIGqGwpFcBa9uilLYHf4y37vV/Aua5ljXUCouGoZn6y+ClWuX1vH4DwSa3bd8eOmq4R8M+VjQOoCzfYbrPSpEEnGOoi8cS0mNSZ3tA3xuz3tNxFm3JdTFDZ3iZoDkQ/hy2pFDDLolOR3H90+YLLA2ow9ImsbkShRckEf0urdM562mmNc8Inwb+JKsSCeUfJ816RVpBajGq0cgD1Lm+N6Yd9Zakb1/N0UhmHunt7vnvgZFaFmlJZ1uCpcD6A3l+mCKfb5aD6B3o9bCQRAOeDcU2MVbu+Cx4+OtTyl+YBSOh7Aek7Qh2HO5JcE6HJ+2AfTMZ2ziCtvS6MWY54Agak8LWmyWeytN69N8XDklX5WmPjyLine truncated
|
||||||
|
alt="Blink"
|
||||||
|
width="383"
|
||||||
|
height="170"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<svg style="width: 0; height: 0; position: absolute" aria-hidden="true" focusable="false">
|
<svg style="width: 0; height: 0; position: absolute" aria-hidden="true" focusable="false">
|
||||||
|
|||||||
+75
-64
@@ -1,90 +1,101 @@
|
|||||||
{
|
{
|
||||||
"name": "blink",
|
"name": "blink",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0-alpha.3",
|
"version": "1.0.0-alpha.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --force && tsr watch",
|
"dev": "vite && tsr watch",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
|
"tauri:dev:mcp": "tauri dev -c src-tauri/tauri.mcp.conf.json -- --features mcp-bridge",
|
||||||
"lint": "biome check src/**/*",
|
"lint": "biome check src/**/*",
|
||||||
"lint:fix": "biome check --apply src/**/*",
|
"lint:fix": "biome check --apply src/**/*",
|
||||||
"tanstack-router-dev": "tsr watch"
|
"tanstack-router-dev": "tsr watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.2.0",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/modifiers": "^8.0.0",
|
"@dnd-kit/modifiers": "^9.0.0",
|
||||||
"@dnd-kit/sortable": "^9.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.13.5",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.13.5",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.1.1",
|
"@fontsource-variable/caveat": "^5.3.0",
|
||||||
"@fontsource-variable/noto-sans": "^5.1.0",
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
||||||
"@fontsource-variable/plus-jakarta-sans": "^5.1.0",
|
"@fontsource-variable/noto-sans": "^5.3.0",
|
||||||
"@fontsource-variable/space-grotesk": "^5.1.0",
|
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
||||||
"@jellyfin/sdk": "0.11.0",
|
"@fontsource-variable/space-grotesk": "^5.3.0",
|
||||||
"@million/lint": "^1.0.13",
|
"@jellyfin/sdk": "1.0.1",
|
||||||
"@mui/lab": "6.0.0-beta.17",
|
"@mui/lab": "9.0.0-beta.10",
|
||||||
"@mui/material": "6.1.9",
|
"@mui/material": "9.5.0",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@react-spring/web": "^9.7.5",
|
"@react-spring/web": "^10.1.2",
|
||||||
"@tanem/react-nprogress": "^5.0.53",
|
"@tanem/react-nprogress": "^7.1.7",
|
||||||
"@tanstack/react-query": "^5.62.0",
|
"@tanstack/react-form": "^1.33.5",
|
||||||
"@tanstack/react-query-devtools": "^5.62.0",
|
"@tanstack/react-query": "^5.104.4",
|
||||||
"@tanstack/react-router": "^1.85.0",
|
"@tanstack/react-router": "^1.170.45",
|
||||||
"@tanstack/react-virtual": "^3.10.9",
|
"@tanstack/react-virtual": "^3.14.21",
|
||||||
"@tauri-apps/api": "2.1.1",
|
"@tauri-apps/api": "2.12.4",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.6",
|
"@tauri-apps/plugin-clipboard-manager": "2.5.0",
|
||||||
"@tauri-apps/plugin-dialog": "2.0.1",
|
"@tauri-apps/plugin-deep-link": "2.6.3",
|
||||||
"@tauri-apps/plugin-notification": "2.0.0",
|
"@tauri-apps/plugin-dialog": "2.8.3",
|
||||||
"@tauri-apps/plugin-process": "2.0.0",
|
"@tauri-apps/plugin-global-shortcut": "~2.4.1",
|
||||||
|
"@tauri-apps/plugin-notification": "2.7.0",
|
||||||
|
"@tauri-apps/plugin-process": "2.4.0",
|
||||||
|
"@tauri-apps/plugin-shell": "~2.5.0",
|
||||||
"@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.14.0",
|
||||||
"@tauri-apps/plugin-upload": "2.1.0",
|
"@tauri-apps/plugin-upload": "2.5.0",
|
||||||
"@types/node": "^22.10.1",
|
"@tauri-apps/plugin-websocket": "2.5.0",
|
||||||
"@types/react": "^18.3.12",
|
"@tauri-apps/plugin-window-state": "~2.5.0",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/node": "^26.6.5",
|
||||||
"axios": "^1.7.8",
|
"@types/react": "^19.3.0",
|
||||||
"axios-tauri-api-adapter": "^2.0.3",
|
"@types/react-dom": "^19.3.0",
|
||||||
|
"axios": "^1.20.0",
|
||||||
|
"axios-tauri-api-adapter": "^2.0.6",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"framer-motion": "^11.12.0",
|
"blurhash-wasm": "^0.2.0",
|
||||||
"immer": "^10.1.1",
|
"immer": "^11.1.21",
|
||||||
"jassub": "^1.7.17",
|
"jassub": "^2.5.22",
|
||||||
"lodash": "^4.17.21",
|
"libpgs": "^0.9.0",
|
||||||
"material-symbols": "^0.27.1",
|
"lodash": "^4.18.1",
|
||||||
"million": "^3.1.11",
|
"material-symbols": "^0.48.0",
|
||||||
"notistack": "^3.0.1",
|
"motion": "^14.4.0",
|
||||||
"react": "18.3.1",
|
"notistack": "^3.0.2",
|
||||||
|
"qrcode": "^1.5.4",
|
||||||
|
"react": "^19.3.1",
|
||||||
"react-blurhash": "^0.3.0",
|
"react-blurhash": "^0.3.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "^19.3.1",
|
||||||
"react-error-boundary": "^4.1.2",
|
"react-error-boundary": "^6.1.6",
|
||||||
"react-intersection-observer": "^9.13.1",
|
"react-intersection-observer": "^11.0.1",
|
||||||
"react-markdown": "^9.0.1",
|
"react-markdown": "^10.1.0",
|
||||||
"react-multi-carousel": "^2.8.5",
|
"react-multi-carousel": "^2.8.6",
|
||||||
"react-player": "^2.16.0",
|
"react-player": "^3.4.0",
|
||||||
"react-popper": "^2.3.0",
|
"remark-gfm": "^4.0.1",
|
||||||
"react-use-konami": "^1.1.0",
|
"typescript": "^7.0.2",
|
||||||
"remark-gfm": "^4.0.0",
|
"vite-plugin-svgr": "^5.2.0",
|
||||||
"typescript": "^5.7.2",
|
"vite-plugin-top-level-await": "^1.6.0",
|
||||||
"vite-plugin-svgr": "^4.3.0",
|
"wavesurfer.js": "^8.0.3",
|
||||||
"wavesurfer.js": "^7.8.10",
|
"zod": "^4.6.7",
|
||||||
"zustand": "5.0.1"
|
"zustand": "5.0.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.25.9",
|
"@babel/plugin-proposal-optional-chaining-assign": "^8.0.1",
|
||||||
"@biomejs/biome": "^1.9.4",
|
"@biomejs/biome": "^2.5.15",
|
||||||
"@tanstack/router-cli": "^1.84.4",
|
"@tanstack/router-cli": "^1.167.45",
|
||||||
"@tanstack/router-devtools": "^1.85.0",
|
"@tanstack/router-vite-plugin": "^1.167.47",
|
||||||
"@tanstack/router-vite-plugin": "^1.84.4",
|
"@tauri-apps/cli": "2.12.3",
|
||||||
"@tauri-apps/cli": "2.1.0",
|
"@types/lodash": "^4.17.26",
|
||||||
"@types/lodash": "^4.17.13",
|
"@types/qrcode": "^1.5.6",
|
||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^6.1.2",
|
||||||
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
||||||
|
"eslint-plugin-react-hooks": "7.1.1",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"sass": "^1.81.0",
|
"sass": "^1.105.2",
|
||||||
"vite": "^6.0.2"
|
"vite": "^8.3.4",
|
||||||
|
"vite-plugin-wasm": "^3.6.0"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only"
|
"license": "GPL-3.0-only"
|
||||||
}
|
}
|
||||||
Generated
+3818
-3717
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,5 @@
|
|||||||
|
allowBuilds:
|
||||||
|
'@parcel/watcher': true
|
||||||
|
'@swc/core': true
|
||||||
|
core-js: true
|
||||||
|
lfa-ponyfill: true
|
||||||
Generated
+2706
-2186
File diff suppressed because it is too large.
Load diff
+13
-4
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "blink"
|
name = "blink"
|
||||||
version = "1.0.0-alpha.3"
|
version = "1.0.0-alpha.4"
|
||||||
description = "A Modern Jellyfin Client"
|
description = "A Modern Jellyfin Client"
|
||||||
authors = ["prayag17", "Blink contributors (https://github.com/prayag17/Blink/graphs/contributors)"]
|
authors = ["prayag17", "Blink contributors (https://github.com/prayag17/Blink/graphs/contributors)"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
@@ -12,17 +12,16 @@ rust-version = "1.59"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
tauri-build = { version = "2.5.4", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "^0.4.21"
|
log = "^0.4.21"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tauri = { version = "2.0.0-beta", features = [ "devtools"] }
|
tauri = { version = "2.10.1", features = [ "devtools"] }
|
||||||
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2", features = ["colored"] }
|
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2", features = ["colored"] }
|
||||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
|
||||||
portpicker = "0.1" # used in the example to pick a random free port
|
portpicker = "0.1" # used in the example to pick a random free port
|
||||||
tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
@@ -30,11 +29,21 @@ tauri-plugin-clipboard-manager = "2.1.0-beta.6"
|
|||||||
tauri-plugin-notification = "2.0.0-rc.1"
|
tauri-plugin-notification = "2.0.0-rc.1"
|
||||||
tauri-plugin-upload = "2.0.0"
|
tauri-plugin-upload = "2.0.0"
|
||||||
tauri-plugin-dialog = "2.0.0"
|
tauri-plugin-dialog = "2.0.0"
|
||||||
|
tauri-plugin-shell = "2.3.5"
|
||||||
|
tauri-plugin-websocket = "2.5.0"
|
||||||
|
tauri-plugin-deep-link = "2.6.3"
|
||||||
|
tauri-plugin-mcp-bridge = { version = "0.13.2", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||||
default = [ "custom-protocol" ]
|
default = [ "custom-protocol" ]
|
||||||
|
# Dev-only MCP bridge for UI automation: `pnpm tauri dev -- --features mcp-bridge`
|
||||||
|
mcp-bridge = ["dep:tauri-plugin-mcp-bridge"]
|
||||||
# this feature is used for production builds where `devPath` points to the filesystem
|
# this feature is used for production builds where `devPath` points to the filesystem
|
||||||
# DO NOT remove this
|
# DO NOT remove this
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
|
|
||||||
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
|
tauri-plugin-global-shortcut = "2"
|
||||||
|
tauri-plugin-window-state = "2"
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"identifier": "desktop-capability",
|
||||||
|
"platforms": [
|
||||||
|
"macOS",
|
||||||
|
"windows",
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"windows": [
|
||||||
|
"main"
|
||||||
|
],
|
||||||
|
"permissions": [
|
||||||
|
"window-state:default",
|
||||||
|
"global-shortcut:default",
|
||||||
|
"global-shortcut:allow-is-registered",
|
||||||
|
"global-shortcut:allow-register",
|
||||||
|
"global-shortcut:allow-unregister",
|
||||||
|
"websocket:default",
|
||||||
|
"shell:default"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -13,10 +13,24 @@
|
|||||||
"store:allow-load",
|
"store:allow-load",
|
||||||
"updater:allow-check",
|
"updater:allow-check",
|
||||||
"updater:allow-download-and-install",
|
"updater:allow-download-and-install",
|
||||||
|
"updater:allow-download",
|
||||||
|
"updater:allow-install",
|
||||||
"notification:default",
|
"notification:default",
|
||||||
"core:webview:allow-internal-toggle-devtools",
|
"core:webview:allow-internal-toggle-devtools",
|
||||||
|
"core:window:allow-start-dragging",
|
||||||
|
"core:window:allow-start-resize-dragging",
|
||||||
|
"core:window:allow-minimize",
|
||||||
|
"core:window:allow-maximize",
|
||||||
|
"core:window:allow-unmaximize",
|
||||||
|
"core:window:allow-toggle-maximize",
|
||||||
|
"core:window:allow-close",
|
||||||
|
"core:window:allow-is-maximized",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"upload:allow-download",
|
"upload:allow-download",
|
||||||
"clipboard-manager:allow-write-text"
|
"clipboard-manager:allow-write-text",
|
||||||
|
"websocket:default",
|
||||||
|
"deep-link:default",
|
||||||
|
"shell:default",
|
||||||
|
"shell:allow-open"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
"identifier": "mcp-bridge-capability",
|
||||||
|
"description": "Dev-only permissions for the Tauri MCP bridge (AI debugging). Enabled only by tauri.mcp.conf.json.",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": ["mcp-bridge:default"]
|
||||||
|
}
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "migrated",
|
"identifier": "migrated",
|
||||||
"description": "permissions that were migrated from v1",
|
"description": "permissions that were migrated from v1",
|
||||||
"local": true,
|
"local": true,
|
||||||
"windows": ["main"],
|
"windows": [
|
||||||
"permissions": [
|
"main"
|
||||||
"core:path:default",
|
],
|
||||||
"core:event:default",
|
"permissions": [
|
||||||
"core:window:default",
|
"core:path:default",
|
||||||
"core:app:default",
|
"core:event:default",
|
||||||
"core:resources:default",
|
"core:window:default",
|
||||||
"core:menu:default",
|
"core:app:default",
|
||||||
"core:tray:default",
|
"core:resources:default",
|
||||||
"core:window:allow-set-fullscreen"
|
"core:menu:default",
|
||||||
]
|
"core:tray:default",
|
||||||
|
"core:window:allow-set-fullscreen",
|
||||||
|
"shell:default"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set which includes:\n- 'core:path:default'\n- 'core:event:default'\n- 'core:window:default'\n- 'core:webview:default'\n- 'core:app:default'\n- 'core:image:default'\n- 'core:resources:default'\n- 'core:menu:default'\n- 'core:tray:default'\n","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_winLine truncated
|
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
||||||
@@ -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","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"]}}
|
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default","global-shortcut:default","global-shortcut:allow-is-registered","global-shortcut:allow-register","global-shortcut:allow-unregister","websocket:default","shell:default"],"platforms":["macOS","windows","linux"]},"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","updater:allow-download","updater:allow-install","notification:default","core:webview:allow-internal-toggle-devtools","core:window:allow-start-dragging","core:window:allow-start-resize-dragging","core:window:allow-minimize","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-toggle-maximize","core:window:allow-close","core:window:allow-is-maximized","dialog:default","upload:allow-download","clipboard-manager:allow-write-text","websocket:default","deep-link:default","shell:default","shell:allow-open"]},"mcp-bridge-capability":{"identifier":"mcp-bridge-capability","description":"Dev-only permissions for the Tauri MCP bridge (AI debugging). Enabled only by tauri.mcp.conf.json.","local":true,"windows":["main"],"permissions":["mcp-bridge:default"]},"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","shell:default"]}}
|
||||||
+2971
-1802
File diff suppressed because it is too large.
Load diff
+2971
-1802
File diff suppressed because it is too large.
Load diff
+28
-1
@@ -3,11 +3,38 @@
|
|||||||
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
let builder = tauri::Builder::default();
|
||||||
|
|
||||||
|
// Dev-only MCP bridge: `pnpm tauri dev -- --features mcp-bridge`.
|
||||||
|
#[cfg(all(debug_assertions, feature = "mcp-bridge"))]
|
||||||
|
let builder = builder.plugin(
|
||||||
|
tauri_plugin_mcp_bridge::Builder::new()
|
||||||
|
.bind_address("127.0.0.1")
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
|
builder
|
||||||
|
.setup(|_app| {
|
||||||
|
// Frameless window outside macOS. macOS uses the native overlay
|
||||||
|
// titlebar with its traffic lights.
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
use tauri::Manager;
|
||||||
|
if let Some(window) = _app.get_webview_window("main") {
|
||||||
|
window.set_decorations(false)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.plugin(tauri_plugin_shell::init())
|
||||||
|
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||||
|
.plugin(tauri_plugin_window_state::Builder::new().build())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
.plugin(tauri_plugin_upload::init())
|
.plugin(tauri_plugin_upload::init())
|
||||||
.plugin(tauri_plugin_notification::init())
|
.plugin(tauri_plugin_notification::init())
|
||||||
.plugin(tauri_plugin_clipboard_manager::init())
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
|
.plugin(tauri_plugin_websocket::init())
|
||||||
|
.plugin(tauri_plugin_deep_link::init())
|
||||||
.plugin(
|
.plugin(
|
||||||
tauri_plugin_log::Builder::default()
|
tauri_plugin_log::Builder::default()
|
||||||
.targets([Target::new(TargetKind::Webview)])
|
.targets([Target::new(TargetKind::Webview)])
|
||||||
|
|||||||
@@ -54,15 +54,19 @@
|
|||||||
"version": "../package.json",
|
"version": "../package.json",
|
||||||
"identifier": "com.blink.prayag17",
|
"identifier": "com.blink.prayag17",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
|
"deep-link": {
|
||||||
|
"desktop": {
|
||||||
|
"schemes": ["blink"]
|
||||||
|
}
|
||||||
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZEMTg0MjEzRDYzRjJDN0EKUldSNkxEL1dFMElZL1dxbHA0V2lyVDFEdGpOZXkxMG9XdHVLVnRpVVV5c1Z0OFNRUE45dkpxbFAK",
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
||||||
"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": {
|
"windows": {
|
||||||
"installMode": "passive"
|
"installMode": "passive"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
@@ -77,11 +81,20 @@
|
|||||||
"center": true,
|
"center": true,
|
||||||
"label": "main",
|
"label": "main",
|
||||||
"dragDropEnabled": false,
|
"dragDropEnabled": false,
|
||||||
"backgroundColor": "#08001f"
|
"backgroundColor": "#08001f",
|
||||||
|
"transparent": false,
|
||||||
|
"titleBarStyle": "Overlay",
|
||||||
|
"hiddenTitle": true,
|
||||||
|
"trafficLightPosition": { "x": 18, "y": 31 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null,
|
||||||
|
"capabilities": [
|
||||||
|
"desktop-capability",
|
||||||
|
"main-capabilities",
|
||||||
|
"migrated"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"withGlobalTauri": true,
|
||||||
|
"security": {
|
||||||
|
"capabilities": [
|
||||||
|
"desktop-capability",
|
||||||
|
"main-capabilities",
|
||||||
|
"migrated",
|
||||||
|
"mcp-bridge-capability"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -1,17 +1,17 @@
|
|||||||
import { setServer } from "@/utils/storage/servers";
|
|
||||||
import { jellyfin } from "@/utils/store/api";
|
|
||||||
import { LoadingButton } from "@mui/lab";
|
import { LoadingButton } from "@mui/lab";
|
||||||
import {
|
import {
|
||||||
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogActions,
|
InputBase,
|
||||||
DialogContent,
|
Stack,
|
||||||
DialogTitle,
|
Typography,
|
||||||
TextField,
|
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { enqueueSnackbar } from "notistack";
|
import { enqueueSnackbar } from "notistack";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { setServer } from "@/utils/storage/servers";
|
||||||
|
import { jellyfin } from "@/utils/store/api";
|
||||||
|
|
||||||
type AddServerDialogProps = {
|
type AddServerDialogProps = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -37,7 +37,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
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.",
|
"Сервер добавлен. Возможно, потребуется обновить список серверов.",
|
||||||
{
|
{
|
||||||
variant: "success",
|
variant: "success",
|
||||||
},
|
},
|
||||||
@@ -50,11 +50,11 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
enqueueSnackbar(`${err}`, { variant: "error" });
|
enqueueSnackbar(`${err}`, { variant: "error" });
|
||||||
enqueueSnackbar("Something went wrong", { variant: "error" });
|
enqueueSnackbar("Что-то пошло не так", { variant: "error" });
|
||||||
},
|
},
|
||||||
onSettled: async (bestServer) => {
|
onSettled: async (bestServer) => {
|
||||||
if (!bestServer) {
|
if (!bestServer) {
|
||||||
enqueueSnackbar("Provided server address is not a Jellyfin server.", {
|
enqueueSnackbar("Указанный адрес не является сервером Jellyfin.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -64,72 +64,130 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open}
|
open={open}
|
||||||
|
onClose={() => setAddServerDialog(false)}
|
||||||
hideBackdrop={Boolean(hideBackdrop)}
|
hideBackdrop={Boolean(hideBackdrop)}
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="sm"
|
maxWidth="sm"
|
||||||
disableScrollLock={true}
|
disableScrollLock={true}
|
||||||
|
slotProps={{
|
||||||
|
paper: {
|
||||||
|
sx: {
|
||||||
|
backgroundColor: "rgba(20, 20, 30, 0.7)",
|
||||||
|
backdropFilter: "blur(24px) saturate(180%)",
|
||||||
|
backgroundImage:
|
||||||
|
"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))",
|
||||||
|
border: "1px solid rgba(255, 255, 255, 0.08)",
|
||||||
|
boxShadow: "0 20px 50px rgba(0,0,0,0.5)",
|
||||||
|
borderRadius: 4,
|
||||||
|
overflow: "hidden",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<DialogTitle variant="h4" align="center" mb={1}>
|
<Stack
|
||||||
Add Server
|
spacing={3}
|
||||||
</DialogTitle>
|
sx={{
|
||||||
<DialogContent className="settings-server-add">
|
p: 4,
|
||||||
<TextField
|
|
||||||
variant="filled"
|
|
||||||
label="Address"
|
|
||||||
fullWidth
|
|
||||||
onChange={(e) => setServerIp(e.target.value)}
|
|
||||||
/>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions
|
|
||||||
style={{
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
padding: "1em",
|
|
||||||
gap: "1em",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Stack
|
||||||
variant="contained"
|
spacing={1}
|
||||||
startIcon={
|
sx={{
|
||||||
<span
|
alignItems: "center",
|
||||||
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
|
<span
|
||||||
</Button>
|
className="material-symbols-rounded"
|
||||||
{/* @ts-ignore */}
|
style={{
|
||||||
<LoadingButton
|
fontSize: "48px",
|
||||||
startIcon={
|
color: "var(--mui-palette-primary-main)",
|
||||||
<span
|
}}
|
||||||
className="material-symbols-rounded"
|
>
|
||||||
style={{
|
add_to_queue
|
||||||
marginRight: "0.25em",
|
</span>
|
||||||
fontVariationSettings:
|
<Typography
|
||||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
variant="h5"
|
||||||
}}
|
sx={{
|
||||||
>
|
fontWeight: "bold",
|
||||||
add_circle
|
textAlign: "center",
|
||||||
</span>
|
}}
|
||||||
}
|
>
|
||||||
variant="contained"
|
Подключиться к серверу
|
||||||
loading={addServer.isPending}
|
</Typography>
|
||||||
loadingPosition="start"
|
<Typography
|
||||||
onClick={addServer.mutate}
|
variant="body2"
|
||||||
color="success"
|
sx={{
|
||||||
|
color: "text.secondary",
|
||||||
|
textAlign: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Введите адрес сервера Jellyfin, чтобы продолжить
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: "2px 16px",
|
||||||
|
bgcolor: "rgba(0,0,0,0.2)",
|
||||||
|
borderRadius: 2,
|
||||||
|
border: "1px solid",
|
||||||
|
borderColor: "rgba(255,255,255,0.05)",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 2,
|
||||||
|
"&:focus-within": {
|
||||||
|
borderColor: "var(--mui-palette-primary-main)",
|
||||||
|
bgcolor: "rgba(0,0,0,0.3)",
|
||||||
|
},
|
||||||
|
transition: "border-color 0.2s, background-color 0.2s",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Add
|
<span className="material-symbols-rounded" style={{ opacity: 0.5 }}>
|
||||||
</LoadingButton>
|
dns
|
||||||
</DialogActions>
|
</span>
|
||||||
|
<InputBase
|
||||||
|
placeholder="https://jellyfin.example.com"
|
||||||
|
fullWidth
|
||||||
|
value={serverIp}
|
||||||
|
onChange={(e) => setServerIp(e.target.value)}
|
||||||
|
sx={{ py: 1.5 }}
|
||||||
|
autoFocus
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
addServer.mutate();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
pt: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={() => setAddServerDialog(false)}
|
||||||
|
color="inherit"
|
||||||
|
variant="text"
|
||||||
|
sx={{ borderRadius: 2 }}
|
||||||
|
>
|
||||||
|
Отмена
|
||||||
|
</Button>
|
||||||
|
<LoadingButton
|
||||||
|
loading={addServer.isPending}
|
||||||
|
onClick={() => addServer.mutate()}
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
sx={{ borderRadius: 2, px: 3 }}
|
||||||
|
disabled={!serverIp}
|
||||||
|
>
|
||||||
|
Подключиться
|
||||||
|
</LoadingButton>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,60 +1,111 @@
|
|||||||
.item-info-track{
|
.album-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 3em 60% 6em 1fr;
|
grid-template-columns: 2.4em minmax(0, 1fr) 4.5em 2.6em;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
padding: 1em;
|
align-items: center;
|
||||||
align-items: center;
|
padding: 0.5em 1em;
|
||||||
cursor: pointer;
|
border-radius: 8px;
|
||||||
border-radius: $border-radius-default;
|
cursor: pointer;
|
||||||
transition: background $transition-time-fast;
|
transition: background $transition-time-fast;
|
||||||
&.header {
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
&-index {
|
||||||
color: rgb(255 255 255 / 0.7);
|
position: relative;
|
||||||
border-radius: 0 !important;
|
display: grid;
|
||||||
}
|
place-items: center;
|
||||||
.index-container {
|
}
|
||||||
justify-self: center;
|
|
||||||
position: relative;
|
&-number {
|
||||||
.material-symbols-rounded {
|
font-size: 0.8rem;
|
||||||
position: absolute;
|
color: rgb(255 255 255 / 0.4);
|
||||||
top: 50%;
|
font-variant-numeric: tabular-nums;
|
||||||
left: 50%;
|
}
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
font-size: 2em !important;
|
&-play {
|
||||||
opacity: 0;
|
position: absolute;
|
||||||
transition: none !important;
|
top: 50%;
|
||||||
color: $clr-accent-default;
|
left: 50%;
|
||||||
}
|
transform: translate(-50%, -50%) scale(0.9);
|
||||||
}
|
opacity: 0;
|
||||||
&-info {
|
font-size: 1.4rem;
|
||||||
display: flex;
|
color: #fff;
|
||||||
flex-direction: column;
|
transition: opacity $transition-time-fast, transform $transition-time-fast;
|
||||||
gap: 0.1em
|
}
|
||||||
}
|
|
||||||
&:hover {
|
&-info {
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
display: flex;
|
||||||
.index-container {
|
flex-direction: column;
|
||||||
// font-size: 0em;
|
gap: 0.15em;
|
||||||
.index {
|
min-width: 0;
|
||||||
opacity: 0;
|
}
|
||||||
transition: opacity 0;
|
|
||||||
}
|
&-name {
|
||||||
.material-symbols-rounded {
|
font-size: 0.95rem;
|
||||||
opacity: 1;
|
color: rgb(255 255 255 / 0.92);
|
||||||
font-size: 2.2em !important;
|
white-space: nowrap;
|
||||||
}
|
overflow: hidden;
|
||||||
}
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
&.playing {
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
&-artist {
|
||||||
.item-info-track-info-name, .index {
|
display: flex;
|
||||||
color: $clr-accent-default;
|
align-items: center;
|
||||||
font-weight: 600;
|
gap: 0.5em;
|
||||||
}
|
font-size: 0.78rem;
|
||||||
}
|
color: rgb(255 255 255 / 0.45);
|
||||||
&-container {
|
|
||||||
display: flex;
|
img {
|
||||||
flex-direction: column;
|
width: 1em;
|
||||||
gap: 0.4em
|
height: 1em;
|
||||||
}
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-duration {
|
||||||
|
text-align: right;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: rgb(255 255 255 / 0.45);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-like {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-fast;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
|
||||||
|
.album-track-number {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-track-play {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translate(-50%, -50%) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-track-like {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-playing {
|
||||||
|
background: rgb(245 25 107 / 0.1);
|
||||||
|
|
||||||
|
.album-track-name,
|
||||||
|
.album-track-number,
|
||||||
|
.album-track-duration {
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-track-like {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,19 @@
|
|||||||
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
BaseItemDtoQueryResult,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import React from "react";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||||
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
import {
|
import {
|
||||||
generateAudioStreamUrl,
|
generateAudioStreamUrl,
|
||||||
playAudio,
|
playAudio,
|
||||||
useAudioPlayback,
|
useAudioPlayback,
|
||||||
} from "@/utils/store/audioPlayback";
|
} 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 { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { setQueue } from "@/utils/store/queue";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
|
||||||
import "./albumMusicTrack.scss";
|
import "./albumMusicTrack.scss";
|
||||||
@@ -45,7 +43,7 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
) => {
|
) => {
|
||||||
if (!user?.Id || !api) {
|
if (!user?.Id || !api) {
|
||||||
console.error("User not logged in");
|
console.error("User not logged in");
|
||||||
enqueueSnackbar("You need to be logged in to play music", {
|
enqueueSnackbar("Войдите, чтобы слушать музыку", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -62,44 +60,42 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
setQueue(queue, index);
|
setQueue(queue, index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isPlaying = currentPlayingItem?.Id === track.Id;
|
||||||
|
const artists = track.Artists?.filter(Boolean) ?? [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={
|
className={isPlaying ? "album-track is-playing" : "album-track"}
|
||||||
currentPlayingItem?.Id === track.Id
|
|
||||||
? "item-info-track playing"
|
|
||||||
: "item-info-track"
|
|
||||||
}
|
|
||||||
key={track.Id}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (musicTracks?.Items) {
|
if (musicTracks?.Items) {
|
||||||
handlePlayback(trackIndex, track, musicTracks.Items);
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="index-container">
|
<div className="album-track-index">
|
||||||
<span className="material-symbols-rounded fill ">play_arrow</span>
|
<span className="material-symbols-rounded album-track-play">
|
||||||
<Typography className="index">{track.IndexNumber ?? "-"}</Typography>
|
play_arrow
|
||||||
|
</span>
|
||||||
|
<span className="album-track-number">
|
||||||
|
{track.IndexNumber ?? "–"}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="item-info-track-info">
|
<div className="album-track-info">
|
||||||
<Typography className="item-info-track-info-name">
|
<span className="album-track-name">{track.Name}</span>
|
||||||
{track.Name}
|
{(artists.length > 0 || track.HasLyrics) && (
|
||||||
</Typography>
|
<span className="album-track-artist">
|
||||||
<Typography
|
{track.HasLyrics && (
|
||||||
variant="subtitle2"
|
<img src={lyricsIcon} alt="Есть текст песни" />
|
||||||
style={{
|
)}
|
||||||
opacity: 0.6,
|
{artists.join(", ")}
|
||||||
display: "flex",
|
</span>
|
||||||
alignItems: "center",
|
)}
|
||||||
gap: "0.6em",
|
|
||||||
}}
|
|
||||||
fontWeight={300}
|
|
||||||
>
|
|
||||||
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
|
||||||
{track.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
</div>
|
||||||
<Typography>{getRuntimeMusic(track.RunTimeTicks ?? 0)}</Typography>
|
<span className="album-track-duration">
|
||||||
<div className="flex flex-align-center">
|
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
||||||
|
</span>
|
||||||
|
<div className="album-track-like" onClick={(e) => e.stopPropagation()}>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={track.Id}
|
itemId={track.Id}
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
.alpha-selector {
|
||||||
|
position: sticky;
|
||||||
|
top: 80px;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
margin-left: auto;
|
||||||
|
user-select: none;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alpha-letter {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(255,255,255,0.7);
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alpha-letter.active {
|
||||||
|
background: rgba(255,255,255,0.12);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alpha-letter:hover {
|
||||||
|
background: rgba(255,255,255,0.08);
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { getRouteApi } from "@tanstack/react-router";
|
||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
|
import "./alphaSelector.scss";
|
||||||
|
|
||||||
|
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||||
|
|
||||||
|
export const AlphaSelector = React.memo(function AlphaSelector() {
|
||||||
|
const { id: currentLibraryId } = libraryRoute.useParams();
|
||||||
|
const { nameStartsWith } = useLibraryStateStore(
|
||||||
|
useShallow((s) => ({
|
||||||
|
nameStartsWith: s.libraries[currentLibraryId || ""]?.nameStartsWith,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||||
|
|
||||||
|
const letters = useMemo(() => {
|
||||||
|
const arr = Array.from({ length: 26 }, (_, i) =>
|
||||||
|
String.fromCharCode(65 + i),
|
||||||
|
);
|
||||||
|
return ["Все", ...arr];
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSelect = (letter: string) => {
|
||||||
|
const value = letter === "Все" ? undefined : letter;
|
||||||
|
if (currentLibraryId)
|
||||||
|
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="alpha-selector">
|
||||||
|
{letters.map((l) => {
|
||||||
|
const active = (nameStartsWith || "Все") === l;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={l}
|
||||||
|
className={active ? "alpha-letter active" : "alpha-letter"}
|
||||||
|
onClick={() => handleSelect(l)}
|
||||||
|
aria-label={`Фильтр по букве ${l}`}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{l}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default AlphaSelector;
|
||||||
@@ -1,22 +1,52 @@
|
|||||||
|
|
||||||
.appBar {
|
.appBar {
|
||||||
transition: background-color $transition-time-fast,
|
// Custom titlebar: the app header itself sits at the very top of the window,
|
||||||
backdrop-filter $transition-time-fast,
|
// under the native overlay titlebar (no native glass strip, no blur panels).
|
||||||
box-shadow $transition-time-default !important;
|
transition: background-color $transition-time-fast;
|
||||||
padding: 0.8em ($page-margin - 1.7em);
|
// Same vertical rhythm as the home page header so every page's controls
|
||||||
|
// sit on one consistent level.
|
||||||
|
padding: 1.3rem ($page-margin - 1.7em);
|
||||||
z-index: 999 !important;
|
z-index: 999 !important;
|
||||||
|
top: 0 !important;
|
||||||
|
|
||||||
|
// Keep the left controls clear of the macOS traffic lights and put the
|
||||||
|
// header row on the same level as them.
|
||||||
|
html.is-macos & {
|
||||||
|
padding-top: 0.6rem;
|
||||||
|
padding-left: calc(#{$page-margin} - 1.7em + 72px);
|
||||||
|
}
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
transition: $transition-time-fast;
|
// Avoid animating padding; it causes layout reflow on each frame.
|
||||||
|
transition: background-color $transition-time-fast;
|
||||||
border-radius: 1000px;
|
border-radius: 1000px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
&.elevated{
|
|
||||||
.flex {
|
// Solid, part-of-the-screen titlebar background once the page scrolls.
|
||||||
padding: 0.5em;
|
&.elevated {
|
||||||
background: rgb(0 0 0 / 0.4);
|
background-color: $clr-background-default !important;
|
||||||
backdrop-filter: blur(40px);
|
border-bottom: 1px solid rgb(255 255 255 / 0.06);
|
||||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
box-shadow: none !important;
|
||||||
}
|
background-image: none !important;
|
||||||
|
backdrop-filter: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-title {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
max-width: min(38vw, 520px);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: rgb(255 255 255 / 0.72);
|
||||||
|
font-size: 0.9rem !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
&-avatar {
|
&-avatar {
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
background: rgb(255 255 255 / 0.1) !important;
|
||||||
&-icon {
|
&-icon {
|
||||||
@@ -62,48 +92,98 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.library-drawer{
|
.library-drawer {
|
||||||
width: 20em;
|
// Ensure the drawer paper itself gets the styling
|
||||||
margin: 1.4em;
|
&.MuiDrawer-paper {
|
||||||
height: calc(100vh - 2.8em) !important;
|
width: 280px;
|
||||||
border-radius: 20px;
|
margin: 16px;
|
||||||
overflow-x: hidden;
|
height: calc(100% - 32px) !important; // float in the middle
|
||||||
overflow-y: auto;
|
border-radius: 24px;
|
||||||
.library-drawer-item{
|
background: rgba(20, 20, 25, 0.75); // Darker, substantial base
|
||||||
position: relative;
|
backdrop-filter: blur(24px) saturate(180%);
|
||||||
overflow: hidden;
|
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
border-radius: 1000px;
|
box-shadow:
|
||||||
> div::before{
|
0 24px 48px rgba(0, 0, 0, 0.4),
|
||||||
content: "";
|
0 4px 8px rgba(0, 0, 0, 0.2);
|
||||||
position: absolute;
|
overflow: hidden; // Contain scrollbars
|
||||||
top: 0;
|
}
|
||||||
left: 0;
|
|
||||||
right: 0;
|
.MuiList-root {
|
||||||
bottom: 0;
|
padding: 8px; // Reduced from 16px
|
||||||
background: transparent;
|
gap: 2px; // Reduced gap
|
||||||
transition: $transition-time-default;
|
}
|
||||||
z-index: -1;
|
|
||||||
border-radius: 100px;
|
.MuiDivider-root {
|
||||||
|
border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
margin: 4px 12px; // Reduced margins
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigation Items
|
||||||
|
.MuiListItemButton-root {
|
||||||
|
border-radius: 12px !important; // Slightly smaller radius
|
||||||
|
padding: 8px 12px; // Reduced padding (was 12px 16px)
|
||||||
|
margin-bottom: 2px;
|
||||||
|
transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: #fff;
|
||||||
|
transform: scale(1.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
margin-right: 12px; // Reduced spacing
|
||||||
|
font-size: 22px; // Slightly smaller icons usually look better with less padding
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiListItemText-primary {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem; // Slightly smaller text
|
||||||
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.active.library-drawer-item {
|
|
||||||
.material-symbols-rounded{
|
// Active State
|
||||||
--fill: 1;
|
.library-drawer-item.active {
|
||||||
}
|
.MuiListItemButton-root {
|
||||||
&> div::before {
|
background: linear-gradient(90deg, rgba($clr-accent-default, 0.2), rgba($clr-accent-default, 0.05));
|
||||||
background: $clr-accent-default;
|
color: $clr-accent-default;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-variation-settings: 'FILL' 1;
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Active Indicator Bar
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
height: 24px;
|
||||||
|
width: 4px;
|
||||||
|
background: $clr-accent-default;
|
||||||
|
border-radius: 0 4px 4px 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Magic scrollbar
|
|
||||||
|
// Custom Scrollbar for the drawer content
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
&-thumb {
|
width: 4px;
|
||||||
height: 150px;
|
}
|
||||||
max-height: 33%;
|
&::-webkit-scrollbar-track {
|
||||||
}
|
background: transparent;
|
||||||
&-track {
|
}
|
||||||
margin-top: 15px;
|
&::-webkit-scrollbar-thumb {
|
||||||
margin-bottom: 15px;
|
background: rgba(255, 255, 255, 0.1);
|
||||||
background: transparent !important;
|
border-radius: 4px;
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+128
-347
@@ -1,188 +1,61 @@
|
|||||||
import React, {
|
|
||||||
type MouseEventHandler,
|
|
||||||
useCallback,
|
|
||||||
useMemo,
|
|
||||||
type ReactNode,
|
|
||||||
} from "react";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
import MuiAppBar from "@mui/material/AppBar";
|
import MuiAppBar from "@mui/material/AppBar";
|
||||||
import Avatar from "@mui/material/Avatar";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import Menu from "@mui/material/Menu";
|
import Typography from "@mui/material/Typography";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
|
||||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||||
|
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
|
import React, { useCallback, useState } from "react";
|
||||||
|
|
||||||
import {
|
|
||||||
Link,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
useRouter,
|
|
||||||
} from "@tanstack/react-router";
|
|
||||||
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
|
||||||
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { delUser } from "@/utils/storage/user";
|
|
||||||
import "./appBar.scss";
|
import "./appBar.scss";
|
||||||
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import useHeaderStore from "@/utils/store/header";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import useSearchStore from "@/utils/store/search";
|
||||||
import {
|
|
||||||
setSettingsDialogOpen,
|
|
||||||
setSettingsTabValue,
|
|
||||||
} from "@/utils/store/settings";
|
|
||||||
import {
|
|
||||||
Divider,
|
|
||||||
Drawer,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
ListItemText,
|
|
||||||
} from "@mui/material";
|
|
||||||
import BackButton from "../buttons/backButton";
|
import BackButton from "../buttons/backButton";
|
||||||
|
import CastButton from "../buttons/castButton";
|
||||||
interface ListItemLinkProps {
|
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||||
icon?: ReactNode;
|
import { NavigationDrawer } from "./navigationDrawer";
|
||||||
primary: string;
|
import WindowControls from "../windowControls";
|
||||||
to: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ListItemLink(props: ListItemLinkProps) {
|
|
||||||
const { icon, primary, to } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<li>
|
|
||||||
{/* @ts-ignore */}
|
|
||||||
<ListItem
|
|
||||||
component={Link}
|
|
||||||
activeClassName="active"
|
|
||||||
className="library-drawer-item"
|
|
||||||
to={to}
|
|
||||||
>
|
|
||||||
<ListItemButton
|
|
||||||
style={{
|
|
||||||
borderRadius: "100px",
|
|
||||||
gap: "0.85em",
|
|
||||||
color: "white",
|
|
||||||
textDecoration: "none",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">{icon}</div>
|
|
||||||
<ListItemText primary={primary} />
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const MemoizeBackButton = React.memo(BackButton);
|
const MemoizeBackButton = React.memo(BackButton);
|
||||||
|
|
||||||
export const AppBar = () => {
|
const HIDDEN_PATHS = [
|
||||||
const api = useApiInContext((s) => s.api);
|
"/login",
|
||||||
const createApi = useApiInContext((s) => s.createApi);
|
"/setup",
|
||||||
|
"/server",
|
||||||
|
"/player",
|
||||||
|
"/error",
|
||||||
|
"/settings",
|
||||||
|
"/library",
|
||||||
|
"/search",
|
||||||
|
"/remote",
|
||||||
|
// The home page draws its own header inside the hero frame.
|
||||||
|
"/home",
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Whether the global app header is drawn for this route. */
|
||||||
|
export const shouldShowAppBar = (pathname: string) =>
|
||||||
|
!HIDDEN_PATHS.some(
|
||||||
|
(path) => pathname.startsWith(path) || pathname === "/",
|
||||||
|
);
|
||||||
|
|
||||||
|
const AppBarContent = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [display, setDisplay] = useState(false);
|
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const [user, resetCurrentUser] = useCentralStore((s) => [
|
const toggleSearchDialog = useSearchStore(
|
||||||
s.currentUser,
|
useShallow((s) => s.toggleSearchDialog),
|
||||||
s.resetCurrentUser,
|
);
|
||||||
]);
|
|
||||||
const libraries = useQuery({
|
|
||||||
queryKey: ["libraries"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!user?.Id || !api?.accessToken) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
|
||||||
userId: user.Id,
|
|
||||||
});
|
|
||||||
return libs.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id && !!api?.accessToken,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// This hook subscribes to page scroll; keep it out of hidden routes.
|
||||||
const trigger = useScrollTrigger({
|
const trigger = useScrollTrigger({
|
||||||
disableHysteresis: true,
|
disableHysteresis: true,
|
||||||
threshold: 20,
|
threshold: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
|
||||||
const openMenu = Boolean(anchorEl);
|
|
||||||
const handleMenuOpen: MouseEventHandler<HTMLButtonElement> = useCallback(
|
|
||||||
(event) => {
|
|
||||||
setAnchorEl(event.currentTarget);
|
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
const handleMenuClose = useCallback(() => {
|
|
||||||
setAnchorEl(null);
|
|
||||||
}, []);
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const handleLogout = async () => {
|
|
||||||
console.log("Logging out user...");
|
|
||||||
await api?.logout();
|
|
||||||
createApi(api?.basePath ?? "", undefined);
|
|
||||||
console.log(api);
|
|
||||||
resetCurrentUser();
|
|
||||||
delUser();
|
|
||||||
sessionStorage.removeItem("accessToken");
|
|
||||||
await router.invalidate();
|
|
||||||
queryClient.clear();
|
|
||||||
setAnchorEl(null);
|
|
||||||
navigate({ to: "/login" });
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
location.pathname.includes("login") ||
|
|
||||||
location.pathname.includes("setup") ||
|
|
||||||
location.pathname.includes("server") ||
|
|
||||||
location.pathname === "/player" ||
|
|
||||||
location.pathname.includes("error") ||
|
|
||||||
location.pathname === "/"
|
|
||||||
) {
|
|
||||||
setDisplay(false);
|
|
||||||
} else {
|
|
||||||
setDisplay(true);
|
|
||||||
}
|
|
||||||
}, [location]);
|
|
||||||
|
|
||||||
const [showDrawer, setShowDrawer] = useState(false);
|
const [showDrawer, setShowDrawer] = useState(false);
|
||||||
|
|
||||||
const appBarStyling = useMemo(() => {
|
|
||||||
return {
|
|
||||||
backgroundColor: "transparent",
|
|
||||||
paddingRight: "0 !important",
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
const menuStyle = useMemo(() => {
|
|
||||||
return { mt: 2 };
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const drawerPaperProps = useMemo(() => {
|
|
||||||
return {
|
|
||||||
className: "glass library-drawer",
|
|
||||||
elevation: 6,
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleNavigateToSearch = useCallback(
|
|
||||||
() => navigate({ to: "/search", search: { query: "" } }),
|
|
||||||
[navigate],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleDrawerClose = useCallback(() => {
|
const handleDrawerClose = useCallback(() => {
|
||||||
setShowDrawer(false);
|
setShowDrawer(false);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -196,31 +69,45 @@ export const AppBar = () => {
|
|||||||
navigate({ to: "/favorite" });
|
navigate({ to: "/favorite" });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
const { pageTitle } = useHeaderStore(
|
||||||
|
useShallow((s) => ({ pageTitle: s.pageTitle })),
|
||||||
|
);
|
||||||
|
|
||||||
if (!display) {
|
const fallbackTitle = (() => {
|
||||||
return <></>;
|
const path = location.pathname;
|
||||||
}
|
if (path === "/favorite") return "Избранное";
|
||||||
if (display) {
|
if (path.startsWith("/music/")) return "Музыка";
|
||||||
return (
|
if (path.startsWith("/player/audio")) return "Сейчас играет";
|
||||||
<>
|
return "";
|
||||||
<MuiAppBar
|
})();
|
||||||
style={appBarStyling}
|
const title = pageTitle || fallbackTitle;
|
||||||
className={
|
|
||||||
trigger
|
return (
|
||||||
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
<>
|
||||||
: "appBar flex flex-row flex-justify-spaced-between"
|
<MuiAppBar
|
||||||
}
|
data-tauri-drag-region
|
||||||
elevation={0}
|
className={
|
||||||
color="transparent"
|
trigger
|
||||||
|
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
||||||
|
: "appBar flex flex-row flex-justify-spaced-between"
|
||||||
|
}
|
||||||
|
elevation={0}
|
||||||
|
color="transparent"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="flex flex-row"
|
||||||
|
data-tauri-drag-region
|
||||||
|
style={{ gap: "0.6em" }}
|
||||||
>
|
>
|
||||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
<Tooltip title="Открыть меню">
|
||||||
<IconButton onClick={handleDrawerOpen}>
|
<IconButton onClick={handleDrawerOpen} aria-label="Открыть меню">
|
||||||
<div className="material-symbols-rounded">menu</div>
|
<span className="material-symbols-rounded">menu</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<MemoizeBackButton />
|
</Tooltip>
|
||||||
<IconButton onClick={handleNavigateToHome}>
|
<MemoizeBackButton />
|
||||||
<div
|
<Tooltip title="Главная">
|
||||||
|
<IconButton onClick={handleNavigateToHome} aria-label="Главная">
|
||||||
|
<span
|
||||||
className={
|
className={
|
||||||
location.pathname === "/home"
|
location.pathname === "/home"
|
||||||
? "material-symbols-rounded fill"
|
? "material-symbols-rounded fill"
|
||||||
@@ -228,169 +115,63 @@ export const AppBar = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
home
|
home
|
||||||
</div>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
{title && (
|
||||||
<IconButton onClick={handleNavigateToSearch}>
|
<Typography className="appBar-title" noWrap>
|
||||||
<div className="material-symbols-rounded">search</div>
|
{title}
|
||||||
</IconButton>
|
</Typography>
|
||||||
<IconButton onClick={handleNavigateToFavorite}>
|
)}
|
||||||
<div className="material-symbols-rounded">favorite</div>
|
|
||||||
</IconButton>
|
<div
|
||||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
className="flex flex-row"
|
||||||
{!!user?.Id &&
|
data-tauri-drag-region
|
||||||
(user?.PrimaryImageTag === undefined ? (
|
style={{ gap: "0.6em" }}
|
||||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
|
||||||
account_circle
|
|
||||||
</span>
|
|
||||||
</Avatar>
|
|
||||||
) : (
|
|
||||||
<Avatar
|
|
||||||
className="appBar-avatar"
|
|
||||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
|
||||||
alt={user?.Name ?? "image"}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
|
||||||
account_circle
|
|
||||||
</span>
|
|
||||||
</Avatar>
|
|
||||||
))}
|
|
||||||
</IconButton>
|
|
||||||
<Menu
|
|
||||||
anchorEl={anchorEl}
|
|
||||||
open={openMenu}
|
|
||||||
onClose={handleMenuClose}
|
|
||||||
sx={menuStyle}
|
|
||||||
disableScrollLock
|
|
||||||
>
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
handleLogout();
|
|
||||||
handleMenuClose();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<div className="material-symbols-rounded">logout</div>
|
|
||||||
</ListItemIcon>
|
|
||||||
Logout
|
|
||||||
</MenuItem>
|
|
||||||
<Divider />
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
setSettingsDialogOpen(true);
|
|
||||||
setSettingsTabValue(1);
|
|
||||||
handleMenuClose();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<div className="material-symbols-rounded">settings</div>
|
|
||||||
</ListItemIcon>
|
|
||||||
Settings
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
setSettingsDialogOpen(true);
|
|
||||||
setSettingsTabValue(10);
|
|
||||||
handleMenuClose();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<div className="material-symbols-rounded">info</div>
|
|
||||||
</ListItemIcon>
|
|
||||||
About
|
|
||||||
</MenuItem>
|
|
||||||
</Menu>
|
|
||||||
</div>
|
|
||||||
</MuiAppBar>
|
|
||||||
<Drawer
|
|
||||||
open={showDrawer}
|
|
||||||
PaperProps={drawerPaperProps}
|
|
||||||
className="library-drawer"
|
|
||||||
onClose={handleDrawerClose}
|
|
||||||
>
|
>
|
||||||
<List>
|
<Tooltip title="Смотреть вместе">
|
||||||
<ListItem>
|
<IconButton
|
||||||
<ListItemButton
|
onClick={openSyncPlayDialog}
|
||||||
onClick={handleDrawerClose}
|
aria-label="Смотреть вместе"
|
||||||
style={{
|
>
|
||||||
borderRadius: "100px",
|
<span className="material-symbols-rounded">groups</span>
|
||||||
gap: "0.85em",
|
</IconButton>
|
||||||
}}
|
</Tooltip>
|
||||||
>
|
<CastButton />
|
||||||
<span className="material-symbols-rounded">menu_open</span>
|
<Tooltip title="Поиск">
|
||||||
Close
|
<IconButton onClick={toggleSearchDialog} aria-label="Поиск">
|
||||||
</ListItemButton>
|
<span className="material-symbols-rounded">search</span>
|
||||||
</ListItem>
|
</IconButton>
|
||||||
</List>
|
</Tooltip>
|
||||||
<Divider variant="middle" />
|
<Tooltip title="Пульт">
|
||||||
<List>
|
<IconButton
|
||||||
<ListItemLink to="/home" icon="home" primary="Home" />
|
onClick={() => navigate({ to: "/remote" })}
|
||||||
{libraries.isSuccess &&
|
aria-label="Пульт"
|
||||||
libraries.data?.Items?.map((library) => (
|
>
|
||||||
<ListItemLink
|
<span className="material-symbols-rounded">settings_remote</span>
|
||||||
key={library.Id}
|
</IconButton>
|
||||||
to={`/library/${library.Id}`}
|
</Tooltip>
|
||||||
icon={
|
<Tooltip title="Избранное">
|
||||||
library.CollectionType &&
|
<IconButton
|
||||||
getTypeIcon(library.CollectionType)
|
onClick={handleNavigateToFavorite}
|
||||||
}
|
aria-label="Избранное"
|
||||||
primary={library.Name ?? "Library"}
|
>
|
||||||
/>
|
<span className="material-symbols-rounded">favorite</span>
|
||||||
))}
|
</IconButton>
|
||||||
</List>
|
</Tooltip>
|
||||||
<Divider variant="middle" />
|
<UserAvatarMenu />
|
||||||
<List>
|
<WindowControls />
|
||||||
<ListItem>
|
</div>
|
||||||
<ListItemButton
|
</MuiAppBar>
|
||||||
onClick={() => {
|
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||||
setSettingsDialogOpen(true);
|
</>
|
||||||
setSettingsTabValue(1);
|
);
|
||||||
}}
|
};
|
||||||
style={{
|
|
||||||
borderRadius: "100px",
|
export const AppBar = () => {
|
||||||
gap: "0.85em",
|
const location = useLocation();
|
||||||
}}
|
if (!shouldShowAppBar(location.pathname)) return null;
|
||||||
>
|
return <AppBarContent />;
|
||||||
<span className="material-symbols-rounded">settings</span>
|
|
||||||
Settings
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
<ListItem>
|
|
||||||
<ListItemButton
|
|
||||||
onClick={() => {
|
|
||||||
setSettingsDialogOpen(true);
|
|
||||||
setSettingsTabValue(2);
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
borderRadius: "100px",
|
|
||||||
gap: "0.85em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">dns</span>
|
|
||||||
Change Server
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
<ListItem>
|
|
||||||
<ListItemButton
|
|
||||||
onClick={() => {
|
|
||||||
setSettingsDialogOpen(true);
|
|
||||||
setSettingsTabValue(10);
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
borderRadius: "100px",
|
|
||||||
gap: "0.85em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">info</span>
|
|
||||||
About
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
</List>
|
|
||||||
</Drawer>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
@@ -23,7 +23,7 @@ export default function AppBarBackOnly() {
|
|||||||
edge="start"
|
edge="start"
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
aria-label="back"
|
aria-label="Назад"
|
||||||
disabled={history.length <= 1}
|
disabled={history.length <= 1}
|
||||||
onClick={handleBack}
|
onClick={handleBack}
|
||||||
sx={{ mr: 2 }}
|
sx={{ mr: 2 }}
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
||||||
|
import {
|
||||||
|
Divider,
|
||||||
|
Drawer,
|
||||||
|
List,
|
||||||
|
ListItem,
|
||||||
|
ListItemButton,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import React, { useEffect, useMemo } from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import ListItemLink from "../listItemLink";
|
||||||
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
|
interface NavigationDrawerProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
|
const libraries = useQuery({
|
||||||
|
queryKey: ["libraries"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!user?.Id || !api?.accessToken) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const libs = await getUserViewApi(api).getUserViews({
|
||||||
|
userId: user.Id,
|
||||||
|
});
|
||||||
|
return libs.data;
|
||||||
|
},
|
||||||
|
enabled: !!user?.Id && !!api?.accessToken,
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Libraries can be added on the server while the app is running; refresh
|
||||||
|
// the view list every time the drawer opens so they show up without restart.
|
||||||
|
const refetchLibraries = libraries.refetch;
|
||||||
|
useEffect(() => {
|
||||||
|
if (open) refetchLibraries();
|
||||||
|
}, [open, refetchLibraries]);
|
||||||
|
|
||||||
|
const drawerPaperProps = useMemo(() => {
|
||||||
|
return {
|
||||||
|
className: "glass library-drawer",
|
||||||
|
elevation: 6,
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
open={open}
|
||||||
|
slotProps={{ paper: drawerPaperProps }}
|
||||||
|
className="library-drawer"
|
||||||
|
onClose={onClose}
|
||||||
|
>
|
||||||
|
<List>
|
||||||
|
<ListItem>
|
||||||
|
<ListItemButton onClick={onClose}>
|
||||||
|
<span className="material-symbols-rounded">menu_open</span>
|
||||||
|
<div style={{ marginLeft: "8px" }}>Закрыть</div>
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
</List>
|
||||||
|
<Divider variant="middle" />
|
||||||
|
<Typography
|
||||||
|
variant="overline"
|
||||||
|
sx={{ display: "block", px: 2, pt: 1.5, opacity: 0.55 }}
|
||||||
|
>
|
||||||
|
Обзор
|
||||||
|
</Typography>
|
||||||
|
<List>
|
||||||
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
|
to="/home"
|
||||||
|
icon="home"
|
||||||
|
primary="Главная"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
|
to="/search"
|
||||||
|
search={{ query: "" }}
|
||||||
|
icon="search"
|
||||||
|
primary="Поиск"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
|
to="/remote"
|
||||||
|
icon="settings_remote"
|
||||||
|
primary="Пульт"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
|
to="/favorite"
|
||||||
|
icon="favorite"
|
||||||
|
primary="Избранное"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
{libraries.isSuccess &&
|
||||||
|
libraries.data?.Items?.map((library) => (
|
||||||
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
|
key={library.Id}
|
||||||
|
to="/library/$id"
|
||||||
|
params={{ id: library.Id ?? "" }}
|
||||||
|
icon={
|
||||||
|
library.CollectionType && getTypeIcon(library.CollectionType)
|
||||||
|
}
|
||||||
|
primary={library.Name ?? "Библиотека"}
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
<Divider variant="middle" />
|
||||||
|
<Typography
|
||||||
|
variant="overline"
|
||||||
|
sx={{ display: "block", px: 2, pt: 1.5, opacity: 0.55 }}
|
||||||
|
>
|
||||||
|
Настройки
|
||||||
|
</Typography>
|
||||||
|
<List>
|
||||||
|
<ListItemLink
|
||||||
|
to="/settings/preferences"
|
||||||
|
icon="settings"
|
||||||
|
primary="Настройки"
|
||||||
|
className="library-drawer-item"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
<ListItemLink
|
||||||
|
to="/settings/changeServer"
|
||||||
|
icon="dns"
|
||||||
|
primary="Сменить сервер"
|
||||||
|
className="library-drawer-item"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
<ListItemLink
|
||||||
|
to="/settings/about"
|
||||||
|
icon="info"
|
||||||
|
primary="О приложении"
|
||||||
|
className="library-drawer-item"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
</List>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,46 +1,55 @@
|
|||||||
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
import React from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
import React, { useLayoutEffect, useState } from "react";
|
|
||||||
|
|
||||||
export default function Backdrop() {
|
export default function Backdrop() {
|
||||||
const [backdropLoading, setBackdropLoading] = useState(true);
|
const { backdropHash } = useBackdropStore(
|
||||||
|
useShallow((state) => ({
|
||||||
|
backdropHash: state.backdropHash,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
const [backdropId, backdropUrl] = useBackdropStore((state) => [
|
// Routes clear the backdrop when they mount ("") and some set it later.
|
||||||
state.backdropId,
|
// Keep the last non-empty hash so the app background never blanks out
|
||||||
state.backdropUrl,
|
// (which looked like a flash on every page open).
|
||||||
]);
|
const lastHash = React.useRef<string | undefined>(undefined);
|
||||||
|
if (backdropHash) lastHash.current = backdropHash;
|
||||||
|
const hash = backdropHash || lastHash.current;
|
||||||
|
|
||||||
// Reset loading status for backdrop
|
if (!hash) {
|
||||||
useLayoutEffect(() => {
|
return null;
|
||||||
setBackdropLoading(true);
|
}
|
||||||
}, [backdropId]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-backdrop-container">
|
<AnimatePresence mode="sync">
|
||||||
<AnimatePresence>
|
<motion.div
|
||||||
<motion.img
|
initial={{ opacity: 0 }}
|
||||||
key={backdropId}
|
animate={{ opacity: 1 }}
|
||||||
src={backdropUrl}
|
key={hash}
|
||||||
alt=""
|
exit={{ opacity: 0 }}
|
||||||
className="app-backdrop"
|
transition={{
|
||||||
initial={{
|
duration: 0.45,
|
||||||
opacity: 0,
|
ease: "easeInOut",
|
||||||
}}
|
}}
|
||||||
animate={{
|
className="app-backdrop-container"
|
||||||
opacity: backdropLoading ? 0 : 1,
|
>
|
||||||
}}
|
<BlurhashCanvas
|
||||||
exit={{
|
blurhashString={hash}
|
||||||
opacity: 0,
|
width={300}
|
||||||
}}
|
height={150}
|
||||||
transition={{
|
canvasProps={{
|
||||||
opacity: {
|
style: {
|
||||||
duration: 1.2,
|
display: "block",
|
||||||
|
width: "100vw",
|
||||||
|
height: "100vh",
|
||||||
|
margin: "0 auto",
|
||||||
|
filter: "brightness(0.8) contrast(1.6) saturate(1.6)",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onLoad={() => setBackdropLoading(false)}
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
/>
|
||||||
</AnimatePresence>
|
</motion.div>
|
||||||
</div>
|
</AnimatePresence>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import * as blurhash from "blurhash-wasm";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
|
|
||||||
|
type BlurhashCanvasProps = {
|
||||||
|
canvasProps?: React.CanvasHTMLAttributes<HTMLCanvasElement>;
|
||||||
|
blurhashString: string;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
// punch?: number;
|
||||||
|
onLoad?: () => void;
|
||||||
|
onError?: (error: Error) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const BlurhashCanvas = ({
|
||||||
|
canvasProps,
|
||||||
|
blurhashString,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
// punch,
|
||||||
|
onLoad,
|
||||||
|
onError,
|
||||||
|
}: BlurhashCanvasProps) => {
|
||||||
|
const canvasRef = React.useRef<HTMLCanvasElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const canvas = canvasRef.current;
|
||||||
|
if (!canvas) return;
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
if (!ctx) return;
|
||||||
|
const drawBlurhash = async () => {
|
||||||
|
try {
|
||||||
|
const imageDataBuffer = blurhash.decode(
|
||||||
|
blurhashString,
|
||||||
|
width || 32,
|
||||||
|
height || 32,
|
||||||
|
// punch || 1,
|
||||||
|
);
|
||||||
|
// canvas.width = width || 32;
|
||||||
|
// canvas.height = height || 32;
|
||||||
|
if (!imageDataBuffer) {
|
||||||
|
throw new Error("Failed to decode blurhash");
|
||||||
|
}
|
||||||
|
const imageData = new ImageData(
|
||||||
|
new Uint8ClampedArray(imageDataBuffer),
|
||||||
|
width || 32,
|
||||||
|
height || 32,
|
||||||
|
);
|
||||||
|
// imageData.data.set(imageDataBuffer);
|
||||||
|
ctx.putImageData(imageData, 0, 0);
|
||||||
|
if (onLoad) onLoad();
|
||||||
|
} catch (error) {
|
||||||
|
if (onError) onError(error as Error);
|
||||||
|
else console.error("Error decoding blurhash:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
drawBlurhash();
|
||||||
|
}, [blurhash, width, height, onLoad, onError]);
|
||||||
|
return <canvas ref={canvasRef} {...canvasProps} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BlurhashCanvas;
|
||||||
@@ -9,7 +9,12 @@ export default function BackButton() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={handleClick} disabled={history.length === 0}>
|
<IconButton
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={history.length === 0}
|
||||||
|
aria-label="Назад"
|
||||||
|
title="Назад"
|
||||||
|
>
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import React from "react";
|
||||||
|
import useRemoteControlStore, {
|
||||||
|
type RemoteTransfer,
|
||||||
|
} from "@/utils/store/remoteControl";
|
||||||
|
|
||||||
|
type CastButtonProps = {
|
||||||
|
item?: BaseItemDto | null;
|
||||||
|
transfer?: Omit<RemoteTransfer, "item">;
|
||||||
|
/** Computed on click so playback position/queue are current. */
|
||||||
|
getTransfer?: () => Omit<RemoteTransfer, "item">;
|
||||||
|
size?: "small" | "medium" | "large";
|
||||||
|
};
|
||||||
|
|
||||||
|
const CastButton = ({
|
||||||
|
item,
|
||||||
|
transfer,
|
||||||
|
getTransfer,
|
||||||
|
size = "medium",
|
||||||
|
}: CastButtonProps) => {
|
||||||
|
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
||||||
|
return (
|
||||||
|
<Tooltip title={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}>
|
||||||
|
<IconButton
|
||||||
|
size={size}
|
||||||
|
aria-label={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}
|
||||||
|
onClick={() =>
|
||||||
|
openDialog({
|
||||||
|
...(getTransfer ? getTransfer() : transfer),
|
||||||
|
item: item ?? null,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">cast</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CastButton;
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { startInstantMix } from "@/utils/methods/instantMix";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
|
type InstantMixButtonProps = {
|
||||||
|
item?: BaseItemDto | null;
|
||||||
|
/** Render a text button instead of an icon (e.g. on the album page). */
|
||||||
|
withLabel?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const InstantMixButton = ({ item, withLabel = false }: InstantMixButtonProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
|
const handleClick = async () => {
|
||||||
|
if (!api || !user?.Id || !item) return;
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
const { count } = await startInstantMix(api, user.Id, item);
|
||||||
|
if (count === 0) {
|
||||||
|
enqueueSnackbar("Треки для микса не найдены", {
|
||||||
|
variant: "warning",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
enqueueSnackbar(`Микс: ${count} треков`, {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Instant Mix failed", error);
|
||||||
|
enqueueSnackbar("Не удалось запустить микс", { variant: "error" });
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip title="Микс">
|
||||||
|
<span>
|
||||||
|
{withLabel ? (
|
||||||
|
<IconButton
|
||||||
|
aria-label="Микс"
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={busy || !item}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">radio</span>
|
||||||
|
</IconButton>
|
||||||
|
) : (
|
||||||
|
<IconButton
|
||||||
|
aria-label="Микс"
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={busy || !item}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">radio</span>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InstantMixButton;
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import type { UserItemDataDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { UserItemDataDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserDataApi } from "@jellyfin/sdk/lib/utils/api/user-data-api";
|
||||||
import { pink } from "@mui/material/colors";
|
import { pink } from "@mui/material/colors";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
import React from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
export default function LikeButton({
|
export default function LikeButton({
|
||||||
itemId,
|
itemId,
|
||||||
@@ -34,14 +32,14 @@ export default function LikeButton({
|
|||||||
if (!itemName) return;
|
if (!itemName) return;
|
||||||
if (isFavorite) {
|
if (isFavorite) {
|
||||||
result = (
|
result = (
|
||||||
await getUserLibraryApi(api).unmarkFavoriteItem({
|
await getUserDataApi(api).unmarkFavoriteItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
} else if (!isFavorite) {
|
} else if (!isFavorite) {
|
||||||
result = (
|
result = (
|
||||||
await getUserLibraryApi(api).markFavoriteItem({
|
await getUserDataApi(api).markFavoriteItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
})
|
})
|
||||||
@@ -52,7 +50,7 @@ export default function LikeButton({
|
|||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: handleLiking,
|
mutationFn: handleLiking,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
enqueueSnackbar(`Не удалось обновить «${itemName}»`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -78,24 +76,22 @@ export default function LikeButton({
|
|||||||
transition: "opacity 250ms",
|
transition: "opacity 250ms",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<span
|
||||||
className="material-symbols-rounded"
|
className="material-symbols-rounded"
|
||||||
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,
|
||||||
}
|
} as React.CSSProperties)
|
||||||
: {
|
: ({
|
||||||
//@ts-ignore
|
|
||||||
"--fill": mutation.isPending ? 1 : 0,
|
"--fill": mutation.isPending ? 1 : 0,
|
||||||
color: mutation.isPending ? pink.A700 : "white",
|
color: mutation.isPending ? pink.A700 : "white",
|
||||||
}
|
} as React.CSSProperties)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
favorite
|
favorite
|
||||||
</div>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import { green } from "@mui/material/colors";
|
|||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
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 { getUserDataApi } from "@jellyfin/sdk/lib/utils/api/user-data-api";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
export default function MarkPlayedButton({
|
export default function MarkPlayedButton({
|
||||||
@@ -36,12 +36,12 @@ export default function MarkPlayedButton({
|
|||||||
if (!itemName) return;
|
if (!itemName) return;
|
||||||
|
|
||||||
if (!isPlayed) {
|
if (!isPlayed) {
|
||||||
result = await getPlaystateApi(api).markPlayedItem({
|
result = await getUserDataApi(api).markPlayedItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
});
|
});
|
||||||
} else if (isPlayed) {
|
} else if (isPlayed) {
|
||||||
result = await getPlaystateApi(api).markUnplayedItem({
|
result = await getUserDataApi(api).markUnplayedItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
});
|
});
|
||||||
@@ -54,7 +54,7 @@ export default function MarkPlayedButton({
|
|||||||
enqueueSnackbar(`${error}`, {
|
enqueueSnackbar(`${error}`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
enqueueSnackbar(`Не удалось обновить «${itemName}»`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -1,45 +1,28 @@
|
|||||||
import React, { memo, type MouseEvent } from "react"; // Import memo
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
ItemFields,
|
||||||
|
SortOrder,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
|
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
||||||
|
import type { SxProps } from "@mui/material";
|
||||||
import Button, { type ButtonProps } from "@mui/material/Button";
|
import Button, { type ButtonProps } 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";
|
||||||
|
|
||||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
|
||||||
import {
|
|
||||||
type BaseItemDto,
|
|
||||||
type BaseItemDtoQueryResult,
|
|
||||||
BaseItemKind,
|
|
||||||
ItemFields,
|
|
||||||
ItemFilter,
|
|
||||||
LocationType,
|
|
||||||
type MediaSegmentDtoQueryResult,
|
|
||||||
type PlaybackInfoResponse,
|
|
||||||
SortOrder,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
|
||||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { type MouseEvent, memo } from "react"; // Import memo
|
||||||
import { setQueue } from "@/utils/store/queue";
|
|
||||||
|
|
||||||
import { playItem, usePlaybackDataLoadStore } from "@/utils/store/playback";
|
|
||||||
|
|
||||||
import type PlayResult from "@//utils/types/playResult";
|
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 { getNextEpisode, getPlaybackInfo } from "@/utils/methods/playback";
|
||||||
import playbackProfile from "@/utils/playback-profiles";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
import { initializePlayback } from "@/utils/store/playback";
|
||||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
||||||
import { LoadingButton } from "@mui/lab";
|
|
||||||
import type { SxProps } from "@mui/material";
|
|
||||||
import type { AxiosResponse } from "axios";
|
|
||||||
|
|
||||||
type PlayButtonProps = {
|
type PlayButtonProps = {
|
||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
@@ -76,7 +59,7 @@ const MemoizedLinearProgress = memo(({ value }: { value: number }) => (
|
|||||||
zIndex: 0,
|
zIndex: 0,
|
||||||
mixBlendMode: "difference",
|
mixBlendMode: "difference",
|
||||||
}}
|
}}
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
color="white"
|
color="white"
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
@@ -87,7 +70,7 @@ const PlayButton = ({
|
|||||||
itemType,
|
itemType,
|
||||||
currentAudioTrack,
|
currentAudioTrack,
|
||||||
currentSubTrack,
|
currentSubTrack,
|
||||||
currentVideoTrack,
|
// currentVideoTrack,
|
||||||
className,
|
className,
|
||||||
sx,
|
sx,
|
||||||
buttonProps,
|
buttonProps,
|
||||||
@@ -98,11 +81,10 @@ const PlayButton = ({
|
|||||||
playlistItemId = "",
|
playlistItemId = "",
|
||||||
}: PlayButtonProps) => {
|
}: PlayButtonProps) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
// const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
||||||
(state) => state.setisPending,
|
// (state) => state.setisPending,
|
||||||
);
|
// );
|
||||||
const playPhotos = usePhotosPlayback((s) => s.playPhotos);
|
const playPhotos = usePhotosPlayback((s) => s.playPhotos);
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
@@ -110,348 +92,49 @@ const PlayButton = ({
|
|||||||
const itemQuery = useMutation({
|
const itemQuery = useMutation({
|
||||||
mutationKey: ["playButton", item?.Id, userId],
|
mutationKey: ["playButton", item?.Id, userId],
|
||||||
mutationFn: async (currentEpisodeId?: string) => {
|
mutationFn: async (currentEpisodeId?: string) => {
|
||||||
setPlaybackDataLoading(true);
|
|
||||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
|
||||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
|
||||||
let introInfo: undefined | MediaSegmentDtoQueryResult;
|
|
||||||
let index = 0;
|
|
||||||
if (!api) {
|
if (!api) {
|
||||||
throw new Error("API is not available");
|
throw new Error("API недоступно");
|
||||||
|
}
|
||||||
|
if (!userId) {
|
||||||
|
throw new Error("Не указан пользователь");
|
||||||
}
|
}
|
||||||
if (!item.Id) {
|
if (!item.Id) {
|
||||||
throw new Error("Item ID is not available");
|
throw new Error("Не найден идентификатор элемента");
|
||||||
}
|
}
|
||||||
if (playlistItem) {
|
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
|
||||||
userId: userId,
|
|
||||||
playlistId: playlistItemId,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
switch (itemType) {
|
|
||||||
case BaseItemKind.Episode:
|
|
||||||
if (item.SeriesId && item.SeasonId) {
|
|
||||||
result = await getTvShowsApi(api).getEpisodes({
|
|
||||||
seriesId: item.SeriesId,
|
|
||||||
fields: [
|
|
||||||
ItemFields.MediaSources,
|
|
||||||
ItemFields.MediaStreams,
|
|
||||||
ItemFields.Overview,
|
|
||||||
ItemFields.Chapters,
|
|
||||||
ItemFields.Trickplay,
|
|
||||||
],
|
|
||||||
enableUserData: true,
|
|
||||||
userId: userId,
|
|
||||||
seasonId: item.SeasonId,
|
|
||||||
isMissing: false,
|
|
||||||
// startItemId: item.Id,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (
|
return await getPlaybackInfo(api, userId, item, {
|
||||||
result.data.Items?.map((i) => i.Id).indexOf(
|
currentAudioTrack,
|
||||||
currentEpisodeId,
|
currentSubTrack,
|
||||||
) === -1
|
currentEpisodeId,
|
||||||
) {
|
playlistItem,
|
||||||
throw new Error(
|
playlistItemId,
|
||||||
`Episode having id ${currentEpisodeId} not found, index return -1`,
|
});
|
||||||
);
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
case BaseItemKind.Series:
|
|
||||||
result = await getTvShowsApi(api).getEpisodes({
|
|
||||||
seriesId: item.Id,
|
|
||||||
fields: [
|
|
||||||
ItemFields.MediaSources,
|
|
||||||
ItemFields.MediaStreams,
|
|
||||||
ItemFields.Overview,
|
|
||||||
ItemFields.Chapters,
|
|
||||||
ItemFields.Trickplay,
|
|
||||||
],
|
|
||||||
enableUserData: true,
|
|
||||||
userId: userId,
|
|
||||||
isMissing: false,
|
|
||||||
});
|
|
||||||
if (
|
|
||||||
currentEpisodeId &&
|
|
||||||
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ===
|
|
||||||
-1
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Episode having id=${currentEpisodeId} not found, index return -1`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!currentEpisodeId) {
|
|
||||||
index = 0;
|
|
||||||
} else {
|
|
||||||
index =
|
|
||||||
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ??
|
|
||||||
0;
|
|
||||||
}
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
introInfo = (
|
|
||||||
await getMediaSegmentsApi(api).getItemSegments({
|
|
||||||
itemId: result.data.Items?.[index].Id ?? "",
|
|
||||||
})
|
|
||||||
)?.data;
|
|
||||||
} else {
|
|
||||||
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;
|
|
||||||
case BaseItemKind.Playlist:
|
|
||||||
case BaseItemKind.MusicAlbum:
|
|
||||||
result = await getItemsApi(api).getItems({
|
|
||||||
parentId: item.Id,
|
|
||||||
userId: userId,
|
|
||||||
fields: [ItemFields.MediaSources, ItemFields.MediaStreams],
|
|
||||||
sortOrder: [SortOrder.Ascending],
|
|
||||||
sortBy: ["IndexNumber"],
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicArtist:
|
|
||||||
result = await getItemsApi(api).getItems({
|
|
||||||
artistIds: [item.Id ?? ""],
|
|
||||||
recursive: true,
|
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
|
||||||
userId: userId,
|
|
||||||
fields: [ItemFields.MediaSources, ItemFields.MediaStreams],
|
|
||||||
sortOrder: [SortOrder.Ascending],
|
|
||||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case BaseItemKind.BoxSet:
|
|
||||||
result = await getItemsApi(api).getItems({
|
|
||||||
parentId: item.Id,
|
|
||||||
userId,
|
|
||||||
fields: [
|
|
||||||
ItemFields.MediaSources,
|
|
||||||
ItemFields.MediaStreams,
|
|
||||||
ItemFields.Chapters,
|
|
||||||
ItemFields.Trickplay,
|
|
||||||
],
|
|
||||||
sortOrder: [SortOrder.Ascending],
|
|
||||||
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;
|
|
||||||
case BaseItemKind.Photo:
|
|
||||||
{
|
|
||||||
const photo = (
|
|
||||||
await getUserLibraryApi(api).getItem({
|
|
||||||
itemId: item.Id,
|
|
||||||
})
|
|
||||||
).data;
|
|
||||||
result = await getItemsApi(api).getItems({
|
|
||||||
parentId: photo.ParentId ?? "",
|
|
||||||
filters: [ItemFilter.IsNotFolder],
|
|
||||||
recursive: false,
|
|
||||||
sortBy: ["SortName"],
|
|
||||||
mediaTypes: ["Photo"],
|
|
||||||
excludeLocationTypes: [LocationType.Virtual],
|
|
||||||
collapseBoxSetItems: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
result = await getItemsApi(api).getItems({
|
|
||||||
ids: [item.Id ?? ""],
|
|
||||||
userId: userId,
|
|
||||||
fields: [
|
|
||||||
ItemFields.MediaSources,
|
|
||||||
ItemFields.MediaStreams,
|
|
||||||
ItemFields.Chapters,
|
|
||||||
ItemFields.Trickplay,
|
|
||||||
],
|
|
||||||
sortOrder: [SortOrder.Ascending],
|
|
||||||
sortBy: ["IndexNumber"],
|
|
||||||
});
|
|
||||||
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: item.Id ?? "",
|
|
||||||
startTimeTicks:
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
item: result?.data,
|
|
||||||
mediaSource: mediaSource?.data,
|
|
||||||
introInfo,
|
|
||||||
episodeIndex: index,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
onSuccess: (result: PlayResult | null) => {
|
onSuccess: async (result: PlayResult | null) => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
console.error("API is not available");
|
console.error("API недоступно");
|
||||||
enqueueSnackbar("API is not available", { variant: "error" });
|
enqueueSnackbar("API недоступно", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
console.error("User ID is not available");
|
console.error("Не указан пользователь");
|
||||||
enqueueSnackbar("User ID is not available", { variant: "error" });
|
enqueueSnackbar("Не указан пользователь", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.item?.Items?.length) {
|
if (!result?.item?.Items?.length) {
|
||||||
console.error("No items found");
|
console.error("Ничего не найдено");
|
||||||
enqueueSnackbar("No items found", { variant: "error" });
|
enqueueSnackbar("Ничего не найдено", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.item?.Items?.[0]?.Id) {
|
if (!result?.item?.Items?.[0]?.Id) {
|
||||||
console.error("No item ID found");
|
console.error("Не найден идентификатор элемента");
|
||||||
enqueueSnackbar("No item ID found", { variant: "error" });
|
enqueueSnackbar("Не найден идентификатор элемента", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio) {
|
if (audio) {
|
||||||
// Album/Individual audio track playback
|
// Album/Individual audio track playback
|
||||||
|
const playedItem = result?.item?.Items?.[0];
|
||||||
const playbackUrl = generateAudioStreamUrl(
|
const playbackUrl = generateAudioStreamUrl(
|
||||||
result?.item?.Items?.[0].Id,
|
result?.item?.Items?.[0].Id,
|
||||||
userId,
|
userId,
|
||||||
@@ -460,7 +143,68 @@ const PlayButton = ({
|
|||||||
api.accessToken,
|
api.accessToken,
|
||||||
);
|
);
|
||||||
playAudio(playbackUrl, result?.item?.Items?.[0], undefined);
|
playAudio(playbackUrl, result?.item?.Items?.[0], undefined);
|
||||||
setQueue(result?.item?.Items ?? [], 0);
|
|
||||||
|
if (
|
||||||
|
playedItem?.Type === BaseItemKind.Audio &&
|
||||||
|
(result?.item?.Items?.length ?? 0) <= 1
|
||||||
|
) {
|
||||||
|
// A single track has no queue of its own. Queue the record it
|
||||||
|
// belongs to; when the server does not expose AlbumId, fall
|
||||||
|
// back to the artist's songs so "Очередь" is never empty.
|
||||||
|
const loadQueue = async (): Promise<{
|
||||||
|
items: BaseItemDto[];
|
||||||
|
index: number;
|
||||||
|
}> => {
|
||||||
|
if (playedItem.AlbumId) {
|
||||||
|
const albumTracks = await getLibraryApi(api).getItems({
|
||||||
|
parentId: playedItem.AlbumId,
|
||||||
|
userId,
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
sortBy: ["IndexNumber"],
|
||||||
|
fields: [ItemFields.MediaSources],
|
||||||
|
});
|
||||||
|
const items = albumTracks.data.Items ?? [];
|
||||||
|
if (items.length > 0) {
|
||||||
|
return {
|
||||||
|
items,
|
||||||
|
index: Math.max(
|
||||||
|
items.findIndex((t) => t.Id === playedItem.Id),
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const artistName =
|
||||||
|
playedItem.Artists?.[0] ?? playedItem.AlbumArtists?.[0]?.Name;
|
||||||
|
if (artistName) {
|
||||||
|
const artistTracks = await getLibraryApi(api).getItems({
|
||||||
|
userId,
|
||||||
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
|
artists: [artistName],
|
||||||
|
recursive: true,
|
||||||
|
sortBy: ["SortName"],
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
fields: [ItemFields.MediaSources],
|
||||||
|
});
|
||||||
|
const items = artistTracks.data.Items ?? [];
|
||||||
|
const index = items.findIndex((t) => t.Id === playedItem.Id);
|
||||||
|
if (items.length > 1 && index >= 0) {
|
||||||
|
return { items, index };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { items: [playedItem], index: 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const nextQueue = await loadQueue();
|
||||||
|
setQueue(nextQueue.items, nextQueue.index);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Could not build the audio queue", error);
|
||||||
|
setQueue([playedItem], 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setQueue(result?.item?.Items ?? [], 0);
|
||||||
|
}
|
||||||
} else if (item.Type === "Photo") {
|
} else if (item.Type === "Photo") {
|
||||||
const index = result?.item?.Items?.map((i) => i.Id).indexOf(item.Id);
|
const index = result?.item?.Items?.map((i) => i.Id).indexOf(item.Id);
|
||||||
if (result?.item?.Items && index) {
|
if (result?.item?.Items && index) {
|
||||||
@@ -469,92 +213,44 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||||
console.error("No media source ID found");
|
console.error("Не найден источник медиа");
|
||||||
enqueueSnackbar("No media source ID found", { variant: "error" });
|
enqueueSnackbar("Не найден источник медиа", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const episodeIndex = result.episodeIndex;
|
const episodeIndex = result.episodeIndex;
|
||||||
|
const queue = result?.item?.Items ?? [];
|
||||||
|
|
||||||
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
let playItemValue = queue[episodeIndex];
|
||||||
const queue = result?.item?.Items;
|
|
||||||
|
|
||||||
let itemName = item.Name;
|
|
||||||
let episodeTitle = "";
|
|
||||||
if (result?.item?.Items?.[episodeIndex].SeriesId) {
|
|
||||||
itemName = result?.item.Items[episodeIndex].SeriesName;
|
|
||||||
episodeTitle = `S${result?.item.Items[episodeIndex].ParentIndexNumber ?? 0}:E${
|
|
||||||
result?.item.Items[episodeIndex].IndexNumber ?? 0
|
|
||||||
} ${result?.item.Items[episodeIndex].Name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemType === "BoxSet") {
|
|
||||||
itemName = result.item.Items[0].Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subtitle
|
|
||||||
const subtitle = getSubtitle(
|
|
||||||
result.mediaSource.MediaSources?.[0].DefaultSubtitleStreamIndex ?? -1,
|
|
||||||
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
|
|
||||||
const urlOptions: URLSearchParams = {
|
|
||||||
//@ts-ignore
|
|
||||||
Static: true,
|
|
||||||
tag: result?.mediaSource.MediaSources?.[0].ETag,
|
|
||||||
mediaSourceId: result?.mediaSource.MediaSources?.[0].Id,
|
|
||||||
deviceId: api?.deviceInfo.id,
|
|
||||||
api_key: api?.accessToken,
|
|
||||||
};
|
|
||||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
|
||||||
let playbackUrl = `${api?.basePath}/Videos/${result?.mediaSource.MediaSources?.[0].Id}/stream.${result?.mediaSource.MediaSources?.[0].Container}?${urlParams}`;
|
|
||||||
if (
|
|
||||||
result?.mediaSource.MediaSources?.[0].SupportsTranscoding &&
|
|
||||||
result?.mediaSource.MediaSources?.[0].TranscodingUrl
|
|
||||||
) {
|
|
||||||
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
|
||||||
}
|
|
||||||
let playItemValue = result?.item?.Items?.[episodeIndex];
|
|
||||||
if (itemType === BaseItemKind.Movie) {
|
if (itemType === BaseItemKind.Movie) {
|
||||||
playItemValue = result?.item?.Items?.[0];
|
playItemValue = queue[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const startPosition =
|
if (!playItemValue) {
|
||||||
result?.item?.Items?.[episodeIndex].UserData?.PlaybackPositionTicks;
|
console.error("No item to play found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
playItem(
|
const startPosition = playItemValue.UserData?.PlaybackPositionTicks;
|
||||||
itemName,
|
|
||||||
episodeTitle,
|
initializePlayback({
|
||||||
currentVideoTrack ?? 0,
|
api,
|
||||||
Number(result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex),
|
userId,
|
||||||
result?.mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
item: playItemValue,
|
||||||
playbackUrl,
|
mediaSource: result.mediaSource,
|
||||||
userId ?? "",
|
mediaSegments: result.mediaSegments,
|
||||||
startPosition,
|
queueItems: queue,
|
||||||
result?.item?.Items?.[episodeIndex].RunTimeTicks,
|
queueIndex: episodeIndex,
|
||||||
playItemValue ?? item,
|
startPositionTicks: startPosition,
|
||||||
queue,
|
audioStreamIndex:
|
||||||
episodeIndex,
|
currentAudioTrack === "auto" ? undefined : currentAudioTrack,
|
||||||
result?.mediaSource?.MediaSources?.[0]?.Id,
|
subtitleStreamIndex:
|
||||||
result?.mediaSource?.PlaySessionId,
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
subtitle,
|
});
|
||||||
result?.introInfo,
|
|
||||||
audio,
|
|
||||||
);
|
|
||||||
navigate({ to: "/player" });
|
navigate({ to: "/player" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
setPlaybackDataLoading(false);
|
// setPlaybackDataLoading(false);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -564,76 +260,101 @@ const PlayButton = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const handleClick = (
|
const handleClick = (
|
||||||
e: MouseEvent<HTMLAnchorElement | MouseEvent>,
|
e: MouseEvent<HTMLElement>,
|
||||||
currentEpisodeId?: string | undefined,
|
currentEpisodeId?: string | undefined,
|
||||||
) => {
|
) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
itemQuery.mutate(currentEpisodeId);
|
itemQuery.mutate(currentEpisodeId);
|
||||||
};
|
};
|
||||||
|
const currentEpisode = useQuery({
|
||||||
|
queryKey: ["playButton", "currentEpisode", item?.Id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("API недоступно");
|
||||||
|
}
|
||||||
|
if (!userId) {
|
||||||
|
throw new Error("Не указан пользователь");
|
||||||
|
}
|
||||||
|
if (!item.Id) {
|
||||||
|
throw new Error("Не найден идентификатор элемента");
|
||||||
|
}
|
||||||
|
const seasons = await getShowApi(api).getSeasons({
|
||||||
|
seriesId: item.Id,
|
||||||
|
userId: userId,
|
||||||
|
enableUserData: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentSeason = seasons.data.Items?.find((season) => {
|
||||||
|
return season.UserData?.Played !== true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const episode = await getNextEpisode(
|
||||||
|
api,
|
||||||
|
userId,
|
||||||
|
item.Id,
|
||||||
|
currentSeason?.IndexNumber ?? 0,
|
||||||
|
);
|
||||||
|
if (episode) {
|
||||||
|
return { Items: [episode] };
|
||||||
|
}
|
||||||
|
return { Items: [] };
|
||||||
|
},
|
||||||
|
enabled: itemType === BaseItemKind.Series,
|
||||||
|
});
|
||||||
|
|
||||||
|
const isAudioItem =
|
||||||
|
item?.Type === "MusicAlbum" ||
|
||||||
|
item?.Type === "Audio" ||
|
||||||
|
item?.Type === "AudioBook" ||
|
||||||
|
item?.Type === "Playlist" ||
|
||||||
|
audio;
|
||||||
|
const playLabel = item.UserData?.PlaybackPositionTicks
|
||||||
|
? isAudioItem
|
||||||
|
? "Продолжить прослушивание"
|
||||||
|
: "Продолжить просмотр"
|
||||||
|
: isAudioItem
|
||||||
|
? "Слушать"
|
||||||
|
: "Смотреть";
|
||||||
|
|
||||||
if (iconOnly) {
|
if (iconOnly) {
|
||||||
return (
|
return (
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
<Fab
|
<Fab
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label="Play"
|
aria-label={isAudioItem ? "Слушать" : "Смотреть"}
|
||||||
className={className}
|
className={className}
|
||||||
onClick={(e) =>
|
onClick={(e) => {
|
||||||
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
if (item.Type === "Episode") {
|
||||||
}
|
handleClick(e, item.Id);
|
||||||
|
} else if (itemType === BaseItemKind.Series) {
|
||||||
|
handleClick(e, currentEpisode.data?.Items?.[0]?.Id);
|
||||||
|
} else {
|
||||||
|
handleClick(e);
|
||||||
|
}
|
||||||
|
}}
|
||||||
sx={sx}
|
sx={sx}
|
||||||
size={size}
|
size={size}
|
||||||
|
disabled={
|
||||||
|
itemType === BaseItemKind.Series &&
|
||||||
|
(!currentEpisode.data ||
|
||||||
|
!currentEpisode.data.Items ||
|
||||||
|
currentEpisode.data.Items.length === 0)
|
||||||
|
}
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
<div
|
<span
|
||||||
className="material-symbols-rounded em-4 fill"
|
className="material-symbols-rounded em-4 fill"
|
||||||
style={{
|
style={{
|
||||||
fontSize: "3em",
|
fontSize: "3em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
play_arrow
|
play_arrow
|
||||||
</div>
|
</span>
|
||||||
</Fab>
|
</Fab>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemType === BaseItemKind.Series) {
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
className="play-button"
|
className="play-button"
|
||||||
@@ -642,13 +363,18 @@ const PlayButton = ({
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LoadingButton
|
<Button
|
||||||
loading={currentEpisode.isPending}
|
loading={currentEpisode.isPending}
|
||||||
className={className ?? "play-button"}
|
className={className ?? "play-button"}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={(e) => handleClick(e, currentEpisode.data?.Items?.[0]?.Id)}
|
onClick={(e) => {
|
||||||
|
const episodeId = currentEpisode.data?.Items?.[0]?.Id;
|
||||||
|
if (episodeId) {
|
||||||
|
handleClick(e, episodeId);
|
||||||
|
}
|
||||||
|
}}
|
||||||
startIcon={
|
startIcon={
|
||||||
<div
|
<span
|
||||||
className="material-symbols-rounded fill"
|
className="material-symbols-rounded fill"
|
||||||
style={{
|
style={{
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
@@ -656,33 +382,50 @@ const PlayButton = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
play_arrow
|
play_arrow
|
||||||
</div>
|
</span>
|
||||||
}
|
}
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
sx={{
|
sx={{
|
||||||
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
|
//@ts-expect-error - 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}
|
||||||
|
disabled={
|
||||||
|
currentEpisode.isPending ||
|
||||||
|
!currentEpisode.data ||
|
||||||
|
!currentEpisode.data.Items ||
|
||||||
|
currentEpisode.data.Items.length === 0 ||
|
||||||
|
!currentEpisode.data.Items[0].Id
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Watch S{currentEpisode.data?.Items?.[0].ParentIndexNumber ?? 1}E
|
{currentEpisode.isPending ? (
|
||||||
{currentEpisode.data?.Items?.[0]?.IndexNumber ?? 1}
|
"Загрузка..."
|
||||||
<MemoizedLinearProgress
|
) : !currentEpisode.data ||
|
||||||
//@ts-ignore
|
!currentEpisode.data.Items ||
|
||||||
value={
|
currentEpisode.data.Items.length === 0 ? (
|
||||||
100 >
|
"Нет серий для просмотра"
|
||||||
(currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage ??
|
) : (
|
||||||
100) &&
|
<>
|
||||||
(currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage ??
|
Смотреть S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
||||||
0) > 0
|
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
||||||
? currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage
|
<MemoizedLinearProgress
|
||||||
: 0
|
//@ts-expect-error
|
||||||
}
|
value={
|
||||||
/>
|
100 >
|
||||||
</LoadingButton>
|
(currentEpisode.data.Items[0].UserData?.PlayedPercentage ??
|
||||||
{(currentEpisode.data?.Items?.[0].UserData?.PlaybackPositionTicks ??
|
100) &&
|
||||||
|
(currentEpisode.data.Items[0].UserData?.PlayedPercentage ??
|
||||||
|
0) > 0
|
||||||
|
? currentEpisode.data.Items[0].UserData?.PlayedPercentage
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
{(currentEpisode.data?.Items?.[0]?.UserData?.PlaybackPositionTicks ??
|
||||||
0) > 0 && (
|
0) > 0 && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
@@ -695,11 +438,11 @@ const PlayButton = ({
|
|||||||
variant="caption"
|
variant="caption"
|
||||||
>
|
>
|
||||||
{getRuntimeCompact(
|
{getRuntimeCompact(
|
||||||
(currentEpisode.data?.Items?.[0].RunTimeTicks ?? 0) -
|
(currentEpisode.data?.Items?.[0]?.RunTimeTicks ?? 0) -
|
||||||
(currentEpisode.data?.Items?.[0].UserData
|
(currentEpisode.data?.Items?.[0]?.UserData
|
||||||
?.PlaybackPositionTicks ?? 0),
|
?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
left
|
осталось
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -720,7 +463,7 @@ const PlayButton = ({
|
|||||||
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||||
}
|
}
|
||||||
startIcon={
|
startIcon={
|
||||||
<div
|
<span
|
||||||
className="material-symbols-rounded fill"
|
className="material-symbols-rounded fill"
|
||||||
style={{
|
style={{
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
@@ -728,28 +471,20 @@ const PlayButton = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
play_arrow
|
play_arrow
|
||||||
</div>
|
</span>
|
||||||
}
|
}
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
sx={{
|
sx={{
|
||||||
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
|
//@ts-expect-error - 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}
|
||||||
>
|
>
|
||||||
{item.UserData?.PlaybackPositionTicks
|
{playLabel}
|
||||||
? "Continue Watching"
|
|
||||||
: item?.Type === "MusicAlbum" ||
|
|
||||||
item?.Type === "Audio" ||
|
|
||||||
item?.Type === "AudioBook" ||
|
|
||||||
item?.Type === "Playlist" ||
|
|
||||||
audio
|
|
||||||
? "Play Now"
|
|
||||||
: "Watch Now"}
|
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
value={
|
value={
|
||||||
100 > (item.UserData?.PlayedPercentage ?? 100) &&
|
100 > (item.UserData?.PlayedPercentage ?? 100) &&
|
||||||
(item.UserData?.PlayedPercentage ?? 0) > 0
|
(item.UserData?.PlayedPercentage ?? 0) > 0
|
||||||
@@ -773,7 +508,7 @@ const PlayButton = ({
|
|||||||
(item.RunTimeTicks ?? 0) -
|
(item.RunTimeTicks ?? 0) -
|
||||||
(item.UserData?.PlaybackPositionTicks ?? 0),
|
(item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
left
|
осталось
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
|
||||||
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 React from "react";
|
import React from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
|
import useQueue, { getNextTrackIndex } from "@/utils/store/queue";
|
||||||
|
|
||||||
const PlayNextButton = () => {
|
const PlayNextButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -19,18 +19,18 @@ const PlayNextButton = () => {
|
|||||||
});
|
});
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
mutationFn: async () => {
|
||||||
|
const nextIndex = getNextTrackIndex();
|
||||||
|
if (nextIndex === undefined) return;
|
||||||
|
return playItemFromQueue(nextIndex, user.data?.Id, api);
|
||||||
|
},
|
||||||
onError: (error) => console.error(error),
|
onError: (error) => console.error(error),
|
||||||
});
|
});
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
// Re-render when the queue position or repeat mode changes.
|
||||||
state.tracks,
|
useQueue((state) => [state.tracks, state.currentItemIndex, state.repeatMode]);
|
||||||
state.currentItemIndex,
|
const hasNext = getNextTrackIndex() !== undefined;
|
||||||
]);
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton disabled={!hasNext} onClick={() => handlePlayNext.mutate()}>
|
||||||
disabled={queueItems?.length === currentItemIndex + 1}
|
|
||||||
onClick={() => handlePlayNext.mutate()}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
<span className="material-symbols-rounded">skip_next</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
$image-size: 5em;
|
|
||||||
|
|
||||||
.queue{
|
.queue{
|
||||||
&-item{
|
&-item{
|
||||||
|
--image-size: 5em;
|
||||||
|
&.episode {
|
||||||
|
--image-size: 8em !important;
|
||||||
|
}
|
||||||
width: 32em;
|
width: 32em;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
display: grid !important;
|
display: grid !important;
|
||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
height: 5em;
|
height: 5em;
|
||||||
grid-template-columns: 3em $image-size 1fr;
|
grid-template-columns: 3em var(--image-size) 1fr;
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
&-image{
|
&-image{
|
||||||
@@ -25,6 +27,7 @@ $image-size: 5em;
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
width: var(--image-size);
|
||||||
}
|
}
|
||||||
&-icon {
|
&-icon {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -52,4 +55,5 @@ $image-size: 5em;
|
|||||||
opacity: 0.5 !important;
|
opacity: 0.5 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,286 +1,31 @@
|
|||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
import Drawer from "@mui/material/Drawer";
|
||||||
import useQueue from "@/utils/store/queue";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import {
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
MenuList,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import QueueView from "@/components/queue/queueView";
|
||||||
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
/** Opens the play queue in a side drawer. */
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import "./queueButton.scss";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
const QueueButton = () => {
|
const QueueButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
|
||||||
state.tracks,
|
|
||||||
state.currentItemIndex,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const user = useQuery({
|
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api) return;
|
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const [buttonEl, setButtonEl] = useState<HTMLButtonElement | null>(null);
|
|
||||||
|
|
||||||
const handlePlay = useMutation({
|
|
||||||
mutationKey: ["handlePlayIndex"],
|
|
||||||
mutationFn: async ({ index }: { index: number }) => {
|
|
||||||
const result = playItemFromQueue(index, user.data?.Id, api);
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
onSuccess: () => {
|
|
||||||
setButtonEl(null);
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.error(error);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Menu
|
<Tooltip title="Очередь">
|
||||||
open={Boolean(buttonEl)}
|
<IconButton onClick={() => setOpen(true)} aria-label="Открыть очередь">
|
||||||
onClose={() => setButtonEl(null)}
|
<span className="material-symbols-rounded">queue_music</span>
|
||||||
anchorEl={buttonEl}
|
</IconButton>
|
||||||
anchorOrigin={{
|
</Tooltip>
|
||||||
vertical: "top",
|
<Drawer
|
||||||
horizontal: "center",
|
anchor="right"
|
||||||
}}
|
open={open}
|
||||||
transformOrigin={{
|
onClose={() => setOpen(false)}
|
||||||
vertical: "bottom",
|
|
||||||
horizontal: "center",
|
|
||||||
}}
|
|
||||||
slotProps={{
|
slotProps={{
|
||||||
paper: {
|
backdrop: { sx: { backgroundColor: "rgb(0 0 0 / 0.3)" } },
|
||||||
style: {
|
paper: { className: "queue-drawer-paper" },
|
||||||
maxHeight: "30em",
|
|
||||||
overflowX: "hidden",
|
|
||||||
overflowY: "auto",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MenuList
|
<QueueView variant="drawer" onClose={() => setOpen(false)} />
|
||||||
style={{
|
</Drawer>
|
||||||
height: "fit-content",
|
|
||||||
width: " 32em",
|
|
||||||
position: "relative",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{queueItems?.[currentItemIndex]?.Id && (
|
|
||||||
<>
|
|
||||||
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
|
||||||
Currently Playing:
|
|
||||||
</Typography>
|
|
||||||
<MenuItem
|
|
||||||
className="queue-item"
|
|
||||||
disabled
|
|
||||||
key={queueItems[currentItemIndex].Id}
|
|
||||||
>
|
|
||||||
<Typography variant="subtitle2">
|
|
||||||
{queueItems[currentItemIndex]?.Type === "Audio"
|
|
||||||
? currentItemIndex + 1
|
|
||||||
: queueItems[currentItemIndex].IndexNumberEnd
|
|
||||||
? `S${queueItems[currentItemIndex].ParentIndexNumber}:E${queueItems[currentItemIndex].IndexNumber} / ${queueItems[currentItemIndex].IndexNumberEnd}`
|
|
||||||
: `S${queueItems[currentItemIndex].ParentIndexNumber}:E${queueItems[currentItemIndex].IndexNumber}`}
|
|
||||||
</Typography>
|
|
||||||
<div className="queue-item-image-container">
|
|
||||||
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
|
||||||
<img
|
|
||||||
className="queue-item-image"
|
|
||||||
src={
|
|
||||||
api &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
queueItems[currentItemIndex]?.Id,
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
tag: queueItems[currentItemIndex].ImageTags
|
|
||||||
?.Primary,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
|
||||||
/>
|
|
||||||
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
|
||||||
?.length ?? -1) > 0 ? (
|
|
||||||
<img
|
|
||||||
className="queue-item-image"
|
|
||||||
src={
|
|
||||||
api &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
queueItems?.[currentItemIndex]?.AlbumId ?? "",
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
tag: queueItems?.[currentItemIndex]
|
|
||||||
.AlbumPrimaryImageTag?.[0],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="queue-item-image-icon">
|
|
||||||
{queueItems[currentItemIndex].Type &&
|
|
||||||
getTypeIcon(queueItems[currentItemIndex].Type)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%,-50%)",
|
|
||||||
fontSize: "2em",
|
|
||||||
//@ts-ignore
|
|
||||||
"--wght": "100",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
equalizer
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="queue-item-info">
|
|
||||||
{queueItems[currentItemIndex].SeriesName ? (
|
|
||||||
<>
|
|
||||||
<Typography variant="subtitle1" width="100%">
|
|
||||||
{queueItems[currentItemIndex].SeriesName}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
width="100%"
|
|
||||||
style={{ opacity: 0.6 }}
|
|
||||||
>
|
|
||||||
{queueItems[currentItemIndex].Name}
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Typography variant="subtitle1" width="100%">
|
|
||||||
{queueItems[currentItemIndex].Name}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</MenuItem>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{queueItems &&
|
|
||||||
queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
|
||||||
.length > 0 && (
|
|
||||||
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
|
||||||
Queue:
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{queueItems
|
|
||||||
?.slice(currentItemIndex + 1, queueItems.length - 1)
|
|
||||||
.map((item, index) => {
|
|
||||||
return (
|
|
||||||
<MenuItem
|
|
||||||
className="queue-item"
|
|
||||||
onClick={() =>
|
|
||||||
handlePlay.mutate({ index: index + currentItemIndex })
|
|
||||||
}
|
|
||||||
key={item.Id}
|
|
||||||
>
|
|
||||||
<Typography variant="subtitle2">
|
|
||||||
{item.Type === "Audio"
|
|
||||||
? index + 1
|
|
||||||
: item.IndexNumberEnd
|
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} / ${item.IndexNumberEnd}`
|
|
||||||
: `S${item.ParentIndexNumber}:E${item.IndexNumber}`}
|
|
||||||
</Typography>
|
|
||||||
<div className="queue-item-image-container">
|
|
||||||
{item.ImageTags?.Primary ? (
|
|
||||||
<img
|
|
||||||
className="queue-item-image"
|
|
||||||
src={
|
|
||||||
api &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
item?.Id ?? "",
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
tag: item.ImageTags?.Primary,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt={item.Name ?? "image"}
|
|
||||||
/>
|
|
||||||
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
|
||||||
<img
|
|
||||||
className="queue-item-image"
|
|
||||||
src={
|
|
||||||
api &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
item?.AlbumId ?? "",
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
tag: item.AlbumPrimaryImageTag?.[0],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt={item.Name ?? "image"}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="queue-item-image-icon">
|
|
||||||
{item.Type && getTypeIcon(item.Type)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="queue-item-info">
|
|
||||||
{item.SeriesName ? (
|
|
||||||
<>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
width="100%"
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
|
||||||
>
|
|
||||||
{item.SeriesName}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
width="100%"
|
|
||||||
style={{ opacity: 0.6 }}
|
|
||||||
>
|
|
||||||
{item.Name}
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
width="100%"
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
|
||||||
>
|
|
||||||
{item.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
width="100%"
|
|
||||||
style={{ opacity: 0.6 }}
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
|
||||||
>
|
|
||||||
{item.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</MenuItem>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</MenuList>
|
|
||||||
</Menu>
|
|
||||||
<IconButton onClick={(e) => setButtonEl(e.currentTarget)}>
|
|
||||||
<span className="material-symbols-rounded">playlist_play</span>
|
|
||||||
</IconButton>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import useInterval from "@/utils/hooks/useInterval";
|
import { getAuthenticationApi } from "@jellyfin/sdk/lib/utils/api/authentication-api";
|
||||||
import { saveUser } from "@/utils/storage/user";
|
|
||||||
import { useApiInContext } from "@/utils/store/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,
|
||||||
@@ -18,10 +14,15 @@ 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 { useNavigate, useRouter } 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, { useCallback, useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
|
import QRCodeImage from "@/components/qrCode";
|
||||||
|
import { buildQuickConnectDeepLink } from "@/utils/deepLinks";
|
||||||
|
import useInterval from "@/utils/hooks/useInterval";
|
||||||
|
import { saveUser } from "@/utils/storage/user";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
const Transition = React.forwardRef(function Transition(
|
const Transition = React.forwardRef(function Transition(
|
||||||
props: TransitionProps & {
|
props: TransitionProps & {
|
||||||
@@ -56,11 +57,12 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
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
|
||||||
? async () => await getQuickConnectApi(api).getQuickConnectEnabled()
|
? async () => await getAuthenticationApi(api).getQuickConnectEnabled()
|
||||||
: skipToken,
|
: skipToken,
|
||||||
enabled: Boolean(api),
|
enabled: Boolean(api),
|
||||||
});
|
});
|
||||||
@@ -74,28 +76,30 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mutationKey: ["quick-connect-button", "authenticate-user"],
|
mutationKey: ["quick-connect-button", "authenticate-user"],
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (api && quickConnectSecret) {
|
if (api && quickConnectSecret) {
|
||||||
return await getUserApi(api).authenticateWithQuickConnect(
|
return await getAuthenticationApi(api).authenticateWithQuickConnect(
|
||||||
{ quickConnectDto: { Secret: quickConnectSecret } },
|
{ quickConnectDto: { Secret: quickConnectSecret } },
|
||||||
{ headers },
|
{ headers },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess: (result) => {
|
onSuccess: async (result) => {
|
||||||
if (api && result?.data?.AccessToken && result.data.User?.Name) {
|
const { AccessToken, User } = result?.data ?? {};
|
||||||
|
if (api && AccessToken && User?.Name && User.Id) {
|
||||||
setCheckForQuickConnect(false);
|
setCheckForQuickConnect(false);
|
||||||
// saveUser({ username, password, rememberMe: rememberUser });
|
enqueueSnackbar(`Вы вошли как ${User.Name}!`, {
|
||||||
enqueueSnackbar(`Logged in as ${result.data.User?.Name}!`, {
|
|
||||||
variant: "success",
|
variant: "success",
|
||||||
});
|
});
|
||||||
createApi(api.basePath, result.data.AccessToken);
|
createApi(api.basePath, AccessToken);
|
||||||
if (rememberUser) {
|
if (rememberUser) {
|
||||||
saveUser(result.data.User?.Name, result.data.AccessToken);
|
await saveUser(User.Name, AccessToken, User.Id);
|
||||||
}
|
}
|
||||||
navigate({ to: "/home", replace: true });
|
router.invalidate().finally(() => {
|
||||||
|
navigate({ to: "/home", replace: true });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Error authenticating user.", { variant: "error" });
|
enqueueSnackbar("Не удалось войти.", { variant: "error" });
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -104,7 +108,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mutationFn: async (secret: string) =>
|
mutationFn: async (secret: string) =>
|
||||||
api &&
|
api &&
|
||||||
(
|
(
|
||||||
await getQuickConnectApi(api).getQuickConnectState(
|
await getAuthenticationApi(api).getQuickConnectState(
|
||||||
{ secret },
|
{ secret },
|
||||||
{ headers },
|
{ headers },
|
||||||
)
|
)
|
||||||
@@ -122,12 +126,14 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mutationKey: ["quick-connect-button", "initiate-connection"],
|
mutationKey: ["quick-connect-button", "initiate-connection"],
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!quickConnectEnabled.data?.data) {
|
if (!quickConnectEnabled.data?.data) {
|
||||||
enqueueSnackbar("Quick Connect is not enabled on server.", {
|
enqueueSnackbar("Quick Connect не включён на сервере.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (api) {
|
if (api) {
|
||||||
return await getQuickConnectApi(api).initiateQuickConnect({ headers });
|
return await getAuthenticationApi(api).initiateQuickConnect({
|
||||||
|
headers,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
@@ -136,7 +142,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
setCheckForQuickConnect(true);
|
setCheckForQuickConnect(true);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
enqueueSnackbar("Не удалось запустить Quick Connect.", { variant: "error" });
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -173,18 +179,23 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
(quickConnectCode && !checkQuickConnectStatus.data?.Authenticated),
|
(quickConnectCode && !checkQuickConnectStatus.data?.Authenticated),
|
||||||
)}
|
)}
|
||||||
variant={props.variant ?? "contained"}
|
variant={props.variant ?? "contained"}
|
||||||
onClick={initQuickConnect.mutate}
|
onClick={() => initQuickConnect.mutate()}
|
||||||
>
|
>
|
||||||
{quickConnectEnabled.data?.data
|
{quickConnectEnabled.data?.data
|
||||||
? "Use Quick Connect"
|
? "Войти через Quick Connect"
|
||||||
: "Quick Connect Disabled"}
|
: "Quick Connect недоступен"}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={Boolean(quickConnectCode)}
|
open={Boolean(quickConnectCode)}
|
||||||
onClose={handleQuickConnectClose}
|
onClose={handleQuickConnectClose}
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="xs"
|
maxWidth="xs"
|
||||||
TransitionComponent={Transition}
|
slots={{
|
||||||
|
transition: Transition,
|
||||||
|
}}
|
||||||
|
slotProps={{
|
||||||
|
paper: { className: "glass", sx: { borderRadius: "24px" } },
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
style={{
|
style={{
|
||||||
@@ -195,44 +206,62 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h5"
|
variant="h5"
|
||||||
mb={2}
|
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
}}
|
}}
|
||||||
|
sx={{
|
||||||
|
mb: 2,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Quick Connect Code:
|
Код Quick Connect:
|
||||||
</Typography>
|
</Typography>
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
Use this code in the Quick Connect tab in your server to login.
|
Введите этот код в разделе Quick Connect на сервере, чтобы войти.
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
<div
|
<div
|
||||||
className="flex flex-row"
|
className="flex flex-row"
|
||||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||||
>
|
>
|
||||||
<Tooltip title="Click to copy" arrow placement="top">
|
<Tooltip title="Нажмите, чтобы скопировать" arrow placement="top">
|
||||||
<Typography
|
<Typography
|
||||||
variant="h3"
|
variant="h3"
|
||||||
color="textPrimary"
|
color="textPrimary"
|
||||||
textAlign="center"
|
onClick={async () => {
|
||||||
|
quickConnectCode && (await writeText(quickConnectCode));
|
||||||
|
enqueueSnackbar("Код Quick Connect скопирован!", {
|
||||||
|
variant: "info",
|
||||||
|
key: "copiedText",
|
||||||
|
});
|
||||||
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
|
textAlign: "center",
|
||||||
background: "rgb(255 255 255 / 0.1)",
|
background: "rgb(255 255 255 / 0.1)",
|
||||||
width: "fit-content",
|
width: "fit-content",
|
||||||
padding: "0.4em",
|
padding: "0.4em",
|
||||||
borderRadius: "10px",
|
borderRadius: "10px",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
}}
|
}}
|
||||||
onClick={async () => {
|
|
||||||
quickConnectCode && (await writeText(quickConnectCode));
|
|
||||||
enqueueSnackbar("Quick Connect Code copied!", {
|
|
||||||
variant: "info",
|
|
||||||
key: "copiedText",
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{quickConnectCode}
|
{quickConnectCode}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
{quickConnectCode && (
|
||||||
|
<>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ mt: 2, opacity: 0.75, textAlign: "center" }}
|
||||||
|
>
|
||||||
|
Или отсканируйте код в Blink на телефоне, чтобы подтвердить вход.
|
||||||
|
</Typography>
|
||||||
|
<div style={{ marginTop: "1em", background: "#08001f", borderRadius: 12, padding: 8 }}>
|
||||||
|
<QRCodeImage
|
||||||
|
value={buildQuickConnectDeepLink(quickConnectCode)}
|
||||||
|
size={180}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions
|
<DialogActions
|
||||||
className="flex flex-row"
|
className="flex flex-row"
|
||||||
@@ -248,10 +277,10 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
onChange={(e) => setRememberUser(e.target.checked)}
|
onChange={(e) => setRememberUser(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="Remember device"
|
label="Запомнить устройство"
|
||||||
/>
|
/>
|
||||||
<Button variant="contained" onClick={handleQuickConnectClose}>
|
<Button variant="contained" onClick={handleQuickConnectClose}>
|
||||||
Close
|
Закрыть
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -22,17 +22,20 @@ const TrailerButton = (props: TrailerButtonType) => {
|
|||||||
maxWidth="md"
|
maxWidth="md"
|
||||||
fullWidth
|
fullWidth
|
||||||
open={dialog}
|
open={dialog}
|
||||||
PaperProps={{
|
onClose={() => setDialog(false)}
|
||||||
style: {
|
slotProps={{
|
||||||
overflow: "hidden",
|
paper: {
|
||||||
|
className: "glass",
|
||||||
|
style: {
|
||||||
|
overflow: "hidden",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onClose={() => setDialog(false)}
|
|
||||||
>
|
>
|
||||||
{props.trailerItem[0]?.Url && (
|
{props.trailerItem[0]?.Url && (
|
||||||
<ReactPlayer
|
<ReactPlayer
|
||||||
playing={false}
|
playing={false}
|
||||||
url={props.trailerItem[0]?.Url}
|
src={props.trailerItem[0]?.Url}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="auto"
|
height="auto"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
transition: all $transition-time-fast;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -82,12 +81,13 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity $transition-time-default;
|
transition: all $transition-time-default;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
background: rgb(0 0 0 / 0.6);
|
background: rgba(20, 20, 30, 0.6);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
}
|
}
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus,
|
&:focus,
|
||||||
|
|||||||
@@ -1,41 +1,25 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import React, { memo } from "react";
|
|
||||||
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
type ImageType,
|
type ImageType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import React, { memo, type Ref, useCallback } from "react";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { useInView } from "react-intersection-observer";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
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 { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
import "./card.scss";
|
import "./card.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import { getItemLinkOptions } from "@/utils/navigation/itemLink";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
|
|
||||||
import { useInView } from "react-intersection-observer";
|
interface CardProps {
|
||||||
|
|
||||||
const CardComponent = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageType = "Primary",
|
|
||||||
cardType = "square",
|
|
||||||
queryKey,
|
|
||||||
userId,
|
|
||||||
seriesId,
|
|
||||||
hideText = false,
|
|
||||||
onClick,
|
|
||||||
disableOverlay = false,
|
|
||||||
overrideIcon,
|
|
||||||
}: {
|
|
||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
cardTitle: string | undefined | null;
|
cardTitle: string | undefined | null;
|
||||||
cardCaption?: string | null | number;
|
cardCaption?: string | null | number;
|
||||||
@@ -48,52 +32,49 @@ const CardComponent = ({
|
|||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
disableOverlay?: boolean;
|
disableOverlay?: boolean;
|
||||||
overrideIcon?: any;
|
overrideIcon?: any;
|
||||||
|
skipInView?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CardContent = ({
|
||||||
|
item,
|
||||||
|
cardTitle,
|
||||||
|
cardCaption,
|
||||||
|
imageType = "Primary",
|
||||||
|
cardType = "square",
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
seriesId,
|
||||||
|
hideText = false,
|
||||||
|
onClick,
|
||||||
|
disableOverlay = false,
|
||||||
|
overrideIcon,
|
||||||
|
inView,
|
||||||
|
forwardedRef,
|
||||||
|
}: CardProps & {
|
||||||
|
inView: boolean;
|
||||||
|
forwardedRef?: Ref<HTMLDivElement>;
|
||||||
}) => {
|
}) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const defaultOnClick = () => {
|
|
||||||
if (item?.Id) {
|
|
||||||
switch (item?.Type) {
|
|
||||||
case BaseItemKind.BoxSet:
|
|
||||||
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Episode:
|
|
||||||
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicAlbum:
|
|
||||||
navigate({ to: "/album/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicArtist:
|
|
||||||
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Person:
|
|
||||||
navigate({ to: "/person/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Series:
|
|
||||||
navigate({ to: "/series/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Playlist:
|
|
||||||
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
navigate({ to: "/item/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { ref, inView } = useInView({
|
const image = resolveItemImage(item, imageType, {
|
||||||
threshold: 0,
|
seriesId: seriesId ? (item.SeriesId ?? undefined) : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const defaultOnClick = useCallback(() => {
|
||||||
|
if (item?.Id) {
|
||||||
|
navigate(getItemLinkOptions(item.Id, item?.Type));
|
||||||
|
}
|
||||||
|
}, [item?.Id, item?.Type, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="card"
|
className="card"
|
||||||
ref={ref}
|
ref={forwardedRef}
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
onClick={onClick || defaultOnClick}
|
||||||
>
|
>
|
||||||
<div className={`card-image-container ${cardType}`}>
|
<div className={`card-image-container ${cardType}`}>
|
||||||
<ErrorBoundary fallback>
|
<ErrorBoundary fallback={<></>}>
|
||||||
<div
|
<div
|
||||||
className="card-indicator check"
|
className="card-indicator check"
|
||||||
style={{
|
style={{
|
||||||
@@ -108,13 +89,17 @@ const CardComponent = ({
|
|||||||
opacity: item.UserData?.UnplayedItemCount ? 1 : 0,
|
opacity: item.UserData?.UnplayedItemCount ? 1 : 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<span
|
||||||
variant="subtitle2"
|
style={{
|
||||||
padding="0.1em 0.4em"
|
padding: "0.1em 0.4em",
|
||||||
fontWeight={400}
|
fontWeight: 400,
|
||||||
|
fontSize: "0.875rem",
|
||||||
|
lineHeight: 1.57,
|
||||||
|
fontFamily: "inherit",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{item.UserData?.UnplayedItemCount}
|
{item.UserData?.UnplayedItemCount}
|
||||||
</Typography>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
<div className="card-image-icon-container">
|
<div className="card-image-icon-container">
|
||||||
@@ -122,20 +107,21 @@ const CardComponent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
{inView && (
|
{image && (
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "blink"}
|
alt={item.Name ?? "blink"}
|
||||||
|
decoding="async"
|
||||||
src={
|
src={
|
||||||
api
|
api && image
|
||||||
? overrideIcon === "User"
|
? overrideIcon === "User"
|
||||||
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
||||||
: getImageUrlsApi(api).getItemImageUrlById(
|
: getImageUrlsApi(api).getItemImageUrlById(
|
||||||
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ??
|
image.itemId,
|
||||||
"",
|
image.imageType,
|
||||||
imageType,
|
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
fillWidth: cardType === "thumb" ? 560 : 320,
|
fillWidth: cardType === "thumb" ? 560 : 320,
|
||||||
|
tag: image.tag,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: ""
|
: ""
|
||||||
@@ -143,26 +129,18 @@ const CardComponent = ({
|
|||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
opacity: 0,
|
display: "block",
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
onLoad={(e) => {
|
|
||||||
e.currentTarget.style.setProperty("opacity", "1");
|
|
||||||
}}
|
|
||||||
onLoadStart={(e) => console.log(e)}
|
|
||||||
className="card-image"
|
className="card-image"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{inView && !disableOverlay && (
|
{inView && !disableOverlay && (
|
||||||
<div className="card-overlay">
|
<div className="card-overlay">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type ?? "Movie"}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentAudioTrack="auto"
|
|
||||||
currentSubTrack={-1}
|
|
||||||
currentVideoTrack={0}
|
|
||||||
className="card-play-button"
|
className="card-play-button"
|
||||||
iconOnly
|
iconOnly
|
||||||
audio={
|
audio={
|
||||||
@@ -203,22 +181,50 @@ const CardComponent = ({
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="card-text-container"
|
className="card-text-container"
|
||||||
style={{ display: hideText ? "none" : "block" }}
|
style={{ display: hideText ? "none" : "block", marginLeft: "0.2em" }}
|
||||||
>
|
>
|
||||||
<Typography mt={1} variant="subtitle2" noWrap style={{ opacity: 0.9 }}>
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: "8px",
|
||||||
|
opacity: 0.9,
|
||||||
|
fontSize: "0.875rem",
|
||||||
|
fontWeight: 500,
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{cardTitle}
|
{cardTitle}
|
||||||
</Typography>
|
</div>
|
||||||
<Typography
|
<div
|
||||||
variant="caption"
|
style={{
|
||||||
noWrap
|
opacity: 0.6,
|
||||||
style={{ opacity: 0.6 }}
|
fontSize: "0.75rem",
|
||||||
lineHeight="auto"
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{cardCaption}
|
{cardCaption}
|
||||||
</Typography>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CardWithInView = (props: CardProps) => {
|
||||||
|
const { ref, inView } = useInView({
|
||||||
|
threshold: 0.1,
|
||||||
|
});
|
||||||
|
|
||||||
|
return <CardContent {...props} inView={inView} forwardedRef={ref} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const CardComponent = (props: CardProps) => {
|
||||||
|
if (props.skipInView) {
|
||||||
|
return <CardContent {...props} inView={true} />;
|
||||||
|
}
|
||||||
|
return <CardWithInView {...props} />;
|
||||||
|
};
|
||||||
|
|
||||||
export const Card = memo(CardComponent);
|
export const Card = memo(CardComponent);
|
||||||
@@ -1,51 +1,82 @@
|
|||||||
|
@use "@/styles/variables.scss" as *;
|
||||||
|
|
||||||
|
.card-scroller-container {
|
||||||
|
margin-bottom: 2.5em;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
// Ensure the container handles overflow if needed, but usually Carousel handles it
|
||||||
|
}
|
||||||
|
|
||||||
.card-scroller {
|
.card-scroller {
|
||||||
// height: 20em;
|
// Override carousel default outline
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
&-slide {
|
&-slide {
|
||||||
overflow: visible;
|
padding-right: 0.5em; // Gap between cards (handled by slide padding instead of gap for carousel)
|
||||||
display: flex;
|
// With react-multi-carousel, better to rely on their gap logic or item class
|
||||||
}
|
|
||||||
&-button {
|
|
||||||
position: absolute !important;
|
|
||||||
height: 100%;
|
|
||||||
font-size: 1em !important;
|
|
||||||
width: $page-margin;
|
|
||||||
&.right{
|
|
||||||
border-radius: $border-radius-default 0 0 $border-radius-default !important;
|
|
||||||
right: -$page-margin;
|
|
||||||
}
|
|
||||||
&.left{
|
|
||||||
border-radius: 0 $border-radius-default $border-radius-default 0 !important;
|
|
||||||
left: -$page-margin;
|
|
||||||
}
|
|
||||||
.material-symbols-rounded{
|
|
||||||
font-size: 3.2em;
|
|
||||||
--wght: 200;
|
|
||||||
--opsz: 48;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-item {
|
||||||
|
padding-right: 0.6em; // Consistent gap
|
||||||
|
}
|
||||||
|
|
||||||
&-header-container {
|
&-header-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
min-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-heading {
|
&-heading {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
gap: 0.35em;
|
gap: 0.5em;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 0.25em !important;
|
font-weight: 600 !important;
|
||||||
|
|
||||||
&-decoration {
|
&-decoration {
|
||||||
width: 0.75em;
|
width: 4px;
|
||||||
height: 2px;
|
height: 24px;
|
||||||
background: white;
|
background: $clr-accent-default;
|
||||||
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-container .MuiButtonGroup-outlined{
|
|
||||||
gap: 1em;
|
&-controls {
|
||||||
}
|
display: flex;
|
||||||
|
gap: 0.5em;
|
||||||
|
|
||||||
|
.scroller-nav-btn {
|
||||||
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
color: #fff;
|
||||||
|
border-color: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disabled state
|
||||||
|
&.Mui-disabled {
|
||||||
|
background-color: transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.hidden-decoration {
|
.hidden-decoration {
|
||||||
|
|||||||
@@ -1,31 +1,66 @@
|
|||||||
import React, { type ReactNode } from "react";
|
import React, { type ReactNode, useRef, useState } from "react";
|
||||||
|
import CarouselModule from "react-multi-carousel";
|
||||||
import Carousel from "react-multi-carousel";
|
|
||||||
import "react-multi-carousel/lib/styles.css";
|
import "react-multi-carousel/lib/styles.css";
|
||||||
|
|
||||||
|
// react-multi-carousel is CJS with `exports.default`; Vite 8 hands default imports the whole
|
||||||
|
// `module.exports`, so unwrap `.default` when present.
|
||||||
|
const Carousel = ((
|
||||||
|
CarouselModule as unknown as { default?: typeof CarouselModule }
|
||||||
|
).default ?? CarouselModule) as typeof CarouselModule;
|
||||||
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import "./cardScroller.scss";
|
import "./cardScroller.scss";
|
||||||
|
|
||||||
//@ts-ignore - I don't know the prop type for react-multi-carousel's customRightArrow and customLeftArrow
|
// Custom Header + Button Group component
|
||||||
function RightButton(props) {
|
const ScrollerHeader = ({
|
||||||
const { carouselState, children, rtl, ...restProps } = props;
|
onNext,
|
||||||
|
onPrevious,
|
||||||
|
title,
|
||||||
|
headingProps,
|
||||||
|
disableDecoration,
|
||||||
|
currentSlide = 0,
|
||||||
|
isNextDisabled = false,
|
||||||
|
}: any) => {
|
||||||
|
// Basic disable logic for visual feedback
|
||||||
|
const isFirst = currentSlide === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton className="card-scroller-button right" {...restProps}>
|
<div
|
||||||
<div className="material-symbols-rounded">chevron_right</div>
|
className={`card-scroller-header-container ${disableDecoration ? "hidden-decoration" : ""}`}
|
||||||
</IconButton>
|
>
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
|
color="textPrimary"
|
||||||
|
className="card-scroller-heading"
|
||||||
|
{...headingProps}
|
||||||
|
>
|
||||||
|
<div className="card-scroller-heading-decoration" />
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<div className="card-scroller-controls">
|
||||||
|
<IconButton
|
||||||
|
onClick={onPrevious}
|
||||||
|
disabled={isFirst}
|
||||||
|
size="small"
|
||||||
|
className="scroller-nav-btn"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">chevron_left</span>
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
onClick={onNext}
|
||||||
|
disabled={isNextDisabled}
|
||||||
|
size="small"
|
||||||
|
className="scroller-nav-btn"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">chevron_right</span>
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
//@ts-ignore - I don't know the prop type for react-multi-carousel's customRightArrow and customLeftArrow
|
|
||||||
function LeftButton(props) {
|
|
||||||
const { carouselState, children, rtl, ...restProps } = props;
|
|
||||||
return (
|
|
||||||
<IconButton className="card-scroller-button left" {...restProps}>
|
|
||||||
<div className="material-symbols-rounded">chevron_left</div>
|
|
||||||
</IconButton>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type CardScrollerProps = {
|
type CardScrollerProps = {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -44,9 +79,13 @@ export default function CardScroller({
|
|||||||
disableDecoration = false,
|
disableDecoration = false,
|
||||||
boxProps,
|
boxProps,
|
||||||
}: CardScrollerProps) {
|
}: CardScrollerProps) {
|
||||||
|
const carouselRef = useRef<any>(null);
|
||||||
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
|
const [slidesToShow, setSlidesToShow] = useState(displayCards);
|
||||||
|
const totalItems = React.Children.count(children);
|
||||||
|
|
||||||
const responsive = {
|
const responsive = {
|
||||||
superLargeDesktop: {
|
superLargeDesktop: {
|
||||||
// the naming can be any, depends on you.
|
|
||||||
breakpoint: { max: 4000, min: 3000 },
|
breakpoint: { max: 4000, min: 3000 },
|
||||||
items: displayCards + 1,
|
items: displayCards + 1,
|
||||||
slidesToSlide: displayCards + 1,
|
slidesToSlide: displayCards + 1,
|
||||||
@@ -55,62 +94,67 @@ export default function CardScroller({
|
|||||||
desktop: {
|
desktop: {
|
||||||
breakpoint: { max: 3000, min: 925 },
|
breakpoint: { max: 3000, min: 925 },
|
||||||
items: displayCards,
|
items: displayCards,
|
||||||
slidesToSlide: displayCards, // optional, default to 1.
|
slidesToSlide: displayCards,
|
||||||
partialVisibilityGutter: 30,
|
partialVisibilityGutter: 30,
|
||||||
},
|
},
|
||||||
tablet: {
|
tablet: {
|
||||||
breakpoint: { max: 925, min: 600 },
|
breakpoint: { max: 925, min: 600 },
|
||||||
items: displayCards - 3,
|
items: Math.max(2, displayCards - 2),
|
||||||
slidesToSlide: displayCards - 3, // optional, default to 1.
|
slidesToSlide: Math.max(2, displayCards - 2),
|
||||||
partialVisibilityGutter: 20,
|
partialVisibilityGutter: 20,
|
||||||
},
|
},
|
||||||
mobile: {
|
mobile: {
|
||||||
breakpoint: { max: 600, min: 424 },
|
breakpoint: { max: 600, min: 424 },
|
||||||
items: displayCards - 5,
|
items: Math.max(1, displayCards - 4),
|
||||||
slidesToSlide: displayCards - 5, // optional, default to 1.
|
slidesToSlide: Math.max(1, displayCards - 4),
|
||||||
partialVisibilityGutter: 10,
|
partialVisibilityGutter: 10,
|
||||||
},
|
},
|
||||||
smallScreen: {
|
smallScreen: {
|
||||||
breakpoint: { max: 424, min: 0 },
|
breakpoint: { max: 424, min: 0 },
|
||||||
items: 1,
|
items: 1,
|
||||||
slidesToSlide: 1, // optional, default to 1.
|
slidesToSlide: 1,
|
||||||
partialVisibilityGutter: 10,
|
partialVisibilityGutter: 10,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleNext = () => {
|
||||||
|
if (carouselRef.current) {
|
||||||
|
carouselRef.current.next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrevious = () => {
|
||||||
|
if (carouselRef.current) {
|
||||||
|
carouselRef.current.previous();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div {...boxProps} className="card-scroller-container">
|
||||||
{...boxProps}
|
<ScrollerHeader
|
||||||
className="card-scroller-container"
|
title={title}
|
||||||
style={{ marginBottom: "1.2em" }}
|
headingProps={headingProps}
|
||||||
>
|
disableDecoration={disableDecoration}
|
||||||
<div
|
onNext={handleNext}
|
||||||
style={{ marginBottom: "1.2em" }}
|
onPrevious={handlePrevious}
|
||||||
className={
|
currentSlide={currentSlide}
|
||||||
disableDecoration
|
isNextDisabled={currentSlide + slidesToShow >= totalItems}
|
||||||
? "card-scroller-header-container hidden-decoration"
|
/>
|
||||||
: "card-scroller-header-container"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h5"
|
|
||||||
color="textPrimary"
|
|
||||||
className="card-scroller-heading"
|
|
||||||
{...headingProps}
|
|
||||||
>
|
|
||||||
<div className="card-scroller-heading-decoration" /> {title}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<Carousel
|
<Carousel
|
||||||
|
ref={carouselRef}
|
||||||
swipeable
|
swipeable
|
||||||
draggable
|
draggable
|
||||||
responsive={responsive}
|
responsive={responsive}
|
||||||
arrows
|
arrows={false}
|
||||||
className="card-scroller"
|
className="card-scroller"
|
||||||
customTransition="all .6s"
|
customTransition="transform 400ms ease-in-out"
|
||||||
transitionDuration={600}
|
transitionDuration={400}
|
||||||
customRightArrow={<RightButton />}
|
containerClass="card-scroller-track"
|
||||||
customLeftArrow={<LeftButton />}
|
itemClass="card-scroller-item"
|
||||||
|
beforeChange={(nextSlide, state) => {
|
||||||
|
setCurrentSlide(nextSlide);
|
||||||
|
setSlidesToShow(state.slidesToShow);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
|
|||||||
@@ -1,72 +1,509 @@
|
|||||||
.carousel {
|
@use "@/styles/variables.scss" as *;
|
||||||
|
|
||||||
|
/* Cinematic home hero: full-bleed artwork, integrated type, bottom rail. */
|
||||||
|
.cinema-hero {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 64vh;
|
height: calc(100vh - 16px);
|
||||||
width: calc(100% + 2*$page-margin);
|
min-height: 620px;
|
||||||
left: -$page-margin;
|
overflow: hidden;
|
||||||
margin-bottom: 3.2em;
|
isolation: isolate;
|
||||||
.slider {
|
|
||||||
|
.hero-carousel-slide {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-container {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 0;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
inset: 0;
|
||||||
max-width: 35%;
|
z-index: 2;
|
||||||
right: $page-margin;
|
background:
|
||||||
}
|
linear-gradient(
|
||||||
&-button {
|
90deg,
|
||||||
position: absolute !important;
|
rgb(6 8 12 / 0.94) 0%,
|
||||||
top: 50%;
|
rgb(6 8 12 / 0.72) 28%,
|
||||||
transform: translateY(-50%);
|
rgb(6 8 12 / 0.28) 52%,
|
||||||
z-index: 100;
|
rgb(6 8 12 / 0) 72%
|
||||||
|
),
|
||||||
&.right {
|
linear-gradient(
|
||||||
right: 0.5em;
|
0deg,
|
||||||
}
|
rgb(6 8 12 / 0.96) 0%,
|
||||||
|
rgb(6 8 12 / 0.55) 26%,
|
||||||
&.left {
|
rgb(6 8 12 / 0) 56%
|
||||||
left: 0.5em;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-indicator {
|
.hero-carousel-background-image {
|
||||||
aspect-ratio: 1.77777;
|
position: absolute;
|
||||||
overflow: hidden;
|
inset: 0;
|
||||||
border-radius: 2px;
|
width: 100%;
|
||||||
padding: 2px;
|
height: 100%;
|
||||||
transition: opacity $transition-time-fast;
|
object-fit: cover;
|
||||||
opacity: 0.5;
|
object-position: center;
|
||||||
width: auto;
|
|
||||||
|
&.is-poster {
|
||||||
|
filter: blur(42px) saturate(1.5) brightness(0.55);
|
||||||
|
transform: scale(1.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-blurhash {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
z-index: 0;
|
||||||
|
filter: blur(40px) saturate(1.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-icon-container {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 0;
|
||||||
|
background: linear-gradient(135deg, #12141a, #1d2028);
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 15em !important;
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-detail {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 3;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.9rem;
|
||||||
|
max-width: none;
|
||||||
|
padding: 0 clamp(2rem, 5vw, 4.5rem) calc(var(--home-trending-space, 200px) + 4rem);
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 16px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgb(255 255 255 / 0.16);
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.18);
|
||||||
|
backdrop-filter: blur(14px);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.86rem;
|
||||||
|
font-weight: 500;
|
||||||
|
letter-spacing: 0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
display: block;
|
||||||
|
overflow: visible;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 16ch;
|
||||||
|
font-size: clamp(2.4rem, 4.1vw, 4.4rem) !important;
|
||||||
|
line-height: 0.98 !important;
|
||||||
|
font-weight: 650 !important;
|
||||||
|
letter-spacing: -0.035em;
|
||||||
|
text-shadow: 0 2px 30px rgb(0 0 0 / 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-info {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.9em !important;
|
||||||
|
margin-top: 0.1em !important;
|
||||||
|
color: rgb(255 255 255 / 0.78);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
|
||||||
|
|
||||||
|
.MuiTypography-root {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiChip-root {
|
||||||
|
height: 24px;
|
||||||
|
background: rgb(255 255 255 / 0.14);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-info-rating {
|
||||||
|
gap: 0.2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: 34rem;
|
||||||
|
margin: 0.15rem 0 0;
|
||||||
|
color: rgb(255 255 255 / 0.82);
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 1.55;
|
||||||
|
text-shadow: 0 1px 3px rgb(0 0 0 / 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-button-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.85rem;
|
||||||
|
width: auto;
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
|
||||||
|
.MuiButton-root {
|
||||||
|
min-height: 50px;
|
||||||
|
padding: 0 24px;
|
||||||
|
border-radius: 999px;
|
||||||
|
text-transform: none;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.play-button .MuiButton-root,
|
||||||
|
.MuiButton-contained {
|
||||||
|
background: #f5f5f4;
|
||||||
|
color: #101116;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
color: #101116;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiButton-outlined {
|
||||||
|
border-color: rgb(255 255 255 / 0.34);
|
||||||
|
color: #fff;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
border-color: rgb(255 255 255 / 0.6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
color: rgb(255 255 255 / 0.75);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Big cinematic arrows */
|
||||||
|
.cinema-arrow {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
z-index: 7;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.18);
|
||||||
|
background: rgb(14 16 21 / 0.36);
|
||||||
|
backdrop-filter: blur(14px);
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
opacity: 0;
|
||||||
|
transition:
|
||||||
|
opacity 0.2s ease,
|
||||||
|
background-color 0.2s ease,
|
||||||
|
color 0.2s ease;
|
||||||
|
|
||||||
|
&.right {
|
||||||
|
right: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
background: #f5f5f4;
|
||||||
|
color: #101116;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover .cinema-arrow,
|
||||||
|
&.paused .cinema-arrow {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bottom rail */
|
||||||
|
.cinema-trending {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 6;
|
||||||
|
padding: 2rem clamp(2rem, 5vw, 4.5rem) 1.5rem;
|
||||||
|
background: linear-gradient(
|
||||||
|
0deg,
|
||||||
|
rgb(7 8 12 / 0.98) 0%,
|
||||||
|
rgb(7 8 12 / 0.9) 46%,
|
||||||
|
rgb(7 8 12 / 0) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
margin-bottom: 0.9rem;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-dots {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 26px;
|
||||||
|
height: 3px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgb(255 255 255 / 0.3);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
opacity: 0.8;
|
transition:
|
||||||
|
background-color 0.2s ease,
|
||||||
|
width 0.2s ease;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
width: 38px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-rail {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-card {
|
||||||
|
position: relative;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: clamp(200px, 21vw, 300px);
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.12);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: rgb(255 255 255 / 0.05);
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0.72;
|
||||||
|
transition:
|
||||||
|
opacity 0.2s ease,
|
||||||
|
border-color 0.2s ease,
|
||||||
|
transform 0.2s ease;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-container {
|
&::after {
|
||||||
display: flex;
|
content: "";
|
||||||
gap: 1em;
|
position: absolute;
|
||||||
align-items: center;
|
inset: 0;
|
||||||
justify-content: center;
|
background: linear-gradient(0deg, rgb(0 0 0 / 0.35), transparent 55%);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
border-color: rgb(255 255 255 / 0.4);
|
||||||
|
transform: translateY(-2px);
|
||||||
}
|
}
|
||||||
&-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-icon {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: rgb(155 155 155 / 0.4);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
&.active {
|
&.active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
border-color: rgb(255 255 255 / 0.7);
|
||||||
|
box-shadow: 0 0 0 1px rgb(255 255 255 / 0.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.material-symbols-rounded {
|
.cinema-trending-chip {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
left: 10px;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgb(245 245 244 / 0.9);
|
||||||
|
color: #131419;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
--fill: 1;
|
.cinema-trending-placeholder {
|
||||||
}
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
}
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: rgb(255 255 255 / 0.5);
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reserve room for the floating player bar so the rail is never covered. */
|
||||||
|
body.has-player-bar .cinema-trending {
|
||||||
|
padding-bottom: 116px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* With the player bar visible the hero has less vertical room, so keep the
|
||||||
|
copy compact instead of pushing it under the header. */
|
||||||
|
body.has-player-bar .cinema-hero .hero-carousel-text {
|
||||||
|
font-size: clamp(2.1rem, 3.6vw, 4rem) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.has-player-bar .cinema-hero .hero-carousel-overview {
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1100px) {
|
||||||
|
.cinema-hero {
|
||||||
|
height: calc(100vh - 16px);
|
||||||
|
min-height: 560px;
|
||||||
|
|
||||||
|
.hero-carousel-detail {
|
||||||
|
padding-left: 2rem;
|
||||||
|
padding-right: 2rem;
|
||||||
|
padding-bottom: calc(var(--home-trending-space, 200px) + 1.5rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
font-size: 2.6rem !important;
|
||||||
|
max-width: 14ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview {
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
max-width: 30rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending {
|
||||||
|
padding-left: 2rem;
|
||||||
|
padding-right: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Short windows (and the player bar) leave little vertical room: drop the
|
||||||
|
secondary copy instead of pushing the headline under the header. */
|
||||||
|
@media (max-height: 760px) {
|
||||||
|
.cinema-hero {
|
||||||
|
height: calc(100vh - 16px);
|
||||||
|
min-height: 540px;
|
||||||
|
|
||||||
|
.hero-carousel-detail {
|
||||||
|
gap: 0.65rem;
|
||||||
|
padding-bottom: calc(var(--home-trending-space, 200px) + 1rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview,
|
||||||
|
.hero-carousel-info {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
max-width: 18ch;
|
||||||
|
font-size: clamp(2rem, 3.2vw, 3rem) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending {
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-head {
|
||||||
|
margin-bottom: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-card {
|
||||||
|
width: clamp(150px, 15vw, 220px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.cinema-hero {
|
||||||
|
min-height: 520px;
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
font-size: 2.1rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-info {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-arrow {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-card {
|
||||||
|
width: 160px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+142
-122
@@ -1,28 +1,44 @@
|
|||||||
import { AnimatePresence, motion } from "framer-motion";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import type { PanInfo } from "framer-motion";
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
import {
|
||||||
import type { MouseEvent, PointerEvent } from "react";
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
import "./carousel.scss";
|
import "./carousel.scss";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import CarouselSlide from "../carouselSlide";
|
import CarouselSlide from "../carouselSlide";
|
||||||
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
const AUTOPLAY_MS = 9000;
|
||||||
import Slider from "../Slider";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
|
||||||
|
|
||||||
const swipeConfidenceThreshold = 8000;
|
|
||||||
const swipePower = (offset: number, velocity: number) => {
|
|
||||||
return Math.abs(offset) * velocity;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||||
|
|
||||||
// Memoize Slider to prevent unnecessary re-renders
|
/** Wide artwork for the trending rail, falling back through the item's images. */
|
||||||
const MemoizedSlider = React.memo(Slider);
|
const trendingImageUrl = (
|
||||||
|
api: Api,
|
||||||
|
item: BaseItemDto,
|
||||||
|
): string | undefined => {
|
||||||
|
const image = resolveItemImage(item, "Thumb");
|
||||||
|
if (!image) return undefined;
|
||||||
|
return getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
image.itemId,
|
||||||
|
image.imageType,
|
||||||
|
{
|
||||||
|
quality: 85,
|
||||||
|
fillWidth: 480,
|
||||||
|
tag: image.tag,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const trendingLabel = (item: BaseItemDto): string => {
|
||||||
|
const genre = item.Genres?.[0];
|
||||||
|
if (genre) return genre.charAt(0).toUpperCase() + genre.slice(1);
|
||||||
|
return item.Type === BaseItemKind.Series ? "Сериал" : "Фильм";
|
||||||
|
};
|
||||||
|
|
||||||
const Carousel = ({
|
const Carousel = ({
|
||||||
content,
|
content,
|
||||||
@@ -32,122 +48,126 @@ const Carousel = ({
|
|||||||
onChange: (currentSlide: number) => void;
|
onChange: (currentSlide: number) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
|
const [isPaused, setIsPaused] = useState(false);
|
||||||
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const total = content.length;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentSlide >= total && total > 0) {
|
||||||
|
setCurrentSlide(total - 1);
|
||||||
|
}
|
||||||
|
}, [currentSlide, total]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onChange(currentSlide);
|
onChange(currentSlide);
|
||||||
}, [content[currentSlide]?.Id]);
|
}, [currentSlide, onChange]);
|
||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const goTo = useCallback(
|
||||||
|
(index: number) => {
|
||||||
// Memoize the content mapping
|
if (index === currentSlide) return;
|
||||||
const sliderContent = useMemo(() => {
|
setDirection(index > currentSlide ? "right" : "left");
|
||||||
return content.map((item, index) => {
|
setCurrentSlide(index);
|
||||||
return (
|
|
||||||
<motion.div
|
|
||||||
className={
|
|
||||||
currentSlide === index
|
|
||||||
? "carousel-indicator active"
|
|
||||||
: "carousel-indicator"
|
|
||||||
}
|
|
||||||
layout
|
|
||||||
initial={{
|
|
||||||
height: "4.6em",
|
|
||||||
}}
|
|
||||||
whileHover={{
|
|
||||||
height: "5.5em",
|
|
||||||
}}
|
|
||||||
transition={{
|
|
||||||
duration: 0.05,
|
|
||||||
}}
|
|
||||||
key={item.Id}
|
|
||||||
onClick={() => {
|
|
||||||
if (currentSlide > index) {
|
|
||||||
setDirection("left");
|
|
||||||
} else if (currentSlide <= index) {
|
|
||||||
setDirection("right");
|
|
||||||
}
|
|
||||||
setCurrentSlide(index);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{item.ImageTags?.Thumb ? (
|
|
||||||
<img
|
|
||||||
src={
|
|
||||||
api &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
item.Id ?? "",
|
|
||||||
"Thumb",
|
|
||||||
{
|
|
||||||
tag: item.ImageTags.Primary,
|
|
||||||
fillWidth: 300,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt={item.Name ?? "item-image"}
|
|
||||||
className="carousel-indicator-image"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="carousel-indicator-icon">
|
|
||||||
{getTypeIcon(item.Type ?? "Movie")}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</motion.div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}, [content, currentSlide, api, setDirection]);
|
|
||||||
|
|
||||||
const handleDragEnd = useCallback(
|
|
||||||
(
|
|
||||||
_: MouseEvent | TouchEvent | PointerEvent,
|
|
||||||
{ offset, velocity }: PanInfo,
|
|
||||||
) => {
|
|
||||||
const swipe = swipePower(offset.x, velocity.x);
|
|
||||||
if (
|
|
||||||
currentSlide !== content.length - 1 &&
|
|
||||||
swipe < -swipeConfidenceThreshold
|
|
||||||
) {
|
|
||||||
setDirection("right");
|
|
||||||
setCurrentSlide((init) => init + 1);
|
|
||||||
} else if (currentSlide !== 0 && swipe > swipeConfidenceThreshold) {
|
|
||||||
setDirection("left");
|
|
||||||
setCurrentSlide((init) => init - 1);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[currentSlide, content.length, setDirection],
|
[currentSlide, setDirection],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const next = useCallback(() => {
|
||||||
|
if (total < 2) return;
|
||||||
|
setDirection("right");
|
||||||
|
setCurrentSlide((prev) => (prev + 1) % total);
|
||||||
|
}, [total, setDirection]);
|
||||||
|
|
||||||
|
// Autoplay; pauses while the pointer is over the hero.
|
||||||
|
useEffect(() => {
|
||||||
|
if (isPaused || total < 2) return;
|
||||||
|
const timer = window.setInterval(() => {
|
||||||
|
setDirection("right");
|
||||||
|
setCurrentSlide((prev) => (prev + 1) % total);
|
||||||
|
}, AUTOPLAY_MS);
|
||||||
|
return () => window.clearInterval(timer);
|
||||||
|
}, [isPaused, total, setDirection]);
|
||||||
|
|
||||||
|
if (!api || total === 0) return null;
|
||||||
|
|
||||||
|
const currentItem = content[currentSlide];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="carousel">
|
<section
|
||||||
<AnimatePresence mode="sync">
|
className={`cinema-hero ${isPaused ? "paused" : ""}`}
|
||||||
<motion.div
|
aria-roledescription="carousel"
|
||||||
key={currentSlide}
|
aria-label="Рекомендуемое"
|
||||||
initial={{ opacity: 0 }}
|
onMouseEnter={() => setIsPaused(true)}
|
||||||
animate={{ opacity: 1 }}
|
onMouseLeave={() => setIsPaused(false)}
|
||||||
exit={{ opacity: 0 }}
|
>
|
||||||
transition={{
|
<MemoizedCarouselSlide key={currentItem.Id} item={currentItem} />
|
||||||
duration: 0.25,
|
|
||||||
ease: "linear",
|
{total > 1 && (
|
||||||
}}
|
<button
|
||||||
drag={"x"}
|
type="button"
|
||||||
dragConstraints={{ left: 0, right: 0 }}
|
className="cinema-arrow right"
|
||||||
dragElastic={1}
|
onClick={next}
|
||||||
//@ts-ignore
|
aria-label="Далее"
|
||||||
onDragEnd={handleDragEnd}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
position: "absolute",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<MemoizedCarouselSlide
|
<span className="material-symbols-rounded">chevron_right</span>
|
||||||
item={content[currentSlide]}
|
</button>
|
||||||
key={content[currentSlide].Id}
|
)}
|
||||||
/>
|
|
||||||
</motion.div>
|
<div className="cinema-trending">
|
||||||
</AnimatePresence>
|
<div className="cinema-trending-head">
|
||||||
<MemoizedSlider currentSlide={currentSlide} content={sliderContent} />
|
<h3>В тренде</h3>
|
||||||
</div>
|
{total > 1 && (
|
||||||
|
<div className="cinema-dots">
|
||||||
|
{content.map((item, index) => (
|
||||||
|
<button
|
||||||
|
key={item.Id}
|
||||||
|
type="button"
|
||||||
|
className={index === currentSlide ? "active" : ""}
|
||||||
|
onClick={() => goTo(index)}
|
||||||
|
aria-label={item.Name ?? `Slide ${index + 1}`}
|
||||||
|
aria-current={index === currentSlide}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="cinema-trending-rail">
|
||||||
|
{content.map((item, index) => {
|
||||||
|
const imageUrl = trendingImageUrl(api, item);
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={item.Id}
|
||||||
|
type="button"
|
||||||
|
className={`cinema-trending-card ${
|
||||||
|
index === currentSlide ? "active" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => goTo(index)}
|
||||||
|
aria-label={item.Name ?? "Рекомендуемое"}
|
||||||
|
>
|
||||||
|
{imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
alt=""
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="cinema-trending-placeholder">
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
{ item.Type === BaseItemKind.Series ? "tv" : "movie" }
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<span className="cinema-trending-chip">
|
||||||
|
{trendingLabel(item)}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,59 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
|
||||||
|
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import Chip from "@mui/material/Chip";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { yellow } from "@mui/material/colors";
|
|
||||||
|
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
|
||||||
import { green, red } from "@mui/material/colors";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCarouselStore } from "@/utils/store/carousel";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import Chip from "@mui/material/Chip";
|
||||||
|
import { green, red, yellow } from "@mui/material/colors";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { motion, type Variants } from "motion/react";
|
||||||
|
import React from "react";
|
||||||
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
|
import {
|
||||||
|
getHeroPosterUrl,
|
||||||
|
getItemImagesQueryOptions,
|
||||||
|
resolveHeroArtwork,
|
||||||
|
} from "@/utils/methods/heroArtwork";
|
||||||
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
|
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCarouselStore } from "@/utils/store/carousel";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
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 { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
import { getItemLinkOptions } from "@/utils/navigation/itemLink";
|
||||||
|
|
||||||
|
const MotionTypography = motion.create(Typography);
|
||||||
|
const MotionStack = motion.create(Stack);
|
||||||
|
|
||||||
|
const textVariants: Variants = {
|
||||||
|
// No hidden start state: hero text must not blink on slide changes.
|
||||||
|
initial: {
|
||||||
|
x: 0,
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
animate: {
|
||||||
|
x: 0,
|
||||||
|
opacity: 1,
|
||||||
|
transition: {
|
||||||
|
duration: 0.35,
|
||||||
|
ease: [0.2, 0, 0, 1] as const,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exit: (direction: string) => ({
|
||||||
|
x: direction === "right" ? -40 : 40,
|
||||||
|
opacity: 0,
|
||||||
|
transition: {
|
||||||
|
duration: 0.2,
|
||||||
|
ease: "easeInOut",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -33,150 +63,123 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
|
|
||||||
const handleMoreInfo = () => {
|
const handleMoreInfo = () => {
|
||||||
if (item.Id) {
|
if (item.Id) {
|
||||||
switch (item.Type) {
|
navigate(getItemLinkOptions(item.Id, item.Type));
|
||||||
case BaseItemKind.BoxSet:
|
|
||||||
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Episode:
|
|
||||||
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicAlbum:
|
|
||||||
navigate({ to: "/album/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicArtist:
|
|
||||||
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Person:
|
|
||||||
navigate({ to: "/person/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Series:
|
|
||||||
navigate({ to: "/series/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Playlist:
|
|
||||||
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
navigate({ to: "/item/$id", params: { id: item.Id } });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [animationDirection] = useCarouselStore((state) => [state.direction]);
|
const [animationDirection] = useCarouselStore((state) => [state.direction]);
|
||||||
|
|
||||||
|
// Jellyfin stores several images per item (poster, thumb, backdrops).
|
||||||
|
// Ask the server which ones exist and their real size, then pick the wide one.
|
||||||
|
const imageInfos = useQuery(getItemImagesQueryOptions(api, item.Id));
|
||||||
|
const heroArtwork = resolveHeroArtwork(api, item, imageInfos.data);
|
||||||
|
const heroPoster = heroArtwork?.isPortrait
|
||||||
|
? getHeroPosterUrl(api, item)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="hero-carousel-slide">
|
<div className="hero-carousel-slide">
|
||||||
<div className="hero-carousel-background-container">
|
<motion.div
|
||||||
{item.BackdropImageTags?.length ? (
|
className="hero-carousel-background-container"
|
||||||
|
initial={{ opacity: 1 }}
|
||||||
|
animate={{ opacity: 1 }}
|
||||||
|
exit={{ opacity: 0 }}
|
||||||
|
transition={{ duration: 0.4, ease: "easeInOut" }}
|
||||||
|
>
|
||||||
|
{heroArtwork?.blurhash && (
|
||||||
|
<BlurhashCanvas
|
||||||
|
blurhashString={heroArtwork.blurhash}
|
||||||
|
width={48}
|
||||||
|
height={27}
|
||||||
|
canvasProps={{
|
||||||
|
className: "hero-carousel-background-blurhash",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{heroArtwork ? (
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "item"}
|
alt={item.Name ?? "item"}
|
||||||
className="hero-carousel-background-image"
|
className={`hero-carousel-background-image${heroArtwork.isPortrait ? " is-poster" : ""}`}
|
||||||
src={
|
src={heroArtwork.url}
|
||||||
item.ParentBackdropItemId
|
|
||||||
? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
|
||||||
: `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
|
||||||
}
|
|
||||||
style={{
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.currentTarget.style.opacity = "1";
|
|
||||||
}}
|
|
||||||
loading="eager"
|
loading="eager"
|
||||||
|
decoding="async"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="hero-carousel-background-icon-container">
|
<div className="hero-carousel-background-icon-container">
|
||||||
{getTypeIcon(item.Type ?? "Movie")}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
{heroPoster && (
|
||||||
<div className="hero-carousel-detail">
|
<img
|
||||||
<Typography
|
alt={item.Name ?? "poster"}
|
||||||
component={motion.div}
|
className="hero-carousel-poster"
|
||||||
initial={{
|
src={heroPoster}
|
||||||
transform:
|
loading="eager"
|
||||||
animationDirection === "right"
|
/>
|
||||||
? "translateX(60px)"
|
)}
|
||||||
: "translateX(-60px)",
|
</motion.div>
|
||||||
opacity: 0,
|
<motion.div
|
||||||
}}
|
className="hero-carousel-detail"
|
||||||
animate={{
|
initial="initial"
|
||||||
transform: "translateX(0px)",
|
animate="animate"
|
||||||
opacity: 1,
|
exit="exit"
|
||||||
}}
|
variants={{
|
||||||
exit={{
|
animate: {
|
||||||
transform:
|
transition: {
|
||||||
animationDirection === "right"
|
staggerChildren: 0.05,
|
||||||
? "translateX(-60px)"
|
delayChildren: 0.05,
|
||||||
: "translateX(60px)",
|
},
|
||||||
opacity: 0,
|
},
|
||||||
}}
|
exit: {
|
||||||
transition={{
|
transition: {
|
||||||
duration: 0.25,
|
staggerChildren: 0.02,
|
||||||
ease: "easeInOut",
|
staggerDirection: -1,
|
||||||
}}
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MotionStack
|
||||||
|
custom={animationDirection}
|
||||||
|
variants={textVariants}
|
||||||
|
direction="row"
|
||||||
|
sx={{ alignItems: "center", gap: 1 }}
|
||||||
|
>
|
||||||
|
<span className="hero-carousel-label">
|
||||||
|
{item.UserData?.PlaybackPositionTicks
|
||||||
|
? "Продолжить просмотр"
|
||||||
|
: item.Type === BaseItemKind.Series
|
||||||
|
? "Новый сериал"
|
||||||
|
: "Новый фильм"}
|
||||||
|
</span>
|
||||||
|
</MotionStack>
|
||||||
|
<MotionTypography
|
||||||
|
custom={animationDirection}
|
||||||
|
variants={textVariants}
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
variant="h2"
|
variant="h2"
|
||||||
className="hero-carousel-text"
|
className="hero-carousel-text"
|
||||||
sx={{
|
sx={{
|
||||||
mb: "5px",
|
fontWeight: 600,
|
||||||
|
overflow: "visible",
|
||||||
}}
|
}}
|
||||||
fontWeight={200}
|
|
||||||
overflow="visible"
|
|
||||||
>
|
>
|
||||||
{!item.ImageTags?.Logo ? (
|
{item.Name}
|
||||||
item.Name
|
</MotionTypography>
|
||||||
) : (
|
<MotionStack
|
||||||
<img
|
custom={animationDirection}
|
||||||
alt={item.Name ?? "Item"}
|
variants={textVariants}
|
||||||
className="hero-carousel-text-logo"
|
|
||||||
src={`${api?.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
|
||||||
style={{
|
|
||||||
opacity: 0,
|
|
||||||
transition: "opacity 0.2s",
|
|
||||||
objectFit: "contain",
|
|
||||||
}}
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.currentTarget.style.opacity = "1";
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
component={motion.div}
|
|
||||||
initial={{
|
|
||||||
transform:
|
|
||||||
animationDirection === "right"
|
|
||||||
? "translateX(20px)"
|
|
||||||
: "translateX(-20px)",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
animate={{
|
|
||||||
transform: "translateX(0px)",
|
|
||||||
opacity: 1,
|
|
||||||
}}
|
|
||||||
exit={{
|
|
||||||
transform:
|
|
||||||
animationDirection === "right"
|
|
||||||
? "translateX(-20px)"
|
|
||||||
: "translateX(20px)",
|
|
||||||
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
transition={{
|
|
||||||
duration: 0.25,
|
|
||||||
ease: "easeInOut",
|
|
||||||
}}
|
|
||||||
direction="row"
|
direction="row"
|
||||||
gap={2}
|
|
||||||
className="hero-carousel-info"
|
className="hero-carousel-info"
|
||||||
mt={1}
|
sx={{
|
||||||
justifyItems="flex-start"
|
gap: 2,
|
||||||
alignItems="center"
|
mt: 1,
|
||||||
|
justifyItems: "flex-start",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{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 && (
|
||||||
@@ -239,82 +242,49 @@ 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(
|
{endsAt(
|
||||||
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
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(" / ")}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</MotionStack>
|
||||||
<Typography
|
<MotionTypography
|
||||||
component={motion.div}
|
custom={animationDirection}
|
||||||
initial={{
|
variants={textVariants}
|
||||||
transform:
|
className="hero-carousel-overview"
|
||||||
animationDirection === "right"
|
variant="body1"
|
||||||
? "translateX(20px)"
|
|
||||||
: "translateX(-20px)",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
animate={{
|
|
||||||
transform: "translateX(0px)",
|
|
||||||
opacity: 1,
|
|
||||||
}}
|
|
||||||
exit={{
|
|
||||||
transform:
|
|
||||||
animationDirection === "right"
|
|
||||||
? "translateX(-20px)"
|
|
||||||
: "translateX(20px)",
|
|
||||||
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
transition={{
|
|
||||||
duration: 0.25,
|
|
||||||
ease: "easeInOut",
|
|
||||||
}}
|
|
||||||
className="hero-carousel-text"
|
|
||||||
sx={{
|
sx={{
|
||||||
display: "-webkit-box",
|
fontWeight: 400,
|
||||||
maxWidth: "70%",
|
|
||||||
maxHeight: "50%",
|
|
||||||
textOverflow: "ellipsis",
|
|
||||||
overflow: "hidden",
|
|
||||||
WebkitLineClamp: "4",
|
|
||||||
WebkitBoxOrient: "vertical",
|
|
||||||
}}
|
}}
|
||||||
variant="subtitle2"
|
|
||||||
fontWeight={300}
|
|
||||||
>
|
>
|
||||||
{item.Overview}
|
{item.Overview}
|
||||||
</Typography>
|
</MotionTypography>
|
||||||
|
|
||||||
<Stack
|
<MotionStack
|
||||||
mt={3}
|
|
||||||
direction="row"
|
direction="row"
|
||||||
gap={3}
|
|
||||||
width="100%"
|
|
||||||
className="hero-carousel-button-container"
|
className="hero-carousel-button-container"
|
||||||
alignItems="center"
|
custom={animationDirection}
|
||||||
|
variants={textVariants}
|
||||||
|
sx={{
|
||||||
|
gap: 2,
|
||||||
|
width: "100%",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
itemType={item.Type ?? "Movie"}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentAudioTrack={0}
|
|
||||||
currentSubTrack={0}
|
|
||||||
currentVideoTrack={0}
|
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
size: "large",
|
size: "large",
|
||||||
}}
|
}}
|
||||||
@@ -330,7 +300,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="large"
|
size="large"
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
endIcon={
|
endIcon={
|
||||||
@@ -345,9 +315,14 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
}
|
}
|
||||||
onClick={handleMoreInfo}
|
onClick={handleMoreInfo}
|
||||||
>
|
>
|
||||||
More info
|
Подробнее
|
||||||
</Button>
|
</Button>
|
||||||
<Stack direction="row" gap={1}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
sx={{
|
||||||
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
queryKey={["home", "latestMedia"]}
|
queryKey={["home", "latestMedia"]}
|
||||||
@@ -363,8 +338,8 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</MotionStack>
|
||||||
</div>
|
</motion.div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// Write a react component that included an MUI circluar progress element utilizing NProgrss
|
||||||
|
|
||||||
|
import { CircularProgress } from "@mui/material";
|
||||||
|
import { useNProgress } from "@tanem/react-nprogress";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const CircularPageLoadingAnimation = () => {
|
||||||
|
const { progress } = useNProgress({
|
||||||
|
isAnimating: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
pointerEvents: "none",
|
||||||
|
position: "absolute",
|
||||||
|
top: "50%",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, -50%)",
|
||||||
|
zIndex: "10001",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress
|
||||||
|
// variant="indeterminate"
|
||||||
|
sx={{
|
||||||
|
transitionDuration: "0.3s",
|
||||||
|
transform: `scale(${progress})`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CircularPageLoadingAnimation;
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
|
import {
|
||||||
|
consumePendingDeepLink,
|
||||||
|
handleDeepLink,
|
||||||
|
} from "@/utils/methods/deepLinks";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
|
const DeepLinkHandler = () => {
|
||||||
|
const api = useApiInContext((state) => state.api);
|
||||||
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let disposed = false;
|
||||||
|
let unlisten: (() => void) | undefined;
|
||||||
|
|
||||||
|
const process = async (urls: string[] | null | undefined) => {
|
||||||
|
for (const url of urls ?? []) {
|
||||||
|
try {
|
||||||
|
await handleDeepLink(url, { api, user, navigate });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Could not handle deep link", url, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getCurrent()
|
||||||
|
.then((urls) => {
|
||||||
|
if (!disposed) void process(urls);
|
||||||
|
})
|
||||||
|
.catch((error) => console.warn("Could not read deep links", error));
|
||||||
|
|
||||||
|
onOpenUrl((urls) => {
|
||||||
|
if (!disposed) void process(urls);
|
||||||
|
})
|
||||||
|
.then((stop) => {
|
||||||
|
if (disposed) stop();
|
||||||
|
else unlisten = stop;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn("Deep-link listener is unavailable", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
const pending = consumePendingDeepLink();
|
||||||
|
if (pending) void process([pending]);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disposed = true;
|
||||||
|
unlisten?.();
|
||||||
|
};
|
||||||
|
}, [api, user?.Id, navigate]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(DeepLinkHandler);
|
||||||
@@ -0,0 +1,538 @@
|
|||||||
|
import { getGenreApi } from "@jellyfin/sdk/lib/utils/api/genre-api";
|
||||||
|
import {
|
||||||
|
Accordion,
|
||||||
|
AccordionDetails,
|
||||||
|
AccordionSummary,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogTitle,
|
||||||
|
FormControlLabel,
|
||||||
|
FormGroup,
|
||||||
|
IconButton,
|
||||||
|
Stack,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
import { getRouteApi } from "@tanstack/react-router";
|
||||||
|
import React, { useMemo, useRef, useState } from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import type { FILTERS } from "@/utils/constants/library";
|
||||||
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
|
|
||||||
|
const route = getRouteApi("/_api/library/$id");
|
||||||
|
|
||||||
|
const FILTER_LABELS: Record<FILTERS, string> = {
|
||||||
|
isPlayed: "Просмотрено",
|
||||||
|
isUnPlayed: "Не просмотрено",
|
||||||
|
isResumable: "Можно продолжить",
|
||||||
|
isFavorite: "Избранное",
|
||||||
|
hasSubtitles: "Есть субтитры",
|
||||||
|
hasTrailer: "Есть трейлер",
|
||||||
|
hasSpecialFeature: "Дополнительные материалы",
|
||||||
|
hasThemeSong: "Тематическая песня",
|
||||||
|
hasThemeVideo: "Тематическое видео",
|
||||||
|
isSD: "SD",
|
||||||
|
isHD: "HD",
|
||||||
|
is4K: "4K",
|
||||||
|
is3D: "3D",
|
||||||
|
};
|
||||||
|
|
||||||
|
interface FiltersDialogProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||||
|
({ open, onClose }) => {
|
||||||
|
const { id: currentLibraryId } = route.useParams();
|
||||||
|
const { api, user } = route.useRouteContext();
|
||||||
|
const { routeFilters, routeVideoTypes, routeGenreIds } =
|
||||||
|
useLibraryStateStore(
|
||||||
|
useShallow((s) => {
|
||||||
|
const slice = s.libraries[currentLibraryId || ""];
|
||||||
|
return {
|
||||||
|
routeFilters: slice?.filters,
|
||||||
|
routeVideoTypes: slice?.videoTypesState,
|
||||||
|
routeGenreIds: slice?.genreIds,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||||
|
const initial = useMemo(
|
||||||
|
() => ({ ...(routeFilters || {}) }),
|
||||||
|
[routeFilters],
|
||||||
|
);
|
||||||
|
const [localFilters, setLocalFilters] =
|
||||||
|
useState<Record<string, boolean | undefined>>(initial);
|
||||||
|
const initialVideo = useMemo(
|
||||||
|
() => ({ ...(routeVideoTypes || {}) }),
|
||||||
|
[routeVideoTypes],
|
||||||
|
);
|
||||||
|
const [localVideoTypes, setLocalVideoTypes] =
|
||||||
|
useState<Record<string, boolean>>(initialVideo);
|
||||||
|
const initialGenres = useMemo(
|
||||||
|
() => [...(routeGenreIds || [])] as string[],
|
||||||
|
[routeGenreIds],
|
||||||
|
);
|
||||||
|
const [localGenreIds, setLocalGenreIds] = useState<string[]>(initialGenres);
|
||||||
|
const dirty = useMemo(
|
||||||
|
() =>
|
||||||
|
JSON.stringify(initial) !== JSON.stringify(localFilters) ||
|
||||||
|
JSON.stringify(initialVideo) !== JSON.stringify(localVideoTypes) ||
|
||||||
|
JSON.stringify(initialGenres) !== JSON.stringify(localGenreIds),
|
||||||
|
[
|
||||||
|
initial,
|
||||||
|
localFilters,
|
||||||
|
initialVideo,
|
||||||
|
localVideoTypes,
|
||||||
|
initialGenres,
|
||||||
|
localGenreIds,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
const debounceRef = useRef<number | null>(null);
|
||||||
|
const currentLibrary = useSuspenseQuery(
|
||||||
|
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||||
|
);
|
||||||
|
const collectionType = currentLibrary.data.CollectionType;
|
||||||
|
const isVideoCollection = ["movies", "tvshows", "boxsets"].includes(
|
||||||
|
String(collectionType || "").toLowerCase(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Fetch genres for this library (music uses music-genres API)
|
||||||
|
const { data: genresData } = useQuery({
|
||||||
|
queryKey: ["library", "genres", currentLibraryId, collectionType],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !user?.Id || !currentLibraryId) return { Items: [] } as any;
|
||||||
|
if (String(collectionType || "").toLowerCase() === "music") {
|
||||||
|
const res = await getGenreApi(api).getGenres({
|
||||||
|
parentId: currentLibraryId,
|
||||||
|
userId: user.Id,
|
||||||
|
});
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
const res = await getGenreApi(api).getGenres({
|
||||||
|
parentId: currentLibraryId,
|
||||||
|
userId: user.Id,
|
||||||
|
});
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
staleTime: 10 * 60 * 1000,
|
||||||
|
enabled: !!open && !!api && !!user?.Id && !!currentLibraryId,
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleToggle = (key: FILTERS) => {
|
||||||
|
setLocalFilters((prev) => {
|
||||||
|
const next = { ...prev };
|
||||||
|
// isHD special: undefined if unchecked instead of false
|
||||||
|
if (key === "isHD") {
|
||||||
|
if (next[key]) delete next[key];
|
||||||
|
else next[key] = true;
|
||||||
|
} else {
|
||||||
|
next[key] = !next[key];
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const apply = () => {
|
||||||
|
if (!currentLibraryId) return;
|
||||||
|
if (debounceRef.current) window.clearTimeout(debounceRef.current);
|
||||||
|
debounceRef.current = window.setTimeout(() => {
|
||||||
|
updateLibrary(currentLibraryId, {
|
||||||
|
filters: localFilters as any,
|
||||||
|
videoTypesState: localVideoTypes as any,
|
||||||
|
genreIds: localGenreIds as any,
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
}, 40);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearAll = () => {
|
||||||
|
setLocalFilters({});
|
||||||
|
setLocalVideoTypes({});
|
||||||
|
setLocalGenreIds([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const restore = () => setLocalFilters(initial);
|
||||||
|
const restoreVideo = () => setLocalVideoTypes(initialVideo);
|
||||||
|
const restoreGenres = () => setLocalGenreIds(initialGenres);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
fullWidth
|
||||||
|
maxWidth="sm"
|
||||||
|
keepMounted
|
||||||
|
slotProps={{
|
||||||
|
paper: { className: "glass-dialog-paper" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogTitle>Фильтры</DialogTitle>
|
||||||
|
<DialogContent
|
||||||
|
dividers
|
||||||
|
sx={{ borderColor: "rgba(255, 255, 255, 0.1)" }}
|
||||||
|
>
|
||||||
|
<Stack spacing={1.25}>
|
||||||
|
<Accordion
|
||||||
|
disableGutters
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
boxShadow: "none",
|
||||||
|
m: 0,
|
||||||
|
"&:before": { display: "none" },
|
||||||
|
"&:not(:last-of-type)": {
|
||||||
|
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AccordionSummary
|
||||||
|
sx={{
|
||||||
|
minHeight: 40,
|
||||||
|
"& .MuiAccordionSummary-content": { my: 0 },
|
||||||
|
}}
|
||||||
|
expandIcon={
|
||||||
|
<span className="material-symbols-rounded">expand_more</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2">Общие</Typography>
|
||||||
|
</AccordionSummary>
|
||||||
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
|
<FormGroup>
|
||||||
|
{(
|
||||||
|
[
|
||||||
|
"isPlayed",
|
||||||
|
"isUnPlayed",
|
||||||
|
"isResumable",
|
||||||
|
"isFavorite",
|
||||||
|
] as FILTERS[]
|
||||||
|
).map((k) => (
|
||||||
|
<FormControlLabel
|
||||||
|
key={k}
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={!!localFilters[k]}
|
||||||
|
onChange={() => handleToggle(k)}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={FILTER_LABELS[k]}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</FormGroup>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
|
|
||||||
|
{isVideoCollection && (
|
||||||
|
<Accordion
|
||||||
|
disableGutters
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
boxShadow: "none",
|
||||||
|
m: 0,
|
||||||
|
"&:before": { display: "none" },
|
||||||
|
"&:not(:last-of-type)": {
|
||||||
|
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AccordionSummary
|
||||||
|
sx={{
|
||||||
|
minHeight: 40,
|
||||||
|
"& .MuiAccordionSummary-content": { my: 0 },
|
||||||
|
}}
|
||||||
|
expandIcon={
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
expand_more
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2">Видео</Typography>
|
||||||
|
</AccordionSummary>
|
||||||
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
|
<FormGroup>
|
||||||
|
{(
|
||||||
|
[
|
||||||
|
"hasSubtitles",
|
||||||
|
"hasTrailer",
|
||||||
|
"hasSpecialFeature",
|
||||||
|
"hasThemeSong",
|
||||||
|
"hasThemeVideo",
|
||||||
|
] as FILTERS[]
|
||||||
|
).map((k) => (
|
||||||
|
<FormControlLabel
|
||||||
|
key={k}
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={!!localFilters[k]}
|
||||||
|
onChange={() => handleToggle(k)}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={FILTER_LABELS[k]}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</FormGroup>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isVideoCollection && (
|
||||||
|
<Accordion
|
||||||
|
disableGutters
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
boxShadow: "none",
|
||||||
|
m: 0,
|
||||||
|
"&:before": { display: "none" },
|
||||||
|
"&:not(:last-of-type)": {
|
||||||
|
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AccordionSummary
|
||||||
|
sx={{
|
||||||
|
minHeight: 40,
|
||||||
|
"& .MuiAccordionSummary-content": { my: 0 },
|
||||||
|
}}
|
||||||
|
expandIcon={
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
expand_more
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2">Разрешение</Typography>
|
||||||
|
</AccordionSummary>
|
||||||
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
|
<FormGroup>
|
||||||
|
{(["isSD", "isHD", "is4K", "is3D"] as FILTERS[]).map(
|
||||||
|
(k) => (
|
||||||
|
<FormControlLabel
|
||||||
|
key={k}
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={!!localFilters[k]}
|
||||||
|
onChange={() => handleToggle(k)}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={FILTER_LABELS[k]}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</FormGroup>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isVideoCollection && (
|
||||||
|
<Accordion
|
||||||
|
disableGutters
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
boxShadow: "none",
|
||||||
|
m: 0,
|
||||||
|
"&:before": { display: "none" },
|
||||||
|
"&:not(:last-of-type)": {
|
||||||
|
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AccordionSummary
|
||||||
|
sx={{
|
||||||
|
minHeight: 40,
|
||||||
|
"& .MuiAccordionSummary-content": { my: 0 },
|
||||||
|
}}
|
||||||
|
expandIcon={
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
expand_more
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2">Тип медиа</Typography>
|
||||||
|
</AccordionSummary>
|
||||||
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
|
<FormGroup>
|
||||||
|
{(["BluRay", "Dvd", "Iso", "VideoFile"] as const).map(
|
||||||
|
(k) => (
|
||||||
|
<FormControlLabel
|
||||||
|
key={k}
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={!!(localVideoTypes as any)[k]}
|
||||||
|
onChange={() =>
|
||||||
|
setLocalVideoTypes((prev) => ({
|
||||||
|
...(prev || {}),
|
||||||
|
[k]: !(prev as any)?.[k],
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={
|
||||||
|
k === "VideoFile"
|
||||||
|
? "Видеофайл"
|
||||||
|
: k === "BluRay"
|
||||||
|
? "Blu-ray"
|
||||||
|
: k === "Dvd"
|
||||||
|
? "DVD"
|
||||||
|
: k === "Iso"
|
||||||
|
? "ISO"
|
||||||
|
: k
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</FormGroup>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Genres (all collection types) */}
|
||||||
|
{(genresData?.Items?.length || 0) > 0 && (
|
||||||
|
<Accordion
|
||||||
|
disableGutters
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
boxShadow: "none",
|
||||||
|
m: 0,
|
||||||
|
"&:before": { display: "none" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AccordionSummary
|
||||||
|
sx={{
|
||||||
|
minHeight: 40,
|
||||||
|
"& .MuiAccordionSummary-content": { my: 0 },
|
||||||
|
}}
|
||||||
|
expandIcon={
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
expand_more
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2">Жанры</Typography>
|
||||||
|
</AccordionSummary>
|
||||||
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
|
<FormGroup>
|
||||||
|
{(genresData?.Items || []).map((g: any) => (
|
||||||
|
<FormControlLabel
|
||||||
|
key={g.Id}
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={localGenreIds.includes(g.Id)}
|
||||||
|
onChange={() =>
|
||||||
|
setLocalGenreIds((prev) =>
|
||||||
|
prev.includes(g.Id)
|
||||||
|
? prev.filter((id) => id !== g.Id)
|
||||||
|
: [...prev, g.Id],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={g.Name}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</FormGroup>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button
|
||||||
|
onClick={clearAll}
|
||||||
|
color="inherit"
|
||||||
|
disabled={Object.keys(localFilters).length === 0}
|
||||||
|
>
|
||||||
|
Сбросить
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
restore();
|
||||||
|
restoreVideo();
|
||||||
|
restoreGenres();
|
||||||
|
}}
|
||||||
|
color="inherit"
|
||||||
|
disabled={!dirty}
|
||||||
|
>
|
||||||
|
Сбросить всё
|
||||||
|
</Button>
|
||||||
|
<Button onClick={onClose}>Отмена</Button>
|
||||||
|
<Button onClick={apply} disabled={!dirty} variant="contained">
|
||||||
|
Применить
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
(FiltersDialog as any).displayName = "FiltersDialog";
|
||||||
|
|
||||||
|
export const FiltersDialogTrigger: React.FC = () => {
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const { id: currentLibraryId } = route.useParams();
|
||||||
|
const { filters, videoTypesState, genreIds } = useLibraryStateStore(
|
||||||
|
useShallow((s) => {
|
||||||
|
const slice = s.libraries[currentLibraryId || ""];
|
||||||
|
return {
|
||||||
|
filters: slice?.filters,
|
||||||
|
videoTypesState: slice?.videoTypesState,
|
||||||
|
genreIds: slice?.genreIds,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const activeCount = useMemo(() => {
|
||||||
|
const a = Object.values(filters || {}).filter((v) => v === true).length;
|
||||||
|
const b = Object.values(videoTypesState || {}).filter(
|
||||||
|
(v) => v === true,
|
||||||
|
).length;
|
||||||
|
const c = (genreIds || []).length;
|
||||||
|
return a + b + c;
|
||||||
|
}, [filters, videoTypesState, genreIds]);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip
|
||||||
|
title={activeCount ? `${activeCount} активных фильтров` : "Фильтры"}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
aria-label="Открыть фильтры"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ position: "relative" }}
|
||||||
|
>
|
||||||
|
filter_list
|
||||||
|
{activeCount > 0 && (
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: -2,
|
||||||
|
right: -4,
|
||||||
|
background: "#ff4081",
|
||||||
|
color: "#fff",
|
||||||
|
fontSize: 10,
|
||||||
|
borderRadius: 8,
|
||||||
|
lineHeight: 1,
|
||||||
|
padding: "2px 4px",
|
||||||
|
fontFamily: "Plus Jakarta Sans Variable",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{activeCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<FiltersDialog open={open} onClose={() => setOpen(false)} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FiltersDialog;
|
||||||
@@ -0,0 +1,277 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
type SessionInfoDto,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
IconButton,
|
||||||
|
Paper,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { transferSessionToLocal } from "@/utils/methods/transferPlayback";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
|
import useRealtimeStore from "@/utils/store/realtime";
|
||||||
|
|
||||||
|
const DISMISS_STORAGE_KEY = "blink:follow-me-dismissed";
|
||||||
|
const DISMISS_TTL_MS = 30 * 60 * 1000;
|
||||||
|
const MIN_POSITION_TICKS = 45 * 10_000_000;
|
||||||
|
|
||||||
|
type DismissedMap = Record<string, number>;
|
||||||
|
|
||||||
|
const readDismissed = (): DismissedMap => {
|
||||||
|
try {
|
||||||
|
const raw = sessionStorage.getItem(DISMISS_STORAGE_KEY);
|
||||||
|
const parsed = raw ? (JSON.parse(raw) as DismissedMap) : {};
|
||||||
|
const now = Date.now();
|
||||||
|
return Object.fromEntries(
|
||||||
|
Object.entries(parsed).filter(([, at]) => now - at < DISMISS_TTL_MS),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatTime = (ticks: number) => {
|
||||||
|
const total = Math.max(0, Math.round(ticks / 10_000_000));
|
||||||
|
const hours = Math.floor(total / 3600);
|
||||||
|
const minutes = Math.floor((total % 3600) / 60);
|
||||||
|
const seconds = total % 60;
|
||||||
|
return hours > 0
|
||||||
|
? `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`
|
||||||
|
: `${minutes}:${String(seconds).padStart(2, "0")}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const deviceLabel = (session: SessionInfoDto) =>
|
||||||
|
session.DeviceName || session.Client || "другое устройство";
|
||||||
|
|
||||||
|
const posterId = (item: BaseItemDto) =>
|
||||||
|
item.ImageTags?.Primary ? item.Id : (item.SeriesId ?? item.Id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Spotify-Connect style hand-off prompt. When another session of the same
|
||||||
|
* user is already watching something and this client is idle, offer to
|
||||||
|
* continue the same item here at its current position.
|
||||||
|
*/
|
||||||
|
const FollowMe = () => {
|
||||||
|
const api = useApiInContext((state) => state.api);
|
||||||
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
const localVideoActive = usePlaybackStore((state) =>
|
||||||
|
Boolean(state.playbackStream && state.metadata.item?.Id),
|
||||||
|
);
|
||||||
|
const localAudioActive = useAudioPlayback((state) =>
|
||||||
|
Boolean(state.display && state.item?.Id),
|
||||||
|
);
|
||||||
|
const localActive = localVideoActive || localAudioActive;
|
||||||
|
|
||||||
|
const realtimeSessions = useRealtimeStore((state) => state.sessions);
|
||||||
|
const sessionsQuery = useQuery({
|
||||||
|
queryKey: ["remoteSessions"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !user?.Id) return [];
|
||||||
|
return (await getSessionApi(api).getSessions()).data;
|
||||||
|
},
|
||||||
|
enabled: Boolean(api && user?.Id) && !localActive,
|
||||||
|
refetchInterval: localActive ? false : 15_000,
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [dismissed, setDismissed] = useState<DismissedMap>(readDismissed);
|
||||||
|
const [transferring, setTransferring] = useState(false);
|
||||||
|
|
||||||
|
const candidate = useMemo(() => {
|
||||||
|
if (!api || !user?.Id || localActive) return undefined;
|
||||||
|
const sessions =
|
||||||
|
realtimeSessions.length > 0
|
||||||
|
? realtimeSessions
|
||||||
|
: (sessionsQuery.data ?? []);
|
||||||
|
const options = sessions.filter((session) => {
|
||||||
|
const item = session.NowPlayingItem;
|
||||||
|
const lastCheckIn = session.LastPlaybackCheckIn
|
||||||
|
? Date.parse(session.LastPlaybackCheckIn)
|
||||||
|
: 0;
|
||||||
|
const stale =
|
||||||
|
lastCheckIn > 0 && Date.now() - lastCheckIn > 15 * 60 * 1000;
|
||||||
|
return (
|
||||||
|
Boolean(session.Id && item?.Id) &&
|
||||||
|
!stale &&
|
||||||
|
session.DeviceId !== api.deviceInfo.id &&
|
||||||
|
session.UserId === user.Id &&
|
||||||
|
item?.Type !== BaseItemKind.Photo &&
|
||||||
|
(item?.Type === BaseItemKind.Audio ||
|
||||||
|
item?.Type === BaseItemKind.AudioBook ||
|
||||||
|
item?.Type === BaseItemKind.Episode ||
|
||||||
|
item?.Type === BaseItemKind.Movie ||
|
||||||
|
item?.Type === BaseItemKind.Video ||
|
||||||
|
Boolean(item?.MediaType === "Video")) &&
|
||||||
|
(session.PlayState?.PositionTicks ?? 0) >= MIN_POSITION_TICKS
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (options.length === 0) return undefined;
|
||||||
|
options.sort((a, b) => {
|
||||||
|
const aAt = a.LastPlaybackCheckIn ? Date.parse(a.LastPlaybackCheckIn) : 0;
|
||||||
|
const bAt = b.LastPlaybackCheckIn ? Date.parse(b.LastPlaybackCheckIn) : 0;
|
||||||
|
if (aAt !== bAt) return bAt - aAt;
|
||||||
|
return (
|
||||||
|
(b.PlayState?.PositionTicks ?? 0) - (a.PlayState?.PositionTicks ?? 0)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const session = options[0];
|
||||||
|
const item = session.NowPlayingItem;
|
||||||
|
if (!session.Id || !item?.Id) return undefined;
|
||||||
|
const position = session.PlayState?.PositionTicks ?? 0;
|
||||||
|
const key = `${session.Id}:${item.Id}`;
|
||||||
|
if (dismissed[key]) return undefined;
|
||||||
|
return { session, item, position, key };
|
||||||
|
}, [
|
||||||
|
api,
|
||||||
|
user?.Id,
|
||||||
|
localActive,
|
||||||
|
realtimeSessions,
|
||||||
|
sessionsQuery.data,
|
||||||
|
dismissed,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const dismiss = useCallback((key: string) => {
|
||||||
|
setDismissed((current) => {
|
||||||
|
const next = { ...current, [key]: Date.now() };
|
||||||
|
sessionStorage.setItem(DISMISS_STORAGE_KEY, JSON.stringify(next));
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleContinue = useCallback(async () => {
|
||||||
|
if (!api || !user?.Id || !candidate) return;
|
||||||
|
setTransferring(true);
|
||||||
|
try {
|
||||||
|
const kind = await transferSessionToLocal(
|
||||||
|
api,
|
||||||
|
user.Id,
|
||||||
|
candidate.session,
|
||||||
|
);
|
||||||
|
dismiss(candidate.key);
|
||||||
|
if (kind === "video") navigate({ to: "/player" });
|
||||||
|
if (kind === "audio") navigate({ to: "/player/audio" });
|
||||||
|
if (kind !== "none") {
|
||||||
|
enqueueSnackbar(`Продолжаем с ${deviceLabel(candidate.session)}`, {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Follow-me transfer failed", error);
|
||||||
|
enqueueSnackbar("Не удалось продолжить воспроизведение здесь", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setTransferring(false);
|
||||||
|
}
|
||||||
|
}, [api, user?.Id, candidate, dismiss, enqueueSnackbar, navigate]);
|
||||||
|
|
||||||
|
if (!candidate || !api) return null;
|
||||||
|
const { item, session, position } = candidate;
|
||||||
|
const paused = Boolean(session.PlayState?.IsPaused);
|
||||||
|
const imageUrl = getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
posterId(item) ?? item.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{ fillHeight: 168, fillWidth: 112, quality: 85 },
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper
|
||||||
|
elevation={10}
|
||||||
|
sx={{
|
||||||
|
position: "fixed",
|
||||||
|
left: 24,
|
||||||
|
bottom: 24,
|
||||||
|
zIndex: 1300,
|
||||||
|
display: "flex",
|
||||||
|
gap: 1.5,
|
||||||
|
alignItems: "stretch",
|
||||||
|
width: "min(360px, calc(100vw - 48px))",
|
||||||
|
p: 1.25,
|
||||||
|
borderRadius: "18px",
|
||||||
|
background: "rgba(18, 16, 38, 0.94)",
|
||||||
|
border: "1px solid rgba(255, 255, 255, 0.1)",
|
||||||
|
backdropFilter: "blur(24px)",
|
||||||
|
boxShadow: "0 16px 48px rgba(0, 0, 0, 0.45)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={imageUrl}
|
||||||
|
alt=""
|
||||||
|
sx={{
|
||||||
|
width: 56,
|
||||||
|
height: 84,
|
||||||
|
flex: "0 0 auto",
|
||||||
|
objectFit: "cover",
|
||||||
|
borderRadius: "10px",
|
||||||
|
background: "rgba(255,255,255,0.06)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Box
|
||||||
|
sx={{ minWidth: 0, flex: 1, display: "flex", flexDirection: "column" }}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="overline"
|
||||||
|
sx={{ lineHeight: 1.2, opacity: 0.65, letterSpacing: 0.8 }}
|
||||||
|
>
|
||||||
|
{paused ? "Пауза на" : "Идёт на"} {deviceLabel(session)}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="subtitle2" noWrap sx={{ fontWeight: 700 }}>
|
||||||
|
{item.SeriesName ?? item.Name ?? "Продолжить просмотр"}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" noWrap sx={{ opacity: 0.65 }}>
|
||||||
|
{item.SeriesName && item.Name ? `${item.Name} · ` : ""}
|
||||||
|
{formatTime(position)}
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{ display: "flex", gap: 0.5, mt: "auto", pt: 0.5 }}>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleContinue}
|
||||||
|
disabled={transferring}
|
||||||
|
sx={{ textTransform: "none", borderRadius: "999px" }}
|
||||||
|
>
|
||||||
|
{transferring ? "Запуск…" : "Продолжить здесь"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => dismiss(candidate.key)}
|
||||||
|
sx={{ textTransform: "none", borderRadius: "999px", opacity: 0.7 }}
|
||||||
|
>
|
||||||
|
Не сейчас
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Tooltip title="Скрыть">
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
aria-label="Скрыть предложение"
|
||||||
|
onClick={() => dismiss(candidate.key)}
|
||||||
|
sx={{ alignSelf: "flex-start", opacity: 0.55 }}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded" style={{ fontSize: 18 }}>
|
||||||
|
close
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(FollowMe);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Link, Typography } from "@mui/material";
|
import { Link, Tooltip } from "@mui/material";
|
||||||
import React, { memo } from "react";
|
import React, { memo } from "react";
|
||||||
|
|
||||||
import anidbIcon from "../../assets/icons/anidb.png";
|
import anidbIcon from "../../assets/icons/anidb.png";
|
||||||
@@ -12,54 +12,49 @@ import tmdbIcon from "../../assets/icons/themoviedatabase.svg";
|
|||||||
import traktIcon from "../../assets/icons/trakt.svg";
|
import traktIcon from "../../assets/icons/trakt.svg";
|
||||||
import tvMazeIcon from "../../assets/icons/tvmaze.png";
|
import tvMazeIcon from "../../assets/icons/tvmaze.png";
|
||||||
|
|
||||||
const knownIcons = [
|
/**
|
||||||
"imdb",
|
* Provider icons keyed by the start of the normalized link name, so variants like
|
||||||
"themoviedb",
|
* "TMDB"/"TheMovieDb", "TVDB"/"TheTVDB" or "MusicBrainz Artist" all match.
|
||||||
"trakt",
|
*/
|
||||||
"musicbrainz",
|
const providerIcons: [prefixes: string[], icon: string][] = [
|
||||||
"thetvdb",
|
[["imdb"], imdbIcon],
|
||||||
"anidb",
|
[["tmdb", "themoviedb"], tmdbIcon],
|
||||||
"anilist",
|
[["tvdb", "thetvdb"], tvDbIcon],
|
||||||
"tvmaze",
|
[["trakt"], traktIcon],
|
||||||
"theaudiodb",
|
[["musicbrainz"], musicBrainzIcon],
|
||||||
"kitsu",
|
[["anidb"], anidbIcon],
|
||||||
|
[["anilist"], anilistIcon],
|
||||||
|
[["tvmaze"], tvMazeIcon],
|
||||||
|
[["theaudiodb", "audiodb"], audioDBIcon],
|
||||||
|
[["kitsu"], kitsuIcon],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const getProviderIcon = (name: string) => {
|
||||||
|
const normalized = name.toLocaleLowerCase().replace(/[^a-z0-9]/g, "");
|
||||||
|
return providerIcons.find(([prefixes]) =>
|
||||||
|
prefixes.some((prefix) => normalized.startsWith(prefix)),
|
||||||
|
)?.[1];
|
||||||
|
};
|
||||||
|
|
||||||
const IconLink = memo(({ name, url }: { name: string; url: string }) => {
|
const IconLink = memo(({ name, url }: { name: string; url: string }) => {
|
||||||
|
const icon = getProviderIcon(name);
|
||||||
return (
|
return (
|
||||||
<Link target="_blank" href={url} className="item-detail-link">
|
<Tooltip title={name}>
|
||||||
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
<Link
|
||||||
{name.toLocaleLowerCase() === "themoviedb" && (
|
target="_blank"
|
||||||
<img src={tmdbIcon} alt="TheMovieDb" />
|
href={url}
|
||||||
)}
|
className="item-detail-link"
|
||||||
{name.toLocaleLowerCase() === "trakt" && (
|
aria-label={name}
|
||||||
<img src={traktIcon} alt="Trakt" />
|
>
|
||||||
)}
|
{icon ? (
|
||||||
{name.toLocaleLowerCase() === "musicbrainz" && (
|
<img src={icon} alt={name} />
|
||||||
<img src={musicBrainzIcon} alt="MusicBrainz" />
|
) : (
|
||||||
)}
|
<span className="material-symbols-rounded item-detail-link-generic">
|
||||||
{name.toLocaleLowerCase() === "thetvdb" && (
|
link
|
||||||
<img src={tvDbIcon} alt="TheTVDB" />
|
</span>
|
||||||
)}
|
)}
|
||||||
{name.toLocaleLowerCase() === "anidb" && (
|
</Link>
|
||||||
<img src={anidbIcon} alt="AniDB" />
|
</Tooltip>
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "anilist" && (
|
|
||||||
<img src={anilistIcon} alt="AniList" />
|
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "tvmaze" && (
|
|
||||||
<img src={tvMazeIcon} alt="TVMaze" />
|
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "theaudiodb" && (
|
|
||||||
<img src={audioDBIcon} alt="TheAudioDB" />
|
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "kitsu" && (
|
|
||||||
<img src={kitsuIcon} alt="Kitsu" />
|
|
||||||
)}
|
|
||||||
{!knownIcons.includes(name.toLocaleLowerCase()) && (
|
|
||||||
<Typography>{name}</Typography>
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
import {
|
||||||
|
AnimatePresence,
|
||||||
|
type HTMLMotionProps,
|
||||||
|
motion,
|
||||||
|
useScroll,
|
||||||
|
useTransform,
|
||||||
|
} from "motion/react";
|
||||||
|
import React, { type RefObject, useEffect, useState } from "react";
|
||||||
|
|
||||||
|
interface ItemBackdropProps {
|
||||||
|
targetRef: RefObject<HTMLElement | null>;
|
||||||
|
backdropSrc?: string;
|
||||||
|
fallbackSrc: string;
|
||||||
|
alt: string;
|
||||||
|
distance?: number; // parallax distance
|
||||||
|
className?: string;
|
||||||
|
onLoad?: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
||||||
|
motionProps?: HTMLMotionProps<"img">;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MotionImg = motion.img;
|
||||||
|
|
||||||
|
const animationProps = {
|
||||||
|
// Do not fade in from black on every navigation: cached artwork should be
|
||||||
|
// visible immediately (a fade here reads as a flash).
|
||||||
|
initial: { opacity: 1 },
|
||||||
|
animate: { opacity: 1 },
|
||||||
|
exit: { opacity: 0 },
|
||||||
|
transition: { duration: 0.3 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ItemBackdrop delays applying motion-driven parallax until after mount
|
||||||
|
* to avoid hydration timing errors ("Target ref is defined but not hydrated").
|
||||||
|
* It accepts a scroll container ref from the parent; if the ref is not yet
|
||||||
|
* attached, it renders a static img to prevent motion from touching an
|
||||||
|
* unhydrated DOM node.
|
||||||
|
*/
|
||||||
|
const ItemBackdropContent = React.memo(function ItemBackdropContent({
|
||||||
|
targetRef,
|
||||||
|
src,
|
||||||
|
alt,
|
||||||
|
distance,
|
||||||
|
className,
|
||||||
|
onLoad,
|
||||||
|
motionProps,
|
||||||
|
}: {
|
||||||
|
targetRef: RefObject<HTMLElement | null>;
|
||||||
|
src: string;
|
||||||
|
alt: string;
|
||||||
|
distance: number;
|
||||||
|
className?: string;
|
||||||
|
onLoad?: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
||||||
|
motionProps?: HTMLMotionProps<"img">;
|
||||||
|
}) {
|
||||||
|
const { scrollYProgress } = useScroll({
|
||||||
|
target: targetRef,
|
||||||
|
offset: ["start start", "60vh start"],
|
||||||
|
});
|
||||||
|
const y = useTransform(scrollYProgress, [0, 1], [-distance, distance]);
|
||||||
|
return (
|
||||||
|
<MotionImg
|
||||||
|
alt={alt}
|
||||||
|
src={src}
|
||||||
|
className={className ?? "item-hero-backdrop"}
|
||||||
|
onLoad={(e) => {
|
||||||
|
onLoad?.(e);
|
||||||
|
}}
|
||||||
|
style={{ y }}
|
||||||
|
{...motionProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export function ItemBackdrop({
|
||||||
|
targetRef,
|
||||||
|
backdropSrc,
|
||||||
|
fallbackSrc,
|
||||||
|
alt,
|
||||||
|
distance = 50,
|
||||||
|
className,
|
||||||
|
onLoad,
|
||||||
|
motionProps,
|
||||||
|
}: ItemBackdropProps) {
|
||||||
|
const src = backdropSrc || fallbackSrc;
|
||||||
|
const [ready, setReady] = useState(false);
|
||||||
|
// Poll a few animation frames until the target ref hydrates to avoid premature motion initialization.
|
||||||
|
useEffect(() => {
|
||||||
|
if (ready) return;
|
||||||
|
let frame = 0;
|
||||||
|
let raf: number;
|
||||||
|
const tick = () => {
|
||||||
|
if (targetRef.current || frame > 5) {
|
||||||
|
setReady(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
frame++;
|
||||||
|
raf = requestAnimationFrame(tick);
|
||||||
|
};
|
||||||
|
tick();
|
||||||
|
return () => cancelAnimationFrame(raf);
|
||||||
|
}, [targetRef, ready]);
|
||||||
|
|
||||||
|
const finalMotionProps = React.useMemo(
|
||||||
|
() => ({
|
||||||
|
...animationProps,
|
||||||
|
...motionProps,
|
||||||
|
}),
|
||||||
|
[motionProps],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!ready) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
alt={alt}
|
||||||
|
src={src}
|
||||||
|
className={className ?? "item-hero-backdrop"}
|
||||||
|
ref={(el) => {
|
||||||
|
if (el?.complete && el.naturalWidth > 0) el.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
onLoad?.(e);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AnimatePresence>
|
||||||
|
<ItemBackdropContent
|
||||||
|
key={src}
|
||||||
|
targetRef={targetRef}
|
||||||
|
src={src}
|
||||||
|
alt={alt}
|
||||||
|
distance={distance}
|
||||||
|
className={className}
|
||||||
|
onLoad={onLoad}
|
||||||
|
motionProps={finalMotionProps}
|
||||||
|
/>
|
||||||
|
</AnimatePresence>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ItemBackdrop;
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import type { BaseItemPerson } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
|
||||||
|
const groups = [
|
||||||
|
{ type: "Actor", title: "Актёры" },
|
||||||
|
{ type: "Writer", title: "Сценаристы" },
|
||||||
|
{ type: "Director", title: "Режиссёры" },
|
||||||
|
{ type: "Producer", title: "Продюсеры" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
type CastAndCrewProps = {
|
||||||
|
people: BaseItemPerson[] | null | undefined;
|
||||||
|
api: Api | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const CastAndCrew = ({ people, api }: CastAndCrewProps) => {
|
||||||
|
const grouped = useMemo(
|
||||||
|
() =>
|
||||||
|
groups.map((group) => ({
|
||||||
|
...group,
|
||||||
|
people: people?.filter((person) => person.Type === group.type) ?? [],
|
||||||
|
})),
|
||||||
|
[people],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!people?.length) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="item-detail-cast">
|
||||||
|
<Typography variant="h5" sx={{ mb: 2 }}>
|
||||||
|
Актёры и команда
|
||||||
|
</Typography>
|
||||||
|
{grouped.map(
|
||||||
|
(group) =>
|
||||||
|
group.people.length > 0 && (
|
||||||
|
<div className="item-detail-cast-container" key={group.type}>
|
||||||
|
<Typography variant="h6" className="item-detail-cast-title">
|
||||||
|
{group.title}
|
||||||
|
</Typography>
|
||||||
|
<div className="item-detail-cast-grid">
|
||||||
|
{group.people.map((person) => (
|
||||||
|
<Link
|
||||||
|
className="item-detail-cast-card"
|
||||||
|
key={person.Id}
|
||||||
|
to="/item/$id"
|
||||||
|
params={{ id: person.Id ?? "" }}
|
||||||
|
search={{ type: "Person" }}
|
||||||
|
>
|
||||||
|
{person.PrimaryImageTag ? (
|
||||||
|
<img
|
||||||
|
alt={person.Name ?? ""}
|
||||||
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
person.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
quality: 80,
|
||||||
|
fillWidth: 200,
|
||||||
|
fillHeight: 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="item-detail-cast-card-image"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="item-detail-cast-card-icon">
|
||||||
|
{getTypeIcon("Person")}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="item-detail-cast-card-text">
|
||||||
|
<Typography variant="subtitle1">{person.Name}</Typography>
|
||||||
|
<Typography variant="subtitle2" style={{ opacity: 0.5 }}>
|
||||||
|
{person.Role}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CastAndCrew;
|
||||||
@@ -1,91 +1,8 @@
|
|||||||
$cardWidth: 18%;
|
.item-detail-page.item {
|
||||||
|
|
||||||
.item-series.item {
|
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
.item-hero {
|
|
||||||
height: 60vh;
|
&.item-default {
|
||||||
gap: 2em;
|
gap: 1.5em;
|
||||||
row-gap: 1.2em;
|
|
||||||
position: relative;
|
|
||||||
align-items: flex-end;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: $cardWidth 1fr;
|
|
||||||
grid-template-rows: 1fr auto;
|
|
||||||
&-image {
|
|
||||||
opacity: 0;
|
|
||||||
width: 100%;
|
|
||||||
object-fit: contain;
|
|
||||||
transition: opacity $transition-time-default;
|
|
||||||
&-container {
|
|
||||||
height: fit-content;
|
|
||||||
max-height: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius: $border-radius-default;
|
|
||||||
box-shadow: $shadow-card;
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 0;
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
&-blurhash {
|
|
||||||
position: absolute !important;
|
|
||||||
width: 100% !important;
|
|
||||||
height: 100% !important;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-logo {
|
|
||||||
max-width: 34rem;
|
|
||||||
max-height: 10rem;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity $transition-time-default;
|
|
||||||
object-position: bottom;
|
|
||||||
margin-bottom: 2em;
|
|
||||||
}
|
|
||||||
&-detail {
|
|
||||||
width: 100%;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 0.2em;
|
|
||||||
justify-content: end;
|
|
||||||
}
|
|
||||||
&-buttons {
|
|
||||||
&-container {
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
grid-column: 1/3;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: inherit;
|
|
||||||
gap: 2em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-backdrop {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
object-fit: cover;
|
|
||||||
object-position: top;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity $transition-time-default;
|
|
||||||
&-container {
|
|
||||||
filter: brightness(0.8);
|
|
||||||
position: absolute;
|
|
||||||
top: -4.4em;
|
|
||||||
left: -$page-margin;
|
|
||||||
width: 100vw;
|
|
||||||
height: calc(54vh + 4.4em);
|
|
||||||
z-index: -1;
|
|
||||||
mask-image: linear-gradient(to top, transparent, black);
|
|
||||||
-webkit-mask-image: linear-gradient(
|
|
||||||
to top,
|
|
||||||
transparent,
|
|
||||||
black
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
& .play-button {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-detail {
|
.item-detail {
|
||||||
@@ -95,25 +12,11 @@ $cardWidth: 18%;
|
|||||||
align-items: start;
|
align-items: start;
|
||||||
gap: 3em;
|
gap: 3em;
|
||||||
|
|
||||||
&-nextUp {
|
&.single {
|
||||||
max-width: 23em;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-cast {
|
&-cast {
|
||||||
max-height: 50vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
mask-image: linear-gradient(to top, transparent, black 1.2em);
|
|
||||||
-webkit-mask-image: linear-gradient(to top, transparent, black 1.2em);
|
|
||||||
&-title {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
background: black;
|
|
||||||
border:1px solid rgb(255 255 255 / 0.2) ;
|
|
||||||
padding: 0.35em;
|
|
||||||
border-radius: 10px;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
&-container {
|
&-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -121,9 +24,9 @@ $cardWidth: 18%;
|
|||||||
}
|
}
|
||||||
&-grid {
|
&-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
}
|
}
|
||||||
&-card {
|
&-card {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -166,12 +69,19 @@ $cardWidth: 18%;
|
|||||||
text-decoration-color: white;
|
text-decoration-color: white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-episode{
|
&-external-links {
|
||||||
display:grid;
|
display: flex;
|
||||||
|
gap: 0.6em;
|
||||||
|
align-self: end;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-episode {
|
||||||
|
display: grid;
|
||||||
grid-template-columns: 3.2em 12em 1fr 6em;
|
grid-template-columns: 3.2em 12em 1fr 6em;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
gap:1.8em;
|
gap: 1.8em;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -187,24 +97,22 @@ $cardWidth: 18%;
|
|||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
&-image{
|
&-image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
opacity: 0;
|
|
||||||
transition: opacity $transition-time-default;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
&-container{
|
&-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
aspect-ratio: 1.66666;
|
aspect-ratio: 1.66666;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: $border-radius-default;
|
border-radius: $border-radius-default;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
&::after{
|
&::after {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -219,7 +127,7 @@ $cardWidth: 18%;
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-overlay{
|
&-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -244,7 +152,7 @@ $cardWidth: 18%;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-info{
|
&-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
@@ -253,43 +161,81 @@ $cardWidth: 18%;
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding-right: 2em;
|
padding-right: 2em;
|
||||||
}
|
}
|
||||||
&-buttons{
|
&-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover .item-detail-episode-image-overlay, &:focus-within .item-detail-episode-image-overlay{
|
&:hover .item-detail-episode-image-overlay,
|
||||||
|
&:focus-within .item-detail-episode-image-overlay {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1320px) {
|
&-person {
|
||||||
.item-series .item-detail {
|
&-container {
|
||||||
&-cast {
|
position: relative;
|
||||||
&-grid {
|
width: 100%;
|
||||||
grid-template-columns: 1fr;
|
}
|
||||||
|
&-header {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
&-cards {
|
||||||
|
display: grid;
|
||||||
|
align-items: start;
|
||||||
|
&.col-7 {
|
||||||
|
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
&.col-4 {
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-episodes-container {
|
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 830px) {
|
// Global item-detail
|
||||||
.item-series .item-detail {
|
.item-detail-link {
|
||||||
&-episodes-container {
|
margin-top: 0.85em !important;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
&:hover > img {
|
||||||
}
|
filter: brightness(1);
|
||||||
|
}
|
||||||
|
& > img {
|
||||||
|
width: 2em;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
filter: brightness(0.5);
|
||||||
|
transition: filter $transition-time-default;
|
||||||
|
}
|
||||||
|
&-generic {
|
||||||
|
display: block;
|
||||||
|
font-size: 2em !important;
|
||||||
|
color: white;
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
}
|
||||||
|
&:hover > &-generic {
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 564px) {
|
.item {
|
||||||
.item-series .item-detail {
|
gap: 1.5em;
|
||||||
&-episodes-container {
|
&-hero {
|
||||||
grid-template-columns: repeat(1, minmax(0, 1fr));
|
&-image {
|
||||||
|
box-sizing: border-box;
|
||||||
|
&-container {
|
||||||
|
box-sizing: content-box;
|
||||||
|
box-shadow: 0px 10px 20px -10px rgb(0 0 0 / 0.5) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-mediaInfo {
|
||||||
|
margin-top: 1em;
|
||||||
|
height: 1.1em;
|
||||||
|
opacity: 0.8;
|
||||||
|
&.badge {
|
||||||
|
margin: 0;
|
||||||
|
height: 1.2em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { motion } from "motion/react";
|
||||||
|
import React, { type ReactNode, useEffect, useRef } from "react";
|
||||||
|
import CastButton from "@/components/buttons/castButton";
|
||||||
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
|
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||||
|
import TrailerButton from "@/components/buttons/trailerButton";
|
||||||
|
import IconLink from "@/components/iconLink";
|
||||||
|
import ItemHeader from "@/components/itemHeader";
|
||||||
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import useHeaderStore from "@/utils/store/header";
|
||||||
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
|
||||||
|
import "./itemDetail.scss";
|
||||||
|
|
||||||
|
export const ExternalLinks = ({ item }: { item: BaseItemDto }) => (
|
||||||
|
<div className="item-detail-external-links">
|
||||||
|
{item.ExternalUrls?.map(
|
||||||
|
(url) =>
|
||||||
|
url.Url &&
|
||||||
|
url.Name && <IconLink key={url.Url} url={url.Url} name={url.Name} />,
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const getDefaultBackdropHash = (item: BaseItemDto) => {
|
||||||
|
const tag =
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? item.ParentBackdropImageTags?.[0]
|
||||||
|
: item.BackdropImageTags?.[0];
|
||||||
|
return (tag && item.ImageBlurHashes?.Backdrop?.[tag]) || "";
|
||||||
|
};
|
||||||
|
|
||||||
|
type ItemDetailLayoutProps = {
|
||||||
|
item: BaseItemDto;
|
||||||
|
/** CSS modifier, rendered as `item-<variant>`. */
|
||||||
|
variant: "default" | "episode" | "series" | "boxset" | "person";
|
||||||
|
mediaQualityInfo?: MediaQualityInfo;
|
||||||
|
backdropSrc?: string | null;
|
||||||
|
/** Blurhash for the app backdrop; defaults to the item's (or an episode's series) backdrop. */
|
||||||
|
backdropHash?: string;
|
||||||
|
/** Play button area; omitted for items that can't be played (people). */
|
||||||
|
playButton?: ReactNode;
|
||||||
|
showTrailer?: boolean;
|
||||||
|
showMarkPlayed?: boolean;
|
||||||
|
/** Extra content under the overview in the main column. */
|
||||||
|
main?: ReactNode;
|
||||||
|
/** Right-hand column next to the overview. */
|
||||||
|
aside?: ReactNode;
|
||||||
|
/** Sections rendered below the overview. */
|
||||||
|
children?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ItemDetailLayout = ({
|
||||||
|
item,
|
||||||
|
variant,
|
||||||
|
mediaQualityInfo,
|
||||||
|
backdropSrc,
|
||||||
|
backdropHash,
|
||||||
|
playButton,
|
||||||
|
showTrailer = true,
|
||||||
|
showMarkPlayed = true,
|
||||||
|
main,
|
||||||
|
aside,
|
||||||
|
children,
|
||||||
|
}: ItemDetailLayoutProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const queryKey = ["item", item.Id ?? ""];
|
||||||
|
|
||||||
|
const canCast =
|
||||||
|
item.Type === BaseItemKind.Movie ||
|
||||||
|
item.Type === BaseItemKind.Episode ||
|
||||||
|
item.Type === BaseItemKind.Audio ||
|
||||||
|
item.Type === BaseItemKind.AudioBook ||
|
||||||
|
item.Type === BaseItemKind.MusicVideo ||
|
||||||
|
item.Type === BaseItemKind.Video ||
|
||||||
|
item.Type === BaseItemKind.Trailer;
|
||||||
|
|
||||||
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
|
const hash = backdropHash ?? getDefaultBackdropHash(item);
|
||||||
|
useEffect(() => {
|
||||||
|
setBackdrop(hash);
|
||||||
|
}, [hash, setBackdrop]);
|
||||||
|
|
||||||
|
// Show a human-readable location in the global app bar.
|
||||||
|
const setPageTitle = useHeaderStore((state) => state.setPageTitle);
|
||||||
|
useEffect(() => {
|
||||||
|
setPageTitle(item.Name ?? null);
|
||||||
|
return () => setPageTitle(null);
|
||||||
|
}, [item.Name, setPageTitle]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<motion.div
|
||||||
|
key={item.Id}
|
||||||
|
initial={{ opacity: 1 }}
|
||||||
|
animate={{ opacity: 1 }}
|
||||||
|
transition={{ duration: 0.12, ease: "easeOut" }}
|
||||||
|
className={`scrollY padded-top flex flex-column item item-detail-page item-${variant}`}
|
||||||
|
ref={containerRef}
|
||||||
|
>
|
||||||
|
<ItemHeader
|
||||||
|
item={item}
|
||||||
|
api={api}
|
||||||
|
mediaQualityInfo={mediaQualityInfo}
|
||||||
|
scrollTargetRef={containerRef}
|
||||||
|
backdropSrc={backdropSrc}
|
||||||
|
>
|
||||||
|
<div className="item-hero-buttons-container">
|
||||||
|
<div className="flex flex-row" style={{ width: "100%" }}>
|
||||||
|
{playButton}
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-row" style={{ gap: "1em" }}>
|
||||||
|
{showTrailer && item.RemoteTrailers && (
|
||||||
|
<TrailerButton
|
||||||
|
trailerItem={item.RemoteTrailers}
|
||||||
|
disabled={item.RemoteTrailers.length === 0}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<LikeButton
|
||||||
|
itemName={item.Name}
|
||||||
|
itemId={item.Id}
|
||||||
|
queryKey={queryKey}
|
||||||
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
{canCast && <CastButton item={item} />}
|
||||||
|
{showMarkPlayed && (
|
||||||
|
<MarkPlayedButton
|
||||||
|
itemName={item.Name}
|
||||||
|
itemId={item.Id}
|
||||||
|
queryKey={queryKey}
|
||||||
|
isPlayed={item.UserData?.Played}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ItemHeader>
|
||||||
|
<div className={aside ? "item-detail" : "item-detail single"}>
|
||||||
|
<div className="fullWidth">
|
||||||
|
{(item.Taglines?.length ?? 0) > 0 && (
|
||||||
|
<Typography variant="h5" sx={{ mb: 2, fontWeight: 300 }}>
|
||||||
|
{item.Taglines?.[0]}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
<ShowMoreText content={item.Overview ?? ""} collapsedLines={4} />
|
||||||
|
{main}
|
||||||
|
</div>
|
||||||
|
{aside && <div className="fullWidth">{aside}</div>}
|
||||||
|
</div>
|
||||||
|
{children}
|
||||||
|
</motion.div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ItemDetailLayout;
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
type MediaStream,
|
||||||
|
MediaStreamType,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
import React, { useMemo, useState } from "react";
|
||||||
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
|
||||||
|
const titleIncludes = (stream: MediaStream, ...needles: string[]) => {
|
||||||
|
const title = stream.DisplayTitle?.toLocaleLowerCase();
|
||||||
|
return needles.some((needle) => title?.includes(needle));
|
||||||
|
};
|
||||||
|
|
||||||
|
const getMediaQualityInfo = (
|
||||||
|
videoTracks: MediaStream[],
|
||||||
|
audioTracks: MediaStream[],
|
||||||
|
): MediaQualityInfo => ({
|
||||||
|
isAtmos: audioTracks.some((a) => titleIncludes(a, "atmos")),
|
||||||
|
isDolbyVision: videoTracks.some(
|
||||||
|
(v) =>
|
||||||
|
titleIncludes(v, "dv", "dolby vision") ||
|
||||||
|
!!v.VideoDoViTitle ||
|
||||||
|
v.VideoRangeType === "DOVI",
|
||||||
|
),
|
||||||
|
isDts: audioTracks.some(
|
||||||
|
(a) =>
|
||||||
|
titleIncludes(a, "dts") && !titleIncludes(a, "dts-hd ma", "dts-hd.ma"),
|
||||||
|
),
|
||||||
|
isDtsHDMA: audioTracks.some((a) =>
|
||||||
|
titleIncludes(a, "dts-hd ma", "dts-hd.ma"),
|
||||||
|
),
|
||||||
|
isDD: audioTracks.some(
|
||||||
|
(a) =>
|
||||||
|
(titleIncludes(a, "dd") && !titleIncludes(a, "ddp")) ||
|
||||||
|
(titleIncludes(a, "dolby digital") &&
|
||||||
|
!titleIncludes(a, "dolby digital+")),
|
||||||
|
),
|
||||||
|
isDDP: audioTracks.some((a) => titleIncludes(a, "ddp", "dolby digital+")),
|
||||||
|
isUHD: videoTracks.some((v) => titleIncludes(v, "4k", "2160p", "uhd")),
|
||||||
|
isHD: videoTracks.some(
|
||||||
|
(v) =>
|
||||||
|
(titleIncludes(v, "hd") && !titleIncludes(v, "hdr")) ||
|
||||||
|
titleIncludes(v, "1080p", "fhd"),
|
||||||
|
),
|
||||||
|
isSD: videoTracks.some(
|
||||||
|
(v) =>
|
||||||
|
(titleIncludes(v, "sd") && !titleIncludes(v, "sdr")) ||
|
||||||
|
titleIncludes(v, "720p"),
|
||||||
|
),
|
||||||
|
isSDR: videoTracks.some((v) => v.VideoRangeType === "SDR"),
|
||||||
|
isHDR: videoTracks.some(
|
||||||
|
(v) => v.VideoRange === "HDR" || titleIncludes(v, "dv"),
|
||||||
|
),
|
||||||
|
isHDR10: videoTracks.some(
|
||||||
|
(v) => v.VideoRangeType === "HDR10" && !titleIncludes(v, "hdr10+"),
|
||||||
|
),
|
||||||
|
isHDR10Plus: videoTracks.some(
|
||||||
|
(v) => v.VideoRangeType === "HDR10Plus" || titleIncludes(v, "hdr10+"),
|
||||||
|
),
|
||||||
|
isTrueHD: audioTracks.some((a) => titleIncludes(a, "truehd")),
|
||||||
|
isIMAX: videoTracks.some((v) => titleIncludes(v, "imax")),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits an item's media streams into tracks, tracks the user's track selection
|
||||||
|
* (reset whenever the item changes) and derives the media quality badges.
|
||||||
|
*/
|
||||||
|
export const useMediaTracks = (item: BaseItemDto) => {
|
||||||
|
const tracks = useMemo(() => {
|
||||||
|
const streams = item.MediaStreams ?? [];
|
||||||
|
return {
|
||||||
|
video: streams.filter((s) => s.Type === MediaStreamType.Video),
|
||||||
|
audio: streams.filter((s) => s.Type === MediaStreamType.Audio),
|
||||||
|
subtitle: streams.filter((s) => s.Type === MediaStreamType.Subtitle),
|
||||||
|
};
|
||||||
|
}, [item.MediaStreams]);
|
||||||
|
|
||||||
|
const defaults = {
|
||||||
|
itemId: item.Id,
|
||||||
|
video:
|
||||||
|
tracks.video.find((track) => track.IsDefault)?.Index ??
|
||||||
|
tracks.video[0]?.Index ??
|
||||||
|
0,
|
||||||
|
audio: item.MediaSources?.[0]?.DefaultAudioStreamIndex ?? 0,
|
||||||
|
subtitle: item.MediaSources?.[0]?.DefaultSubtitleStreamIndex ?? -1,
|
||||||
|
};
|
||||||
|
const [selection, setSelection] = useState(defaults);
|
||||||
|
if (selection.itemId !== item.Id) {
|
||||||
|
setSelection(defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mediaQualityInfo = useMemo(
|
||||||
|
() => getMediaQualityInfo(tracks.video, tracks.audio),
|
||||||
|
[tracks],
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
tracks,
|
||||||
|
selection,
|
||||||
|
setSelection: (patch: Partial<Omit<typeof defaults, "itemId">>) =>
|
||||||
|
setSelection((prev) => ({ ...prev, ...patch })),
|
||||||
|
mediaQualityInfo,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
type TrackSelectorsProps = Pick<
|
||||||
|
ReturnType<typeof useMediaTracks>,
|
||||||
|
"tracks" | "selection" | "setSelection"
|
||||||
|
>;
|
||||||
|
|
||||||
|
export const TrackSelectors = ({
|
||||||
|
tracks,
|
||||||
|
selection,
|
||||||
|
setSelection,
|
||||||
|
}: TrackSelectorsProps) => (
|
||||||
|
<>
|
||||||
|
{tracks.video.length > 0 && (
|
||||||
|
<TextField
|
||||||
|
label="Видео"
|
||||||
|
select
|
||||||
|
style={{ width: "100%", marginBottom: "1em" }}
|
||||||
|
value={selection.video}
|
||||||
|
variant="filled"
|
||||||
|
onChange={(e) => setSelection({ video: Number(e.target.value) })}
|
||||||
|
>
|
||||||
|
{tracks.video.map((track) => (
|
||||||
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
|
{track.DisplayTitle}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
)}
|
||||||
|
{tracks.audio.length > 0 && (
|
||||||
|
<TextField
|
||||||
|
label="Аудио"
|
||||||
|
select
|
||||||
|
style={{ width: "100%", marginBottom: "1em" }}
|
||||||
|
value={selection.audio}
|
||||||
|
variant="filled"
|
||||||
|
onChange={(e) => setSelection({ audio: Number(e.target.value) })}
|
||||||
|
>
|
||||||
|
{tracks.audio.map((track) => (
|
||||||
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
|
{track.DisplayTitle}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
)}
|
||||||
|
{tracks.subtitle.length > 0 && (
|
||||||
|
<TextField
|
||||||
|
label="Субтитры"
|
||||||
|
select
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
value={selection.subtitle}
|
||||||
|
variant="filled"
|
||||||
|
slotProps={{ select: { MenuProps: { disablePortal: true } } }}
|
||||||
|
onChange={(e) => setSelection({ subtitle: Number(e.target.value) })}
|
||||||
|
>
|
||||||
|
<MenuItem key={-1} value={-1}>
|
||||||
|
Без субтитров
|
||||||
|
</MenuItem>
|
||||||
|
{tracks.subtitle.map((track) => (
|
||||||
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
|
{track.DisplayTitle}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import React from "react";
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import { getSimilarItemsQueryOptions } from "@/utils/queries/itemDetail";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
|
export const getItemCardTitle = (item: BaseItemDto) =>
|
||||||
|
item.Type === BaseItemKind.Episode ? item.SeriesName : item.Name;
|
||||||
|
|
||||||
|
export const getItemCardCaption = (item: BaseItemDto) => {
|
||||||
|
if (item.Type === BaseItemKind.Episode) {
|
||||||
|
return `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`;
|
||||||
|
}
|
||||||
|
if (item.Type === BaseItemKind.Series) {
|
||||||
|
const end = item.EndDate
|
||||||
|
? new Date(item.EndDate).toLocaleString("ru-RU", { year: "numeric" })
|
||||||
|
: "н.в.";
|
||||||
|
return `${item.ProductionYear} - ${end}`;
|
||||||
|
}
|
||||||
|
return item.ProductionYear;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SimilarItems = ({ item }: { item: BaseItemDto }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const id = item.Id ?? "";
|
||||||
|
const similarItems = useQuery(
|
||||||
|
getSimilarItemsQueryOptions(api, user?.Id, id, item.Type),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!similarItems.data?.TotalRecordCount) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CardScroller
|
||||||
|
title="Вам может понравиться"
|
||||||
|
displayCards={7}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{similarItems.data.Items?.map((similar) => (
|
||||||
|
<Card
|
||||||
|
key={similar.Id}
|
||||||
|
item={similar}
|
||||||
|
seriesId={similar.SeriesId}
|
||||||
|
cardTitle={getItemCardTitle(similar)}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={getItemCardCaption(similar)}
|
||||||
|
cardType={
|
||||||
|
similar.Type === BaseItemKind.MusicAlbum ||
|
||||||
|
similar.Type === BaseItemKind.Audio
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={["item", id, "similarItem"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SimilarItems;
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import React from "react";
|
||||||
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import { getCollectionItemsQueryOptions } from "@/utils/queries/itemDetail";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import ItemDetailLayout, { ExternalLinks } from "../itemDetailLayout";
|
||||||
|
import SimilarItems, { getItemCardTitle } from "../similarItems";
|
||||||
|
|
||||||
|
const BoxSetView = ({ item }: { item: BaseItemDto }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const id = item.Id ?? "";
|
||||||
|
const collectionItems = useQuery(
|
||||||
|
getCollectionItemsQueryOptions(api, user?.Id, id),
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ItemDetailLayout
|
||||||
|
item={item}
|
||||||
|
variant="boxset"
|
||||||
|
showTrailer={false}
|
||||||
|
playButton={
|
||||||
|
<PlayButton
|
||||||
|
item={item}
|
||||||
|
itemType={item.Type ?? "BoxSet"}
|
||||||
|
userId={user?.Id}
|
||||||
|
buttonProps={{ fullWidth: true }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
aside={<ExternalLinks item={item} />}
|
||||||
|
>
|
||||||
|
{(collectionItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
|
<CardScroller title="" displayCards={7} disableDecoration>
|
||||||
|
{collectionItems.data?.Items?.map((collectionItem) => (
|
||||||
|
<Card
|
||||||
|
key={collectionItem.Id}
|
||||||
|
item={collectionItem}
|
||||||
|
seriesId={collectionItem.SeriesId}
|
||||||
|
cardTitle={getItemCardTitle(collectionItem)}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={collectionItem.ProductionYear}
|
||||||
|
cardType="portrait"
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
<SimilarItems item={item} />
|
||||||
|
</ItemDetailLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BoxSetView;
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import React from "react";
|
||||||
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import { getUpcomingEpisodesQueryOptions } from "@/utils/queries/itemDetail";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import CastAndCrew from "../castAndCrew";
|
||||||
|
import ItemDetailLayout, { ExternalLinks } from "../itemDetailLayout";
|
||||||
|
import { TrackSelectors, useMediaTracks } from "../mediaTracks";
|
||||||
|
import SimilarItems from "../similarItems";
|
||||||
|
|
||||||
|
const UpcomingEpisodes = ({ episode }: { episode: BaseItemDto }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const options = getUpcomingEpisodesQueryOptions(api, user?.Id, episode);
|
||||||
|
const upcomingEpisodes = useQuery(options);
|
||||||
|
|
||||||
|
if (!upcomingEpisodes.data?.Items?.length) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CardScroller title="Будущие серии" displayCards={4} disableDecoration>
|
||||||
|
{upcomingEpisodes.data.Items.map((upcoming) => (
|
||||||
|
<Card
|
||||||
|
key={upcoming.Id}
|
||||||
|
item={upcoming}
|
||||||
|
cardTitle={upcoming.SeriesName}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={`S${upcoming.ParentIndexNumber}:E${upcoming.IndexNumber} - ${upcoming.Name}`}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={options.queryKey as string[]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Movies, episodes, videos and any other playable item. */
|
||||||
|
const DefaultView = ({ item }: { item: BaseItemDto }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const { tracks, selection, setSelection, mediaQualityInfo } =
|
||||||
|
useMediaTracks(item);
|
||||||
|
const isEpisode = item.Type === BaseItemKind.Episode;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ItemDetailLayout
|
||||||
|
item={item}
|
||||||
|
variant={isEpisode ? "episode" : "default"}
|
||||||
|
mediaQualityInfo={mediaQualityInfo}
|
||||||
|
playButton={
|
||||||
|
<PlayButton
|
||||||
|
item={item}
|
||||||
|
itemType={item.Type ?? "Movie"}
|
||||||
|
audio={item.Type === BaseItemKind.Audio}
|
||||||
|
currentVideoTrack={selection.video}
|
||||||
|
currentAudioTrack={selection.audio}
|
||||||
|
currentSubTrack={selection.subtitle}
|
||||||
|
userId={user?.Id}
|
||||||
|
buttonProps={{ fullWidth: true }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
aside={
|
||||||
|
<>
|
||||||
|
<TrackSelectors
|
||||||
|
tracks={tracks}
|
||||||
|
selection={selection}
|
||||||
|
setSelection={setSelection}
|
||||||
|
/>
|
||||||
|
<ExternalLinks item={item} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<CastAndCrew people={item.People} api={api} />
|
||||||
|
{isEpisode ? (
|
||||||
|
<UpcomingEpisodes episode={item} />
|
||||||
|
) : (
|
||||||
|
<SimilarItems item={item} />
|
||||||
|
)}
|
||||||
|
</ItemDetailLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DefaultView;
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
|
import Tab from "@mui/material/Tab";
|
||||||
|
import Tabs from "@mui/material/Tabs";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { useQueries } from "@tanstack/react-query";
|
||||||
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import {
|
||||||
|
getPersonItemsQueryOptions,
|
||||||
|
personTabs,
|
||||||
|
} from "@/utils/queries/itemDetail";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import ItemDetailLayout, { ExternalLinks } from "../itemDetailLayout";
|
||||||
|
import { getItemCardCaption, getItemCardTitle } from "../similarItems";
|
||||||
|
|
||||||
|
const PersonView = ({ item }: { item: BaseItemDto }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const id = item.Id ?? "";
|
||||||
|
|
||||||
|
const tabQueries = useQueries({
|
||||||
|
queries: personTabs.map((tab) =>
|
||||||
|
getPersonItemsQueryOptions(api, user?.Id, id, tab),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Until the user picks a tab, show the first one that has items.
|
||||||
|
const [pickedTab, setPickedTab] = useState<number | null>(null);
|
||||||
|
const allLoaded = tabQueries.every((query) => query.isSuccess);
|
||||||
|
const firstNonEmptyTab = tabQueries.findIndex(
|
||||||
|
(query) => (query.data?.TotalRecordCount ?? 0) > 0,
|
||||||
|
);
|
||||||
|
const activeTab =
|
||||||
|
pickedTab ?? (allLoaded ? Math.max(firstNonEmptyTab, 0) : 0);
|
||||||
|
const [animationDirection, setAnimationDirection] = useState<
|
||||||
|
"forward" | "backwards"
|
||||||
|
>("forward");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ItemDetailLayout
|
||||||
|
item={item}
|
||||||
|
variant="person"
|
||||||
|
showTrailer={false}
|
||||||
|
showMarkPlayed={false}
|
||||||
|
main={<ExternalLinks item={item} />}
|
||||||
|
aside={
|
||||||
|
<>
|
||||||
|
{item.PremiereDate && (
|
||||||
|
<div>
|
||||||
|
<Typography variant="h6">Дата рождения</Typography>
|
||||||
|
<Typography variant="subtitle1" sx={{ opacity: 0.8 }}>
|
||||||
|
{new Date(item.PremiereDate).toLocaleDateString("ru-RU")}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{item.EndDate && (
|
||||||
|
<div>
|
||||||
|
<Typography variant="h6" sx={{ mt: 2 }}>
|
||||||
|
Дата смерти
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="subtitle2" sx={{ opacity: 0.8 }}>
|
||||||
|
{new Date(item.EndDate).toLocaleDateString("ru-RU")}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="item-detail-person-container">
|
||||||
|
<div className="item-detail-person-header">
|
||||||
|
<Tabs
|
||||||
|
variant="scrollable"
|
||||||
|
value={activeTab}
|
||||||
|
onChange={(_, newTab: number) => {
|
||||||
|
setAnimationDirection(
|
||||||
|
newTab > activeTab ? "forward" : "backwards",
|
||||||
|
);
|
||||||
|
setPickedTab(newTab);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{personTabs.map((tab, index) => (
|
||||||
|
<Tab
|
||||||
|
key={tab.key}
|
||||||
|
label={tab.title}
|
||||||
|
disabled={tabQueries[index].data?.TotalRecordCount === 0}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Tabs>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
<AnimatePresence>
|
||||||
|
{personTabs.map((tab, index) => {
|
||||||
|
if (index !== activeTab) return null;
|
||||||
|
const query = tabQueries[index];
|
||||||
|
const isWide =
|
||||||
|
tab.kind === BaseItemKind.Photo ||
|
||||||
|
tab.kind === BaseItemKind.Episode;
|
||||||
|
return (
|
||||||
|
<motion.div
|
||||||
|
role="tabpanel"
|
||||||
|
style={{ marginTop: "1em" }}
|
||||||
|
className={`item-detail-person-cards ${isWide ? "col-4" : "col-7"}`}
|
||||||
|
key={tab.key}
|
||||||
|
initial={{
|
||||||
|
opacity: 0,
|
||||||
|
transform:
|
||||||
|
animationDirection === "forward"
|
||||||
|
? "translate(30px)"
|
||||||
|
: "translate(-30px)",
|
||||||
|
}}
|
||||||
|
animate={{ opacity: 1, transform: "translate(0px)" }}
|
||||||
|
transition={{ duration: 0.2, ease: "anticipate" }}
|
||||||
|
>
|
||||||
|
{query.data?.Items?.map((tabItem) => (
|
||||||
|
<Card
|
||||||
|
key={tabItem.Id}
|
||||||
|
item={tabItem}
|
||||||
|
cardTitle={getItemCardTitle(tabItem)}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={getItemCardCaption(tabItem)}
|
||||||
|
cardType={
|
||||||
|
tabItem.Type === BaseItemKind.Episode
|
||||||
|
? "thumb"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={["item", id, tab.key]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</motion.div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</AnimatePresence>
|
||||||
|
</div>
|
||||||
|
</ItemDetailLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PersonView;
|
||||||
@@ -0,0 +1,367 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
ItemFields,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
|
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
||||||
|
import Chip from "@mui/material/Chip";
|
||||||
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { motion } from "motion/react";
|
||||||
|
import React from "react";
|
||||||
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
|
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||||
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||||
|
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
||||||
|
import { getRuntimeCompact, getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
import useDefaultSeason from "@/utils/hooks/useDefaultSeason";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import {
|
||||||
|
getSeasonsQueryOptions,
|
||||||
|
getSpecialFeaturesQueryOptions,
|
||||||
|
} from "@/utils/queries/itemDetail";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import CastAndCrew from "../castAndCrew";
|
||||||
|
import ItemDetailLayout, { ExternalLinks } from "../itemDetailLayout";
|
||||||
|
import SimilarItems from "../similarItems";
|
||||||
|
|
||||||
|
const getEpisodeDateString = (date: Date) =>
|
||||||
|
new Intl.DateTimeFormat("ru-RU", {
|
||||||
|
dateStyle: "full",
|
||||||
|
}).format(date);
|
||||||
|
|
||||||
|
const SeriesView = ({ item }: { item: BaseItemDto }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const id = item.Id ?? "";
|
||||||
|
|
||||||
|
const seasons = useQuery(getSeasonsQueryOptions(api, user?.Id, id));
|
||||||
|
const specialFeatures = useQuery(
|
||||||
|
getSpecialFeaturesQueryOptions(api, user?.Id, id),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [currentSeason, setCurrentSeason] = useDefaultSeason(seasons, id);
|
||||||
|
const currentSeasonId = seasons.data?.Items?.[currentSeason]?.Id;
|
||||||
|
|
||||||
|
const currentSeasonItem = useQuery({
|
||||||
|
queryKey: ["item", id, "season", currentSeason],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !currentSeasonId) return null;
|
||||||
|
const result = await getLibraryApi(api).getItem({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: currentSeasonId,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: seasons.isSuccess,
|
||||||
|
networkMode: "always",
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const episodes = useQuery({
|
||||||
|
queryKey: ["item", id, "season", currentSeason, "episodes"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
const result = await getShowApi(api).getEpisodes({
|
||||||
|
userId: user?.Id,
|
||||||
|
seriesId: id,
|
||||||
|
seasonId: currentSeasonId,
|
||||||
|
fields: [ItemFields.Overview],
|
||||||
|
isMissing: false,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: seasons.isSuccess,
|
||||||
|
networkMode: "always",
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prefer the selected season's backdrop over the series one.
|
||||||
|
const season = currentSeasonItem.data;
|
||||||
|
const backdropOwner = season?.BackdropImageTags?.length ? season : item;
|
||||||
|
const backdropTag = backdropOwner.BackdropImageTags?.[0];
|
||||||
|
const backdropSrc =
|
||||||
|
api && backdropTag
|
||||||
|
? getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
backdropOwner.Id ?? "",
|
||||||
|
"Backdrop",
|
||||||
|
{ tag: backdropTag },
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
const backdropHash =
|
||||||
|
(backdropTag && backdropOwner.ImageBlurHashes?.Backdrop?.[backdropTag]) ||
|
||||||
|
"";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ItemDetailLayout
|
||||||
|
item={item}
|
||||||
|
variant="series"
|
||||||
|
backdropSrc={backdropSrc}
|
||||||
|
backdropHash={backdropHash}
|
||||||
|
playButton={
|
||||||
|
<PlayButton
|
||||||
|
item={item}
|
||||||
|
itemType={BaseItemKind.Series}
|
||||||
|
userId={user?.Id}
|
||||||
|
buttonProps={{ fullWidth: true }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
main={<ExternalLinks item={item} />}
|
||||||
|
>
|
||||||
|
{seasons.isPending ? (
|
||||||
|
<SeasonSelectorSkeleton />
|
||||||
|
) : (
|
||||||
|
<div className="item-series-seasons-container">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
width: "100%",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
paddingBottom: " 0.5em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ display: "flex", gap: "1em" }}>
|
||||||
|
<Typography variant="h5">
|
||||||
|
{seasons.data?.Items?.[currentSeason]?.Name}
|
||||||
|
</Typography>
|
||||||
|
<Chip
|
||||||
|
label={
|
||||||
|
episodes.isPending ? (
|
||||||
|
<CircularProgress
|
||||||
|
size={20}
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
episodes.data?.TotalRecordCount
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div style={{ display: "flex", gap: "0.75em" }}>
|
||||||
|
{season && (
|
||||||
|
<>
|
||||||
|
<LikeButton
|
||||||
|
itemId={season.Id}
|
||||||
|
isFavorite={season.UserData?.IsFavorite}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={season.Name}
|
||||||
|
/>
|
||||||
|
<MarkPlayedButton
|
||||||
|
itemId={season.Id}
|
||||||
|
isPlayed={season.UserData?.Played}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={season.Name}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<TextField
|
||||||
|
value={currentSeason}
|
||||||
|
onChange={(e) => {
|
||||||
|
const seasonIndex = Number(e.target.value);
|
||||||
|
if (Number.isFinite(seasonIndex)) {
|
||||||
|
setCurrentSeason(seasonIndex);
|
||||||
|
sessionStorage.setItem(
|
||||||
|
`season-${id}`,
|
||||||
|
seasonIndex.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
select
|
||||||
|
slotProps={{
|
||||||
|
select: { MenuProps: { disableScrollLock: true } },
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{seasons.data?.Items?.map((seasonItem, index) => (
|
||||||
|
<MenuItem key={seasonItem.Id} value={index}>
|
||||||
|
{seasonItem.Name}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Divider />
|
||||||
|
<div className="item-detail-episode-container">
|
||||||
|
{episodes.isPending ? (
|
||||||
|
<EpisodeSkeleton />
|
||||||
|
) : (
|
||||||
|
episodes.data?.Items?.map((episode) => (
|
||||||
|
<motion.div
|
||||||
|
key={episode.Id}
|
||||||
|
onClick={() =>
|
||||||
|
navigate({
|
||||||
|
to: "/item/$id",
|
||||||
|
params: { id: episode.Id ?? "" },
|
||||||
|
search: { type: BaseItemKind.Episode },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
initial={{ transform: "translateY(10px)", opacity: 0 }}
|
||||||
|
whileInView={{ opacity: 1, transform: "translateY(0px)" }}
|
||||||
|
viewport={{ once: true }}
|
||||||
|
transition={{ duration: 0.2, ease: "backInOut" }}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
className="item-detail-episode"
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle1" sx={{ textAlign: "center" }}>
|
||||||
|
{episode.IndexNumberEnd
|
||||||
|
? `${episode.IndexNumber} / ${episode.IndexNumberEnd}`
|
||||||
|
: (episode.IndexNumber ?? 0)}
|
||||||
|
</Typography>
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
episode.UserData?.Played
|
||||||
|
? "item-detail-episode-image-container watched"
|
||||||
|
: "item-detail-episode-image-container"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="item-detail-episode-image-overlay">
|
||||||
|
<PlayButton
|
||||||
|
item={episode}
|
||||||
|
itemType={BaseItemKind.Episode}
|
||||||
|
userId={user?.Id}
|
||||||
|
size="medium"
|
||||||
|
buttonProps={{
|
||||||
|
//@ts-expect-error
|
||||||
|
color: "white",
|
||||||
|
style: { color: "black " },
|
||||||
|
}}
|
||||||
|
iconOnly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="item-detail-episode-image-icon-container">
|
||||||
|
<span className="material-symbols-rounded item-detail-episode-image-icon">
|
||||||
|
tv_gen
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<img
|
||||||
|
alt={episode.Name ?? ""}
|
||||||
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
episode.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{ tag: episode.ImageTags?.Primary, fillHeight: 300 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="item-detail-episode-image"
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{(episode.UserData?.PlaybackPositionTicks ?? 0) > 0 && (
|
||||||
|
<div className="card-progress-container">
|
||||||
|
<div
|
||||||
|
className="card-progress"
|
||||||
|
style={{
|
||||||
|
width: `${episode.UserData?.PlayedPercentage}%`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="item-detail-episode-info">
|
||||||
|
<Typography variant="subtitle1">{episode.Name}</Typography>
|
||||||
|
<div
|
||||||
|
className="flex flex-row flex-align-center"
|
||||||
|
style={{ gap: "0.5em" }}
|
||||||
|
>
|
||||||
|
{episode.PremiereDate && (
|
||||||
|
<Chip
|
||||||
|
variant="filled"
|
||||||
|
label={getEpisodeDateString(
|
||||||
|
new Date(episode.PremiereDate),
|
||||||
|
)}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Typography variant="caption">
|
||||||
|
{getRuntimeCompact(episode.RunTimeTicks ?? 0)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
style={{
|
||||||
|
display: "-webkit-box",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
overflow: "hidden",
|
||||||
|
WebkitLineClamp: 2,
|
||||||
|
WebkitBoxOrient: "vertical",
|
||||||
|
width: "100%",
|
||||||
|
opacity: 0.7,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{episode.Overview}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="item-detail-episode-buttons"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<LikeButton
|
||||||
|
itemId={episode.Id}
|
||||||
|
itemName={episode.Name}
|
||||||
|
isFavorite={episode.UserData?.IsFavorite}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
<MarkPlayedButton
|
||||||
|
itemId={episode.Id}
|
||||||
|
itemName={episode.Name}
|
||||||
|
isPlayed={episode.UserData?.Played}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</motion.div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<CastAndCrew people={item.People} api={api} />
|
||||||
|
{(specialFeatures.data?.length ?? 0) > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Дополнительные материалы"
|
||||||
|
displayCards={7}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{specialFeatures.data?.map((special) => (
|
||||||
|
<Card
|
||||||
|
key={special.Id}
|
||||||
|
item={special}
|
||||||
|
seriesId={special.SeriesId}
|
||||||
|
cardTitle={special.Name}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={getRuntimeMusic(special.RunTimeTicks ?? 0)}
|
||||||
|
cardType="portrait"
|
||||||
|
queryKey={["item", id, "similarItem"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
onClick={() => {}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
<SimilarItems item={item} />
|
||||||
|
</ItemDetailLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SeriesView;
|
||||||
@@ -0,0 +1,378 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import Chip from "@mui/material/Chip";
|
||||||
|
import { green, red, yellow } from "@mui/material/colors";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import React, { type ReactNode, type RefObject } from "react";
|
||||||
|
import { Blurhash } from "react-blurhash";
|
||||||
|
import heroBg from "@/assets/herobg.png";
|
||||||
|
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||||
|
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||||
|
import dolbyDigitalIcon from "@/assets/icons/dolby-digital.svg";
|
||||||
|
import dolbyTrueHDIcon from "@/assets/icons/dolby-truehd.svg";
|
||||||
|
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||||
|
import dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||||
|
import dtsIcon from "@/assets/icons/dts.svg";
|
||||||
|
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.svg";
|
||||||
|
import hdIcon from "@/assets/icons/hd.svg";
|
||||||
|
import hdrIcon from "@/assets/icons/hdr.svg";
|
||||||
|
import hdr10Icon from "@/assets/icons/hdr10.svg";
|
||||||
|
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||||
|
import sdIcon from "@/assets/icons/sd.svg";
|
||||||
|
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||||
|
import ItemBackdrop from "@/components/itemBackdrop";
|
||||||
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
import "./itemHeader.scss";
|
||||||
|
|
||||||
|
interface ItemHeaderProps {
|
||||||
|
item: BaseItemDto;
|
||||||
|
api: Api | undefined;
|
||||||
|
mediaQualityInfo?: MediaQualityInfo;
|
||||||
|
scrollTargetRef?: RefObject<HTMLDivElement | null>;
|
||||||
|
children?: ReactNode;
|
||||||
|
backdropSrc?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ItemHeader = ({
|
||||||
|
item,
|
||||||
|
api,
|
||||||
|
mediaQualityInfo,
|
||||||
|
scrollTargetRef,
|
||||||
|
children,
|
||||||
|
backdropSrc,
|
||||||
|
}: ItemHeaderProps) => {
|
||||||
|
const isEpisode = item.Type === "Episode";
|
||||||
|
// A runtime / "ends at" is meaningless for people and artists (it sums their whole catalogue)
|
||||||
|
const showRuntime = item.Type !== "MusicArtist" && item.Type !== "Person";
|
||||||
|
const backdropTag =
|
||||||
|
isEpisode && item.ParentBackdropImageTags?.length
|
||||||
|
? item.ParentBackdropImageTags[0]
|
||||||
|
: item.BackdropImageTags?.[0];
|
||||||
|
const backdropId =
|
||||||
|
isEpisode && item.ParentBackdropImageTags?.length
|
||||||
|
? (item.ParentBackdropItemId ?? item.Id)
|
||||||
|
: item.Id;
|
||||||
|
|
||||||
|
const parentLogoImageTag =
|
||||||
|
(item as any).ParentLogoImageTag || (item as any).ParentLogoImageTags?.[0];
|
||||||
|
const logoTag =
|
||||||
|
isEpisode && parentLogoImageTag ? parentLogoImageTag : item.ImageTags?.Logo;
|
||||||
|
const logoId =
|
||||||
|
isEpisode && parentLogoImageTag ? (item.SeriesId ?? item.Id) : item.Id;
|
||||||
|
|
||||||
|
const logo = logoTag ? (
|
||||||
|
<img
|
||||||
|
alt={item.Name ?? ""}
|
||||||
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(logoId ?? "", "Logo", {
|
||||||
|
quality: 90,
|
||||||
|
fillWidth: 592,
|
||||||
|
fillHeight: 592,
|
||||||
|
tag: logoTag,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="item-hero-logo"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Typography
|
||||||
|
variant="h2"
|
||||||
|
sx={{
|
||||||
|
mb: 2,
|
||||||
|
fontWeight: 200,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isEpisode ? item.SeriesName : item.Name}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="item-hero">
|
||||||
|
<div className="item-hero-backdrop-container">
|
||||||
|
{scrollTargetRef && (
|
||||||
|
<ItemBackdrop
|
||||||
|
targetRef={scrollTargetRef}
|
||||||
|
alt={item.Name ?? ""}
|
||||||
|
backdropSrc={
|
||||||
|
backdropSrc ??
|
||||||
|
(backdropTag
|
||||||
|
? api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
backdropId ?? "",
|
||||||
|
"Backdrop",
|
||||||
|
{ tag: backdropTag },
|
||||||
|
)
|
||||||
|
: undefined)
|
||||||
|
}
|
||||||
|
fallbackSrc={heroBg}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="item-hero-image-container"
|
||||||
|
style={{
|
||||||
|
aspectRatio: item.PrimaryImageAspectRatio ?? 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.ImageTags?.Primary ? (
|
||||||
|
<div>
|
||||||
|
<Blurhash
|
||||||
|
hash={
|
||||||
|
item.ImageBlurHashes?.Primary?.[item.ImageTags.Primary] ?? ""
|
||||||
|
}
|
||||||
|
className="item-hero-image-blurhash"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
alt={item.Name ?? ""}
|
||||||
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
quality: 90,
|
||||||
|
tag: item.ImageTags.Primary,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="item-hero-image"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="item-hero-image-icon">
|
||||||
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="item-hero-detail flex flex-column">
|
||||||
|
{isEpisode && logoId ? (
|
||||||
|
<Link
|
||||||
|
to="/item/$id"
|
||||||
|
params={{ id: logoId }}
|
||||||
|
search={{ type: "Series" }}
|
||||||
|
style={{
|
||||||
|
textDecoration: "none",
|
||||||
|
color: "inherit",
|
||||||
|
width: "fit-content",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{logo}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
logo
|
||||||
|
)}
|
||||||
|
{isEpisode && (
|
||||||
|
<Typography
|
||||||
|
variant="h4"
|
||||||
|
sx={{
|
||||||
|
mb: 2,
|
||||||
|
fontWeight: 200,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.ParentIndexNumber !== undefined &&
|
||||||
|
item.IndexNumber !== undefined
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - `
|
||||||
|
: ""}
|
||||||
|
{item.Name}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
sx={{
|
||||||
|
gap: 2,
|
||||||
|
justifyItems: "flex-start",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{mediaQualityInfo?.isUHD && (
|
||||||
|
<img
|
||||||
|
src={ultraHdIcon}
|
||||||
|
alt="ultra hd"
|
||||||
|
className="item-hero-mediaInfo badge"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo?.isHD && (
|
||||||
|
<img src={hdIcon} alt="hd" className="item-hero-mediaInfo badge" />
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo?.isSD && (
|
||||||
|
<img src={sdIcon} alt="sd" className="item-hero-mediaInfo badge" />
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo?.isSDR && (
|
||||||
|
<img
|
||||||
|
src={sdrIcon}
|
||||||
|
alt="sdr"
|
||||||
|
className="item-hero-mediaInfo badge"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo?.isHDR &&
|
||||||
|
!mediaQualityInfo?.isHDR10 &&
|
||||||
|
!mediaQualityInfo?.isHDR10Plus && (
|
||||||
|
<img
|
||||||
|
src={hdrIcon}
|
||||||
|
alt="hdr"
|
||||||
|
className="item-hero-mediaInfo badge"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo?.isHDR10 && (
|
||||||
|
<img
|
||||||
|
src={hdr10Icon}
|
||||||
|
alt="hdr10"
|
||||||
|
className="item-hero-mediaInfo badge"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{item.PremiereDate && (
|
||||||
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
|
{item.ProductionYear ?? ""}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{item.OfficialRating && (
|
||||||
|
<Chip variant="filled" size="small" label={item.OfficialRating} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{item.CommunityRating && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "0.25em",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
className="hero-carousel-info-rating"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded fill"
|
||||||
|
style={{
|
||||||
|
// fontSize: "2.2em",
|
||||||
|
color: yellow[400],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
star
|
||||||
|
</div>
|
||||||
|
<Typography
|
||||||
|
style={{
|
||||||
|
opacity: "0.8",
|
||||||
|
}}
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
{Math.round(item.CommunityRating * 10) / 10}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{item.CriticRating && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "0.25em",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
className="hero-carousel-info-rating"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded fill"
|
||||||
|
style={{
|
||||||
|
color: item.CriticRating > 50 ? green[400] : red[400],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||||
|
</div>
|
||||||
|
<Typography
|
||||||
|
style={{
|
||||||
|
opacity: "0.8",
|
||||||
|
}}
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
{item.CriticRating}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showRuntime && item.RunTimeTicks && (
|
||||||
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
|
{getRuntime(item.RunTimeTicks)}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{showRuntime && item.RunTimeTicks && (
|
||||||
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
|
{endsAt(
|
||||||
|
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||||
|
{item.Genres?.slice(0, 4).join(" / ")}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
{mediaQualityInfo && (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
sx={{
|
||||||
|
gap: 2,
|
||||||
|
justifyItems: "flex-start",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{mediaQualityInfo?.isHDR10Plus && (
|
||||||
|
<img
|
||||||
|
src={hdr10PlusIcon}
|
||||||
|
alt="hdr10+"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isDts && (
|
||||||
|
<img src={dtsIcon} alt="dts" className="item-hero-mediaInfo" />
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isDtsHDMA && (
|
||||||
|
<img
|
||||||
|
src={dtsHdMaIcon}
|
||||||
|
alt="dts-hd ma"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && (
|
||||||
|
<img
|
||||||
|
src={dolbyVisionAtmosIcon}
|
||||||
|
alt="dolby vision atmos"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isAtmos && !mediaQualityInfo.isDolbyVision && (
|
||||||
|
<img
|
||||||
|
src={dolbyAtmosIcon}
|
||||||
|
alt="dolby atmos"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isDolbyVision && !mediaQualityInfo.isAtmos && (
|
||||||
|
<img
|
||||||
|
src={dolbyVisionIcon}
|
||||||
|
alt="dolby vision"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isTrueHD && (
|
||||||
|
<img
|
||||||
|
src={dolbyTrueHDIcon}
|
||||||
|
alt="dolby truehd"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{mediaQualityInfo.isDD && (
|
||||||
|
<img
|
||||||
|
src={dolbyDigitalIcon}
|
||||||
|
alt="dolby digital"
|
||||||
|
className="item-hero-mediaInfo"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ItemHeader;
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
@import "../../styles/variables.scss";
|
||||||
|
|
||||||
|
$cardWidth: 18%;
|
||||||
|
|
||||||
|
.item-hero {
|
||||||
|
height: 60vh;
|
||||||
|
gap: 2em;
|
||||||
|
row-gap: 1.2em;
|
||||||
|
position: relative;
|
||||||
|
align-items: flex-end;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: $cardWidth 1fr;
|
||||||
|
grid-template-rows: 1fr auto;
|
||||||
|
&-image {
|
||||||
|
width: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
&-container {
|
||||||
|
height: fit-content;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
box-shadow: $shadow-card;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
&-blurhash {
|
||||||
|
position: absolute !important;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
&-icon {
|
||||||
|
background: linear-gradient(45deg, rgb(255 255 255 / 0.05), rgb(255 255 255 / 0.15));
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
.material-symbols-rounded{
|
||||||
|
font-size: 4em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-logo {
|
||||||
|
max-width: 34rem;
|
||||||
|
max-height: 10rem;
|
||||||
|
object-position: bottom;
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
&-detail {
|
||||||
|
width: 100%;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.2em;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
&-buttons {
|
||||||
|
&-container {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
grid-column: 1/3;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: inherit;
|
||||||
|
gap: 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-backdrop {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: top;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
&-container {
|
||||||
|
filter: brightness(0.8);
|
||||||
|
position: absolute;
|
||||||
|
top: -4.4em;
|
||||||
|
left: -$page-margin;
|
||||||
|
width: 100vw;
|
||||||
|
height: calc(64vh + 4.4em);
|
||||||
|
z-index: -1;
|
||||||
|
mask-image: linear-gradient(to top, transparent, black);
|
||||||
|
-webkit-mask-image: linear-gradient(
|
||||||
|
to top,
|
||||||
|
transparent,
|
||||||
|
black
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
& .play-button {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import React from "react";
|
|||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -30,7 +30,7 @@ export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
|||||||
queryKey: ["artist", "album", album.Id],
|
queryKey: ["artist", "album", album.Id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return null;
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getLibraryApi(api).getItems({
|
||||||
userId: user.Id,
|
userId: user.Id,
|
||||||
parentId: album.Id,
|
parentId: album.Id,
|
||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
@@ -55,7 +55,7 @@ export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
|||||||
{!!album.ImageTags?.Primary && (
|
{!!album.ImageTags?.Primary && (
|
||||||
<div className="album-image">
|
<div className="album-image">
|
||||||
<img
|
<img
|
||||||
alt={album.Name ?? "Album Image"}
|
alt={album.Name ?? "Обложка альбома"}
|
||||||
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
@@ -91,13 +91,15 @@ export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
|||||||
<div className="flex flex-column">
|
<div className="flex flex-column">
|
||||||
<Typography
|
<Typography
|
||||||
variant="h5"
|
variant="h5"
|
||||||
fontWeight={300}
|
|
||||||
style={{ opacity: "0.6" }}
|
style={{ opacity: "0.6" }}
|
||||||
|
sx={{
|
||||||
|
fontWeight: 300,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{album.ProductionYear}
|
{album.ProductionYear}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Link
|
<Link
|
||||||
to="/album/$id"
|
to="/music/album/$id"
|
||||||
params={{ id: album.Id ?? "" }}
|
params={{ id: album.Id ?? "" }}
|
||||||
style={{ color: "white", textDecoration: "none" }}
|
style={{ color: "white", textDecoration: "none" }}
|
||||||
>
|
>
|
||||||
@@ -148,8 +150,8 @@ export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
|||||||
<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">Название</Typography>
|
||||||
<Typography variant="subtitle1">Duration</Typography>
|
<Typography variant="subtitle1">Длительность</Typography>
|
||||||
</div>
|
</div>
|
||||||
{albumTracks.data?.Items?.map((track, index) => (
|
{albumTracks.data?.Items?.map((track, index) => (
|
||||||
<AlbumMusicTrack
|
<AlbumMusicTrack
|
||||||
|
|||||||
@@ -10,32 +10,21 @@ import {
|
|||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getLibraryLatestQueryOptions } from "@/utils/queries/items";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Latest Media Section
|
* @description Latest Media Section
|
||||||
*/
|
*/
|
||||||
export const LatestMediaSection = ({
|
export const LatestMediaSection = ({
|
||||||
latestMediaLib,
|
latestMediaLib,
|
||||||
}: { latestMediaLib: BaseItemDto }) => {
|
}: {
|
||||||
|
latestMediaLib: BaseItemDto;
|
||||||
|
}) => {
|
||||||
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 data = useQuery(
|
||||||
if (!api || !user?.Id) return null;
|
getLibraryLatestQueryOptions(api, user?.Id, latestMediaLib.Id),
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
);
|
||||||
userId: user.Id,
|
|
||||||
parentId: library.Id,
|
|
||||||
limit: 16,
|
|
||||||
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
|
||||||
});
|
|
||||||
return media.data;
|
|
||||||
};
|
|
||||||
const data = useQuery({
|
|
||||||
queryKey: ["home", "latestMedia", latestMediaLib.Id],
|
|
||||||
queryFn: () => fetchLatestMedia(latestMediaLib),
|
|
||||||
enabled: !!user?.Id,
|
|
||||||
refetchOnMount: true,
|
|
||||||
});
|
|
||||||
if (data.isPending) {
|
if (data.isPending) {
|
||||||
return <CardsSkeleton />;
|
return <CardsSkeleton />;
|
||||||
}
|
}
|
||||||
@@ -56,14 +45,14 @@ export const LatestMediaSection = ({
|
|||||||
item.Type === BaseItemKind.Episode
|
item.Type === BaseItemKind.Episode
|
||||||
? `S${item.ParentIndexNumber ?? 0}:E${
|
? `S${item.ParentIndexNumber ?? 0}:E${
|
||||||
item.IndexNumber ?? 0
|
item.IndexNumber ?? 0
|
||||||
} - ${item.Name ?? "Unknown"}`
|
} - ${item.Name ?? "Неизвестно"}`
|
||||||
: item.Type === BaseItemKind.Series
|
: item.Type === BaseItemKind.Series
|
||||||
? `${item.ProductionYear} - ${
|
? `${item.ProductionYear} - ${
|
||||||
item.EndDate
|
item.EndDate
|
||||||
? new Date(item.EndDate).toLocaleString([], {
|
? new Date(item.EndDate).toLocaleString("ru-RU", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
})
|
})
|
||||||
: "Present"
|
: "н.в."
|
||||||
}`
|
}`
|
||||||
: item.ProductionYear
|
: item.ProductionYear
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,427 @@
|
|||||||
|
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { ItemSortBy, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
|
import {
|
||||||
|
AppBar,
|
||||||
|
Chip,
|
||||||
|
IconButton,
|
||||||
|
MenuItem,
|
||||||
|
TextField,
|
||||||
|
Typography,
|
||||||
|
useScrollTrigger,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||||
|
import type { ChangeEvent } from "react";
|
||||||
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
||||||
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
|
// import removed: header reads name/count from Zustand slice
|
||||||
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
|
import useSearchStore from "@/utils/store/search";
|
||||||
|
import { NavigationDrawer } from "../appBar/navigationDrawer";
|
||||||
|
import BackButton from "../buttons/backButton";
|
||||||
|
import CastButton from "../buttons/castButton";
|
||||||
|
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||||
|
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||||
|
import WindowControls from "../windowControls";
|
||||||
|
import "./libraryHeader.scss";
|
||||||
|
|
||||||
|
const route = getRouteApi("/_api/library/$id");
|
||||||
|
|
||||||
|
const MemoizeBackButton = React.memo(BackButton);
|
||||||
|
|
||||||
|
export const LibraryHeader = () => {
|
||||||
|
const { id: currentLibraryId } = route.useParams();
|
||||||
|
const { api, user } = route.useRouteContext();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
// Zustand library state (selected via shallow comparator)
|
||||||
|
const {
|
||||||
|
currentViewType,
|
||||||
|
storeSortBy,
|
||||||
|
storeSortAscending,
|
||||||
|
filters,
|
||||||
|
vts,
|
||||||
|
nameStartsWith,
|
||||||
|
genreIds,
|
||||||
|
libraryNameFromStore,
|
||||||
|
itemsTotalCount,
|
||||||
|
} = useLibraryStateStore(
|
||||||
|
useShallow((s) => {
|
||||||
|
const slice = s.libraries[currentLibraryId || ""];
|
||||||
|
return {
|
||||||
|
currentViewType: slice?.currentViewType,
|
||||||
|
storeSortBy: slice?.sortBy,
|
||||||
|
storeSortAscending: slice?.sortAscending,
|
||||||
|
filters: slice?.filters,
|
||||||
|
vts: slice?.videoTypesState,
|
||||||
|
nameStartsWith: slice?.nameStartsWith,
|
||||||
|
genreIds: slice?.genreIds,
|
||||||
|
libraryNameFromStore: slice?.libraryName,
|
||||||
|
itemsTotalCount: slice?.itemsTotalCount,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const { initLibrary, updateLibrary } = useLibraryStateStore(
|
||||||
|
useShallow((s) => ({
|
||||||
|
initLibrary: s.initLibrary,
|
||||||
|
updateLibrary: s.updateLibrary,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!currentLibraryId) return;
|
||||||
|
// If the slice isn't initialized, these fields will be undefined
|
||||||
|
if (
|
||||||
|
currentViewType === undefined &&
|
||||||
|
storeSortBy === undefined &&
|
||||||
|
storeSortAscending === undefined
|
||||||
|
) {
|
||||||
|
initLibrary(currentLibraryId, {
|
||||||
|
sortBy: ItemSortBy.Name,
|
||||||
|
sortAscending: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
currentLibraryId,
|
||||||
|
currentViewType,
|
||||||
|
storeSortBy,
|
||||||
|
storeSortAscending,
|
||||||
|
initLibrary,
|
||||||
|
]);
|
||||||
|
const currentLibrary = useSuspenseQuery(
|
||||||
|
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||||
|
);
|
||||||
|
const scrollTrigger = useScrollTrigger({
|
||||||
|
disableHysteresis: true,
|
||||||
|
threshold: 20,
|
||||||
|
});
|
||||||
|
|
||||||
|
const compatibleViews = useMemo(
|
||||||
|
() =>
|
||||||
|
AVAILABLE_VIEWS.filter((v) =>
|
||||||
|
v.compatibleCollectionTypes.includes(
|
||||||
|
currentLibrary.data.CollectionType as any,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
[currentLibrary.data.CollectionType],
|
||||||
|
);
|
||||||
|
// Values from store
|
||||||
|
const sortBy = (storeSortBy ?? ItemSortBy.Name) as string;
|
||||||
|
const sortAscending = storeSortAscending ?? true;
|
||||||
|
const effectiveViewType = currentViewType as any;
|
||||||
|
const effectiveSortByRaw = sortBy;
|
||||||
|
const effectiveSortAscending = sortAscending;
|
||||||
|
|
||||||
|
const normalizedViewType = useMemo(() => {
|
||||||
|
const values = compatibleViews.map((v) => v.value);
|
||||||
|
if (effectiveViewType && values.includes(effectiveViewType as any))
|
||||||
|
return effectiveViewType as any;
|
||||||
|
return values[0] as BaseItemKind | "Artist";
|
||||||
|
}, [effectiveViewType, compatibleViews]);
|
||||||
|
|
||||||
|
const normalizedSortBy = useMemo(() => {
|
||||||
|
const compatibleOptions = SORT_BY_OPTIONS.filter(
|
||||||
|
(option) =>
|
||||||
|
option.compatibleViewTypes?.includes(normalizedViewType as any) ||
|
||||||
|
option.compatibleCollectionTypes?.includes(
|
||||||
|
currentLibrary.data.CollectionType as any,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const compatibleValues = compatibleOptions.map((opt) =>
|
||||||
|
Array.isArray(opt.value) ? opt.value.join(",") : String(opt.value),
|
||||||
|
);
|
||||||
|
const current = String(effectiveSortByRaw ?? "");
|
||||||
|
if (current && compatibleValues.includes(current)) return current;
|
||||||
|
return compatibleValues[0] ?? String(ItemSortBy.Name);
|
||||||
|
}, [
|
||||||
|
effectiveSortByRaw,
|
||||||
|
normalizedViewType,
|
||||||
|
currentLibrary.data.CollectionType,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const handleChangeViewType = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const next = e.target.value as unknown as BaseItemKind | "Artist";
|
||||||
|
if (currentLibraryId)
|
||||||
|
updateLibrary(currentLibraryId, { currentViewType: next });
|
||||||
|
};
|
||||||
|
const handleChangeSortBy = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const next = e.target.value as unknown as string;
|
||||||
|
if (currentLibraryId) updateLibrary(currentLibraryId, { sortBy: next });
|
||||||
|
};
|
||||||
|
const handleSortAscendingToggle = () => {
|
||||||
|
if (currentLibraryId)
|
||||||
|
updateLibrary(currentLibraryId, {
|
||||||
|
sortAscending: !effectiveSortAscending,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// (Video type multi-select temporarily removed; logic cleaned to reduce overhead.)
|
||||||
|
|
||||||
|
// Prefetch helpers to reduce perceived latency on sort changes
|
||||||
|
// filters, vts, nameStartsWith, genreIds are already selected above
|
||||||
|
// Prefetch handler will be attached on menu items below
|
||||||
|
const prefetchItems = useCallback(
|
||||||
|
async (sortByValue: string, asc: boolean) => {
|
||||||
|
if (!api || !user?.Id || !currentLibraryId || !normalizedViewType) return;
|
||||||
|
const key = [
|
||||||
|
"library",
|
||||||
|
"items",
|
||||||
|
currentLibraryId,
|
||||||
|
{
|
||||||
|
currentViewType: normalizedViewType,
|
||||||
|
sortAscending: asc,
|
||||||
|
sortBy: sortByValue,
|
||||||
|
filters,
|
||||||
|
videoTypesState: vts,
|
||||||
|
nameStartsWith,
|
||||||
|
genreIds,
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
await queryClient.prefetchQuery({
|
||||||
|
queryKey: key,
|
||||||
|
queryFn: async () => {
|
||||||
|
const result = await getLibraryApi(api).getItems({
|
||||||
|
userId: user.Id!,
|
||||||
|
parentId: currentLibraryId,
|
||||||
|
recursive: true,
|
||||||
|
includeItemTypes: [normalizedViewType as any],
|
||||||
|
sortOrder: [asc ? SortOrder.Ascending : SortOrder.Descending],
|
||||||
|
sortBy: String(sortByValue).split(",") as any,
|
||||||
|
enableUserData: true,
|
||||||
|
nameStartsWith: nameStartsWith || undefined,
|
||||||
|
genreIds: genreIds && genreIds.length > 0 ? genreIds : undefined,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
staleTime: 5_000,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[
|
||||||
|
api,
|
||||||
|
user?.Id,
|
||||||
|
currentLibraryId,
|
||||||
|
normalizedViewType,
|
||||||
|
filters,
|
||||||
|
vts,
|
||||||
|
nameStartsWith,
|
||||||
|
genreIds,
|
||||||
|
queryClient,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
const disableSortOption = useMemo(
|
||||||
|
() =>
|
||||||
|
!normalizedViewType ||
|
||||||
|
!SORT_BY_OPTIONS.some(
|
||||||
|
(option) =>
|
||||||
|
option.compatibleViewTypes?.includes(normalizedViewType as any) ||
|
||||||
|
option.compatibleCollectionTypes?.includes(
|
||||||
|
currentLibrary.data.CollectionType as any,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
[normalizedViewType, currentLibrary.data.CollectionType],
|
||||||
|
);
|
||||||
|
|
||||||
|
const appBarStyling = useMemo(
|
||||||
|
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Read values from Zustand: name set by route, count set by grid
|
||||||
|
const libraryName = libraryNameFromStore ?? currentLibrary.data.Name;
|
||||||
|
const totalCount = itemsTotalCount;
|
||||||
|
|
||||||
|
const toggleSearchDialog = useSearchStore(
|
||||||
|
useShallow((s) => s.toggleSearchDialog),
|
||||||
|
);
|
||||||
|
const handleNavigateToHome = useCallback(
|
||||||
|
() => navigate({ to: "/home" }),
|
||||||
|
[navigate],
|
||||||
|
);
|
||||||
|
const handleNavigateToFavorite = useCallback(
|
||||||
|
() => navigate({ to: "/favorite" }),
|
||||||
|
[navigate],
|
||||||
|
);
|
||||||
|
|
||||||
|
const [showDrawer, setShowDrawer] = useState(false);
|
||||||
|
|
||||||
|
const handleDrawerClose = useCallback(() => {
|
||||||
|
setShowDrawer(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleDrawerOpen = useCallback(() => {
|
||||||
|
setShowDrawer(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AppBar
|
||||||
|
data-tauri-drag-region
|
||||||
|
className={
|
||||||
|
scrollTrigger
|
||||||
|
? "library-header scrolling flex flex-row"
|
||||||
|
: "library-header flex flex-row"
|
||||||
|
}
|
||||||
|
style={appBarStyling}
|
||||||
|
elevation={0}
|
||||||
|
color="transparent"
|
||||||
|
>
|
||||||
|
<div className="flex flex-row" data-tauri-drag-region style={{ gap: "0.6em" }}>
|
||||||
|
<IconButton
|
||||||
|
onClick={handleDrawerOpen}
|
||||||
|
aria-label="Открыть меню"
|
||||||
|
title="Открыть меню"
|
||||||
|
>
|
||||||
|
<div className="material-symbols-rounded">menu</div>
|
||||||
|
</IconButton>
|
||||||
|
<MemoizeBackButton />
|
||||||
|
<IconButton
|
||||||
|
onClick={handleNavigateToHome}
|
||||||
|
aria-label="Главная"
|
||||||
|
title="Главная"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
location.pathname === "/home"
|
||||||
|
? "material-symbols-rounded fill"
|
||||||
|
: "material-symbols-rounded"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
home
|
||||||
|
</div>
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="flex flex-row library-header-center"
|
||||||
|
style={{ gap: "0.6em" }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="library-title-count flex flex-row flex-align-center"
|
||||||
|
title={`${libraryName}${typeof totalCount === "number" ? ` · ${totalCount.toLocaleString()} элементов` : ""}`}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle1" noWrap align="center">
|
||||||
|
{libraryName}
|
||||||
|
</Typography>
|
||||||
|
{typeof totalCount === "number" && (
|
||||||
|
<Chip label={totalCount} sx={{ px: 0.5, ml: 1 }} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
size="small"
|
||||||
|
value={String(normalizedViewType)}
|
||||||
|
onChange={handleChangeViewType}
|
||||||
|
slotProps={{
|
||||||
|
select: {
|
||||||
|
MenuProps: {
|
||||||
|
slotProps: { paper: { className: "glass-menu-paper" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem disabled value="">
|
||||||
|
<Typography variant="overline" color="textSecondary">
|
||||||
|
Вид
|
||||||
|
</Typography>
|
||||||
|
</MenuItem>
|
||||||
|
{compatibleViews.map((v) => (
|
||||||
|
<MenuItem key={String(v.value)} value={String(v.value)}>
|
||||||
|
{v.title}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
<IconButton
|
||||||
|
onClick={handleSortAscendingToggle}
|
||||||
|
aria-label="Изменить порядок сортировки"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
transform: sortAscending ? "rotateX(0deg)" : "rotateX(180deg)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
sort
|
||||||
|
</div>
|
||||||
|
</IconButton>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
size="small"
|
||||||
|
value={normalizedSortBy}
|
||||||
|
onChange={handleChangeSortBy}
|
||||||
|
disabled={disableSortOption}
|
||||||
|
slotProps={{
|
||||||
|
select: {
|
||||||
|
MenuProps: {
|
||||||
|
slotProps: { paper: { className: "glass-menu-paper" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem disabled value="">
|
||||||
|
<Typography variant="overline" color="textSecondary">
|
||||||
|
Сортировка
|
||||||
|
</Typography>
|
||||||
|
</MenuItem>
|
||||||
|
{SORT_BY_OPTIONS.map((option) => {
|
||||||
|
const isCompatible =
|
||||||
|
option.compatibleViewTypes?.includes(currentViewType as any) ||
|
||||||
|
option.compatibleCollectionTypes?.includes(
|
||||||
|
currentLibrary.data.CollectionType as any,
|
||||||
|
);
|
||||||
|
if (!isCompatible) return null;
|
||||||
|
const valueStr = Array.isArray(option.value)
|
||||||
|
? option.value.join(",")
|
||||||
|
: option.value;
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={
|
||||||
|
Array.isArray(option.value)
|
||||||
|
? option.value.join(",")
|
||||||
|
: option.value
|
||||||
|
}
|
||||||
|
value={valueStr}
|
||||||
|
onMouseEnter={() =>
|
||||||
|
prefetchItems(String(valueStr), sortAscending)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{option.title}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TextField>
|
||||||
|
<FiltersDialogTrigger />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="library-header-actions flex flex-row"
|
||||||
|
style={{ gap: "0.6em" }}
|
||||||
|
>
|
||||||
|
<span className="library-header-cast">
|
||||||
|
<CastButton />
|
||||||
|
</span>
|
||||||
|
<IconButton
|
||||||
|
onClick={toggleSearchDialog}
|
||||||
|
aria-label="Поиск"
|
||||||
|
title="Поиск"
|
||||||
|
>
|
||||||
|
<div className="material-symbols-rounded">search</div>
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
className="library-header-favorite"
|
||||||
|
onClick={handleNavigateToFavorite}
|
||||||
|
aria-label="Избранное"
|
||||||
|
title="Избранное"
|
||||||
|
>
|
||||||
|
<div className="material-symbols-rounded">favorite</div>
|
||||||
|
</IconButton>
|
||||||
|
<UserAvatarMenu />
|
||||||
|
<WindowControls />
|
||||||
|
</div>
|
||||||
|
</AppBar>
|
||||||
|
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
@media (max-width: 980px) {
|
||||||
|
.library-header-cast,
|
||||||
|
.library-header-favorite {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.library-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
// Fixed at the very top so the row of controls sits on the same level as
|
||||||
|
// the home page header instead of floating further down the page.
|
||||||
|
inset: 1em 2em auto 2em !important;
|
||||||
|
border-radius: 9999px;
|
||||||
|
margin: 0 auto;
|
||||||
|
position: fixed;
|
||||||
|
width: calc(100vw - 4em) !important;
|
||||||
|
z-index: 10;
|
||||||
|
// Keep the scrolled pill surface behind the controls but above the page.
|
||||||
|
isolation: isolate;
|
||||||
|
padding: 0.25em !important;
|
||||||
|
transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
|
||||||
|
|
||||||
|
html.is-macos & {
|
||||||
|
// The window has an overlay titlebar: shift the whole pill clear of the
|
||||||
|
// traffic lights, matching the home header's left edge for the controls.
|
||||||
|
width: calc(100vw - 4em - 64px) !important;
|
||||||
|
left: calc(2em + 64px) !important;
|
||||||
|
right: 2em !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: -0.35em;
|
||||||
|
pointer-events: none;
|
||||||
|
border-radius: inherit;
|
||||||
|
// Solid titlebar surface: no glass/blur.
|
||||||
|
background-color: $clr-background-default;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.08);
|
||||||
|
box-shadow: 0 4px 20px rgb(0 0 0 / 0.4);
|
||||||
|
opacity: 0;
|
||||||
|
z-index: -1;
|
||||||
|
transition: opacity 150ms;
|
||||||
|
}
|
||||||
|
&.scrolling {
|
||||||
|
&::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,395 @@
|
|||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
import { getRouteApi } from "@tanstack/react-router";
|
||||||
|
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||||
|
import React, {
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
import "./libraryItemsGrid.scss";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
|
import { AVAILABLE_VIEWS } from "@/utils/constants/library";
|
||||||
|
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
|
import BackdropWorker from "@/utils/workers/backdrop.worker?worker";
|
||||||
|
import { Card } from "../card/card";
|
||||||
|
|
||||||
|
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtualized library items grid.
|
||||||
|
* Virtualizes vertical scrolling only; items are arranged into responsive columns.
|
||||||
|
* Assumptions:
|
||||||
|
* - Card aspect ratio handled by CSS; we approximate a fixed height for virtualization.
|
||||||
|
* - Width changes trigger re-measure via ResizeObserver.
|
||||||
|
* Future improvements:
|
||||||
|
* - Dynamic row height based on item type.
|
||||||
|
* - Horizontal virtualization for extremely wide displays.
|
||||||
|
*/
|
||||||
|
const LibraryItemsGrid = () => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const { id: currentLibraryId } = libraryRoute.useParams();
|
||||||
|
const {
|
||||||
|
currentViewType,
|
||||||
|
sortAscending,
|
||||||
|
sortBy,
|
||||||
|
filters,
|
||||||
|
videoTypesState,
|
||||||
|
nameStartsWith,
|
||||||
|
genreIds,
|
||||||
|
} = useLibraryStateStore(
|
||||||
|
useShallow((s) => {
|
||||||
|
const slice = s.libraries[currentLibraryId || ""];
|
||||||
|
return {
|
||||||
|
currentViewType: slice?.currentViewType,
|
||||||
|
sortAscending: slice?.sortAscending ?? true,
|
||||||
|
sortBy: slice?.sortBy ?? "Name",
|
||||||
|
filters: slice?.filters,
|
||||||
|
videoTypesState: slice?.videoTypesState,
|
||||||
|
nameStartsWith: slice?.nameStartsWith,
|
||||||
|
genreIds: slice?.genreIds,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||||
|
const currentLibrary = useSuspenseQuery(
|
||||||
|
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||||
|
);
|
||||||
|
|
||||||
|
const collectionType = currentLibrary.data.CollectionType;
|
||||||
|
const defaultViewType: BaseItemKind =
|
||||||
|
collectionType === "music"
|
||||||
|
? BaseItemKind.MusicAlbum
|
||||||
|
: collectionType === "movies"
|
||||||
|
? BaseItemKind.Movie
|
||||||
|
: collectionType === "tvshows"
|
||||||
|
? BaseItemKind.Series
|
||||||
|
: collectionType === "boxsets"
|
||||||
|
? BaseItemKind.BoxSet
|
||||||
|
: collectionType === "books"
|
||||||
|
? BaseItemKind.Book
|
||||||
|
: collectionType === "playlists"
|
||||||
|
? BaseItemKind.Playlist
|
||||||
|
: BaseItemKind.Movie;
|
||||||
|
|
||||||
|
// Persisted slices may hold no view type or a view from another collection
|
||||||
|
// type (e.g. CollectionFolder left by an older build). Reset those.
|
||||||
|
const compatibleViews = AVAILABLE_VIEWS.filter((view) =>
|
||||||
|
view.compatibleCollectionTypes.includes(collectionType as any),
|
||||||
|
).map((view) => view.value);
|
||||||
|
const isViewValid =
|
||||||
|
!!currentViewType &&
|
||||||
|
(compatibleViews.includes(currentViewType) || currentViewType === "Artist");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentLibraryId && !isViewValid) {
|
||||||
|
updateLibrary(currentLibraryId, {
|
||||||
|
currentViewType: defaultViewType,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [currentLibraryId, isViewValid, defaultViewType, updateLibrary]);
|
||||||
|
|
||||||
|
const effectiveViewType: BaseItemKind | "Artist" = isViewValid
|
||||||
|
? (currentViewType as BaseItemKind | "Artist")
|
||||||
|
: defaultViewType;
|
||||||
|
|
||||||
|
const items = useSuspenseQuery(
|
||||||
|
getLibraryItemsQueryOptions(api, user?.Id, currentLibraryId, {
|
||||||
|
currentViewType: effectiveViewType,
|
||||||
|
sortAscending,
|
||||||
|
sortBy,
|
||||||
|
filters,
|
||||||
|
videoTypesState,
|
||||||
|
nameStartsWith,
|
||||||
|
genreIds,
|
||||||
|
collectionType: collectionType as any,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
// A music library with no album grouping (flat audio files) opens on an
|
||||||
|
// empty "Albums" view. Fall back to Songs so the tracks are visible.
|
||||||
|
useEffect(() => {
|
||||||
|
if (collectionType !== "music") return;
|
||||||
|
if (effectiveViewType !== BaseItemKind.MusicAlbum) return;
|
||||||
|
if (!items.isSuccess) return;
|
||||||
|
if ((items.data?.TotalRecordCount ?? 0) > 0) return;
|
||||||
|
updateLibrary(currentLibraryId, {
|
||||||
|
currentViewType: BaseItemKind.Audio,
|
||||||
|
});
|
||||||
|
}, [
|
||||||
|
collectionType,
|
||||||
|
effectiveViewType,
|
||||||
|
items.isSuccess,
|
||||||
|
items.data?.TotalRecordCount,
|
||||||
|
currentLibraryId,
|
||||||
|
updateLibrary,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// --- Backdrop ---
|
||||||
|
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
||||||
|
const backdropItems = useMemo<BaseItemDto[]>(() => {
|
||||||
|
if (!items.isSuccess || !items.data?.Items) return [];
|
||||||
|
return items.data.Items.filter(
|
||||||
|
(item) => Object.keys(item.ImageBlurHashes?.Backdrop ?? {}).length > 0,
|
||||||
|
);
|
||||||
|
}, [items.isSuccess, items.data?.Items]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const worker = new BackdropWorker();
|
||||||
|
|
||||||
|
worker.onmessage = (event: MessageEvent) => {
|
||||||
|
if (event.data.type === "UPDATE_BACKDROP") {
|
||||||
|
const schedule =
|
||||||
|
(window as any).requestIdleCallback || window.requestAnimationFrame;
|
||||||
|
schedule(() => setBackdrop(event.data.payload));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (backdropItems.length > 0) {
|
||||||
|
worker.postMessage({
|
||||||
|
type: "SET_BACKDROP_ITEMS",
|
||||||
|
payload: backdropItems,
|
||||||
|
});
|
||||||
|
worker.postMessage({ type: "START" });
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
worker.postMessage({ type: "STOP" });
|
||||||
|
worker.terminate();
|
||||||
|
};
|
||||||
|
}, [backdropItems, setBackdrop]);
|
||||||
|
// --- Virtualization setup ---
|
||||||
|
const parentRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const [containerWidth, setContainerWidth] = useState<number>(0);
|
||||||
|
const [scrollMargin, setScrollMargin] = useState<number>(0);
|
||||||
|
|
||||||
|
// Determine column count based on container width (simple heuristic).
|
||||||
|
// Only width changes matter: observing height caused re-layout feedback while
|
||||||
|
// the window was resized, and a transitioned header made rows jump.
|
||||||
|
const [columns, setColumns] = useState(1);
|
||||||
|
useEffect(() => {
|
||||||
|
const element = parentRef.current;
|
||||||
|
if (!element) return;
|
||||||
|
let frame = 0;
|
||||||
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
let lastWidth = -1;
|
||||||
|
|
||||||
|
const apply = () => {
|
||||||
|
timer = undefined;
|
||||||
|
const width = element.clientWidth;
|
||||||
|
if (Math.abs(width - lastWidth) < 1) return;
|
||||||
|
lastWidth = width;
|
||||||
|
setContainerWidth(width);
|
||||||
|
setColumns(Math.max(1, Math.floor(width / 180)));
|
||||||
|
// Read offsetTop after the browser has applied the new columns.
|
||||||
|
frame = requestAnimationFrame(() => {
|
||||||
|
frame = 0;
|
||||||
|
setScrollMargin(element.offsetTop);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const schedule = () => {
|
||||||
|
// While the user drags the window edge, don't reflow the whole grid
|
||||||
|
// on every pixel; repack once the width has been stable briefly.
|
||||||
|
if (timer) clearTimeout(timer);
|
||||||
|
timer = setTimeout(apply, 120);
|
||||||
|
};
|
||||||
|
|
||||||
|
apply();
|
||||||
|
const observer = new ResizeObserver(schedule);
|
||||||
|
observer.observe(element);
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
if (timer) clearTimeout(timer);
|
||||||
|
if (frame) cancelAnimationFrame(frame);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const itemCount = items.data?.Items?.length ?? 0;
|
||||||
|
// Compute number of virtual rows
|
||||||
|
const rowCount = Math.ceil(itemCount / columns);
|
||||||
|
|
||||||
|
// Estimated row height (depends on card type). Using 260px as base (portrait taller)
|
||||||
|
// Compute card width minus gaps
|
||||||
|
const cardGap = 16; // px gap between cards
|
||||||
|
const cardWidth = useMemo(() => {
|
||||||
|
if (columns <= 0) return 180;
|
||||||
|
const totalGap = (columns - 1) * cardGap;
|
||||||
|
return Math.floor((containerWidth - totalGap) / columns);
|
||||||
|
}, [columns, containerWidth]);
|
||||||
|
|
||||||
|
// Approximate card height: width / aspect ratio + text block (title + caption).
|
||||||
|
// Square artwork (music, genres) is shorter than portrait posters.
|
||||||
|
const cardAspect = useMemo(() => {
|
||||||
|
const first = items.data?.Items?.[0];
|
||||||
|
const square =
|
||||||
|
first?.Type === BaseItemKind.MusicAlbum ||
|
||||||
|
first?.Type === BaseItemKind.Audio ||
|
||||||
|
first?.Type === BaseItemKind.Genre ||
|
||||||
|
first?.Type === BaseItemKind.MusicGenre ||
|
||||||
|
first?.Type === BaseItemKind.Studio ||
|
||||||
|
first?.Type === BaseItemKind.Playlist;
|
||||||
|
return square ? 1 : 0.666666;
|
||||||
|
}, [items.data?.Items]);
|
||||||
|
|
||||||
|
const estimateRowHeight = useCallback(
|
||||||
|
() => Math.round(cardWidth / cardAspect + 60),
|
||||||
|
[cardWidth, cardAspect],
|
||||||
|
);
|
||||||
|
|
||||||
|
const virtualizer = useWindowVirtualizer({
|
||||||
|
count: rowCount,
|
||||||
|
estimateSize: estimateRowHeight,
|
||||||
|
overscan: 4,
|
||||||
|
scrollMargin,
|
||||||
|
});
|
||||||
|
|
||||||
|
const virtualItems = virtualizer.getVirtualItems();
|
||||||
|
|
||||||
|
// Update count in Zustand so header can display it without extra fetches
|
||||||
|
useEffect(() => {
|
||||||
|
const total = items.data?.TotalRecordCount;
|
||||||
|
if (currentLibraryId && typeof total === "number") {
|
||||||
|
updateLibrary(currentLibraryId, { itemsTotalCount: total });
|
||||||
|
}
|
||||||
|
}, [items.data?.TotalRecordCount, currentLibraryId, updateLibrary]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={parentRef}
|
||||||
|
className="library-items-container virtualized"
|
||||||
|
style={{ position: "relative" }}
|
||||||
|
>
|
||||||
|
{items.isSuccess && itemCount === 0 ? (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
minHeight: 240,
|
||||||
|
width: "100%",
|
||||||
|
opacity: 0.8,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ textAlign: "center" }}>
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ fontSize: 48, marginBottom: 8 }}
|
||||||
|
>
|
||||||
|
sentiment_dissatisfied
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: 16 }}>Нет элементов для отображения</div>
|
||||||
|
<div style={{ fontSize: 13, marginTop: 6 }}>
|
||||||
|
Попробуйте изменить фильтры, сортировку или выбор по алфавиту.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
height: virtualizer.getTotalSize(),
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{virtualItems.map((row) => {
|
||||||
|
const startIndex = row.index * columns;
|
||||||
|
const endIndex = Math.min(startIndex + columns, itemCount);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={row.key}
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
transform: `translateY(${
|
||||||
|
row.start - virtualizer.options.scrollMargin
|
||||||
|
}px)`,
|
||||||
|
left: 0,
|
||||||
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
gap: `${cardGap}px`,
|
||||||
|
}}
|
||||||
|
data-index={row.index}
|
||||||
|
ref={virtualizer.measureElement}
|
||||||
|
>
|
||||||
|
{items.data?.Items?.slice(startIndex, endIndex).map(
|
||||||
|
(item: BaseItemDto, localIndex: number) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={item?.Id ?? localIndex}
|
||||||
|
style={{
|
||||||
|
width: `${cardWidth}px`,
|
||||||
|
flex: "0 0 auto",
|
||||||
|
// Override default card margins to avoid compounding with gaps
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item?.SeriesId}
|
||||||
|
skipInView
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "н.в."
|
||||||
|
}`
|
||||||
|
: item?.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item?.Type === BaseItemKind.Person ||
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
userId={user?.Id}
|
||||||
|
// Inline style overrides to neutralize original margins for virtualization
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default LibraryItemsGrid;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Overrides for virtualized library items layout to prevent horizontal overflow
|
||||||
|
.library-items-container.virtualized {
|
||||||
|
overflow-x: hidden;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
display: block !important; // override grid from route styles
|
||||||
|
padding: 0 !important; // override padding from route styles
|
||||||
|
position: relative; // required for absolutely positioned rows
|
||||||
|
gap: 0 !important;
|
||||||
|
justify-items: normal !important;
|
||||||
|
align-content: stretch !important;
|
||||||
|
> .card {
|
||||||
|
max-width: none !important;
|
||||||
|
}
|
||||||
|
// Ensure no unintended padding expands width
|
||||||
|
padding-right: 0;
|
||||||
|
padding-left: 0;
|
||||||
|
.card {
|
||||||
|
margin-right: 0 !important;
|
||||||
|
margin-bottom: 0.6em !important; // keep a consistent vertical rhythm
|
||||||
|
}
|
||||||
|
.card-image-container {
|
||||||
|
// Remove box shadow spread from affecting layout width calculation
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// When page has audio-playing class, avoid extra bottom padding causing scrollbars
|
||||||
|
.audio-playing .library-items-container.virtualized {
|
||||||
|
padding-bottom: 8em; // mimic original intent without affecting width
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import {
|
||||||
|
ListItem,
|
||||||
|
ListItemButton,
|
||||||
|
type ListItemProps,
|
||||||
|
ListItemText,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { createLink } from "@tanstack/react-router";
|
||||||
|
import React, { forwardRef, type ReactNode } from "react";
|
||||||
|
|
||||||
|
interface MUIListItemLinkProps extends ListItemProps<"a"> {
|
||||||
|
icon?: ReactNode;
|
||||||
|
primary: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreatedListItemLink = forwardRef<HTMLAnchorElement, MUIListItemLinkProps>(
|
||||||
|
(props, ref) => (
|
||||||
|
<ListItem component="a" ref={ref} {...props}>
|
||||||
|
<ListItemButton
|
||||||
|
sx={{
|
||||||
|
color: "inherit",
|
||||||
|
textDecoration: "none",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="material-symbols-rounded">{props.icon}</div>
|
||||||
|
<ListItemText primary={props.primary} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const ListItemLink = createLink(CreatedListItemLink);
|
||||||
|
|
||||||
|
export default ListItemLink;
|
||||||
|
|
||||||
|
/* export default function ListItemLink(props: ListItemLinkProps) {
|
||||||
|
const { icon, primary, to, className } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
{/* @ts-expect-error /*}
|
||||||
|
<ListItem
|
||||||
|
component={Link}
|
||||||
|
activeClassName="active"
|
||||||
|
className={className}
|
||||||
|
to={to}
|
||||||
|
>
|
||||||
|
<ListItemButton
|
||||||
|
style={{
|
||||||
|
borderRadius: "100px",
|
||||||
|
gap: "0.85em",
|
||||||
|
color: "white",
|
||||||
|
textDecoration: "none",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="material-symbols-rounded">{icon}</div>
|
||||||
|
<ListItemText primary={primary} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||||
|
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import React, { type ReactNode, useEffect } from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
|
import "./loginShell.scss";
|
||||||
|
|
||||||
|
type LoginShellProps = {
|
||||||
|
title: ReactNode;
|
||||||
|
subtitle?: ReactNode;
|
||||||
|
/** Max width of the content column. */
|
||||||
|
width?: "narrow" | "wide";
|
||||||
|
children: ReactNode;
|
||||||
|
footer?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Shared full-screen layout for the sign-in pages. */
|
||||||
|
const LoginShell = ({
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
width = "narrow",
|
||||||
|
children,
|
||||||
|
footer,
|
||||||
|
}: LoginShellProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const serverInfo = useQuery({
|
||||||
|
queryKey: ["login", "serverInfo"],
|
||||||
|
queryFn: async () =>
|
||||||
|
api ? (await getSystemApi(api).getPublicSystemInfo()).data : null,
|
||||||
|
enabled: Boolean(api),
|
||||||
|
staleTime: 5 * 60_000,
|
||||||
|
});
|
||||||
|
const branding = useQuery({
|
||||||
|
queryKey: ["login", "branding"],
|
||||||
|
queryFn: async () =>
|
||||||
|
api ? (await getBrandingApi(api).getBrandingOptions()).data : null,
|
||||||
|
enabled: Boolean(api),
|
||||||
|
staleTime: 5 * 60_000,
|
||||||
|
});
|
||||||
|
|
||||||
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
|
useEffect(() => {
|
||||||
|
setBackdrop("");
|
||||||
|
}, [setBackdrop]);
|
||||||
|
|
||||||
|
const serverName = serverInfo.data?.ServerName;
|
||||||
|
const serverHost = api?.basePath.replace(/^https?:\/\//, "");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="login-shell scrollY" data-tauri-drag-region>
|
||||||
|
<div className={`login-shell-content login-shell-${width}`}>
|
||||||
|
{serverHost && (
|
||||||
|
<div className="login-shell-server">
|
||||||
|
<span className="material-symbols-rounded">dns</span>
|
||||||
|
<span className="login-shell-server-name" title={serverHost}>
|
||||||
|
{serverName ?? serverHost}
|
||||||
|
</span>
|
||||||
|
<Link to="/setup/server/list" className="login-shell-server-change">
|
||||||
|
Сменить
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<header className="login-shell-header">
|
||||||
|
<h1 className="login-shell-title">{title}</h1>
|
||||||
|
{subtitle && <p className="login-shell-subtitle">{subtitle}</p>}
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main className="login-shell-body">{children}</main>
|
||||||
|
|
||||||
|
{footer && <footer className="login-shell-footer">{footer}</footer>}
|
||||||
|
|
||||||
|
{branding.data?.LoginDisclaimer && (
|
||||||
|
<aside className="login-shell-disclaimer">
|
||||||
|
<span className="material-symbols-rounded">info</span>
|
||||||
|
<p>{branding.data.LoginDisclaimer}</p>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LoginShell;
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
.login-shell {
|
||||||
|
// In normal flow (not fixed) so the app bar above stays clickable
|
||||||
|
position: relative;
|
||||||
|
min-height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 5rem 1.5rem 3rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: white;
|
||||||
|
// Soft accent glow instead of a boxed card
|
||||||
|
background:
|
||||||
|
radial-gradient(ellipse 60% 45% at 50% 0%, rgb(255 41 128 / 0.14), transparent 70%),
|
||||||
|
radial-gradient(ellipse 50% 40% at 50% 100%, rgb(110 0 184 / 0.18), transparent 70%);
|
||||||
|
|
||||||
|
&-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
margin: auto 0;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
&-narrow {
|
||||||
|
max-width: 380px;
|
||||||
|
}
|
||||||
|
&-wide {
|
||||||
|
max-width: 880px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-server {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 0.35rem 0.5rem 0.35rem 0.75rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.08);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
&-name {
|
||||||
|
opacity: 0.85;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
&-change {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 0.15rem 0.6rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
color: white;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
background: rgb(255 255 255 / 0.08);
|
||||||
|
transition: background 0.15s ease;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus-visible {
|
||||||
|
background: rgb(255 255 255 / 0.16);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-header {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
&-title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: clamp(1.75rem, 4vw, 2.5rem);
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
line-height: 1.15;
|
||||||
|
}
|
||||||
|
&-subtitle {
|
||||||
|
margin: 0.5rem 0 0;
|
||||||
|
opacity: 0.65;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-body {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-footer {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5rem 1rem;
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-disclaimer {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.6rem;
|
||||||
|
max-width: 480px;
|
||||||
|
padding: 0.9rem 1rem;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
background: rgb(255 255 255 / 0.04);
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.08);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Text-style secondary action used in login footers
|
||||||
|
.login-link {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
padding: 0.4rem 0.75rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: rgb(255 255 255 / 0.75);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background 0.15s ease, color 0.15s ease;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
}
|
||||||
|
&:hover,
|
||||||
|
&:focus-visible {
|
||||||
|
color: white;
|
||||||
|
background: rgb(255 255 255 / 0.08);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Profile picker
|
||||||
|
.profile-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(128px, 148px));
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1.5rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile {
|
||||||
|
all: unset;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.75rem 0.5rem;
|
||||||
|
border-radius: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
&-avatar {
|
||||||
|
position: relative;
|
||||||
|
width: 112px;
|
||||||
|
height: 112px;
|
||||||
|
border-radius: 50%;
|
||||||
|
// Ring that lights up on hover / focus
|
||||||
|
box-shadow: 0 0 0 3px transparent, 0 10px 24px rgb(0 0 0 / 0.4);
|
||||||
|
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
||||||
|
|
||||||
|
img,
|
||||||
|
.profile-avatar-fallback {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
&-fallback {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 2.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
background: linear-gradient(135deg, $clr-accent-default, $clr-secondary-default);
|
||||||
|
}
|
||||||
|
&-add {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
border: 2px dashed rgb(255 255 255 / 0.25);
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-lock {
|
||||||
|
position: absolute;
|
||||||
|
right: 2px;
|
||||||
|
bottom: 2px;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(18 18 24);
|
||||||
|
border: 2px solid rgb(18 18 24);
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1rem;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-name {
|
||||||
|
max-width: 100%;
|
||||||
|
font-weight: 600;
|
||||||
|
opacity: 0.8;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus-visible {
|
||||||
|
.profile-avatar {
|
||||||
|
transform: translateY(-3px);
|
||||||
|
box-shadow: 0 0 0 3px $clr-accent-default, 0 14px 30px rgb(0 0 0 / 0.5);
|
||||||
|
}
|
||||||
|
.profile-name {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Password / manual sign-in form
|
||||||
|
.login-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&-avatar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
|
||||||
|
.profile-avatar {
|
||||||
|
width: 96px;
|
||||||
|
height: 96px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-options {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin: -0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-submit.MuiButton-root {
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: none;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
|
/** Public (listed) users of the current server; shared by the login pages. */
|
||||||
|
export const getPublicUsersQueryOptions = (api: Api | null | undefined) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["login", "public-users"],
|
||||||
|
queryFn: async () =>
|
||||||
|
api ? (await getUserApi(api).getPublicUsers()).data : [],
|
||||||
|
enabled: Boolean(api),
|
||||||
|
});
|
||||||
|
|
||||||
|
type ProfileAvatarProps = {
|
||||||
|
userId: string;
|
||||||
|
name: string;
|
||||||
|
imageTag?: string | null;
|
||||||
|
/** Shows a lock badge for password-protected profiles. */
|
||||||
|
locked?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Round profile picture, falling back to the user's initial. */
|
||||||
|
export const ProfileAvatar = ({
|
||||||
|
userId,
|
||||||
|
name,
|
||||||
|
imageTag,
|
||||||
|
locked,
|
||||||
|
}: ProfileAvatarProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const [failed, setFailed] = useState(false);
|
||||||
|
const showImage = api && imageTag && !failed;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className="profile-avatar">
|
||||||
|
{showImage ? (
|
||||||
|
<img
|
||||||
|
alt=""
|
||||||
|
src={`${api.basePath}/Users/${userId}/Images/Primary?quality=85&fillWidth=224&fillHeight=224&tag=${imageTag}`}
|
||||||
|
onError={() => setFailed(true)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<span className="profile-avatar-fallback" aria-hidden>
|
||||||
|
{name.trim().charAt(0).toUpperCase() || "?"}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{locked && (
|
||||||
|
<span className="profile-lock" title="Защищено паролем">
|
||||||
|
<span className="material-symbols-rounded">lock</span>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isPasswordProtected = (user: UserDto | undefined) =>
|
||||||
|
user?.HasPassword !== false;
|
||||||
@@ -46,7 +46,7 @@ const MusicTrack = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "Music Track"}
|
alt={item.Name ?? "Трек"}
|
||||||
src={
|
src={
|
||||||
api &&
|
api &&
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
@@ -105,7 +105,7 @@ const MusicTrack = ({
|
|||||||
{item.HasLyrics && (
|
{item.HasLyrics && (
|
||||||
<img
|
<img
|
||||||
src={lyrics_icon}
|
src={lyrics_icon}
|
||||||
alt="Lyrics"
|
alt="Текст песни"
|
||||||
className="music-track-info-lyrics"
|
className="music-track-info-lyrics"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -116,14 +116,16 @@ const MusicTrack = ({
|
|||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
fontWeight="400"
|
|
||||||
style={{
|
style={{
|
||||||
textDecoration: "none",
|
textDecoration: "none",
|
||||||
}}
|
}}
|
||||||
|
sx={{
|
||||||
|
fontWeight: "400",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
style={{ textDecoration: "none", color: "white" }}
|
style={{ textDecoration: "none", color: "white" }}
|
||||||
to="/artist/$id"
|
to="/music/artist/$id"
|
||||||
params={{ id: artist.Id ?? "" }}
|
params={{ id: artist.Id ?? "" }}
|
||||||
>
|
>
|
||||||
{artist.Name}
|
{artist.Name}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useNProgress } from "@tanem/react-nprogress";
|
|||||||
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
||||||
import { useRouterState } from "@tanstack/react-router";
|
import { useRouterState } from "@tanstack/react-router";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
import { createPortal } from "react-dom";
|
|
||||||
|
|
||||||
export default function NProgress() {
|
export default function NProgress() {
|
||||||
const isQueryFetching = useIsFetching();
|
const isQueryFetching = useIsFetching();
|
||||||
@@ -21,7 +20,7 @@ export default function NProgress() {
|
|||||||
isAnimating,
|
isAnimating,
|
||||||
});
|
});
|
||||||
|
|
||||||
return createPortal(
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
pointerEvents: "none",
|
pointerEvents: "none",
|
||||||
@@ -44,8 +43,7 @@ export default function NProgress() {
|
|||||||
variant="determinate"
|
variant="determinate"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>,
|
</div>
|
||||||
document.body,
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { yellow } from "@mui/material/colors";
|
import { yellow } from "@mui/material/colors";
|
||||||
@@ -29,10 +28,21 @@ export const EmptyNotice = ({ extraMsg }: { extraMsg?: string }) => {
|
|||||||
>
|
>
|
||||||
sentiment_dissatisfied
|
sentiment_dissatisfied
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="h4" fontWeight={300}>
|
<Typography
|
||||||
No results found
|
variant="h4"
|
||||||
|
sx={{
|
||||||
|
fontWeight: 300,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Ничего не найдено
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle1" fontWeight={300} style={{ opacity: 0.5 }}>
|
<Typography
|
||||||
|
variant="subtitle1"
|
||||||
|
style={{ opacity: 0.5 }}
|
||||||
|
sx={{
|
||||||
|
fontWeight: 300,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{extraMsg}
|
{extraMsg}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -3,8 +3,14 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { red } from "@mui/material/colors";
|
import { red } from "@mui/material/colors";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const ErrorNotice = ({ error }: { error?: Error }) => {
|
export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
||||||
console.error(error);
|
const normalizedError =
|
||||||
|
error instanceof Error
|
||||||
|
? error
|
||||||
|
: error
|
||||||
|
? new Error(String(error))
|
||||||
|
: undefined;
|
||||||
|
console.error(normalizedError ?? error);
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -29,13 +35,18 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
|
|||||||
>
|
>
|
||||||
error
|
error
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="h3" color="white" fontWeight={300}>
|
<Typography
|
||||||
Something went wrong.
|
variant="h3"
|
||||||
|
sx={{
|
||||||
|
color: "white",
|
||||||
|
fontWeight: 300,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Что-то пошло не так.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
fontFamily="JetBrains Mono Variable"
|
variant="body2"
|
||||||
fontWeight={100}
|
component="pre"
|
||||||
variant="h5"
|
|
||||||
style={{
|
style={{
|
||||||
padding: "0.5em",
|
padding: "0.5em",
|
||||||
background: "rgb(0 0 0 / 1)",
|
background: "rgb(0 0 0 / 1)",
|
||||||
@@ -45,11 +56,17 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
|
|||||||
maxHeight: "20em",
|
maxHeight: "20em",
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
// opacity: 0.6,
|
whiteSpace: "pre-wrap",
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
color: "grey.400",
|
||||||
|
fontFamily: "JetBrains Mono Variable",
|
||||||
}}
|
}}
|
||||||
color="gray"
|
|
||||||
>
|
>
|
||||||
{JSON.stringify(error?.stack)}
|
{normalizedError
|
||||||
|
? normalizedError.stack ||
|
||||||
|
`${normalizedError.name}: ${normalizedError.message}`
|
||||||
|
: "Неизвестная ошибка"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
if (!item || !item.Type) return null;
|
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">Далее</Typography>
|
||||||
<div className="outro-card-content">
|
<div className="outro-card-content">
|
||||||
{item?.ImageTags?.Primary ? (
|
{item?.ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
@@ -57,7 +57,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<div className="outro-card-content-buttons">
|
<div className="outro-card-content-buttons">
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePlayNext.mutate}
|
onClick={() => handlePlayNext.mutate()}
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
@@ -73,7 +73,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Play Now
|
Смотреть
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={props.handleShowCredits}
|
onClick={props.handleShowCredits}
|
||||||
@@ -81,7 +81,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>
|
>
|
||||||
Watch Credits
|
Смотреть титры
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,258 @@
|
|||||||
|
import React, { useEffect, useRef } from "react";
|
||||||
|
|
||||||
|
import "./overlayScrollbar.scss";
|
||||||
|
|
||||||
|
const MIN_THUMB_HEIGHT = 28;
|
||||||
|
const HIDE_DELAY = 1100;
|
||||||
|
const EDGE_ZONE = 28;
|
||||||
|
const SHOW_THROTTLE = 120;
|
||||||
|
|
||||||
|
type Metrics = {
|
||||||
|
maxScroll: number;
|
||||||
|
maxTop: number;
|
||||||
|
scrollable: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPageScroller = (): HTMLElement =>
|
||||||
|
(document.scrollingElement as HTMLElement | null) ?? document.documentElement;
|
||||||
|
|
||||||
|
const clamp = (value: number, min: number, max: number) =>
|
||||||
|
Math.min(Math.max(value, min), max);
|
||||||
|
|
||||||
|
// Where supported the thumb is driven by a CSS scroll timeline, so it moves
|
||||||
|
// with the compositor and never trails the page. Older engines fall back to
|
||||||
|
// the scroll listener below.
|
||||||
|
const supportsScrollTimeline =
|
||||||
|
typeof CSS !== "undefined" &&
|
||||||
|
CSS.supports("animation-timeline", "scroll(root block)");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overlay scrollbar for the page scroller. It sits on top of the content
|
||||||
|
* instead of taking layout space, so pages no longer shift when the native
|
||||||
|
* scrollbar appears or disappears.
|
||||||
|
*
|
||||||
|
* Measuring (track size, thumb size) happens only when the page or window
|
||||||
|
* size changes. Scrolling just paints the cached thumb position, which keeps
|
||||||
|
* the thumb moving with the page instead of lagging behind it.
|
||||||
|
*/
|
||||||
|
const OverlayScrollbar = () => {
|
||||||
|
const trackRef = useRef<HTMLDivElement>(null);
|
||||||
|
const thumbRef = useRef<HTMLDivElement>(null);
|
||||||
|
const metrics = useRef<Metrics>({ maxScroll: 0, maxTop: 0, scrollable: false });
|
||||||
|
const dragging = useRef(false);
|
||||||
|
const hideTimer = useRef<number | undefined>(undefined);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const track = trackRef.current;
|
||||||
|
const thumb = thumbRef.current;
|
||||||
|
if (!track || !thumb) return;
|
||||||
|
|
||||||
|
const scroller = getPageScroller();
|
||||||
|
document.documentElement.classList.add("has-overlay-scrollbar");
|
||||||
|
document.body.classList.add("has-overlay-scrollbar");
|
||||||
|
|
||||||
|
let frame = 0;
|
||||||
|
let measureTimer = 0;
|
||||||
|
let lastShow = 0;
|
||||||
|
|
||||||
|
const setVisible = (visible: boolean) => {
|
||||||
|
const next = visible ? "true" : "false";
|
||||||
|
if (track.dataset.visible !== next) track.dataset.visible = next;
|
||||||
|
};
|
||||||
|
|
||||||
|
const scheduleHide = () => {
|
||||||
|
if (dragging.current) return;
|
||||||
|
window.clearTimeout(hideTimer.current);
|
||||||
|
hideTimer.current = window.setTimeout(() => {
|
||||||
|
if (!dragging.current) setVisible(false);
|
||||||
|
}, HIDE_DELAY);
|
||||||
|
};
|
||||||
|
|
||||||
|
const show = () => {
|
||||||
|
if (!metrics.current.scrollable) return;
|
||||||
|
setVisible(true);
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - lastShow > SHOW_THROTTLE) {
|
||||||
|
lastShow = now;
|
||||||
|
scheduleHide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cheap path: only reads scrollTop and writes a compositor-friendly
|
||||||
|
// transform. No layout reads, no track/thumb size writes.
|
||||||
|
const paint = () => {
|
||||||
|
if (supportsScrollTimeline) return;
|
||||||
|
const { scrollable, maxScroll, maxTop } = metrics.current;
|
||||||
|
if (!scrollable || maxScroll <= 0) return;
|
||||||
|
const top = clamp(scroller.scrollTop, 0, maxScroll);
|
||||||
|
const offset = (top / maxScroll) * maxTop;
|
||||||
|
thumb.style.transform = `translate3d(0, ${offset}px, 0)`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Expensive path: runs on mount and when page/window geometry changes.
|
||||||
|
const measure = () => {
|
||||||
|
// Use the header height rather than its viewport position: the
|
||||||
|
// header scrolls with the page, but the track must stay put.
|
||||||
|
const header = document.querySelector("header");
|
||||||
|
const insetTop = Math.max(
|
||||||
|
0,
|
||||||
|
Math.round(header?.getBoundingClientRect().height ?? 0) + 6,
|
||||||
|
);
|
||||||
|
const trackHeight = Math.max(0, window.innerHeight - insetTop - 6);
|
||||||
|
const topStyle = `${insetTop}px`;
|
||||||
|
const heightStyle = `${trackHeight}px`;
|
||||||
|
if (track.style.top !== topStyle) track.style.top = topStyle;
|
||||||
|
if (track.style.height !== heightStyle) track.style.height = heightStyle;
|
||||||
|
|
||||||
|
const viewport = scroller.clientHeight;
|
||||||
|
const total = scroller.scrollHeight;
|
||||||
|
const scrollable = total - viewport > 1 && trackHeight > 0;
|
||||||
|
|
||||||
|
if (!scrollable) {
|
||||||
|
metrics.current = { maxScroll: 0, maxTop: 0, scrollable: false };
|
||||||
|
track.dataset.scrollable = "false";
|
||||||
|
setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const thumbHeight = Math.min(
|
||||||
|
trackHeight,
|
||||||
|
Math.max(
|
||||||
|
MIN_THUMB_HEIGHT,
|
||||||
|
Math.round((viewport / total) * trackHeight),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const thumbHeightStyle = `${thumbHeight}px`;
|
||||||
|
if (thumb.style.height !== thumbHeightStyle) {
|
||||||
|
thumb.style.height = thumbHeightStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
const maxTop = trackHeight - thumbHeight;
|
||||||
|
metrics.current = {
|
||||||
|
maxScroll: total - viewport,
|
||||||
|
maxTop,
|
||||||
|
scrollable: true,
|
||||||
|
};
|
||||||
|
track.style.setProperty("--overlay-thumb-travel", `${maxTop}px`);
|
||||||
|
track.dataset.scrollable = "true";
|
||||||
|
paint();
|
||||||
|
};
|
||||||
|
|
||||||
|
const requestMeasure = () => {
|
||||||
|
if (frame) return;
|
||||||
|
frame = window.requestAnimationFrame(() => {
|
||||||
|
frame = 0;
|
||||||
|
window.clearTimeout(measureTimer);
|
||||||
|
measure();
|
||||||
|
});
|
||||||
|
// Animation frames stop in an occluded window, but the page can
|
||||||
|
// still grow (route/data changes). Refresh geometry on a timer too.
|
||||||
|
window.clearTimeout(measureTimer);
|
||||||
|
measureTimer = window.setTimeout(() => {
|
||||||
|
if (frame) {
|
||||||
|
window.cancelAnimationFrame(frame);
|
||||||
|
frame = 0;
|
||||||
|
}
|
||||||
|
measure();
|
||||||
|
}, 250);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onScroll = () => {
|
||||||
|
paint();
|
||||||
|
show();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onResize = () => {
|
||||||
|
requestMeasure();
|
||||||
|
show();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPointerMove = (event: PointerEvent) => {
|
||||||
|
if (event.clientX >= window.innerWidth - EDGE_ZONE) show();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onVisibilityChange = () => {
|
||||||
|
if (document.hidden) return;
|
||||||
|
measure();
|
||||||
|
show();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onThumbPointerDown = (event: PointerEvent) => {
|
||||||
|
if (event.pointerType === "mouse" && event.button !== 0) return;
|
||||||
|
const { maxScroll, maxTop } = metrics.current;
|
||||||
|
if (maxScroll <= 0 || maxTop <= 0) return;
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
dragging.current = true;
|
||||||
|
window.clearTimeout(hideTimer.current);
|
||||||
|
setVisible(true);
|
||||||
|
|
||||||
|
const startY = event.clientY;
|
||||||
|
const startScroll = scroller.scrollTop;
|
||||||
|
const ratio = maxScroll / maxTop;
|
||||||
|
|
||||||
|
const onMove = (moveEvent: PointerEvent) => {
|
||||||
|
scroller.scrollTop = startScroll + (moveEvent.clientY - startY) * ratio;
|
||||||
|
paint();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onUp = () => {
|
||||||
|
dragging.current = false;
|
||||||
|
window.removeEventListener("pointermove", onMove);
|
||||||
|
window.removeEventListener("pointerup", onUp);
|
||||||
|
window.removeEventListener("pointercancel", onUp);
|
||||||
|
scheduleHide();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("pointermove", onMove);
|
||||||
|
window.addEventListener("pointerup", onUp);
|
||||||
|
window.addEventListener("pointercancel", onUp);
|
||||||
|
};
|
||||||
|
|
||||||
|
measure();
|
||||||
|
show();
|
||||||
|
scheduleHide();
|
||||||
|
|
||||||
|
scroller.addEventListener("scroll", onScroll, { passive: true });
|
||||||
|
window.addEventListener("resize", onResize);
|
||||||
|
window.addEventListener("pointermove", onPointerMove, { passive: true });
|
||||||
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||||
|
thumb.addEventListener("pointerdown", onThumbPointerDown);
|
||||||
|
|
||||||
|
const content = document.getElementById("root");
|
||||||
|
const resizeObserver = content ? new ResizeObserver(requestMeasure) : null;
|
||||||
|
if (content && resizeObserver) resizeObserver.observe(content);
|
||||||
|
|
||||||
|
const mutationObserver = new MutationObserver(requestMeasure);
|
||||||
|
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.clearTimeout(hideTimer.current);
|
||||||
|
window.clearTimeout(measureTimer);
|
||||||
|
if (frame) window.cancelAnimationFrame(frame);
|
||||||
|
scroller.removeEventListener("scroll", onScroll);
|
||||||
|
window.removeEventListener("resize", onResize);
|
||||||
|
window.removeEventListener("pointermove", onPointerMove);
|
||||||
|
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||||
|
thumb.removeEventListener("pointerdown", onThumbPointerDown);
|
||||||
|
resizeObserver?.disconnect();
|
||||||
|
mutationObserver.disconnect();
|
||||||
|
document.documentElement.classList.remove("has-overlay-scrollbar");
|
||||||
|
document.body.classList.remove("has-overlay-scrollbar");
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={trackRef}
|
||||||
|
className="overlay-scrollbar"
|
||||||
|
data-visible="false"
|
||||||
|
data-scrollable="false"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<div ref={thumbRef} className="overlay-scrollbar__thumb" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OverlayScrollbar;
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// Hide the native page scrollbar only. Nested panels keep their own styling.
|
||||||
|
html.has-overlay-scrollbar,
|
||||||
|
body.has-overlay-scrollbar {
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay-scrollbar {
|
||||||
|
--overlay-thumb-travel: 0px;
|
||||||
|
|
||||||
|
position: fixed;
|
||||||
|
top: 70px;
|
||||||
|
right: 2px;
|
||||||
|
z-index: 95;
|
||||||
|
width: 12px;
|
||||||
|
height: calc(100vh - 76px);
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
|
||||||
|
&[data-scrollable="true"] {
|
||||||
|
opacity: 0.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-visible="true"] {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__thumb {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 3px;
|
||||||
|
width: 6px;
|
||||||
|
min-height: 28px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgb(255 255 255 / 0.28);
|
||||||
|
box-shadow: 0 0 0 1px rgb(0 0 0 / 0.18);
|
||||||
|
pointer-events: auto;
|
||||||
|
cursor: grab;
|
||||||
|
will-change: transform;
|
||||||
|
transition:
|
||||||
|
width 0.15s ease,
|
||||||
|
right 0.15s ease,
|
||||||
|
background-color 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
right: 2px;
|
||||||
|
width: 8px;
|
||||||
|
background: rgb(255 255 255 / 0.46);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
background: rgb(255 255 255 / 0.58);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scroll-driven thumb for engines that support it: the compositor moves it in
|
||||||
|
// lockstep with the page, so scrolling stays smooth. The JS listener is the
|
||||||
|
// fallback for older engines.
|
||||||
|
@supports (animation-timeline: scroll(root block)) {
|
||||||
|
.overlay-scrollbar__thumb {
|
||||||
|
animation: overlay-scrollbar-thumb linear both;
|
||||||
|
animation-timeline: scroll(root block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes overlay-scrollbar-thumb {
|
||||||
|
from {
|
||||||
|
transform: translate3d(0, 0, 0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translate3d(0, var(--overlay-thumb-travel), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
import {
|
||||||
|
PlaystateCommand,
|
||||||
|
type SessionInfoDto,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
import { secToTicks } from "@/utils/date/time";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
|
import useSyncPlayback from "@/utils/store/syncPlayback";
|
||||||
|
|
||||||
|
const TICKS_PER_SECOND = 10_000_000;
|
||||||
|
/** How far a device may drift before we send a correcting seek. */
|
||||||
|
const DRIFT_TOLERANCE = 2 * TICKS_PER_SECOND;
|
||||||
|
/** Do not hammer a device that is still catching up. */
|
||||||
|
const SEEK_COOLDOWN_MS = 5000;
|
||||||
|
const TICK_MS = 2000;
|
||||||
|
|
||||||
|
/** Session reports are a few seconds old; extrapolate the live position. */
|
||||||
|
const estimateSessionPosition = (session: SessionInfoDto) => {
|
||||||
|
const paused = Boolean(session.PlayState?.IsPaused);
|
||||||
|
const base = session.PlayState?.PositionTicks ?? 0;
|
||||||
|
const lastCheckIn = session.LastPlaybackCheckIn
|
||||||
|
? Date.parse(session.LastPlaybackCheckIn)
|
||||||
|
: Number.NaN;
|
||||||
|
const elapsed = !paused && Number.isFinite(lastCheckIn)
|
||||||
|
? Math.max(0, Date.now() - lastCheckIn)
|
||||||
|
: 0;
|
||||||
|
// 1 ms = 10 000 Jellyfin ticks.
|
||||||
|
return { position: base + elapsed * 10_000, paused };
|
||||||
|
};
|
||||||
|
|
||||||
|
const getLocalState = () => {
|
||||||
|
const video = usePlaybackStore.getState();
|
||||||
|
if (video.metadata.item?.Id && video.playerState.isPlayerReady) {
|
||||||
|
return {
|
||||||
|
active: true,
|
||||||
|
itemId: video.metadata.item.Id,
|
||||||
|
position: secToTicks(video.getCurrentTime()),
|
||||||
|
paused: !video.playerState.isPlayerPlaying,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const audio = useAudioPlayback.getState();
|
||||||
|
if (audio.display && audio.item?.Id) {
|
||||||
|
const element = audio.player.ref?.current;
|
||||||
|
return {
|
||||||
|
active: true,
|
||||||
|
itemId: audio.item.Id,
|
||||||
|
position: element
|
||||||
|
? secToTicks(element.currentTime)
|
||||||
|
: audio.player.currentTick,
|
||||||
|
paused: !audio.player.playing,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { active: false, itemId: null as string | null, position: 0, paused: false };
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps other Jellyfin sessions aligned with the sync master. This is a
|
||||||
|
* pragmatic seek-based sync (works with any client that accepts remote
|
||||||
|
* commands), not Jellyfin SyncPlay: expect sub-second to ~2 s accuracy plus
|
||||||
|
* the target clients' own buffering.
|
||||||
|
*/
|
||||||
|
const PlaybackSync = () => {
|
||||||
|
const enabled = useSyncPlayback((state) => state.enabled);
|
||||||
|
const master = useSyncPlayback((state) => state.master);
|
||||||
|
const stop = useSyncPlayback((state) => state.stop);
|
||||||
|
const api = useApiInContext((state) => state.api);
|
||||||
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
|
const lastSeek = useRef<Record<string, number>>({});
|
||||||
|
const lastPauseCommand = useRef<Record<string, number>>({});
|
||||||
|
const misses = useRef(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!enabled || !master || !api || !user?.Id) return;
|
||||||
|
const userId = user.Id;
|
||||||
|
const sessionApi = getSessionApi(api);
|
||||||
|
let cancelled = false;
|
||||||
|
let busy = false;
|
||||||
|
|
||||||
|
const tick = async () => {
|
||||||
|
if (busy || cancelled) return;
|
||||||
|
if (document.visibilityState !== "visible") return;
|
||||||
|
busy = true;
|
||||||
|
try {
|
||||||
|
const sessions = (await sessionApi.getSessions()).data;
|
||||||
|
let position = 0;
|
||||||
|
let paused = false;
|
||||||
|
let masterFound = false;
|
||||||
|
// The master may move on to the next queue item; follow it.
|
||||||
|
let itemId = master.itemId;
|
||||||
|
|
||||||
|
if (master.sessionId) {
|
||||||
|
const session = sessions.find(
|
||||||
|
(entry) => entry.Id === master.sessionId,
|
||||||
|
);
|
||||||
|
if (session?.NowPlayingItem?.Id) {
|
||||||
|
itemId = session.NowPlayingItem.Id;
|
||||||
|
const estimated = estimateSessionPosition(session);
|
||||||
|
position = estimated.position;
|
||||||
|
paused = estimated.paused;
|
||||||
|
masterFound = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const local = getLocalState();
|
||||||
|
if (local.active && local.itemId) {
|
||||||
|
itemId = local.itemId;
|
||||||
|
position = local.position;
|
||||||
|
paused = local.paused;
|
||||||
|
masterFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!masterFound) {
|
||||||
|
misses.current += 1;
|
||||||
|
if (misses.current >= 3) stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
misses.current = 0;
|
||||||
|
|
||||||
|
const followers = sessions.filter(
|
||||||
|
(session) =>
|
||||||
|
session.Id &&
|
||||||
|
session.Id !== master.sessionId &&
|
||||||
|
session.UserId === userId &&
|
||||||
|
session.DeviceId !== api.deviceInfo.id &&
|
||||||
|
session.NowPlayingItem?.Id === itemId,
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const follower of followers) {
|
||||||
|
if (!follower.Id) continue;
|
||||||
|
const playState = follower.PlayState;
|
||||||
|
const followerPaused = Boolean(playState?.IsPaused);
|
||||||
|
|
||||||
|
if (followerPaused !== paused) {
|
||||||
|
const now = Date.now();
|
||||||
|
if (
|
||||||
|
!lastPauseCommand.current[follower.Id] ||
|
||||||
|
now - lastPauseCommand.current[follower.Id] > SEEK_COOLDOWN_MS
|
||||||
|
) {
|
||||||
|
lastPauseCommand.current[follower.Id] = now;
|
||||||
|
try {
|
||||||
|
await sessionApi.sendPlaystateCommand({
|
||||||
|
sessionId: follower.Id,
|
||||||
|
command: paused
|
||||||
|
? PlaystateCommand.Pause
|
||||||
|
: PlaystateCommand.Unpause,
|
||||||
|
controllingUserId: userId,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Sync pause command failed", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playState?.CanSeek === false) continue;
|
||||||
|
const estimated = estimateSessionPosition(follower);
|
||||||
|
if (Math.abs(estimated.position - position) <= DRIFT_TOLERANCE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
if (
|
||||||
|
lastSeek.current[follower.Id] &&
|
||||||
|
now - lastSeek.current[follower.Id] < SEEK_COOLDOWN_MS
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lastSeek.current[follower.Id] = now;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await sessionApi.sendPlaystateCommand({
|
||||||
|
sessionId: follower.Id,
|
||||||
|
command: PlaystateCommand.Seek,
|
||||||
|
seekPositionTicks: Math.max(
|
||||||
|
0,
|
||||||
|
Math.round(
|
||||||
|
position +
|
||||||
|
(paused ? 0 : 0.3 * TICKS_PER_SECOND),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
controllingUserId: userId,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Sync seek failed", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Playback sync tick failed", error);
|
||||||
|
} finally {
|
||||||
|
busy = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tick();
|
||||||
|
const timer = window.setInterval(tick, TICK_MS);
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
window.clearInterval(timer);
|
||||||
|
};
|
||||||
|
}, [enabled, master, api, user?.Id, stop]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlaybackSync;
|
||||||
@@ -1,108 +1,434 @@
|
|||||||
$image-size: 4em;
|
$art-size: 48px;
|
||||||
|
|
||||||
.audio-player {
|
.audio-player {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0.75rem;
|
||||||
right: 0;
|
left: 50%;
|
||||||
z-index: 10;
|
transform: translateX(-50%);
|
||||||
|
width: min(1100px, calc(100% - 1.5rem));
|
||||||
|
height: 80px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
z-index: 100;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
padding: 0.5em 1.5em;
|
// Equal side columns keep the transport truly centred
|
||||||
gap: 1em;
|
grid-template-columns: minmax(0, 1fr) minmax(0, 540px) minmax(0, 1fr);
|
||||||
box-shadow: 0 0 20px rgb(0 0 0 / 0.25);
|
align-items: center;
|
||||||
grid-template-columns: 30% 1fr 30%;
|
gap: 1.5rem;
|
||||||
background: rgb(0 0 0 / 0.8) !important;
|
padding: 0 0.75rem 0 1rem;
|
||||||
#waveform {
|
|
||||||
width: 100%;
|
color: white;
|
||||||
transform: scaleY(0);
|
// Opaque bar: backdrop-filter over the virtualized grid caused constant
|
||||||
transition: transform $transition-time-default;
|
// compositing/shifting on WebKit.
|
||||||
&[data-show="true"] {
|
background: rgb(18 18 24 / 0.98);
|
||||||
transform: scaleY(1) !important;
|
border: 1px solid rgb(255 255 255 / 0.08);
|
||||||
}
|
border-radius: 14px;
|
||||||
}
|
box-shadow: 0 12px 40px rgb(0 0 0 / 0.45);
|
||||||
&-controls {
|
|
||||||
|
&-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
gap: 0.75rem;
|
||||||
gap: 0.5em;
|
min-width: 0;
|
||||||
padding: 0.5em 0;
|
|
||||||
flex-flow: column;
|
> .MuiIconButton-root {
|
||||||
}
|
flex-shrink: 0;
|
||||||
&-info {
|
color: rgb(255 255 255 / 0.75);
|
||||||
display: grid;
|
.material-symbols-rounded {
|
||||||
gap: 1em;
|
font-size: 1.25rem;
|
||||||
grid-template-columns: minmax(0, $image-size) minmax(0, 1fr);
|
}
|
||||||
width: fit-content;
|
}
|
||||||
align-items: center;
|
|
||||||
flex-grow: 1;
|
&-text {
|
||||||
width: 100%;
|
display: flex;
|
||||||
overflow: hidden;
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-title {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 600 !important;
|
||||||
|
line-height: 1.25 !important;
|
||||||
|
// Wrap long titles onto a second line before truncating
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus-visible {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-artist {
|
||||||
|
opacity: 0.6;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
width: $image-size;
|
position: absolute;
|
||||||
aspect-ratio: 1;
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
flex-shrink: 0;
|
|
||||||
flex-grow: 1;
|
|
||||||
|
|
||||||
position: relative;
|
|
||||||
&-container {
|
&-container {
|
||||||
border-radius: $border-radius_04;
|
all: unset;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: $art-size;
|
||||||
|
height: $art-size;
|
||||||
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: fit-content;
|
cursor: pointer;
|
||||||
aspect-ratio: 1;
|
background: rgb(255 255 255 / 0.08);
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
|
&:hover .audio-player-image-expand,
|
||||||
|
&:focus-visible .audio-player-image-expand {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&-icon {
|
|
||||||
|
&-icon,
|
||||||
|
&-expand {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
font-size: 2em !important;
|
}
|
||||||
z-index: 0;
|
|
||||||
|
&-icon {
|
||||||
|
font-size: 1.5rem !important;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Open player" affordance shown over the art on hover
|
||||||
|
&-expand {
|
||||||
|
z-index: 2;
|
||||||
|
inset: 0;
|
||||||
|
transform: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(0 0 0 / 0.5);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-track {
|
|
||||||
grid-template-columns: $image-size 60% 0.5fr 0.5fr !important;
|
// Transport on top, compact seek row underneath
|
||||||
}
|
&-center {
|
||||||
&-playlist{
|
|
||||||
background: $clr-background-dark !important;
|
|
||||||
border: 1.2px solid rgb(255 255 255 / 0.2);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1em;
|
align-items: center;
|
||||||
// Magic scrollbar
|
gap: 2px;
|
||||||
&::-webkit-scrollbar {
|
min-width: 0;
|
||||||
&-thumb {
|
|
||||||
height: 150px;
|
.player-controls {
|
||||||
max-height: 33%;
|
gap: 0.5rem !important;
|
||||||
}
|
|
||||||
&-track {
|
.MuiFab-root {
|
||||||
margin-top: 20px;
|
width: 36px;
|
||||||
margin-bottom: 20px;
|
height: 36px;
|
||||||
background: transparent !important;
|
min-height: 36px;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.6rem !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-track{
|
&-progress {
|
||||||
display: grid;
|
gap: 0.6rem !important;
|
||||||
gap: 1em;
|
|
||||||
grid-template-columns: 4em 1fr 4em;
|
.MuiTypography-root {
|
||||||
cursor: pointer;
|
min-width: 2.75em !important;
|
||||||
&.active{
|
font-size: 0.7rem;
|
||||||
color: $clr-accent-default;
|
opacity: 0.6 !important;
|
||||||
}
|
|
||||||
&-image{
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius:5px;
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
height: 4em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.MuiSlider-root {
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
.MuiSlider-thumb {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
|
}
|
||||||
|
&:hover .MuiSlider-thumb,
|
||||||
|
.MuiSlider-root.Mui-active .MuiSlider-thumb {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 0.25rem;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
color: rgb(255 255 255 / 0.75);
|
||||||
|
&:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-volume {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
|
// Secondary control: neutral and compact
|
||||||
|
.MuiSlider-root {
|
||||||
|
width: 5.5rem !important;
|
||||||
|
color: rgb(255 255 255 / 0.85);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.audio-player-volume,
|
||||||
|
.audio-player-progress .MuiTypography-root {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||||
|
gap: 0.5rem;
|
||||||
|
bottom: 0.5rem;
|
||||||
|
width: calc(100% - 1rem);
|
||||||
|
height: 64px;
|
||||||
|
|
||||||
|
.audio-player-center .player-controls > :not(:has(.MuiFab-root)),
|
||||||
|
.audio-player-progress {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.audio-player-actions > :not(:last-child) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unified, minimal media bar (local playback + remote device control). */
|
||||||
|
.audio-player {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: min(1440px, calc(100% - 1.5rem));
|
||||||
|
height: 82px;
|
||||||
|
gap: 1.25rem;
|
||||||
|
padding: 0 0.9rem;
|
||||||
|
background: #0b0816;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.08);
|
||||||
|
border-radius: 18px;
|
||||||
|
|
||||||
|
.media-bar {
|
||||||
|
&-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
width: 30%;
|
||||||
|
min-width: 220px;
|
||||||
|
max-width: 360px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-cover {
|
||||||
|
width: 52px;
|
||||||
|
height: 52px;
|
||||||
|
flex: 0 0 52px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
color: rgb(255 255 255 / 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-title {
|
||||||
|
font-weight: 600 !important;
|
||||||
|
line-height: 1.2 !important;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-subtitle {
|
||||||
|
opacity: 0.55;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-more {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: rgb(255 255 255 / 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
&-center {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.25rem;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.15rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
color: rgb(255 255 255 / 0.7);
|
||||||
|
transition: color 0.15s ease, transform 0.15s ease;
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
}
|
||||||
|
&.active {
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-play {
|
||||||
|
width: 46px !important;
|
||||||
|
height: 46px !important;
|
||||||
|
margin: 0 0.5rem;
|
||||||
|
background: #fff !important;
|
||||||
|
border: 0;
|
||||||
|
color: #0b0417 !important;
|
||||||
|
box-shadow: 0 6px 18px rgb(0 0 0 / 0.35);
|
||||||
|
transition: transform 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #fff !important;
|
||||||
|
transform: scale(1.04);
|
||||||
|
}
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.6rem !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-progress {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 140px;
|
||||||
|
|
||||||
|
.MuiSlider-root {
|
||||||
|
padding: 10px 0;
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
.MuiSlider-rail {
|
||||||
|
background: rgb(255 255 255 / 0.16);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.MuiSlider-track {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
.MuiSlider-thumb {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: none;
|
||||||
|
&:hover,
|
||||||
|
&.Mui-focusVisible {
|
||||||
|
box-shadow: 0 0 0 6px rgb(124 199 255 / 0.16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.MuiTypography-root {
|
||||||
|
opacity: 0.55;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.1rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
color: rgb(255 255 255 / 0.65);
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
}
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-volume {
|
||||||
|
width: 84px !important;
|
||||||
|
margin: 0 0.35rem 0 0 !important;
|
||||||
|
color: $clr-accent-default !important;
|
||||||
|
|
||||||
|
.MuiSlider-rail {
|
||||||
|
background: rgb(255 255 255 / 0.16);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.MuiSlider-thumb {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.audio-player {
|
||||||
|
.media-bar-left {
|
||||||
|
min-width: 160px;
|
||||||
|
}
|
||||||
|
.media-bar-volume,
|
||||||
|
.media-bar-right .MuiSlider-root {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import type { SessionInfoDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import {
|
||||||
|
Divider,
|
||||||
|
IconButton,
|
||||||
|
ListItemIcon,
|
||||||
|
ListItemText,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
Switch,
|
||||||
|
Tooltip,
|
||||||
|
} from "@mui/material";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
type DeviceMenuProps = {
|
||||||
|
sessions: SessionInfoDto[];
|
||||||
|
activeRemoteId: string | null;
|
||||||
|
localActive: boolean;
|
||||||
|
localItem?: BaseItemDto | null;
|
||||||
|
onSelectLocal: () => void;
|
||||||
|
onSelectRemote: (session: SessionInfoDto) => void;
|
||||||
|
onOpenRemoteControl: () => void;
|
||||||
|
syncEnabled?: boolean;
|
||||||
|
canSync?: boolean;
|
||||||
|
onToggleSync?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const DeviceMenu = ({
|
||||||
|
sessions,
|
||||||
|
activeRemoteId,
|
||||||
|
localActive,
|
||||||
|
localItem,
|
||||||
|
onSelectLocal,
|
||||||
|
onSelectRemote,
|
||||||
|
onOpenRemoteControl,
|
||||||
|
syncEnabled = false,
|
||||||
|
canSync = false,
|
||||||
|
onToggleSync,
|
||||||
|
}: DeviceMenuProps) => {
|
||||||
|
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
const handleClose = () => setAnchor(null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title="Устройства">
|
||||||
|
<IconButton
|
||||||
|
aria-label="Устройства"
|
||||||
|
onClick={(event) => setAnchor(event.currentTarget)}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">devices</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Menu
|
||||||
|
anchorEl={anchor}
|
||||||
|
open={Boolean(anchor)}
|
||||||
|
onClose={handleClose}
|
||||||
|
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
||||||
|
>
|
||||||
|
<MenuItem
|
||||||
|
selected={!activeRemoteId}
|
||||||
|
onClick={() => {
|
||||||
|
handleClose();
|
||||||
|
onSelectLocal();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ListItemIcon>
|
||||||
|
<span className="material-symbols-rounded">computer</span>
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText
|
||||||
|
primary="Это устройство"
|
||||||
|
secondary={
|
||||||
|
localActive ? (localItem?.Name ?? "Играет") : "Свободно"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</MenuItem>
|
||||||
|
<Divider />
|
||||||
|
{sessions.length === 0 ? (
|
||||||
|
<MenuItem disabled>
|
||||||
|
<ListItemText primary="Другие устройства не в сети" />
|
||||||
|
</MenuItem>
|
||||||
|
) : (
|
||||||
|
sessions.map((session) => (
|
||||||
|
<MenuItem
|
||||||
|
key={session.Id}
|
||||||
|
selected={session.Id === activeRemoteId}
|
||||||
|
onClick={() => {
|
||||||
|
handleClose();
|
||||||
|
onSelectRemote(session);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ListItemIcon>
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
{session.NowPlayingItem ? "tv" : "devices_other"}
|
||||||
|
</span>
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText
|
||||||
|
primary={session.DeviceName || session.Client || "Устройство"}
|
||||||
|
secondary={
|
||||||
|
session.NowPlayingItem?.Name ??
|
||||||
|
session.Client ??
|
||||||
|
"Ничего не играет"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</MenuItem>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
<Divider />
|
||||||
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
handleClose();
|
||||||
|
onOpenRemoteControl();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ListItemIcon>
|
||||||
|
<span className="material-symbols-rounded">settings_remote</span>
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText primary="Удалённое управление…" />
|
||||||
|
</MenuItem>
|
||||||
|
<Divider />
|
||||||
|
<MenuItem
|
||||||
|
disabled={!canSync}
|
||||||
|
onClick={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
onToggleSync?.();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ListItemIcon>
|
||||||
|
<span className="material-symbols-rounded">sync</span>
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText
|
||||||
|
primary="Синхронизация воспроизведения"
|
||||||
|
secondary={
|
||||||
|
syncEnabled
|
||||||
|
? "Устройства следуют за этим сеансом"
|
||||||
|
: "Синхронизировать устройства"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Switch
|
||||||
|
edge="end"
|
||||||
|
checked={syncEnabled}
|
||||||
|
disabled={!canSync}
|
||||||
|
onClick={(event) => event.stopPropagation()}
|
||||||
|
onChange={() => onToggleSync?.()}
|
||||||
|
/>
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DeviceMenu;
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getLyricApi } from "@jellyfin/sdk/lib/utils/api/lyric-api";
|
||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import { queryOptions, useQuery } from "@tanstack/react-query";
|
||||||
|
import React, { useEffect, useRef } from "react";
|
||||||
|
import { secToTicks } from "@/utils/date/time";
|
||||||
|
|
||||||
|
export const getLyricsQueryOptions = (
|
||||||
|
item: BaseItemDto | undefined | null,
|
||||||
|
api: Api | undefined,
|
||||||
|
) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["player", "audio", item?.Id, "lyrics"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!item?.Id || !api) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await getLyricApi(api).getLyrics({
|
||||||
|
itemId: item.Id,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch {
|
||||||
|
// Items without lyrics return 404
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enabled: Boolean(item?.Id) && Boolean(api),
|
||||||
|
});
|
||||||
|
|
||||||
|
interface LyricsPanelProps {
|
||||||
|
item: BaseItemDto | undefined | null;
|
||||||
|
api: Api | undefined;
|
||||||
|
currentTime: number;
|
||||||
|
/** Seeks playback to a position in ticks; enables clicking synced lines. */
|
||||||
|
onSeek?: (ticks: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
||||||
|
const lyricsContainer = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
const lyrics = useQuery(getLyricsQueryOptions(item, api));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (lyrics.data && lyricsContainer.current) {
|
||||||
|
const currentLyric = lyricsContainer.current.querySelector(
|
||||||
|
"[data-active-lyric='true']",
|
||||||
|
);
|
||||||
|
if (currentLyric) {
|
||||||
|
currentLyric.scrollIntoView({
|
||||||
|
block: "center",
|
||||||
|
inline: "nearest",
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [currentTime, lyrics.data]);
|
||||||
|
|
||||||
|
if (lyrics.isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="audio-lyrics-status">
|
||||||
|
<Typography>Загрузка текста...</Typography>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lyrics.isError || !lyrics.data || !lyrics.data.Lyrics?.length) {
|
||||||
|
return (
|
||||||
|
<div className="audio-lyrics-status">
|
||||||
|
<Typography>Текст недоступен</Typography>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasSyncedLyrics = (lyrics.data.Lyrics[0].Start ?? -1) >= 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="audio-lyrics" data-has-synced-lyrics={hasSyncedLyrics}>
|
||||||
|
<div className="audio-lyrics-container" ref={lyricsContainer}>
|
||||||
|
{lyrics.data.Lyrics.map((lyric, index) => {
|
||||||
|
const isActive =
|
||||||
|
hasSyncedLyrics &&
|
||||||
|
secToTicks(currentTime) >= (lyric.Start ?? 0) &&
|
||||||
|
secToTicks(currentTime) <
|
||||||
|
(lyrics.data?.Lyrics?.[index + 1]?.Start ??
|
||||||
|
Number.POSITIVE_INFINITY);
|
||||||
|
|
||||||
|
const canSeek = hasSyncedLyrics && onSeek && lyric.Start != null;
|
||||||
|
const seek = () => {
|
||||||
|
if (canSeek) onSeek(lyric.Start ?? 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
component="p"
|
||||||
|
className={`audio-lyrics-line ${isActive ? "active" : ""}`}
|
||||||
|
key={`${lyric.Text}-${index}`}
|
||||||
|
data-active-lyric={isActive}
|
||||||
|
{...(canSeek && {
|
||||||
|
role: "button",
|
||||||
|
tabIndex: 0,
|
||||||
|
"data-seekable": true,
|
||||||
|
onClick: seek,
|
||||||
|
onKeyDown: (e: React.KeyboardEvent) => {
|
||||||
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
|
e.preventDefault();
|
||||||
|
seek();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{lyric.Text}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
{!hasSyncedLyrics && (
|
||||||
|
<div className="audio-lyrics-unsynced-notice">
|
||||||
|
<span className="material-symbols-rounded">info</span>
|
||||||
|
<Typography variant="caption">Синхронизированный текст недоступен</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(LyricsPanel);
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import React, { type ReactNode } from "react";
|
||||||
|
import CastButton from "@/components/buttons/castButton";
|
||||||
|
import InstantMixButton from "@/components/buttons/instantMixButton";
|
||||||
|
import QueueButton from "@/components/buttons/queueButton";
|
||||||
|
|
||||||
|
interface PlayerActionsProps {
|
||||||
|
/** Opens the full-screen player. */
|
||||||
|
onExpand: () => void;
|
||||||
|
onClose: () => void;
|
||||||
|
/** The track currently playing (for cast / instant mix). */
|
||||||
|
item?: BaseItemDto | null;
|
||||||
|
positionTicks?: number;
|
||||||
|
queue?: BaseItemDto[];
|
||||||
|
startIndex?: number;
|
||||||
|
/** Volume control, rendered between the queue and expand buttons. */
|
||||||
|
children?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerActions = ({
|
||||||
|
onExpand,
|
||||||
|
onClose,
|
||||||
|
item,
|
||||||
|
positionTicks = 0,
|
||||||
|
queue = [],
|
||||||
|
startIndex = 0,
|
||||||
|
children,
|
||||||
|
}: PlayerActionsProps) => {
|
||||||
|
return (
|
||||||
|
<div className="audio-player-actions">
|
||||||
|
{item && <InstantMixButton item={item} />}
|
||||||
|
{item && <CastButton
|
||||||
|
item={item}
|
||||||
|
transfer={{
|
||||||
|
kind: "audio",
|
||||||
|
positionTicks,
|
||||||
|
queue,
|
||||||
|
startIndex,
|
||||||
|
}}
|
||||||
|
/>}
|
||||||
|
<QueueButton />
|
||||||
|
<div className="audio-player-volume">{children}</div>
|
||||||
|
<Tooltip title="Открыть плеер">
|
||||||
|
<IconButton onClick={onExpand} aria-label="Открыть плеер">
|
||||||
|
<span className="material-symbols-rounded">open_in_full</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Остановить и закрыть">
|
||||||
|
<IconButton onClick={onClose} aria-label="Остановить и закрыть">
|
||||||
|
<span className="material-symbols-rounded">close</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlayerActions;
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import Fab from "@mui/material/Fab";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import React from "react";
|
||||||
|
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||||
|
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||||
|
|
||||||
|
interface PlayerControlsProps {
|
||||||
|
playing: boolean;
|
||||||
|
onPlayPause: () => void;
|
||||||
|
size?: "small" | "medium" | "large";
|
||||||
|
onRewind?: () => void;
|
||||||
|
onForward?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerControls = ({
|
||||||
|
playing,
|
||||||
|
onPlayPause,
|
||||||
|
size = "small",
|
||||||
|
onRewind,
|
||||||
|
onForward,
|
||||||
|
}: PlayerControlsProps) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="player-controls"
|
||||||
|
style={{ display: "flex", gap: "1em", alignItems: "center" }}
|
||||||
|
>
|
||||||
|
<PlayPreviousButton />
|
||||||
|
{onRewind && (
|
||||||
|
<IconButton onClick={onRewind}>
|
||||||
|
<span className="material-symbols-rounded">fast_rewind</span>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "inline-flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
position: "relative",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Fab size={size} onClick={onPlayPause}>
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
fontSize: size === "large" ? "2.4em" : "2em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{playing ? "pause" : "play_arrow"}
|
||||||
|
</div>
|
||||||
|
</Fab>
|
||||||
|
</div>
|
||||||
|
{onForward && (
|
||||||
|
<IconButton onClick={onForward}>
|
||||||
|
<span className="material-symbols-rounded">fast_forward</span>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
<PlayNextButton />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(PlayerControls);
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import React from "react";
|
||||||
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
|
interface PlayerInfoProps {
|
||||||
|
item: BaseItemDto | undefined | null;
|
||||||
|
api: Api | undefined;
|
||||||
|
/** Opens the full-screen player. */
|
||||||
|
onOpen: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerInfo = ({ item, api, onOpen }: PlayerInfoProps) => {
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
// Fresh user data so the like button reflects changes immediately.
|
||||||
|
const itemDetails = useQuery({
|
||||||
|
...getItemQueryOptions(item?.Id ?? "", api, user?.Id),
|
||||||
|
enabled: Boolean(item?.Id && api && user?.Id),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!api || !item) return null;
|
||||||
|
|
||||||
|
const artists = item.ArtistItems?.length
|
||||||
|
? item.ArtistItems
|
||||||
|
: (item.AlbumArtists ?? []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="audio-player-info">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="audio-player-image-container"
|
||||||
|
onClick={onOpen}
|
||||||
|
aria-label="Открыть плеер"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded audio-player-image-icon">
|
||||||
|
music_note
|
||||||
|
</span>
|
||||||
|
<img
|
||||||
|
alt=""
|
||||||
|
className="audio-player-image"
|
||||||
|
src={getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
(!item.ImageTags?.Primary ? item.AlbumId : item.Id) ?? "",
|
||||||
|
"Primary",
|
||||||
|
{ quality: 85, fillHeight: 120, fillWidth: 120 },
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<span className="material-symbols-rounded audio-player-image-expand">
|
||||||
|
expand_less
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<div className="audio-player-info-text">
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
component="button"
|
||||||
|
className="audio-player-info-title"
|
||||||
|
title={item.Name ?? undefined}
|
||||||
|
onClick={onOpen}
|
||||||
|
>
|
||||||
|
{item.Name}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
noWrap
|
||||||
|
className="audio-player-info-artist"
|
||||||
|
>
|
||||||
|
{artists.map((artist, index) => (
|
||||||
|
<React.Fragment key={artist.Id ?? artist.Name}>
|
||||||
|
{index > 0 && ", "}
|
||||||
|
{artist.Id ? (
|
||||||
|
<Link to="/music/artist/$id" params={{ id: artist.Id }}>
|
||||||
|
{artist.Name}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
artist.Name
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<LikeButton
|
||||||
|
itemId={item.Id ?? undefined}
|
||||||
|
itemName={item.Name}
|
||||||
|
isFavorite={
|
||||||
|
itemDetails.data?.UserData?.IsFavorite ?? item.UserData?.IsFavorite
|
||||||
|
}
|
||||||
|
queryKey={["item", item.Id ?? ""]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlayerInfo;
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
import Slider from "@mui/material/Slider";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
|
||||||
|
interface PlayerProgressProps {
|
||||||
|
progress: number;
|
||||||
|
duration: number;
|
||||||
|
onSeek?: (value: number) => void;
|
||||||
|
onSeekCommit: (value: number) => void;
|
||||||
|
/**
|
||||||
|
* "inline" puts the times beside the bar, "stacked" puts them underneath,
|
||||||
|
* "bare" renders only the slider.
|
||||||
|
*/
|
||||||
|
layout?: "inline" | "stacked" | "bare";
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerProgress = ({
|
||||||
|
progress,
|
||||||
|
duration,
|
||||||
|
onSeek,
|
||||||
|
onSeekCommit,
|
||||||
|
layout = "inline",
|
||||||
|
className,
|
||||||
|
}: PlayerProgressProps) => {
|
||||||
|
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||||
|
const [sliderValue, setSliderValue] = useState(progress);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isScrubbing) {
|
||||||
|
setSliderValue(progress);
|
||||||
|
}
|
||||||
|
}, [progress, isScrubbing]);
|
||||||
|
|
||||||
|
const handleChange = (_: Event, value: number | number[]) => {
|
||||||
|
setIsScrubbing(true);
|
||||||
|
const newValue = Array.isArray(value) ? value[0] : value;
|
||||||
|
setSliderValue(newValue);
|
||||||
|
onSeek?.(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeCommitted = (_: unknown, value: number | number[]) => {
|
||||||
|
setIsScrubbing(false);
|
||||||
|
const newValue = Array.isArray(value) ? value[0] : value;
|
||||||
|
onSeekCommit(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layout === "bare") {
|
||||||
|
return (
|
||||||
|
<Slider
|
||||||
|
className={className}
|
||||||
|
value={sliderValue}
|
||||||
|
step={1}
|
||||||
|
size="small"
|
||||||
|
max={duration}
|
||||||
|
onChange={handleChange}
|
||||||
|
onChangeCommitted={handleChangeCommitted}
|
||||||
|
aria-label="Перемотка"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (layout === "stacked") {
|
||||||
|
return (
|
||||||
|
<div className="player-progress-stacked">
|
||||||
|
<Slider
|
||||||
|
value={sliderValue}
|
||||||
|
step={1}
|
||||||
|
size="small"
|
||||||
|
max={duration}
|
||||||
|
onChange={handleChange}
|
||||||
|
onChangeCommitted={handleChangeCommitted}
|
||||||
|
aria-label="Перемотка"
|
||||||
|
/>
|
||||||
|
<div className="player-progress-stacked-times">
|
||||||
|
<span>{getRuntimeMusic(sliderValue)}</span>
|
||||||
|
<span>-{getRuntimeMusic(Math.max(duration - sliderValue, 0))}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={className}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
gap: "1em",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
style={{
|
||||||
|
opacity: 0.8,
|
||||||
|
minWidth: "3.5em",
|
||||||
|
textAlign: "right",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
fontWeight: 300,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{getRuntimeMusic(sliderValue)}
|
||||||
|
</Typography>
|
||||||
|
<Slider
|
||||||
|
value={sliderValue}
|
||||||
|
step={1}
|
||||||
|
size="small"
|
||||||
|
max={duration}
|
||||||
|
onChange={handleChange}
|
||||||
|
onChangeCommitted={handleChangeCommitted}
|
||||||
|
/>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
style={{
|
||||||
|
opacity: 0.8,
|
||||||
|
minWidth: "3.5em",
|
||||||
|
textAlign: "left",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
fontWeight: 300,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{getRuntimeMusic(duration)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlayerProgress;
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Slider from "@mui/material/Slider";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
interface PlayerVolumeProps {
|
||||||
|
volume: number;
|
||||||
|
isMuted: boolean;
|
||||||
|
onVolumeChange: (value: number) => void;
|
||||||
|
onMuteToggle: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PlayerVolume = ({
|
||||||
|
volume,
|
||||||
|
isMuted,
|
||||||
|
onVolumeChange,
|
||||||
|
onMuteToggle,
|
||||||
|
}: PlayerVolumeProps) => {
|
||||||
|
const [localVolume, setLocalVolume] = React.useState(volume * 100);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
setLocalVolume(volume * 100);
|
||||||
|
}, [volume]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<IconButton onClick={onMuteToggle}>
|
||||||
|
<div className="material-symbols-rounded">
|
||||||
|
{isMuted ? "volume_mute" : "volume_up"}
|
||||||
|
</div>
|
||||||
|
</IconButton>
|
||||||
|
<Slider
|
||||||
|
value={isMuted ? 0 : localVolume}
|
||||||
|
step={1}
|
||||||
|
max={100}
|
||||||
|
onChange={(_, newVal) => {
|
||||||
|
const newVolume = Array.isArray(newVal) ? newVal[0] : newVal;
|
||||||
|
setLocalVolume(newVolume);
|
||||||
|
onVolumeChange(newVolume / 100);
|
||||||
|
}}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
|
valueLabelFormat={(value) => Math.floor(value)}
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
mr: 1,
|
||||||
|
ml: 1,
|
||||||
|
width: "10em",
|
||||||
|
"& .MuiSlider-valueLabel": {
|
||||||
|
// Compact pill hugging the thumb; above the play FAB (zIndex.fab)
|
||||||
|
zIndex: (theme) => theme.zIndex.tooltip,
|
||||||
|
lineHeight: 1.2,
|
||||||
|
fontSize: "0.75rem",
|
||||||
|
fontWeight: 600,
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
minWidth: "2.25em",
|
||||||
|
background: "rgb(0 0 0 / 0.75)",
|
||||||
|
padding: "2px 6px",
|
||||||
|
borderRadius: "6px",
|
||||||
|
border: "1px solid rgb(255 255 255 / 0.15)",
|
||||||
|
boxShadow: "0 2px 8px rgb(0 0 0 / 0.4)",
|
||||||
|
top: -6,
|
||||||
|
transform: "translatey(-100%) scale(0)",
|
||||||
|
"&:before": {
|
||||||
|
display: "none",
|
||||||
|
},
|
||||||
|
"&.MuiSlider-valueLabelOpen": {
|
||||||
|
transform: "translateY(-100%) scale(1)",
|
||||||
|
},
|
||||||
|
"& > *": {
|
||||||
|
transform: "rotate(0deg)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlayerVolume;
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Box, Paper, Typography } from "@mui/material";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
interface StatsPanelProps {
|
||||||
|
item: BaseItemDto | undefined | null;
|
||||||
|
audioRef: React.RefObject<HTMLAudioElement | null> | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatRow = ({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string | number | undefined | null;
|
||||||
|
}) => (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
mb: 1,
|
||||||
|
borderBottom: "1px solid rgba(255,255,255,0.1)",
|
||||||
|
pb: 0.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="body2" sx={{ opacity: 0.7, fontFamily: "monospace" }}>
|
||||||
|
{label}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ fontFamily: "monospace", fontWeight: 600 }}
|
||||||
|
>
|
||||||
|
{value || "-"}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
|
||||||
|
const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
||||||
|
const [buffered, setBuffered] = useState<string>("0%");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const player = audioRef?.current;
|
||||||
|
if (!player) return;
|
||||||
|
|
||||||
|
const updateStats = () => {
|
||||||
|
if (player.buffered.length > 0) {
|
||||||
|
const bufferedEnd = player.buffered.end(player.buffered.length - 1);
|
||||||
|
const duration = player.duration;
|
||||||
|
if (duration > 0) {
|
||||||
|
setBuffered(`${Math.round((bufferedEnd / duration) * 100)}%`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const interval = setInterval(updateStats, 1000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [audioRef]);
|
||||||
|
|
||||||
|
const mediaSource = item?.MediaSources?.[0];
|
||||||
|
const mediaStream = mediaSource?.MediaStreams?.find(
|
||||||
|
(s) => s.Type === "Audio",
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ p: 2 }}>
|
||||||
|
<Typography variant="h6" sx={{ mb: 2 }}>
|
||||||
|
Статистика
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Paper
|
||||||
|
sx={{
|
||||||
|
p: 2,
|
||||||
|
background: "rgba(0,0,0,0.2)",
|
||||||
|
backdropFilter: "blur(10px)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||||
|
>
|
||||||
|
Источник медиа
|
||||||
|
</Typography>
|
||||||
|
<StatRow label="Контейнер" value={mediaSource?.Container} />
|
||||||
|
<StatRow
|
||||||
|
label="Битрейт"
|
||||||
|
value={
|
||||||
|
mediaSource?.Bitrate
|
||||||
|
? `${Math.round(mediaSource.Bitrate / 1000)} kbps`
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<StatRow
|
||||||
|
label="Размер"
|
||||||
|
value={
|
||||||
|
mediaSource?.Size
|
||||||
|
? `${(mediaSource.Size / 1024 / 1024).toFixed(2)} MB`
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<StatRow label="Путь" value={mediaSource?.Path} />
|
||||||
|
|
||||||
|
<Box sx={{ mt: 3 }}>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||||
|
>
|
||||||
|
Аудиопоток
|
||||||
|
</Typography>
|
||||||
|
<StatRow label="Кодек" value={mediaStream?.Codec} />
|
||||||
|
<StatRow label="Каналы" value={mediaStream?.Channels} />
|
||||||
|
<StatRow
|
||||||
|
label="Частота дискретизации"
|
||||||
|
value={
|
||||||
|
mediaStream?.SampleRate
|
||||||
|
? `${mediaStream.SampleRate} Hz`
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<StatRow label="Глубина" value={mediaStream?.BitDepth} />
|
||||||
|
<StatRow label="Язык" value={mediaStream?.Language} />
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ mt: 3 }}>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||||
|
>
|
||||||
|
Плеер
|
||||||
|
</Typography>
|
||||||
|
<StatRow label="Буфер" value={buffered} />
|
||||||
|
<StatRow
|
||||||
|
label="Громкость"
|
||||||
|
value={
|
||||||
|
audioRef?.current
|
||||||
|
? `${Math.round(audioRef.current.volume * 100)}%`
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<StatRow
|
||||||
|
label="Скорость воспроизведения"
|
||||||
|
value={audioRef?.current?.playbackRate}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(StatsPanel);
|
||||||
Loaded 100 of 272 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user