Skip to content

Commit

Permalink
fix: undifined with unplay episode when mark as play or mark as unplay
Browse files Browse the repository at this point in the history
  • Loading branch information
viethung0823 committed May 25, 2024
1 parent f1e10bd commit 137bac9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const playedEpisodes = (function () {
},
markAsPlayed: (episode: Episode) => {
update((playedEpisodes) => {
const playedEpisode = playedEpisodes[episode.title];
const playedEpisode = playedEpisodes[episode.title] || episode;

if (playedEpisode) {
playedEpisode.time = playedEpisode.duration;
Expand All @@ -86,7 +86,7 @@ export const playedEpisodes = (function () {
},
markAsUnplayed: (episode: Episode) => {
update((playedEpisodes) => {
const playedEpisode = playedEpisodes[episode.title];
const playedEpisode = playedEpisodes[episode.title] || episode;

if (playedEpisode) {
playedEpisode.time = 0;
Expand Down Expand Up @@ -241,13 +241,13 @@ export const localFiles = function () {
set,
getLocalEpisode: (title: string): LocalEpisode | undefined => {
const ep = get(store).episodes.find(ep => ep.title === title);

return ep as LocalEpisode;
},
updateStreamUrl: (title: string, newUrl: string): void => {
store.update((playlist) => {
const idx = playlist.episodes.findIndex(ep => ep.title === title);

if (idx !== -1) playlist.episodes[idx].streamUrl = newUrl;

return playlist;
Expand Down

0 comments on commit 137bac9

Please sign in to comment.