Skip to content

Commit

Permalink
refactor: rely on react compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyPorthouse committed Dec 17, 2024
1 parent 8fe9624 commit 59afe74
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 48 deletions.
1 change: 0 additions & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/* tslint:disable */

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Components/AlbumArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getScaledCoverArtUrl } from "@api/artwork.js";
import { useAuth } from "@hooks/useAuth";
import classNames from "classnames";
import md5 from "md5";
import { memo, useEffect, useMemo, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";

export interface AlbumArtProps {
/**
Expand Down Expand Up @@ -97,4 +97,4 @@ function AlbumArt({
);
}

export default memo(AlbumArt);
export default AlbumArt;
4 changes: 2 additions & 2 deletions src/Components/AlbumHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { SongIds, Songs } from "@api/types.js";
import { useTrackList } from "@hooks/useTrackList.js";
import { Link } from "@tanstack/react-router";
import { Play, Shuffle } from "lucide-react";
import { SyntheticEvent, memo, useCallback, useMemo } from "react";
import { SyntheticEvent, useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next";

import AlbumArt from "./AlbumArt.js";
Expand Down Expand Up @@ -100,4 +100,4 @@ function AlbumHeader({ album, tracks }: Readonly<AlbumHeaderProps>) {
);
}

export default memo(AlbumHeader);
export default AlbumHeader;
3 changes: 1 addition & 2 deletions src/Components/AlbumList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Albums } from "@api/types.js";
import { memo } from "react";

import Album from "./Album.js";
import Grid from "./Grid.js";
Expand All @@ -19,4 +18,4 @@ function AlbumList({ className, albums }: Readonly<AlbumListProps>) {
);
}

export default memo(AlbumList);
export default AlbumList;
9 changes: 2 additions & 7 deletions src/Components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import classNames from "classnames";
import {
ButtonHTMLAttributes,
PropsWithChildren,
ReactElement,
memo,
} from "react";
import { ButtonHTMLAttributes, PropsWithChildren, ReactElement } from "react";

interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
/** A function that returns a React component to use as an icon */
Expand Down Expand Up @@ -33,4 +28,4 @@ function Button({
);
}

export default memo(Button);
export default Button;
3 changes: 1 addition & 2 deletions src/Components/Duration.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { memo } from "react";
import { Temporal } from "temporal-polyfill";

interface DurationProps {
Expand Down Expand Up @@ -27,4 +26,4 @@ function Duration({ time }: DurationProps) {
return <span className="tabular-nums">{output}</span>;
}

export default memo(Duration);
export default Duration;
4 changes: 2 additions & 2 deletions src/Components/MediaControls/FullscreenButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useFullscreen } from "@hooks/useFullscreen";
import { Fullscreen, Shrink } from "lucide-react";
import { SyntheticEvent, memo } from "react";
import { SyntheticEvent } from "react";
import { useTranslation } from "react-i18next";

function FullscreenButton() {
Expand Down Expand Up @@ -39,4 +39,4 @@ function FullscreenButton() {
);
}

export default memo(FullscreenButton);
export default FullscreenButton;
4 changes: 2 additions & 2 deletions src/Components/MediaControls/PlayButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useAudioRef } from "@hooks/useAudio";
import { Play } from "lucide-react";
import { SyntheticEvent, memo } from "react";
import { SyntheticEvent } from "react";
import { useTranslation } from "react-i18next";

function PlayButton() {
Expand All @@ -24,4 +24,4 @@ function PlayButton() {
);
}

export default memo(PlayButton);
export default PlayButton;
4 changes: 2 additions & 2 deletions src/Components/MediaControls/SkipButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTrackList } from "@hooks/useTrackList";
import { SkipForward } from "lucide-react";
import { SyntheticEvent, memo } from "react";
import { SyntheticEvent } from "react";
import { useTranslation } from "react-i18next";

function SkipButton() {
Expand All @@ -23,4 +23,4 @@ function SkipButton() {
);
}

export default memo(SkipButton);
export default SkipButton;
4 changes: 2 additions & 2 deletions src/Components/MediaControls/StopButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAudioRef } from "@hooks/useAudio";
import { useTrackList } from "@hooks/useTrackList";
import { Square } from "lucide-react";
import { SyntheticEvent, memo } from "react";
import { SyntheticEvent } from "react";
import { useTranslation } from "react-i18next";

function StopButton() {
Expand Down Expand Up @@ -31,4 +31,4 @@ function StopButton() {
);
}

export default memo(StopButton);
export default StopButton;
4 changes: 2 additions & 2 deletions src/Components/MediaPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Song } from "@api/types.js";
import { useTrackList } from "@hooks/useTrackList.js";
import { AudioProvider } from "@providers/AudioProvider.js";
import { Link } from "@tanstack/react-router";
import { memo, useMemo, useState } from "react";
import { useMemo, useState } from "react";

import AlbumArt from "./AlbumArt.js";
import Fullscreen from "./MediaPlayer/Fullscreen.js";
Expand Down Expand Up @@ -78,4 +78,4 @@ function MediaPlayer() {
);
}

export default memo(MediaPlayer);
export default MediaPlayer;
3 changes: 1 addition & 2 deletions src/Components/MediaPlayer/Fullscreen.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Song } from "@api/types.js";
import { useFullscreen } from "@hooks/useFullscreen.js";
import classNames from "classnames";
import { memo } from "react";
import { createPortal } from "react-dom";
import { AutoFocusInside } from "react-focus-lock";

Expand Down Expand Up @@ -120,4 +119,4 @@ function Fullscreen({ track, currentTime, duration }: FullscreenProps) {
);
}

export default memo(Fullscreen);
export default Fullscreen;
3 changes: 1 addition & 2 deletions src/Components/MediaPlayer/MediaInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Song } from "@api/types.js";
import { memo } from "react";

import TrackInfo from "../TrackInfo.js";
import MediaControls from "./MediaControls.js";
Expand Down Expand Up @@ -33,4 +32,4 @@ function MediaInfo({
);
}

export default memo(MediaInfo);
export default MediaInfo;
4 changes: 2 additions & 2 deletions src/Components/MediaSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getCoverArtUrl } from "@api/artwork.js";
import type { Song } from "@api/types.js";
import { useAuth } from "@hooks/useAuth";
import { useTrackList } from "@hooks/useTrackList";
import { ReactNode, memo, useEffect } from "react";
import { ReactNode, useEffect } from "react";

interface MediaSessionProps {
track: Song;
Expand Down Expand Up @@ -47,4 +47,4 @@ function MediaSession({ track, children }: MediaSessionProps) {
return children;
}

export default memo(MediaSession);
export default MediaSession;
4 changes: 2 additions & 2 deletions src/Components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from "@tanstack/react-router";
import { Menu, X } from "lucide-react";
import { memo, useCallback, useState } from "react";
import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";

import logoAvif from "../images/logo192.avif";
Expand Down Expand Up @@ -163,4 +163,4 @@ function Nav() {
);
}

export default memo(Nav);
export default Nav;
3 changes: 1 addition & 2 deletions src/Components/TitleInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Song } from "@api/types.js";
import { memo } from "react";
import { Helmet } from "react-helmet-async";

interface TitleInfoProps {
Expand All @@ -22,4 +21,4 @@ function TitleInfo({ nowPlaying }: Readonly<TitleInfoProps>) {
);
}

export default memo(TitleInfo);
export default TitleInfo;
3 changes: 1 addition & 2 deletions src/Components/TrackInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Song } from "@api/types.js";
import { Link } from "@tanstack/react-router";
import { memo } from "react";

interface TrackInfoProps {
track: Song;
Expand All @@ -25,4 +24,4 @@ function TrackInfo({ track }: Readonly<TrackInfoProps>) {
);
}

export default memo(TrackInfo);
export default TrackInfo;
4 changes: 2 additions & 2 deletions src/Components/TrackListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Song } from "@api/types.js";
import { useAlbumTracks } from "@hooks/useAlbumTracks.js";
import { useTrackList } from "@hooks/useTrackList.js";
import { Play, Plus } from "lucide-react";
import { SyntheticEvent, memo, useCallback, useMemo } from "react";
import { SyntheticEvent, useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next";

import Duration from "./Duration.js";
Expand Down Expand Up @@ -110,4 +110,4 @@ function TrackListItem({
);
}

export default memo(TrackListItem);
export default TrackListItem;
6 changes: 3 additions & 3 deletions src/Providers/AudioProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getStreamUrl } from "@api/stream.js";
import type { Song } from "@api/types.js";
import { useAuth } from "@hooks/useAuth.js";
import { useTrackList } from "@hooks/useTrackList.js";
import { PropsWithChildren, memo, useCallback, useEffect, useRef } from "react";
import { PropsWithChildren, useCallback, useEffect, useRef } from "react";

import { AudioContext } from "../Contexts/AudioContext.js";

Expand All @@ -12,7 +12,7 @@ interface AudioProviderProps {
setState: (state: "playing" | "paused" | "stopped") => void;
}

export const AudioProvider = memo(function AudioProvider({
export const AudioProvider = function AudioProvider({
children,
setCurrentDuration,
setCurrentTime,
Expand Down Expand Up @@ -163,4 +163,4 @@ export const AudioProvider = memo(function AudioProvider({
return (
<AudioContext.Provider value={audio}>{children}</AudioContext.Provider>
);
});
};
9 changes: 4 additions & 5 deletions src/Providers/FullscreenProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
PropsWithChildren,
memo,
useCallback,
useEffect,
useMemo,
Expand All @@ -9,9 +8,7 @@ import {

import { FullscreenContext } from "../Contexts/FullscreenContext";

export const FullscreenProvider = memo(function FullscreenProvider({
children,
}: Readonly<PropsWithChildren>) {
export function FullscreenProvider({ children }: Readonly<PropsWithChildren>) {
const [isFullscreen, setIsFullscreen] = useState(false);

const setFullscreen = useCallback(async (enableFullscreen: boolean) => {
Expand Down Expand Up @@ -49,4 +46,6 @@ export const FullscreenProvider = memo(function FullscreenProvider({
{children}
</FullscreenContext.Provider>
);
});
}

export default FullscreenProvider;

0 comments on commit 59afe74

Please sign in to comment.