Skip to content

Commit

Permalink
feat(youtube): Use just-validated history as recently played on new p…
Browse files Browse the repository at this point in the history
…lays #156

Rather than generating our own just use the known "good" history we just compared against to see if this improves consistency.
  • Loading branch information
FoxxMD committed Jun 26, 2024
1 parent c9ee97c commit db1e8c5
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/backend/sources/YTMusicSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ export default class YTMusicSource extends AbstractSource {
this.recentlyPlayed = plays;
newPlays = plays;
} else {

if(playsAreSortConsistent(this.recentlyPlayed, plays)) {
return newPlays;
}
Expand All @@ -251,20 +250,18 @@ ${humanDiff}`);
} else {
// new plays
newPlays = [...diff].reverse();
}
this.recentlyPlayed = plays;

if(newPlays.length > 0) {
newPlays = newPlays.map((x) => ({
data: {
...x.data,
playDate: dayjs().startOf('minute')
},
meta: {
...x.meta,
newFromSource: true
}
}));
this.recentlyPlayed = newPlays.concat(this.recentlyPlayed).slice(0, 20);
data: {
...x.data,
playDate: dayjs().startOf('minute')
},
meta: {
...x.meta,
newFromSource: true
}
}));
}
}

Expand Down

0 comments on commit db1e8c5

Please sign in to comment.