Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/eq/EqSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { EqBandRow } from "./EqBandRow";
import { EqCurve } from "./EqCurve";
import { EqPresetMenu } from "./EqPresetMenu";

/**
* The EQ has no view of its own, so its entry points (player bar, full-screen
* player, Ctrl+E) link to the Settings view scrolled to this section.
*/
export const EQ_SECTION_ID = "eq";
export const EQ_PATH = `/settings#${EQ_SECTION_ID}`;

function HydrateError() {
const t = useT();
const error = useEqStore((s) => s.hydrateError);
Expand Down
3 changes: 2 additions & 1 deletion src/components/layout/PlayerBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { playerBarAccent } from "../../lib/themes/genshin";
import { usePlayerStore } from "../../stores/playerStore";
import { usePrefsStore } from "../../stores/prefsStore";
import { useUiStore } from "../../stores/uiStore";
import { EQ_PATH } from "../eq/EqSection";
import { ArtistLinks } from "../library/ArtistLinks";
import { CoverImage } from "../library/CoverImage";
import { StarButton } from "../library/StarButton";
Expand Down Expand Up @@ -93,7 +94,7 @@ export function PlayerBar() {
{/* Right controls */}
<div className="flex w-64 items-center justify-end gap-1">
<SignalPathIndicator />
<IconButton label={t("player.eqInSettings")} onClick={() => navigate("/settings")}>
<IconButton label={t("player.eqInSettings")} onClick={() => navigate(EQ_PATH)}>
<SlidersVertical className="size-4" />
</IconButton>
<IconButton
Expand Down
3 changes: 2 additions & 1 deletion src/lib/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useEffect } from "react";
import { useNavigate } from "react-router";
import { EQ_PATH } from "../components/eq/EqSection";
import { usePlayerStore } from "../stores/playerStore";
import { useUiStore } from "../stores/uiStore";
import { positionClock } from "./playback/positionClock";
Expand Down Expand Up @@ -49,7 +50,7 @@ export function useGlobalShortcuts() {
case "E":
if (mod) {
e.preventDefault();
navigate("/settings");
navigate(EQ_PATH);
}
break;
case "m":
Expand Down
3 changes: 2 additions & 1 deletion src/overlays/now-playing/NowPlayingOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "lucide-react";
import { Fragment, useState } from "react";
import { Link, useNavigate } from "react-router";
import { EQ_PATH } from "../../components/eq/EqSection";
import { ArtistLinks } from "../../components/library/ArtistLinks";
import { CoverImage } from "../../components/library/CoverImage";
import { EntityGenreBubbles } from "../../components/library/GenreBubbles";
Expand Down Expand Up @@ -106,7 +107,7 @@ export function NowPlayingOverlay() {
label={t("player.eqInSettings")}
onClick={() => {
setOpen(false);
navigate("/settings");
navigate(EQ_PATH);
}}
>
<SlidersVertical className="size-4" />
Expand Down
21 changes: 18 additions & 3 deletions src/views/settings/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
Volume2,
} from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { EqSection } from "../../components/eq/EqSection";
import { useLocation } from "react-router";
import { EQ_SECTION_ID, EqSection } from "../../components/eq/EqSection";
import { NAV_ITEMS } from "../../components/layout/navItems";
import { Button, IconButton } from "../../components/ui/Button";
import { Input } from "../../components/ui/Input";
Expand Down Expand Up @@ -1204,17 +1205,31 @@ function AboutSection() {

export function SettingsView() {
const t = useT();
const location = useLocation();
const scrollRef = useRef<HTMLDivElement>(null);

// Jump to the section the URL's hash names (the EQ buttons link to #eq).
// Keyed on the location key as well, so following the same link again
// re-scrolls after the user has scrolled away. Only this pane scrolls:
// scrollIntoView would also shift the app shell's overflow-hidden ancestors.
useEffect(() => {
const pane = scrollRef.current;
const target = location.hash ? document.getElementById(location.hash.slice(1)) : null;
if (!pane || !target || !pane.contains(target)) return;
pane.scrollTop += target.getBoundingClientRect().top - pane.getBoundingClientRect().top;
}, [location.key, location.hash]);

return (
<div className="flex h-full flex-col">
<div className="px-6 py-4">
<h1 className="text-2xl font-semibold">{t("nav.settings")}</h1>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-6 pb-8">
<div ref={scrollRef} className="min-h-0 flex-1 overflow-y-auto px-6 pb-8">
<AppearanceSection />
<FullScreenPlayerSection />
<PlaybackSection />
<AudioSection />
<div className="mt-4">
<div id={EQ_SECTION_ID} className="mt-4">
<EqSection />
</div>
<StatsSourcesSection />
Expand Down
Loading