Fixed: Toolbar buttons enabled when no tracks exist for Album

pull/6/head
Qstick 6 years ago
parent 98b610b12e
commit 3cd58d5866

@ -192,6 +192,7 @@ class AlbumDetails extends Component {
isPopulated,
albumsError,
trackFilesError,
hasTrackFiles,
shortDateFormat,
artist,
previousAlbum,
@ -243,18 +244,21 @@ class AlbumDetails extends Component {
<PageToolbarButton
label="Preview Rename"
iconName={icons.ORGANIZE}
isDisabled={!hasTrackFiles}
onPress={this.onOrganizePress}
/>
<PageToolbarButton
label="Preview Retag"
iconName={icons.RETAG}
isDisabled={!hasTrackFiles}
onPress={this.onRetagPress}
/>
<PageToolbarButton
label="Manage Tracks"
iconName={icons.TRACK_FILE}
isDisabled={!hasTrackFiles}
onPress={this.onManageTracksPress}
/>
@ -576,6 +580,7 @@ AlbumDetails.propTypes = {
albumsError: PropTypes.object,
tracksError: PropTypes.object,
trackFilesError: PropTypes.object,
hasTrackFiles: PropTypes.bool.isRequired,
artist: PropTypes.object,
previousAlbum: PropTypes.object,
nextAlbum: PropTypes.object,

@ -16,11 +16,32 @@ import AlbumDetails from './AlbumDetails';
import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector';
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
const selectTrackFiles = createSelector(
(state) => state.trackFiles,
(trackFiles) => {
const {
items,
isFetching,
isPopulated,
error
} = trackFiles;
const hasTrackFiles = !!items.length;
return {
isTrackFilesFetching: isFetching,
isTrackFilesPopulated: isPopulated,
trackFilesError: error,
hasTrackFiles
};
}
);
function createMapStateToProps() {
return createSelector(
(state, { foreignAlbumId }) => foreignAlbumId,
(state) => state.tracks,
(state) => state.trackFiles,
selectTrackFiles,
(state) => state.albums,
createAllArtistSelector(),
createCommandsSelector(),
@ -35,14 +56,20 @@ function createMapStateToProps() {
return {};
}
const {
isTrackFilesFetching,
isTrackFilesPopulated,
trackFilesError,
hasTrackFiles
} = trackFiles;
const previousAlbum = sortedAlbums[albumIndex - 1] || _.last(sortedAlbums);
const nextAlbum = sortedAlbums[albumIndex + 1] || _.first(sortedAlbums);
const isSearching = !!findCommand(commands, { name: commandNames.ALBUM_SEARCH });
const isFetching = tracks.isFetching || trackFiles.isFetching;
const isPopulated = tracks.isPopulated && trackFiles.isPopulated;
const isFetching = tracks.isFetching || isTrackFilesFetching;
const isPopulated = tracks.isPopulated && isTrackFilesPopulated;
const tracksError = tracks.error;
const trackFilesError = trackFiles.error;
return {
...album,
@ -53,6 +80,7 @@ function createMapStateToProps() {
isPopulated,
tracksError,
trackFilesError,
hasTrackFiles,
previousAlbum,
nextAlbum
};

Loading…
Cancel
Save