* Added Star Rating functionality for Songs * Added Star Rating functionality for Artists * Added Star Rating functionality for AlbumListView * Added Star Rating functionality for AlbumDetails and improved typography for title * Added functionality to turn on/off Star Rating functionality for Songs * Added functionality to turn on/off Star Rating functionality for Artists * Added functionality to turn on/off Star Rating functionality for Albums * Added enableStarRating to server config * Resolved the bugs and improved the ratings functionality. * synced repo and removed duplicate key * changed the default rating size to small, and changed the color to match the theme. * Added translations for ratings, and Top Rated tab in side menu. * Changed rating translation to topRated in albumLists, and added has_rating filter to topRated. * Added empty stars icon to RatingField. * Added sortable=false in AlbumSongs and added sortByOrder=DESC in all List components. * Added translations for rating, for artists and albums, and removed the sortByOrder=DESC from SimpleLists.
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import { fetchUtils } from 'react-admin'
|
|
import { baseUrl } from '../utils'
|
|
|
|
const url = (command, id, options) => {
|
|
const params = new URLSearchParams()
|
|
params.append('u', localStorage.getItem('username'))
|
|
params.append('t', localStorage.getItem('subsonic-token'))
|
|
params.append('s', localStorage.getItem('subsonic-salt'))
|
|
params.append('f', 'json')
|
|
params.append('v', '1.8.0')
|
|
params.append('c', 'NavidromeUI')
|
|
id && params.append('id', id)
|
|
if (options) {
|
|
if (options.ts) {
|
|
options['_'] = new Date().getTime()
|
|
delete options.ts
|
|
}
|
|
Object.keys(options).forEach((k) => {
|
|
params.append(k, options[k])
|
|
})
|
|
}
|
|
const url = `/rest/${command}?${params.toString()}`
|
|
return baseUrl(url)
|
|
}
|
|
|
|
const scrobble = (id, submit) =>
|
|
fetchUtils.fetchJson(url('scrobble', id, { submission: submit }))
|
|
|
|
const star = (id) => fetchUtils.fetchJson(url('star', id))
|
|
|
|
const unstar = (id) => fetchUtils.fetchJson(url('unstar', id))
|
|
|
|
const download = (id) => (window.location.href = url('download', id))
|
|
|
|
const getCoverArtUrl = (record, size) => {
|
|
const options = {
|
|
...(record.updatedAt && { _: record.updatedAt }),
|
|
...(size && { size }),
|
|
}
|
|
return url('getCoverArt', record.coverArtId || 'not_found', options)
|
|
}
|
|
|
|
const setRating = (id, rating) =>
|
|
fetchUtils.fetchJson(url('setRating', id, { rating }))
|
|
|
|
export default {
|
|
url,
|
|
getCoverArtUrl,
|
|
scrobble,
|
|
download,
|
|
star,
|
|
unstar,
|
|
setRating,
|
|
}
|