Skip to content

Commit

Permalink
chore: fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leinelissen committed Feb 8, 2024
1 parent fb4af1b commit 789a348
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const { assetExts, sourceExts } = defaultConfig.resolver;
const config = {
transformer: {
babelTransformerPath: require.resolve('./scripts/transformer.js'),

},
resolver: {
assetExts: [
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Music/overlays/NowPlaying/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ActionButton = styled.Pressable`
`;

function SelectActionButton() {
const state = usePlaybackState();
const { state } = usePlaybackState();
const defaultStyles = useDefaultStyles();

switch(state) {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/modals/Player/components/MediaControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 9 additions & 3 deletions src/utility/AddedTrackEvents.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -31,13 +31,19 @@ export function useOnTrackAdded(callback: () => void) {
});
}

type OverloadedParameters<T> =
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<typeof oldAddFunction>) => {
TrackPlayer.add = (...args: OverloadedParameters<typeof oldAddFunction>) => {
emitTrackAdded();
return oldAddFunction(...args);
return oldAddFunction(args[0] as AddTrack, args[1]);
};
}

0 comments on commit 789a348

Please sign in to comment.