Correctly Show View Count for Video when there is Zero Views
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
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).
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
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.
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.
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.
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.