Skip to content

Commit

Permalink
fix(full-screen): queue and progress ba bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
daksh2k committed Sep 14, 2024
1 parent 489c361 commit a8a9b25
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Extensions/full-screen/dist/fullScreen.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Extensions/full-screen/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ async function main() {
deactivate();
setTimeout(() => {
Spicetify.Platform.History.push(formattedUri);
}, 500);
}, 100);
}

async function updateInfo() {
Expand Down Expand Up @@ -555,7 +555,7 @@ async function main() {
"lyrics-unavailable",
!(evt.detail.available && (evt.detail?.synced?.length ?? 5) > 1),
);
if (CFM.get("extraControls") !== "never") {
if (CFM.get("extraControls") !== "never" && !CFM.get("sidebarQueue")) {
lyrics.classList.toggle("hidden", container.classList.contains("lyrics-unavailable"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const SeekableProgressBar = ({ state }: { state: string }) => {
// console.log("Progress Effect called");
if (state === "mousemove") {
hideProgressBar();
} else {
setVisibility(true);
}
const updateInterval = setInterval(updateProgress, 500);

Expand Down
20 changes: 11 additions & 9 deletions Extensions/full-screen/src/ui/components/VolumeBar/VolumeBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import classNames from "classnames";
import { SeekbarProps } from "../../../types/fullscreen";

const SeekableVolumeBar = ({ state }: { state: string }) => {
const DEFAULT_VOLUME = -100;

const [curVolume, setVolume] = React.useState<number>(
Spicetify.Platform?.PlaybackAPI?._isAvailable
? Math.round(Spicetify.Player.getVolume() * 100)
: -100,
: DEFAULT_VOLUME,
);

const [changingProgress, setChangingProgress] = React.useState<SeekbarProps>({
Expand All @@ -18,12 +20,12 @@ const SeekableVolumeBar = ({ state }: { state: string }) => {

const [visibility, setVisibility] = React.useState(true);

const progSlider = React.useRef(null) as React.MutableRefObject<HTMLDivElement | null>;
const progSlider = React.useRef<HTMLDivElement>(null);

const volumeTimer = React.useRef(null) as React.MutableRefObject<NodeJS.Timeout | null>;
const volumeTimer = React.useRef<NodeJS.Timeout | null>(null);

const onMouseDown = (evt: MouseEvent) => {
if (evt.button == 0) {
if (evt.button === 0) {
const sliderHeight = progSlider.current?.getBoundingClientRect().height ?? 250;
const newData = {
isChanging: true,
Expand All @@ -40,6 +42,10 @@ const SeekableVolumeBar = ({ state }: { state: string }) => {
}
};

const debouncedVolume = debounce((newPercentage: number) => {
Spicetify.Player.setVolume(newPercentage / 100);
}, 20);

const onMouseMove = (evt: MouseEvent) => {
if (changingProgress.isChanging && changingProgress.data) {
const moveY = changingProgress.data.beginClient - evt.clientY;
Expand All @@ -50,11 +56,7 @@ const SeekableVolumeBar = ({ state }: { state: string }) => {
);
const newPercentage = Math.round((newPosY / sliderHeight) * 100);
setVolume(newPercentage);
const debouncedVolume = debounce(
() => Spicetify.Player.setVolume(newPercentage / 100),
20,
);
debouncedVolume();
debouncedVolume(newPercentage);
setChangingProgress({
isChanging: true,
data: { ...changingProgress.data, positionCoord: newPosY },
Expand Down

0 comments on commit a8a9b25

Please sign in to comment.