Skip to content

Commit

Permalink
Set fallback values for statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Jan 7, 2024
1 parent 2ee4a33 commit f0eb626
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 23 deletions.
8 changes: 4 additions & 4 deletions frontend/src/Album/Delete/DeleteAlbumModalContent.js
Expand Up @@ -58,8 +58,8 @@ class DeleteAlbumModalContent extends Component {
} = this.props;

const {
trackFileCount,
sizeOnDisk
trackFileCount = 0,
sizeOnDisk = 0
} = statistics;

const deleteFiles = this.state.deleteFiles;
Expand Down Expand Up @@ -133,14 +133,14 @@ class DeleteAlbumModalContent extends Component {

<ModalFooter>
<Button onPress={onModalClose}>
Close
{translate('Close')}
</Button>

<Button
kind={kinds.DANGER}
onPress={this.onDeleteAlbumConfirmed}
>
Delete
{translate('Delete')}
</Button>
</ModalFooter>
</ModalContent>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Album/Details/AlbumDetails.js
Expand Up @@ -216,8 +216,8 @@ class AlbumDetails extends Component {
} = this.props;

const {
trackFileCount,
sizeOnDisk
trackFileCount = 0,
sizeOnDisk = 0
} = statistics;

const {
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/Album/Edit/EditAlbumModalContent.js
Expand Up @@ -43,6 +43,10 @@ class EditAlbumModalContent extends Component {
...otherProps
} = this.props;

const {
trackFileCount = 0
} = statistics;

const {
monitored,
anyReleaseOk,
Expand Down Expand Up @@ -96,7 +100,7 @@ class EditAlbumModalContent extends Component {
type={inputTypes.ALBUM_RELEASE_SELECT}
name="releases"
helpText={translate('ReleasesHelpText')}
isDisabled={anyReleaseOk.value && statistics.trackFileCount > 0}
isDisabled={anyReleaseOk.value && trackFileCount > 0}
albumReleases={releases}
onChange={onInputChange}
/>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Artist/Delete/DeleteArtistModalContent.js
Expand Up @@ -56,8 +56,8 @@ class DeleteArtistModalContent extends Component {
} = this.props;

const {
trackFileCount,
sizeOnDisk
trackFileCount = 0,
sizeOnDisk = 0
} = statistics;

const deleteFiles = this.state.deleteFiles;
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/Artist/Details/AlbumRow.js
Expand Up @@ -85,9 +85,9 @@ class AlbumRow extends Component {
} = this.props;

const {
trackCount,
trackFileCount,
totalTrackCount
trackCount = 0,
trackFileCount = 0,
totalTrackCount = 0
} = statistics;

return (
Expand Down Expand Up @@ -257,7 +257,8 @@ AlbumRow.propTypes = {
AlbumRow.defaultProps = {
statistics: {
trackCount: 0,
trackFileCount: 0
trackFileCount: 0,
totalTrackCount: 0
}
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Artist/Details/ArtistDetails.js
Expand Up @@ -222,8 +222,8 @@ class ArtistDetails extends Component {
} = this.props;

const {
trackFileCount,
sizeOnDisk
trackFileCount = 0,
sizeOnDisk = 0
} = statistics;

const {
Expand Down
Expand Up @@ -33,7 +33,11 @@ function AlbumStudioAlbum(props: AlbumStudioAlbumProps) {
isSaving = false,
} = props;

const { trackFileCount, totalTrackCount, percentOfTracks } = statistics;
const {
trackFileCount = 0,
totalTrackCount = 0,
percentOfTracks = 0,
} = statistics;

const dispatch = useDispatch();
const onAlbumMonitoredPress = useCallback(() => {
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/InteractiveImport/Album/SelectAlbumRow.js
Expand Up @@ -44,9 +44,9 @@ class SelectAlbumRow extends Component {
} = this.props;

const {
trackCount,
trackFileCount,
totalTrackCount
trackCount = 0,
trackFileCount = 0,
totalTrackCount = 0
} = statistics;

const extendedTitle = disambiguation ? `${title} (${disambiguation})` : title;
Expand Down Expand Up @@ -134,7 +134,8 @@ SelectAlbumRow.propTypes = {
SelectAlbumRow.defaultProps = {
statistics: {
trackCount: 0,
trackFileCount: 0
trackFileCount: 0,
totalTrackCount: 0
}
};

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/Store/Actions/artistIndexActions.js
Expand Up @@ -176,7 +176,7 @@ export const defaultState = {

const {
trackCount = 0,
trackFileCount
trackFileCount = 0
} = statistics;

const progress = trackCount ? trackFileCount / trackCount * 100 : 100;
Expand All @@ -201,7 +201,7 @@ export const defaultState = {
albumCount: function(item) {
const { statistics = {} } = item;

return statistics.albumCount;
return statistics.albumCount || 0;
},

trackCount: function(item) {
Expand Down Expand Up @@ -229,7 +229,7 @@ export const defaultState = {

const {
trackCount = 0,
trackFileCount
trackFileCount = 0
} = statistics;

const progress = trackCount ?
Expand Down

0 comments on commit f0eb626

Please sign in to comment.