Skip to content

Commit

Permalink
fix: fixes #403 - cannot read shuffle of undefined error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastermindzh committed May 20, 2024
1 parent 3740ce5 commit b481108
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [next]

- Fixed [#403](https://github.com/Mastermindzh/tidal-hifi/issues/403) "cannot read shuffle of undefined" error

## [5.12.0]

- Added Shuffle and Repeat state to API response - By [ThatGravyBoat](https://github.com/ThatGravyBoat)
Expand Down
2 changes: 1 addition & 1 deletion src/models/mediaInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export interface MediaInfo {
durationInSeconds?: number;
image: string;
favorite: boolean;
player: MediaPlayerInfo;
player?: MediaPlayerInfo;
}
10 changes: 6 additions & 4 deletions src/scripts/mediaInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const mediaInfo = {
status: MediaStatus.paused as string,
shuffle: false,
repeat: RepeatState.off as string,
}
},
};

export const updateMediaInfo = (arg: MediaInfo) => {
Expand All @@ -37,9 +37,11 @@ export const updateMediaInfo = (arg: MediaInfo) => {
mediaInfo.image = propOrDefault(arg.image);
mediaInfo.favorite = arg.favorite;

mediaInfo.player.status = propOrDefault(arg.player?.status);
mediaInfo.player.shuffle = arg.player.shuffle;
mediaInfo.player.repeat = propOrDefault(arg.player?.repeat);
mediaInfo.player = {
status: propOrDefault(arg.player?.status),
shuffle: arg.player?.shuffle ?? false,
repeat: propOrDefault(arg.player?.repeat),
};
};

/**
Expand Down

0 comments on commit b481108

Please sign in to comment.