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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be here?

Copy link
Copy Markdown
Member Author

@ravicious ravicious Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh the changes to types here? Yeah, sorry, I forgot to mention it. After deduping @types/node, this started to raise type errors. TypeScript resolves setInterval without window to the Node version, but clearInterval without window gets resolved to the browser version AFAIR. So TypeScript was complaining about passing intervalRef.current to clearInterval.

Since this code only ever runs on the client side, I just prepended window to resolve the interval functions to the correct variants.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ProgressBarDesktop = (props: {
id?: string;
}) => {
const { playerClient, durationMs } = props;
const intervalRef = useRef<NodeJS.Timer>();
const intervalRef = useRef<number>();
let playSpeed = 1.0;

const toHuman = (currentMs: number) => {
Expand Down Expand Up @@ -73,7 +73,7 @@ export const ProgressBarDesktop = (props: {
const smoothOutProgress = (speed: number) => {
const smoothingInterval = 25;

intervalRef.current = setInterval(() => {
intervalRef.current = window.setInterval(() => {
setState(prevState => {
const nextTimeMs = prevState.current + smoothingInterval * speed;
if (nextTimeMs <= durationMs) {
Expand All @@ -93,7 +93,7 @@ export const ProgressBarDesktop = (props: {
// should be called when the playback is paused or ended.
const stopProgress = () => {
throttledUpdateCurrentTime.cancel();
clearInterval(intervalRef.current);
window.clearInterval(intervalRef.current);
};

const throttledUpdateCurrentTime = throttle(
Expand Down
Loading