Removed the albumSong workaround, as React-Admin's cache seems to behave better now
This commit is contained in:
@@ -112,7 +112,6 @@ const Admin = (props) => {
|
|||||||
) : (
|
) : (
|
||||||
<Resource name="transcoding" />
|
<Resource name="transcoding" />
|
||||||
),
|
),
|
||||||
<Resource name="albumSong" />,
|
|
||||||
<Resource name="translation" />,
|
<Resource name="translation" />,
|
||||||
<Resource name="playlistTrack" />,
|
<Resource name="playlistTrack" />,
|
||||||
<Resource name="keepalive" />,
|
<Resource name="keepalive" />,
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ const AlbumShowLayout = (props) => {
|
|||||||
<ReferenceManyField
|
<ReferenceManyField
|
||||||
{...context}
|
{...context}
|
||||||
addLabel={false}
|
addLabel={false}
|
||||||
reference="albumSong"
|
reference="song"
|
||||||
target="album_id"
|
target="album_id"
|
||||||
sort={{ field: 'album', order: 'ASC' }}
|
sort={{ field: 'album', order: 'ASC' }}
|
||||||
perPage={0}
|
perPage={0}
|
||||||
pagination={null}
|
pagination={null}
|
||||||
>
|
>
|
||||||
<AlbumSongs
|
<AlbumSongs
|
||||||
resource={'albumSong'}
|
resource={'song'}
|
||||||
exporter={false}
|
exporter={false}
|
||||||
album={record}
|
album={record}
|
||||||
actions={
|
actions={
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ const AlbumSongs = (props) => {
|
|||||||
rating: isDesktop && config.enableStarRating && (
|
rating: isDesktop && config.enableStarRating && (
|
||||||
<RatingField
|
<RatingField
|
||||||
source="rating"
|
source="rating"
|
||||||
resource={'albumSong'}
|
|
||||||
sortable={false}
|
sortable={false}
|
||||||
className={classes.ratingField}
|
className={classes.ratingField}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useCallback } from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { useLocation } from 'react-router-dom'
|
|
||||||
import { useGetOne } from 'react-admin'
|
import { useGetOne } from 'react-admin'
|
||||||
import { GlobalHotKeys } from 'react-hotkeys'
|
import { GlobalHotKeys } from 'react-hotkeys'
|
||||||
import { LoveButton, useToggleLove } from '../common'
|
import { LoveButton, useToggleLove } from '../common'
|
||||||
@@ -10,10 +9,8 @@ const Placeholder = () =>
|
|||||||
config.enableFavourites && <LoveButton disabled={true} resource={'song'} />
|
config.enableFavourites && <LoveButton disabled={true} resource={'song'} />
|
||||||
|
|
||||||
const Toolbar = ({ id }) => {
|
const Toolbar = ({ id }) => {
|
||||||
const location = useLocation()
|
const { data, loading } = useGetOne('song', id)
|
||||||
const resource = location.pathname.startsWith('/song') ? 'song' : 'albumSong'
|
const [toggleLove, toggling] = useToggleLove('song', data)
|
||||||
const { data, loading } = useGetOne(resource, id)
|
|
||||||
const [toggleLove, toggling] = useToggleLove(resource, data)
|
|
||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
TOGGLE_LOVE: useCallback(() => toggleLove(), [toggleLove]),
|
TOGGLE_LOVE: useCallback(() => toggleLove(), [toggleLove]),
|
||||||
@@ -24,7 +21,7 @@ const Toolbar = ({ id }) => {
|
|||||||
{config.enableFavourites && (
|
{config.enableFavourites && (
|
||||||
<LoveButton
|
<LoveButton
|
||||||
record={data}
|
record={data}
|
||||||
resource={resource}
|
resource={'song'}
|
||||||
disabled={loading || toggling}
|
disabled={loading || toggling}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ const ContextMenu = ({
|
|||||||
const key = e.target.getAttribute('value')
|
const key = e.target.getAttribute('value')
|
||||||
if (options[key].needData) {
|
if (options[key].needData) {
|
||||||
dataProvider
|
dataProvider
|
||||||
.getList('albumSong', songQueryParams)
|
.getList('song', songQueryParams)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
let { data, ids } = extractSongsData(response)
|
let { data, ids } = extractSongsData(response)
|
||||||
options[key].action(data, ids)
|
options[key].action(data, ids)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const PlayButton = ({ record, size, className }) => {
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const playAlbum = (record) => {
|
const playAlbum = (record) => {
|
||||||
dataProvider
|
dataProvider
|
||||||
.getList('albumSong', {
|
.getList('song', {
|
||||||
pagination: { page: 1, perPage: -1 },
|
pagination: { page: 1, perPage: -1 },
|
||||||
sort: { field: 'discNumber, trackNumber', order: 'ASC' },
|
sort: { field: 'discNumber, trackNumber', order: 'ASC' },
|
||||||
filter: { album_id: record.id, disc_number: record.discNumber },
|
filter: { album_id: record.id, disc_number: record.discNumber },
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ const dataProvider = jsonServerProvider(REST_URL, httpClient)
|
|||||||
|
|
||||||
const mapResource = (resource, params) => {
|
const mapResource = (resource, params) => {
|
||||||
switch (resource) {
|
switch (resource) {
|
||||||
case 'albumSong':
|
|
||||||
return ['song', params]
|
|
||||||
|
|
||||||
case 'playlistTrack':
|
case 'playlistTrack':
|
||||||
// /api/playlistTrack?playlist_id=123 => /api/playlist/123/tracks
|
// /api/playlistTrack?playlist_id=123 => /api/playlist/123/tracks
|
||||||
let plsId = '0'
|
let plsId = '0'
|
||||||
|
|||||||
Reference in New Issue
Block a user