Skip to content

Add Shorten view count numbers using K, M, B suffixes - #9721

Open
ozrendev wants to merge 3 commits into
FreeTubeApp:developmentfrom
ozrendev:add-view-short-notation
Open

Add Shorten view count numbers using K, M, B suffixes#9721
ozrendev wants to merge 3 commits into
FreeTubeApp:developmentfrom
ozrendev:add-view-short-notation

Conversation

@ozrendev

Copy link
Copy Markdown
Contributor

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

closes #9522

Description

Adds a helper function to detect if a number (view count) has been rounded
Calls this function when displaying view counts and shortens the number as per Intl.NumberFormat formatting if true

Testing

Search for any video, see that returned search results view count is not shortened as they contain exact numbers
Watch any video, see recommended videos rounded view count have now been shortened

@FreeTubeBot
FreeTubeBot enabled auto-merge (squash) August 31, 2026 08:58
@github-actions github-actions Bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Aug 31, 2026
Comment thread src/renderer/helpers/utils.js Outdated
@Shadorc Shadorc added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Aug 31, 2026
auto-merge was automatically disabled August 31, 2026 11:41

Head branch was pushed to by a user without write access

@FreeTubeBot
FreeTubeBot enabled auto-merge (squash) August 31, 2026 11:41
@Shadorc

Shadorc commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This is a little bit beyond the initial issue, but I remarked that comment likes have the same issue, they will be displayed as "202000" or "2200" instead of "202k" and "2k2"
I'm wondering if this should be a separate issue or if this could be part of this one

@ozrendev

ozrendev commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

This is a little bit beyond the initial issue, but I remarked that comment likes have the same issue, they will be displayed as "202000" or "2200" instead of "202k" and "2k2" I'm wondering if this should be a separate issue or if this could be part of this one

I think this would be within scope and I'm happy to add it. If we're doing this, then I feel we should make it consistent wherever the number is rounded.

I've also found it in these places, let me know if I missed anywhere:

  • Comment likes
  • Post likes
  • Channel subscriber count under channel thumbnail on search
  • Channel subscriber count on main channel view

Then as you suggested, it would make sense to have this as function with an argument for number of zeroes to check for. We would also have to decide at which point it should use short notation. For now it only catches a view count >= 10,000, while technically view counts in the thousands are also rounded.

If we lower this, the chances of a non-rounded, but matching number will be caught. For example in search results, one video may by chance have 1,234,500 views and be affected, while all others around it would not.

@Shadorc

Shadorc commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

There is something I'm missing, we have view count that are displayed with the same component but sometimes in places where YouTube shorten them and sometimes not, and there is no way to determine that?

I can't really search myself because I don't have access to a computer, but if the previous answer is yes, will it be possible to determine the places where YouTube shorten the counts, and pass a bool to the component to indicate that "this element contains only shorten count" ?

For the other places where shorten count appear, I would agree to do the same, but I would prefer that a code owner answer.

@absidue

absidue commented Sep 2, 2026

Copy link
Copy Markdown
Member

Okay so clearly someone else needs to step in again here and steer the two of you back into the correct direction.

Firstly @Shadorc I already said that saving extra data just for this was a bad idea in the linked issue, not only is it unnecessary because you can just do some math on the number to figure it out but would also mean that we would only display numbers that were saved after this pull request in compact notation. So please lets not go back to that.

Secondly @ozrendev most of that code should not be in the template, it makes it harder to read and also means it runs more often than necessary. Video gets marked as watched, that formatting code gets run again, video gets added or removed from a playlist, you guessed it it runs again, etc. This is a prime candidate for a computed ref.

As for the actual implementation of detecting which numbers should be compacted, which you are both stuck on, maybe I am missing something but, it should be as simple as this pseudo code:

if number >= 1000000000 // billion
  if last 8 digits are 0
    return true
  else
    return false
if number >= 1000000 // million
  if last five digits are 0
    return true
  else
    return false
if number >= 1000 // thousands
  if last two digits are 0
    return true
  else
    return false

@Shadorc

Shadorc commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The possible issue with that was if we have for example three view counts that are not shorten 1234, 1200, 4567, the second one would be shorten. There is only 1% chance that it happens per video, si this could be considered minor enough to be ignored.

@ozrendev

ozrendev commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I've made the above changes now. This logic works with way the view count is returned, I just used switch as I felt it's easier to read.

The possible issue with that was if we have for example three view counts that are not shorten 1234, 1200, 4567, the second one would be shorten. There is only 1% chance that it happens per video, si this could be considered minor enough to be ignored.

I think with this approach it just may have to happen. When the view count gets higher, it becomes such a rare chance anyway.

@ozrendev ozrendev added PR: waiting for review For PRs that are complete, tested, and ready for review and removed PR: changes requested labels Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: waiting for review For PRs that are complete, tested, and ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Shorten view count numbers using K, M, B suffixes

3 participants