FreeTube icon indicating copy to clipboard operation
FreeTube copied to clipboard

Correctly Show View Count for Video when there is Zero Views

Open SudharakaP opened this issue 1 year ago • 6 comments

Title

Correctly Show View Count for Video when there is Zero Views

Pull Request Type

  • [x] Bugfix
  • [ ] Feature Implementation
  • [ ] Documentation
  • [ ] Other

Related issue

Resolve https://github.com/FreeTubeApp/FreeTube/issues/6568

Description

This PR solve the issue of showing NaN Views when there's zero view count for a video

Screenshots

image

SudharakaP avatar Jan 16 '25 20:01 SudharakaP

Please change it in the local API parsing not in the display code. If we know that there are zero views we should show 0 views, we only hide stuff when the information is not available (e.g. published dates on the channel shorts tab).

absidue avatar Jan 16 '25 20:01 absidue

Please change it in the local API parsing not in the display code. If we know that there are zero views we should show 0 views, we only hide stuff when the information is not available (e.g. published dates on the channel shorts tab).

@absidue : Done, let me know if you see any issues

SudharakaP avatar Jan 16 '25 21:01 SudharakaP

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Feb 11 '25 01:02 github-actions[bot]

That is a display issue, isn't it? Should the function extractNumberFromString(str) really return zero if there's no number in the string? NaN is clearly more appropriate.

Displaying a NaN view count as zero should be safe. Redefining NaN to be zero? Not so much.

dinglerod avatar Feb 23 '25 19:02 dinglerod

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Mar 18 '25 02:03 github-actions[bot]

That is a display issue, isn't it? Should the function extractNumberFromString(str) really return zero if there's no number in the string? NaN is clearly more appropriate.

Displaying a NaN view count as zero should be safe. Redefining NaN to be zero? Not so much.

Its not redefining NaN to be zero. The function is only called when a number is going to be displayed on the page, and there is never a case where NaN is a wanted output value.

Changing the return value in this function is a way of nipping most issues with NaN displaying on the page in the bud.

MarmadileManteater avatar Mar 20 '25 10:03 MarmadileManteater