Skip to content

Conversation

@ittipatken
Copy link
Member

@ittipatken
Copy link
Member Author

The bug comes from lastPlayedVideoKey localCompare. It does not compare anything because the .updated_at or in this case played_at data is not in the history. So, the lastPlayedVideoKey becomes the video that has least amount of id value.

this.lastPlayedVideoKey = Object.values(history).map(h => h.video_id).sort((a, b) => {
// force history[b].updated_at to be a string
// @ts-ignore
return ('' + history[b].updated_at).localeCompare(history[a].updated_at);
}).slice(0, 1)[0] ?? null;

For example, this is the results from console.log(history),

{
  "224": {
    "video_id": 224,
    "end_time": 1697,
    "speed": "1.000"
  },
  "225": {
    "video_id": 225,
    "end_time": 4536,
    "speed": "1.478"
  },
}

, this will return the video 224 as the lastPlayedVideoKey.

@keenthekeen keenthekeen marked this pull request as ready for review September 13, 2025 14:09
@keenthekeen keenthekeen merged commit f5f0b26 into master Sep 13, 2025
@ittipatken ittipatken deleted the fix-last-played branch September 13, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants