From 789a348b2f01a8c39e7a150d56f77476fef87dee Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Thu, 8 Feb 2024 22:30:08 +0100 Subject: [PATCH] chore: fix linter issues --- metro.config.js | 1 - src/screens/Music/overlays/NowPlaying/index.tsx | 2 +- .../modals/Player/components/MediaControls.tsx | 2 +- src/utility/AddedTrackEvents.ts | 12 +++++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/metro.config.js b/metro.config.js index 56d4fd10..c35b638f 100644 --- a/metro.config.js +++ b/metro.config.js @@ -16,7 +16,6 @@ const { assetExts, sourceExts } = defaultConfig.resolver; const config = { transformer: { babelTransformerPath: require.resolve('./scripts/transformer.js'), - }, resolver: { assetExts: [ diff --git a/src/screens/Music/overlays/NowPlaying/index.tsx b/src/screens/Music/overlays/NowPlaying/index.tsx index b894f5ae..7881736c 100644 --- a/src/screens/Music/overlays/NowPlaying/index.tsx +++ b/src/screens/Music/overlays/NowPlaying/index.tsx @@ -78,7 +78,7 @@ const ActionButton = styled.Pressable` `; function SelectActionButton() { - const state = usePlaybackState(); + const { state } = usePlaybackState(); const defaultStyles = useDefaultStyles(); switch(state) { diff --git a/src/screens/modals/Player/components/MediaControls.tsx b/src/screens/modals/Player/components/MediaControls.tsx index c457068e..e23515d3 100644 --- a/src/screens/modals/Player/components/MediaControls.tsx +++ b/src/screens/modals/Player/components/MediaControls.tsx @@ -72,7 +72,7 @@ export function NextButton({ fill }: { fill: string }) { } export function MainButton({ fill }: { fill: string }) { - const state = usePlaybackState(); + const { state } = usePlaybackState(); switch (state) { case State.Playing: diff --git a/src/utility/AddedTrackEvents.ts b/src/utility/AddedTrackEvents.ts index 82d96c21..495b9c3d 100644 --- a/src/utility/AddedTrackEvents.ts +++ b/src/utility/AddedTrackEvents.ts @@ -1,4 +1,4 @@ -import TrackPlayer from 'react-native-track-player'; +import TrackPlayer, { AddTrack } from 'react-native-track-player'; import { useEffect } from 'react'; import EventEmitter from 'events'; @@ -31,13 +31,19 @@ export function useOnTrackAdded(callback: () => void) { }); } +type OverloadedParameters = + T extends { (...args: infer A1): any; (...args: infer A2): any; (...args: infer A3): any; (...args: infer A4): any } ? A1 | A2 | A3 | A4 : + T extends { (...args: infer A1): any; (...args: infer A2): any; (...args: infer A3): any } ? A1 | A2 | A3 : + T extends { (...args: infer A1): any; (...args: infer A2): any } ? A1 | A2 : + T extends (...args: infer A) => any ? A : any + /** * Monkey-patch the track-player to also emit track added events */ export function patchTrackPlayer() { const oldAddFunction = TrackPlayer.add; - TrackPlayer.add = (...args: Parameters) => { + TrackPlayer.add = (...args: OverloadedParameters) => { emitTrackAdded(); - return oldAddFunction(...args); + return oldAddFunction(args[0] as AddTrack, args[1]); }; } \ No newline at end of file