🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Optimized call to retrieve album songs
Deluana7640c9df471
diff --git a/ui/src/common/AlbumContextMenu.js b/ui/src/common/AlbumContextMenu.jsindex e1ce0beb4..c0bd72f5a 100644--- a/ui/src/common/AlbumContextMenu.js+++ b/ui/src/common/AlbumContextMenu.js@@ -34,19 +34,19 @@ const AlbumContextMenu = ({ record, discNumber, color, visible }) => {const options = {play: {- label: translate('resources.album.actions.playAll'),+ label: 'resources.album.actions.playAll',action: playTracks,},addToQueue: {- label: translate('resources.album.actions.addToQueue'),+ label: 'resources.album.actions.addToQueue',action: addTracks,},shuffle: {- label: translate('resources.album.actions.shuffle'),+ label: 'resources.album.actions.shuffle',action: shuffleTracks,},addToPlaylist: {- label: translate('resources.song.actions.addToPlaylist'),+ label: 'resources.song.actions.addToPlaylist',action: (data, ids) => openAddToPlaylist({ selectedIds: ids }),},}@@ -63,17 +63,12 @@ const AlbumContextMenu = ({ record, discNumber, color, visible }) => {e.stopPropagation()}- let extractSongsData = function (response, discNumber) {+ let extractSongsData = function (response) {const data = response.data.reduce((acc, cur) => ({ ...acc, [cur.id]: cur }),{})-- const ids = response.data- // Select only songs from discNumber if it is specified- .filter((r) => !discNumber || r.discNumber === discNumber)- .map((r) => r.id)-+ const ids = response.data.map((r) => r.id)return { data, ids }}@@ -84,10 +79,10 @@ const AlbumContextMenu = ({ record, discNumber, color, visible }) => {.getList('albumSong', {pagination: { page: 1, perPage: -1 },sort: { field: 'discNumber, trackNumber', order: 'ASC' },- filter: { album_id: record.id },+ filter: { album_id: record.id, disc_number: discNumber },}).then((response) => {- let { data, ids } = extractSongsData(response, discNumber)+ let { data, ids } = extractSongsData(response)dispatch(options[key].action(data, ids))}).catch(() => {@@ -123,7 +118,7 @@ const AlbumContextMenu = ({ record, discNumber, color, visible }) => {>{Object.keys(options).map((key) => (<MenuItem value={key} key={key} onClick={handleItemClick}>- {options[key].label}+ {translate(options[key].label)}</MenuItem>))}</Menu>diff --git a/ui/src/common/SongContextMenu.js b/ui/src/common/SongContextMenu.jsindex 62faaf759..4be70f593 100644--- a/ui/src/common/SongContextMenu.js+++ b/ui/src/common/SongContextMenu.js@@ -39,15 +39,15 @@ const SongContextMenu = ({const [anchorEl, setAnchorEl] = useState(null)const options = {playNow: {- label: translate('resources.song.actions.playNow'),+ label: 'resources.song.actions.playNow',action: (record) => setTrack(record),},addToQueue: {- label: translate('resources.song.actions.addToQueue'),+ label: 'resources.song.actions.addToQueue',action: (record) => addTracks({ [record.id]: record }),},addToPlaylist: {- label: translate('resources.song.actions.addToPlaylist'),+ label: 'resources.song.actions.addToPlaylist',action: (record) =>openAddToPlaylist({selectedIds: [record.mediaFileId || record.id],@@ -130,7 +130,7 @@ const SongContextMenu = ({>{Object.keys(options).map((key) => (<MenuItem value={key} key={key} onClick={handleItemClick}>- {options[key].label}+ {translate(options[key].label)}</MenuItem>))}</Menu>