Skip to content

Commit

Permalink
Add retry handling for marking an episode as complete after track pla…
Browse files Browse the repository at this point in the history
…yback ended
  • Loading branch information
mitchdowney committed Apr 15, 2023
1 parent 9af3a53 commit 6735b08
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/services/playerAudioEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,21 @@ const audioResetHistoryItemByTrackId = async (loadedTrackId: string, position: n
downloadedEpisodeMarkForDeletion(currentNowPlayingItem.episodeId)
}

const forceUpdateOrderDate = false
const skipSetNowPlaying = true
const completed = true
await addOrUpdateHistoryItem(currentNowPlayingItem, 0, null, forceUpdateOrderDate, skipSetNowPlaying, completed)
const retriesLimit = 5
for (let i = 0; i < retriesLimit; i++) {
try {
const forceUpdateOrderDate = false
const skipSetNowPlaying = true
const completed = true
await addOrUpdateHistoryItem(
currentNowPlayingItem, 0, null, forceUpdateOrderDate, skipSetNowPlaying, completed)
break;
} catch (error) {
// Maybe the network request failed due to poor internet.
// continue to try again.
continue;
}
}
}
}
}
Expand Down

0 comments on commit 6735b08

Please sign in to comment.