Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for DeArrow #4276

Merged
merged 1 commit into from
Jul 20, 2023
Merged

feat: support for DeArrow #4276

merged 1 commit into from
Jul 20, 2023

Conversation

Bnyro
Copy link
Member

@Bnyro Bnyro commented Jul 20, 2023

No description provided.

@Bnyro Bnyro merged commit 1a959bc into libre-tube:master Jul 20, 2023
@Bnyro Bnyro deleted the dearrow branch July 20, 2023 13:01
Comment on lines +22 to +27
val newTitle = content.titles.maxByOrNull { it.votes }?.title
val newThumbnail =
content.thumbnails.filter { it.thumbnail != null }.maxByOrNull { it.votes }
?.takeIf { !it.original }?.thumbnail
return newTitle to newThumbnail
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array is presorted optimally (manually approved submissions above others even if less votes). Just take the first element.

However, you still need to make sure the top value is valid, as it will return submissions at -1 votes.

        val newTitle = content.titles.firstOrNull?.takeIf { it.votes >= 0 || it.locked }.title
        val newThumbnail =
            content.thumbnails.filter { it.thumbnail != null }.firstOrNull?.takeIf { (it.votes >= 0 || it.locked) && !it.original }?.thumbnail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks!

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