Reformat code with Prettier's new rules.

This commit is contained in:
Caio Cotts 2023-12-18 14:56:03 -05:00
parent 735d670a5b
commit 86757663d6
82 changed files with 236 additions and 222 deletions

View File

@ -113,7 +113,7 @@ const useStyles = makeStyles(
}),
{
name: 'NDAlbumDetails',
}
},
)
const AlbumComment = ({ record }) => {
@ -141,7 +141,7 @@ const AlbumComment = ({ record }) => {
timeout={'auto'}
className={clsx(
classes.commentBlock,
lines.length > 1 && classes.pointerCursor
lines.length > 1 && classes.pointerCursor,
)}
>
<Typography variant={'body1'} onClick={handleExpandClick}>
@ -216,9 +216,9 @@ const Details = (props) => {
addDetail(
<>
{[translate('resources.album.fields.originalDate'), originalDate].join(
' '
' ',
)}
</>
</>,
)
yearRange && addDetail(<>{['♫', !isXsmall ? date : yearRange].join(' ')}</>)
@ -230,7 +230,7 @@ const Details = (props) => {
? [translate('resources.album.fields.releaseDate'), releaseDate]
: ['○', record.releaseDate.substring(0, 4)]
).join(' ')}
</>
</>,
)
const showReleases = record.releases > 1
@ -245,7 +245,7 @@ const Details = (props) => {
}),
].join(' ')
: ['(', record.releases, ')))'].join(' ')}
</>
</>,
)
addDetail(
@ -255,7 +255,7 @@ const Details = (props) => {
translate('resources.song.name', {
smart_count: record.songCount,
})}
</>
</>,
)
!isXsmall && addDetail(<DurationField source={'duration'} />)
!isXsmall && addDetail(<SizeField source="size" />)
@ -299,7 +299,7 @@ const AlbumDetails = (props) => {
const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
const handleCloseLightbox = React.useCallback(
() => setLightboxOpen(false),
[]
[],
)
return (
<Card className={classes.root}>

View File

@ -35,7 +35,7 @@ const AlbumExternalLinks = (props) => {
encodeURIComponent(record.name)
}`,
'message.openIn.lastfm',
<ImLastfm2 className="lastfm-icon" />
<ImLastfm2 className="lastfm-icon" />,
)
}
@ -43,7 +43,7 @@ const AlbumExternalLinks = (props) => {
addLink(
`https://musicbrainz.org/release/${record.mbzAlbumId}`,
'message.openIn.musicbrainz',
<MusicBrainz className="musicbrainz-icon" />
<MusicBrainz className="musicbrainz-icon" />,
)
return <div className={className}>{intersperse(links, ' ')}</div>

View File

@ -78,7 +78,7 @@ const useStyles = makeStyles(
albumContainer: {},
albumPlayButton: { color: 'white' },
}),
{ name: 'NDAlbumGridView' }
{ name: 'NDAlbumGridView' },
)
const useCoverStyles = makeStyles({
@ -98,32 +98,34 @@ const getColsForWidth = (width) => {
return 9
}
const Cover = withContentRect('bounds')(
({ record, measureRef, contentRect }) => {
// Force height to be the same as the width determined by the GridList
// noinspection JSSuspiciousNameCombination
const classes = useCoverStyles({ height: contentRect.bounds.width })
const [, dragAlbumRef] = useDrag(
() => ({
type: DraggableTypes.ALBUM,
item: { albumIds: [record.id] },
options: { dropEffect: 'copy' },
}),
[record]
)
return (
<div ref={measureRef}>
<div ref={dragAlbumRef}>
<img
src={subsonic.getCoverArtUrl(record, 300)}
alt={record.name}
className={classes.cover}
/>
</div>
const Cover = withContentRect('bounds')(({
record,
measureRef,
contentRect,
}) => {
// Force height to be the same as the width determined by the GridList
// noinspection JSSuspiciousNameCombination
const classes = useCoverStyles({ height: contentRect.bounds.width })
const [, dragAlbumRef] = useDrag(
() => ({
type: DraggableTypes.ALBUM,
item: { albumIds: [record.id] },
options: { dropEffect: 'copy' },
}),
[record],
)
return (
<div ref={measureRef}>
<div ref={dragAlbumRef}>
<img
src={subsonic.getCoverArtUrl(record, 300)}
alt={record.name}
className={classes.cover}
/>
</div>
)
}
)
</div>
)
})
const AlbumGridTile = ({ showArtist, record, basePath, ...props }) => {
const classes = useStyles()

View File

@ -104,7 +104,7 @@ const AlbumList = (props) => {
'size',
'createdAt',
],
['createdAt', 'size']
['createdAt', 'size'],
)
// If it does not have filter/sort params (usually coming from Menu),

View File

@ -64,7 +64,7 @@ const AlbumViewToggler = React.forwardRef(
</ButtonGroup>
</div>
)
}
},
)
const AlbumListActions = ({

View File

@ -18,7 +18,7 @@ const useStyles = makeStyles(
}),
{
name: 'NDAlbumShow',
}
},
)
const AlbumShowLayout = (props) => {

View File

@ -83,7 +83,7 @@ const useStyles = makeStyles(
visibility: 'hidden',
},
}),
{ name: 'RaList' }
{ name: 'RaList' },
)
const AlbumSongs = (props) => {

View File

@ -59,7 +59,7 @@ const AlbumDatagridRow = (props) => {
item: { albumIds: [record?.id] },
options: { dropEffect: 'copy' },
}),
[record]
[record],
)
return <DatagridRow ref={dragAlbumRef} {...props} />
}

View File

@ -11,7 +11,7 @@ const ArtistExternalLinks = ({ artistInfo, record }) => {
const translate = useTranslate()
let linkButtons = []
const lastFMlink = artistInfo?.biography?.match(
/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/
/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/,
)
const addLink = (url, title, icon) => {
@ -34,13 +34,13 @@ const ArtistExternalLinks = ({ artistInfo, record }) => {
addLink(
lastFMlink[2],
'message.openIn.lastfm',
<ImLastfm2 className="lastfm-icon" />
<ImLastfm2 className="lastfm-icon" />,
)
} else if (artistInfo?.lastFmUrl) {
addLink(
artistInfo?.lastFmUrl,
'message.openIn.lastfm',
<ImLastfm2 className="lastfm-icon" />
<ImLastfm2 className="lastfm-icon" />,
)
}
}
@ -49,7 +49,7 @@ const ArtistExternalLinks = ({ artistInfo, record }) => {
addLink(
`https://musicbrainz.org/artist/${artistInfo.musicBrainzId}`,
'message.openIn.musicbrainz',
<MusicBrainz className="musicbrainz-icon" />
<MusicBrainz className="musicbrainz-icon" />,
)
return <div>{intersperse(linkButtons, ' ')}</div>

View File

@ -90,7 +90,7 @@ const ArtistDatagridRow = (props) => {
item: { artistIds: [record?.id] },
options: { dropEffect: 'copy' },
}),
[record]
[record],
)
return <DatagridRow ref={dragArtistRef} {...props} />
}
@ -132,7 +132,7 @@ const ArtistListView = ({ hasShow, hasEdit, hasList, width, ...rest }) => {
resource: 'artist',
columns: toggleableFields,
},
['size']
['size'],
)
return isXsmall ? (

View File

@ -65,7 +65,7 @@ const useStyles = makeStyles(
wordBreak: 'break-word',
},
}),
{ name: 'NDDesktopArtistDetails' }
{ name: 'NDDesktopArtistDetails' },
)
const DesktopArtistDetails = ({ artistInfo, record, biography }) => {
@ -77,7 +77,7 @@ const DesktopArtistDetails = ({ artistInfo, record, biography }) => {
const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
const handleCloseLightbox = React.useCallback(
() => setLightboxOpen(false),
[]
[],
)
return (

View File

@ -72,7 +72,7 @@ const useStyles = makeStyles(
wordBreak: 'break-word',
},
}),
{ name: 'NDMobileArtistDetails' }
{ name: 'NDMobileArtistDetails' },
)
const MobileArtistDetails = ({ artistInfo, biography, record }) => {
@ -85,7 +85,7 @@ const MobileArtistDetails = ({ artistInfo, biography, record }) => {
const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
const handleCloseLightbox = React.useCallback(
() => setLightboxOpen(false),
[]
[],
)
return (

View File

@ -48,7 +48,7 @@ const Player = () => {
const isDesktop = useMediaQuery('(min-width:810px)')
const isMobilePlayer =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
navigator.userAgent,
)
const { authenticated } = useAuthState()
@ -60,7 +60,7 @@ const Player = () => {
enableCoverAnimation: config.enableCoverAnimation,
})
const showNotifications = useSelector(
(state) => state.settings.notifications || false
(state) => state.settings.notifications || false,
)
const gainInfo = useSelector((state) => state.replayGain)
const [context, setContext] = useState(null)
@ -100,7 +100,7 @@ const Player = () => {
numericGain = calculateReplayGain(
gainInfo.preAmp,
song.rgAlbumGain,
song.rgAlbumPeak
song.rgAlbumPeak,
)
break
}
@ -108,7 +108,7 @@ const Player = () => {
numericGain = calculateReplayGain(
gainInfo.preAmp,
song.rgTrackGain,
song.rgTrackPeak
song.rgTrackPeak,
)
break
}
@ -160,7 +160,7 @@ const Player = () => {
),
locale: locale(translate),
}),
[gainInfo, isDesktop, playerTheme, translate]
[gainInfo, isDesktop, playerTheme, translate],
)
const options = useMemo(() => {
@ -181,12 +181,12 @@ const Player = () => {
const onAudioListsChange = useCallback(
(_, audioLists, audioInfo) => dispatch(syncQueue(audioInfo, audioLists)),
[dispatch]
[dispatch],
)
const nextSong = useCallback(() => {
const idx = playerState.queue.findIndex(
(item) => item.uuid === playerState.current.uuid
(item) => item.uuid === playerState.current.uuid,
)
return idx !== null ? playerState.queue[idx + 1] : null
}, [playerState])
@ -221,13 +221,13 @@ const Player = () => {
setScrobbled(true)
}
},
[startTime, scrobbled, nextSong, preloaded]
[startTime, scrobbled, nextSong, preloaded],
)
const onAudioVolumeChange = useCallback(
// sqrt to compensate for the logarithmic volume
(volume) => dispatch(setVolume(Math.sqrt(volume))),
[dispatch]
[dispatch],
)
const onAudioPlay = useCallback(
@ -260,12 +260,12 @@ const Player = () => {
sendNotification(
song.title,
`${song.artist} - ${song.album}`,
info.cover
info.cover,
)
}
}
},
[context, dispatch, showNotifications, startTime]
[context, dispatch, showNotifications, startTime],
)
const onAudioPlayTrackChange = useCallback(() => {
@ -279,7 +279,7 @@ const Player = () => {
const onAudioPause = useCallback(
(info) => dispatch(currentPlaying(info)),
[dispatch]
[dispatch],
)
const onAudioEnded = useCallback(
@ -291,7 +291,7 @@ const Player = () => {
.getOne('keepalive', { id: info.trackId })
.catch((e) => console.log('Keepalive error:', e))
},
[dispatch, dataProvider]
[dispatch, dataProvider],
)
const onCoverClick = useCallback((mode, audioLists, audioInfo) => {
@ -313,7 +313,7 @@ const Player = () => {
const handlers = useMemo(
() => keyHandlers(audioInstance, playerState),
[audioInstance, playerState]
[audioInstance, playerState],
)
useEffect(() => {

View File

@ -1,14 +1,14 @@
const keyHandlers = (audioInstance, playerState) => {
const nextSong = () => {
const idx = playerState.queue.findIndex(
(item) => item.uuid === playerState.current.uuid
(item) => item.uuid === playerState.current.uuid,
)
return idx !== null ? playerState.queue[idx + 1] : null
}
const prevSong = () => {
const idx = playerState.queue.findIndex(
(item) => item.uuid === playerState.current.uuid
(item) => item.uuid === playerState.current.uuid,
)
return idx !== null ? playerState.queue[idx - 1] : null
}

View File

@ -87,7 +87,7 @@ const useStyle = makeStyles(
},
},
}),
{ name: 'NDAudioPlayer' }
{ name: 'NDAudioPlayer' },
)
export default useStyle

View File

@ -12,7 +12,10 @@ export const AddToPlaylistButton = ({ resource, selectedIds, className }) => {
const handleClick = () => {
dispatch(
openAddToPlaylist({ selectedIds, onSuccess: () => unselectAll(resource) })
openAddToPlaylist({
selectedIds,
onSuccess: () => unselectAll(resource),
}),
)
}

View File

@ -14,28 +14,31 @@ export const useGetHandleArtistClick = (width) => {
}
}
export const ArtistLinkField = withWidth()(
({ record, className, width, source }) => {
const artistLink = useGetHandleArtistClick(width)
export const ArtistLinkField = withWidth()(({
record,
className,
width,
source,
}) => {
const artistLink = useGetHandleArtistClick(width)
const id = record[source + 'Id']
return (
<>
{id ? (
<Link
to={artistLink(id)}
onClick={(e) => e.stopPropagation()}
className={className}
>
{record[source]}
</Link>
) : (
record[source]
)}
</>
)
}
)
const id = record[source + 'Id']
return (
<>
{id ? (
<Link
to={artistLink(id)}
onClick={(e) => e.stopPropagation()}
className={className}
>
{record[source]}
</Link>
) : (
record[source]
)}
</>
)
})
ArtistLinkField.propTypes = {
record: PropTypes.object,

View File

@ -23,7 +23,7 @@ const useStyles = makeStyles(
top: '26px',
},
},
{ name: 'RaArtistSimpleList' }
{ name: 'RaArtistSimpleList' },
)
export const ArtistSimpleList = ({
@ -69,7 +69,7 @@ export const ArtistSimpleList = ({
</ListItemSecondaryAction>
</ListItem>
</span>
)
),
)}
</List>
)

View File

@ -30,7 +30,7 @@ export const BatchPlayButton = ({
// Add tracks to a map for easy lookup by ID, needed for the next step
const tracks = response.data.reduce(
(acc, cur) => ({ ...acc, [cur.id]: cur }),
{}
{},
)
// Add the tracks to the queue in the selection order
dispatch(action(tracks, selectedIds))

View File

@ -18,8 +18,8 @@ export const BatchShareButton = ({ resource, selectedIds, className }) => {
_: 'ra.action.bulk_actions',
smart_count: selectedIds.length,
}),
'message.shareBatchDialogTitle'
)
'message.shareBatchDialogTitle',
),
)
unselectAll(resource)
}

View File

@ -97,8 +97,8 @@ const ContextMenu = ({
record,
record.duration !== undefined
? DOWNLOAD_MENU_ALBUM
: DOWNLOAD_MENU_ARTIST
)
: DOWNLOAD_MENU_ARTIST,
),
)
},
},
@ -127,7 +127,7 @@ const ContextMenu = ({
let extractSongsData = function (response) {
const data = response.data.reduce(
(acc, cur) => ({ ...acc, [cur.id]: cur }),
{}
{},
)
const ids = response.data.map((r) => r.id)
return { data, ids }
@ -186,7 +186,7 @@ const ContextMenu = ({
<MenuItem value={key} key={key} onClick={handleItemClick}>
{options[key].label}
</MenuItem>
)
),
)}
</Menu>
</span>

View File

@ -10,7 +10,7 @@ const useStyles = makeStyles(
color: theme.palette.primary.main,
},
}),
{ name: 'RaLink' }
{ name: 'RaLink' },
)
const Linkify = ({ text, ...rest }) => {
@ -45,7 +45,7 @@ const Linkify = ({ text, ...rest }) => {
href={href}
>
{href}
</Link>
</Link>,
)
lastIndex = match.index + href.length
@ -57,7 +57,7 @@ const Linkify = ({ text, ...rest }) => {
<span
key={'last-span-key'}
dangerouslySetInnerHTML={{ __html: text.substring(lastIndex) }}
/>
/>,
)
}

View File

@ -36,7 +36,7 @@ export const LoveButton = ({
toggleLove()
e.stopPropagation()
},
[toggleLove]
[toggleLove],
)
if (!config.enableFavourites) {

View File

@ -39,11 +39,11 @@ export const MultiLineTextField = memo(
key={md5(line + idx)}
dangerouslySetInnerHTML={{ __html: line }}
/>
)
),
)}
</Typography>
)
}
},
)
MultiLineTextField.defaultProps = {

View File

@ -20,9 +20,9 @@ describe('<MultiLineTextField />', () => {
record={{ id: 123, body }}
emptyText="NA"
source="body"
/>
/>,
)
expect(screen.getByText('NA')).toBeInTheDocument()
}
},
)
})

View File

@ -10,7 +10,7 @@ export const PlayButton = ({ record, size, className }) => {
let extractSongsData = function (response) {
const data = response.data.reduce(
(acc, cur) => ({ ...acc, [cur.id]: cur }),
{}
{},
)
const ids = response.data.map((r) => r.id)
return { data, ids }

View File

@ -16,7 +16,7 @@ const useStyle = makeStyles(
}),
{
name: 'NDQualityInfo',
}
},
)
export const QualityInfo = ({ record, size, gainMode, preAmp, className }) => {

View File

@ -22,7 +22,7 @@ describe('QuickFilter', () => {
resource={'song'}
source={'name'}
label={<StarIcon data-testid="label-icon-test" />}
/>
/>,
)
expect(screen.getByTestId('label-icon-test')).not.toBeNull()
})

View File

@ -40,7 +40,7 @@ export const RatingField = ({
(e, val) => {
rate(val, e.target.name)
},
[rate]
[rate],
)
return (
@ -50,7 +50,7 @@ export const RatingField = ({
className={clsx(
className,
classes.rating,
rating > 0 ? classes.show : classes.hide
rating > 0 ? classes.show : classes.hide,
)}
value={rating}
size={size}

View File

@ -19,7 +19,7 @@ const useStyles = makeStyles(
},
tertiary: { float: 'right', opacity: 0.541176 },
},
{ name: 'RaSimpleList' }
{ name: 'RaSimpleList' },
)
const LinkOrNot = ({

View File

@ -61,7 +61,7 @@ export const SongContextMenu = ({
openAddToPlaylist({
selectedIds: [record.mediaFileId || record.id],
onSuccess: (id) => onAddToPlaylist(id),
})
}),
),
},
share: {
@ -69,7 +69,11 @@ export const SongContextMenu = ({
label: translate('ra.action.share'),
action: (record) =>
dispatch(
openShareMenu([record.mediaFileId || record.id], 'song', record.title)
openShareMenu(
[record.mediaFileId || record.id],
'song',
record.title,
),
),
},
download: {
@ -127,7 +131,7 @@ export const SongContextMenu = ({
<MenuItem value={key} key={key} onClick={handleItemClick}>
{options[key].label}
</MenuItem>
)
),
)}
</Menu>
</span>

View File

@ -97,7 +97,7 @@ const ReleaseRow = forwardRef(
</TableCell>
</TableRow>
)
}
},
)
const DiscSubtitleRow = forwardRef(
@ -141,7 +141,7 @@ const DiscSubtitleRow = forwardRef(
</TableCell>
</TableRow>
)
}
},
)
export const SongDatagridRow = ({
@ -156,7 +156,7 @@ export const SongDatagridRow = ({
}) => {
const classes = useStyles()
const fields = React.Children.toArray(children).filter((c) =>
isValidElement(c)
isValidElement(c),
)
const [, dragDiscRef] = useDrag(
@ -173,7 +173,7 @@ export const SongDatagridRow = ({
},
options: { dropEffect: 'copy' },
}),
[record]
[record],
)
const [, dragSongRef] = useDrag(
@ -182,7 +182,7 @@ export const SongDatagridRow = ({
item: { ids: [record?.mediaFileId || record?.id] },
options: { dropEffect: 'copy' },
}),
[record]
[record],
)
if (!record || !record.title) {
@ -251,14 +251,14 @@ const SongDatagridBody = ({
idsToPlay = ids.filter(
(id) =>
data[id].releaseDate === releaseDate &&
data[id].discNumber === discNumber
data[id].discNumber === discNumber,
)
} else {
idsToPlay = ids.filter((id) => data[id].releaseDate === releaseDate)
}
dispatch(playTracks(data, idsToPlay))
},
[dispatch, data, ids]
[dispatch, data, ids],
)
const firstTracksOfDiscs = useMemo(() => {
@ -280,7 +280,7 @@ const SongDatagridBody = ({
acc.push(id)
}
return acc
}, [])
}, []),
)
if (!showDiscSubtitles || (set.size < 2 && !foundSubtitle)) {
set.clear()
@ -304,7 +304,7 @@ const SongDatagridBody = ({
acc.push(id)
}
return acc
}, [])
}, []),
)
if (!showReleaseDivider || set.size < 2) {
set.clear()

View File

@ -47,7 +47,7 @@ const useStyles = makeStyles(
top: '26px',
},
},
{ name: 'RaSongSimpleList' }
{ name: 'RaSongSimpleList' },
)
export const SongSimpleList = ({
@ -108,7 +108,7 @@ export const SongSimpleList = ({
</ListItemSecondaryAction>
</ListItem>
</span>
)
),
)}
</List>
)

View File

@ -36,7 +36,7 @@ export const ToggleFieldsMenu = ({
const dispatch = useDispatch()
const translate = useTranslate()
const toggleableColumns = useSelector(
(state) => state.settings.toggleableFields[resource]
(state) => state.settings.toggleableFields[resource],
)
const omittedColumns =
useSelector((state) => state.settings.omittedFields[resource]) || []
@ -58,7 +58,7 @@ export const ToggleFieldsMenu = ({
...toggleableColumns,
[selectedColumn]: !toggleableColumns[selectedColumn],
},
})
}),
)
}
@ -95,7 +95,7 @@ export const ToggleFieldsMenu = ({
<Checkbox checked={val} />
{translate(`resources.${resource}.fields.${key}`)}
</MenuItem>
) : null
) : null,
)}
</div>
</div>

View File

@ -15,7 +15,7 @@ export const Writable = (props) => {
const { record = {}, children } = props
if (isWritable(record.ownerId)) {
return Children.map(children, (child) =>
isValidElement(child) ? cloneElement(child, props) : child
isValidElement(child) ? cloneElement(child, props) : child,
)
}
return null

View File

@ -19,7 +19,7 @@ const getPerPageOptions = (width) => {
export const useAlbumsPerPage = (width) => {
const perPage =
useSelector(
(state) => state?.admin.resources?.album?.list?.params?.perPage
(state) => state?.admin.resources?.album?.list?.params?.perPage,
) || getPerPage(width)
return [perPage, getPerPageOptions(width)]

View File

@ -7,7 +7,7 @@ export const useResourceRefresh = (...visibleResources) => {
const refresh = useRefresh()
const dataProvider = useDataProvider()
const refreshData = useSelector(
(state) => state.activity?.refresh || { lastReceived: lastTime }
(state) => state.activity?.refresh || { lastReceived: lastTime },
)
const { resources, lastReceived } = refreshData

View File

@ -12,7 +12,7 @@ export const useSelectedFields = ({
}) => {
const dispatch = useDispatch()
const resourceFields = useSelector(
(state) => state.settings.toggleableFields
(state) => state.settings.toggleableFields,
)?.[resource]
const omittedFields = useSelector((state) => state.settings.omittedFields)?.[
resource
@ -81,7 +81,7 @@ useSelectedFields.propTypes = {
export const useSetToggleableFields = (
resource,
toggleableColumns,
defaultOff = []
defaultOff = [],
) => {
const current = useSelector((state) => state.settings.toggleableFields)?.album
const dispatch = useDispatch()
@ -95,7 +95,7 @@ export const useSetToggleableFields = (
...{ [cur]: true },
}
}, {}),
})
}),
)
dispatch(setOmittedFields({ [resource]: defaultOff }))
}

View File

@ -16,7 +16,7 @@ DraggableTypes.ALL.push(
DraggableTypes.SONG,
DraggableTypes.ALBUM,
DraggableTypes.DISC,
DraggableTypes.ARTIST
DraggableTypes.ARTIST,
)
export const DEFAULT_SHARE_BITRATE = 128

View File

@ -30,7 +30,7 @@ describe('<LinkToVersion />', () => {
const link = screen.queryByRole('link')
expect(link.href).toBe(
'https://github.com/navidrome/navidrome/releases/tag/v0.40.0'
'https://github.com/navidrome/navidrome/releases/tag/v0.40.0',
)
expect(link.textContent).toBe('0.40.0')
@ -44,7 +44,7 @@ describe('<LinkToVersion />', () => {
const link = screen.queryByRole('link')
expect(link.href).toBe(
'https://github.com/navidrome/navidrome/compare/v0.40.0...300a0292'
'https://github.com/navidrome/navidrome/compare/v0.40.0...300a0292',
)
expect(link.textContent).toBe('0.40.0-SNAPSHOT')

View File

@ -72,7 +72,7 @@ export const AddToPlaylistDialog = () => {
const tracks = res.json
if (tracks) {
const dupSng = tracks.filter((song) =>
selectedIds.some((id) => id === song.mediaFileId)
selectedIds.some((id) => id === song.mediaFileId),
)
if (dupSng.length) {
@ -128,7 +128,7 @@ export const AddToPlaylistDialog = () => {
}
const handleSkip = () => {
const distinctSongs = selectedIds.filter(
(id) => duplicateIds.indexOf(id) < 0
(id) => duplicateIds.indexOf(id) < 0,
)
value.slice(-1).pop().distinctIds = distinctSongs
dispatch(closeDuplicateSongDialog())

View File

@ -59,7 +59,7 @@ const createTestUtils = (mockDataProvider) =>
>
<AddToPlaylistDialog />
</TestContext>
</DataProviderContext.Provider>
</DataProviderContext.Provider>,
)
jest.mock('../dataProvider', () => ({
@ -104,7 +104,7 @@ describe('AddToPlaylistDialog', () => {
{
data: { ids: selectedIds },
filter: { playlist_id: 'sample-id1' },
}
},
)
})
await waitFor(() => {
@ -114,7 +114,7 @@ describe('AddToPlaylistDialog', () => {
{
data: { ids: selectedIds },
filter: { playlist_id: 'sample-id2' },
}
},
)
})
})
@ -153,7 +153,7 @@ describe('AddToPlaylistDialog', () => {
{
data: { ids: selectedIds },
filter: { playlist_id: 'created-id1' },
}
},
)
})

View File

@ -14,7 +14,7 @@ import { useTranscodingOptions } from './useTranscodingOptions'
const DownloadMenuDialog = () => {
const { open, record, recordType } = useSelector(
(state) => state.downloadMenuDialog
(state) => state.downloadMenuDialog,
)
const dispatch = useDispatch()
const translate = useTranslate()

View File

@ -54,7 +54,7 @@ const HelpTable = (props) => {
</TableContainer>
</DialogContent>
</Dialog>,
document.body
document.body,
)
}

View File

@ -58,7 +58,7 @@ export const ListenBrainzTokenDialog = ({ setLinked }) => {
event.stopPropagation()
})
},
[dispatch, notify, setLinked, token]
[dispatch, notify, setLinked, token],
)
const handleClickClose = (event) => {
@ -74,7 +74,7 @@ export const ListenBrainzTokenDialog = ({ setLinked }) => {
handleSave(event)
}
},
[token, handleSave]
[token, handleSave],
)
return (

View File

@ -25,7 +25,7 @@ export const SelectPlaylistInput = ({ onChange }) => {
'playlist',
{ page: 1, perPage: -1 },
{ field: 'name', order: 'ASC' },
{ smart: false }
{ smart: false },
)
const options =

View File

@ -65,7 +65,7 @@ describe('SelectPlaylistInput', () => {
>
<SelectPlaylistInput onChange={onChangeHandler} />
</TestContext>
</DataProviderContext.Provider>
</DataProviderContext.Provider>,
)
await waitFor(() => {

View File

@ -33,7 +33,7 @@ export const ShareDialog = () => {
const translate = useTranslate()
const [description, setDescription] = useState('')
const [downloadable, setDownloadable] = useState(
config.defaultDownloadableShare && config.enableDownloads
config.defaultDownloadableShare && config.enableDownloads,
)
useEffect(() => {
setDescription('')
@ -66,7 +66,7 @@ export const ShareDialog = () => {
type: 'warning',
multiLine: true,
duration: 0,
}
},
)
})
} else prompt(translate('message.shareCopyToClipboard'), url)
@ -75,7 +75,7 @@ export const ShareDialog = () => {
notify(translate('ra.page.error') + ': ' + error.message, {
type: 'warning',
}),
}
},
)
const handleShare = (e) => {

View File

@ -20,7 +20,7 @@ export const useTranscodingOptions = () => {
page: 1,
perPage: 1000,
},
{ field: 'name', order: 'ASC' }
{ field: 'name', order: 'ASC' },
)
const formatOptions = useMemo(
@ -30,7 +30,7 @@ export const useTranscodingOptions = () => {
: Object.values(formats).map((f) => {
return { id: f.targetFormat, name: f.name }
}),
[formats, loadingFormats]
[formats, loadingFormats],
)
const handleOriginal = useCallback(
@ -41,7 +41,7 @@ export const useTranscodingOptions = () => {
setMaxBitRate(DEFAULT_SHARE_BITRATE)
}
},
[setUseOriginalFormat, setFormat, setMaxBitRate]
[setUseOriginalFormat, setFormat, setMaxBitRate],
)
const TranscodingOptionsInput = useMemo(() => {

View File

@ -30,7 +30,7 @@ const startEventStream = async (dispatchFn) => {
newStream.addEventListener('serverStart', eventHandler(dispatchFn))
newStream.addEventListener(
'scanStatus',
throttledEventHandler(dispatchFn)
throttledEventHandler(dispatchFn),
)
newStream.addEventListener('refreshResource', eventHandler(dispatchFn))
newStream.addEventListener('keepAlive', eventHandler(dispatchFn))

View File

@ -6,7 +6,7 @@ const useGetLanguageChoices = () => {
'translation',
{ page: 1, perPage: -1 },
{ field: '', order: '' },
{}
{},
)
const choices = [{ id: 'en', name: 'English' }]

View File

@ -31,7 +31,7 @@ const useStyles = makeStyles(
}),
{
name: 'NDAppBar',
}
},
)
const AboutMenuItem = forwardRef(({ onClick, ...rest }, ref) => {
@ -90,7 +90,7 @@ const CustomUserMenu = ({ onClick, ...rest }) => {
}
return renderSettingsMenuItemLink(
userResource,
permissions !== 'admin' ? localStorage.getItem('userId') : null
permissions !== 'admin' ? localStorage.getItem('userId') : null,
)
}

View File

@ -17,7 +17,7 @@ describe('<DynamicMenuIcon />', () => {
render(
<Router history={history}>
<DynamicMenuIcon icon={StarIcon} path={'test'} />
</Router>
</Router>,
)
expect(screen.getByTestId('icon')).not.toBeNull()
})
@ -34,7 +34,7 @@ describe('<DynamicMenuIcon />', () => {
activeIcon={StarBorderIcon}
path={'otherpath'}
/>
</Router>
</Router>,
)
expect(screen.getByTestId('icon')).not.toBeNull()
})
@ -51,7 +51,7 @@ describe('<DynamicMenuIcon />', () => {
activeIcon={StarBorderIcon}
path={'path'}
/>
</Router>
</Router>,
)
expect(screen.getByTestId('activeIcon')).not.toBeNull()
})

View File

@ -82,7 +82,7 @@ const useStyles = makeStyles(
textDecoration: 'none',
},
}),
{ name: 'NDLogin' }
{ name: 'NDLogin' },
)
const renderInput = ({
@ -263,14 +263,14 @@ const Login = ({ location }) => {
typeof error === 'string'
? error
: typeof error === 'undefined' || !error.message
? 'ra.auth.sign_in_error'
: error.message,
'warning'
? 'ra.auth.sign_in_error'
: error.message,
'warning',
)
}
},
)
},
[dispatch, login, notify, setLoading, location]
[dispatch, login, notify, setLoading, location],
)
const validateLogin = useCallback(
@ -284,7 +284,7 @@ const Login = ({ location }) => {
}
return errors
},
[translate]
[translate],
)
const validateSignup = useCallback(
@ -302,7 +302,7 @@ const Login = ({ location }) => {
}
return errors
},
[translate, validateLogin]
[translate, validateLogin],
)
if (config.firstTime) {
@ -348,7 +348,7 @@ const LoginWithTheme = (props) => {
})
.catch((e) => {
throw new Error(
'Cannot load language "' + config.defaultLanguage + '": ' + e
'Cannot load language "' + config.defaultLanguage + '": ' + e,
)
})
}

View File

@ -121,7 +121,7 @@ const Menu = ({ dense = false }) => {
dense={dense}
>
{Object.keys(albumLists).map((type) =>
renderAlbumMenuItemLink(type, albumLists[type])
renderAlbumMenuItemLink(type, albumLists[type]),
)}
</SubMenu>
{resources.filter(subItems(undefined)).map(renderResourceMenuItemLink)}

View File

@ -93,7 +93,7 @@ const PlaylistsSubMenu = ({ state, setState, sidebarIsOpen, dense }) => {
const onPlaylistConfig = useCallback(
() => history.push('/playlist'),
[history]
[history],
)
return (

View File

@ -42,7 +42,7 @@ const useStyles = makeStyles(
}),
{
name: 'NDSubMenu',
}
},
)
const SubMenu = ({

View File

@ -118,7 +118,7 @@ const UserMenu = (props) => {
? cloneElement(menuItem, {
onClick: handleClose,
})
: null
: null,
)}
{!config.auth && logout}
</MenuList>

View File

@ -20,11 +20,11 @@ const Progress = (props) => {
useEffect(() => {
const callbackEndpoint = baseUrl(
`/api/lastfm/link/callback?uid=${localStorage.getItem('userId')}`
`/api/lastfm/link/callback?uid=${localStorage.getItem('userId')}`,
)
const callbackUrl = `${window.location.origin}${callbackEndpoint}`
openedTab.current = openInNewTab(
`https://www.last.fm/api/auth/?api_key=${config.lastFMApiKey}&cb=${callbackUrl}`
`https://www.last.fm/api/auth/?api_key=${config.lastFMApiKey}&cb=${callbackUrl}`,
)
}, [])

View File

@ -21,7 +21,7 @@ export const SelectTheme = (props) => {
themeChoices.push(
...Object.keys(themes).map((key) => {
return { id: key, name: themes[key].themeName }
})
}),
)
themeChoices.push({
id: helpKey,

View File

@ -59,7 +59,7 @@ const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
.then((res) => {
const data = res.data.reduce(
(acc, curr) => ({ ...acc, [curr.id]: curr }),
{}
{},
)
dispatch(action(data))
})
@ -67,7 +67,7 @@ const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
notify('ra.page.error', 'warning')
})
},
[dataProvider, dispatch, record, data, ids, notify]
[dataProvider, dispatch, record, data, ids, notify],
)
const handlePlay = React.useCallback(() => {
@ -108,7 +108,7 @@ const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
link.click()
link.parentNode.removeChild(link)
}),
[record]
[record],
)
return (

View File

@ -38,7 +38,7 @@ const useStyles = makeStyles(
}),
{
name: 'NDPlaylistDetails',
}
},
)
const PlaylistDetails = (props) => {

View File

@ -65,7 +65,7 @@ const TogglePublicInput = ({ resource, source }) => {
console.log(error)
notify('ra.page.error', 'warning')
},
}
},
)
const handleClick = (e) => {
@ -108,7 +108,7 @@ const PlaylistList = (props) => {
),
comment: <TextField source="comment" />,
}),
[isDesktop, isXsmall]
[isDesktop, isXsmall],
)
const columns = useSelectedFields({

View File

@ -20,7 +20,7 @@ const useStyles = makeStyles(
}),
{
name: 'NDPlaylistShow',
}
},
)
const PlaylistShowLayout = (props) => {

View File

@ -72,7 +72,7 @@ const useStyles = makeStyles(
visibility: (props) => (props.isDesktop ? 'hidden' : 'visible'),
},
}),
{ name: 'RaList' }
{ name: 'RaList' },
)
const ReorderableList = ({ readOnly, children, ...rest }) => {
@ -99,7 +99,7 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
refetch()
}
},
[playlistId, refetch]
[playlistId, refetch],
)
const reorder = useCallback(
@ -117,7 +117,7 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
notify('ra.page.error', 'warning')
})
},
[dataProvider, notify, refetch]
[dataProvider, notify, refetch],
)
const handleDragEnd = useCallback(
@ -126,7 +126,7 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
const fromId = ids[from]
reorder(playlistId, fromId, toId)
},
[playlistId, reorder, ids]
[playlistId, reorder, ids],
)
const toggleableFields = useMemo(() => {

View File

@ -26,7 +26,7 @@ export const StreamField = (props) => {
evt.preventDefault()
dispatch(setTrack(await songFromRadio(record)))
},
[dispatch, record]
[dispatch, record],
)
return (

View File

@ -4,7 +4,7 @@ export const albumViewReducer = (
previousState = {
grid: true,
},
payload
payload,
) => {
const { type } = payload
switch (type) {

View File

@ -24,7 +24,7 @@ export const shareDialogReducer = (
resource: '',
name: '',
},
payload
payload,
) => {
const { type, ids, resource, name, label } = payload
switch (type) {
@ -52,7 +52,7 @@ export const addToPlaylistDialogReducer = (
open: false,
duplicateSong: false,
},
payload
payload,
) => {
const { type } = payload
switch (type) {
@ -82,7 +82,7 @@ export const downloadMenuDialogReducer = (
previousState = {
open: false,
},
payload
payload,
) => {
const { type } = payload
switch (type) {
@ -125,7 +125,7 @@ export const expandInfoDialogReducer = (
previousState = {
open: false,
},
payload
payload,
) => {
const { type } = payload
switch (type) {
@ -149,7 +149,7 @@ export const listenBrainzTokenDialogReducer = (
previousState = {
open: false,
},
payload
payload,
) => {
const { type } = payload
switch (type) {

View File

@ -55,7 +55,7 @@ const mapToAudioLists = (item) => {
updatedAt: item.updatedAt,
album: item.album,
},
300
300,
),
}
}
@ -140,7 +140,7 @@ const reduceSyncQueue = (state, { data: { audioInfo, audioLists } }) => {
const reduceCurrent = (state, { data }) => {
const current = data.ended ? {} : data
const savedPlayIndex = state.queue.findIndex(
(item) => item.uuid === current.uuid
(item) => item.uuid === current.uuid,
)
return {
...state,

View File

@ -18,7 +18,7 @@ const initialState = {
export const replayGainReducer = (
previousState = initialState,
{ type, payload }
{ type, payload },
) => {
switch (type) {
case CHANGE_GAIN: {

View File

@ -5,14 +5,14 @@ import themes from '../themes'
const defaultTheme = () => {
return (
Object.keys(themes).find(
(t) => themes[t].themeName === config.defaultTheme
(t) => themes[t].themeName === config.defaultTheme,
) || 'DarkTheme'
)
}
export const themeReducer = (
previousState = defaultTheme(),
{ type, payload }
{ type, payload },
) => {
if (type === CHANGE_THEME) {
return payload

View File

@ -16,8 +16,8 @@ const isLocalhost = Boolean(
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
),
)
export function register(config) {
@ -43,7 +43,7 @@ export function register(config) {
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
'worker. To learn more, visit https://bit.ly/CRA-PWA',
)
})
} else {
@ -71,7 +71,7 @@ function registerValidSW(swUrl, config) {
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
)
// Execute callback
@ -123,7 +123,7 @@ function checkValidServiceWorker(swUrl, config) {
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
'No internet connection found. App is running in offline mode.',
)
})
}

View File

@ -48,7 +48,7 @@ const ShareList = (props) => {
type: 'warning',
multiLine: true,
duration: 0,
}
},
)
})
} else prompt(translate('message.shareCopyToClipboard'), url)

View File

@ -48,7 +48,9 @@ const createAdminStore = ({
const store = createStore(
resettableAppReducer,
persistedState,
composeEnhancers(applyMiddleware(sagaMiddleware, routerMiddleware(history)))
composeEnhancers(
applyMiddleware(sagaMiddleware, routerMiddleware(history)),
),
)
store.subscribe(
@ -61,7 +63,7 @@ const createAdminStore = ({
settings: state.settings,
})
}),
1000
1000,
)
sagaMiddleware.run(saga)

View File

@ -27,7 +27,7 @@ const scrobble = (id, time, submission = true) =>
url('scrobble', id, {
...(submission && time && { time }),
submission,
})
}),
)
const nowPlaying = (id) => scrobble(id, null, false)
@ -74,7 +74,7 @@ const streamUrl = (id, options) => {
url('stream', id, {
ts: true,
...options,
})
}),
)
}

View File

@ -14,7 +14,7 @@ const useCurrentTheme = () => {
const themeName =
Object.keys(themes).find((t) => t === state.theme) ||
Object.keys(themes).find(
(t) => themes[t].themeName === config.defaultTheme
(t) => themes[t].themeName === config.defaultTheme,
) ||
'DarkTheme'
return themes[themeName]

View File

@ -24,7 +24,7 @@ const useStyles = makeStyles(
},
},
}),
{ name: 'RaDeleteWithConfirmButton' }
{ name: 'RaDeleteWithConfirmButton' },
)
const DeleteUserButton = (props) => {

View File

@ -33,7 +33,7 @@ const UserCreate = (props) => {
resource: 'user',
payload: { data: values },
},
{ returnPromise: true }
{ returnPromise: true },
)
notify('resources.user.notifications.created', 'info', {
smart_count: 1,
@ -45,7 +45,7 @@ const UserCreate = (props) => {
}
}
},
[mutate, notify, redirect]
[mutate, notify, redirect],
)
return (

View File

@ -85,7 +85,7 @@ const UserEdit = (props) => {
resource: 'user',
payload: { id: values.id, data: values },
},
{ returnPromise: true }
{ returnPromise: true },
)
notify('resources.user.notifications.updated', 'info', {
smart_count: 1,
@ -97,7 +97,7 @@ const UserEdit = (props) => {
}
}
},
[mutate, notify, permissions, redirect, refresh]
[mutate, notify, permissions, redirect, refresh],
)
return (

View File

@ -25,7 +25,7 @@ describe('formatDuration', () => {
it('formats days, hours and minutes', () => {
expect(formatDuration(hour + minute + 1)).toEqual('01:01:01')
expect(formatDuration(3 * day + 3 * hour + 7 * minute)).toEqual(
'3:03:07:00'
'3:03:07:00',
)
expect(formatDuration(day)).toEqual('1:00:00:00')
expect(formatDuration(day + minute + 0.6)).toEqual('1:00:01:01')

View File

@ -15,6 +15,6 @@ export const intersperse = (arr, sep) => {
function (xs, x, i) {
return xs.concat([sep, x])
},
[arr[0]]
[arr[0]],
)
}

View File

@ -10,7 +10,7 @@ export const baseUrl = (path) => {
export const shareUrl = (id) => {
const url = new URL(
baseUrl(config.publicBaseUrl + '/' + id),
window.location.href
window.location.href,
)
return url.href
}