Fix note detail showing "/ 0 (-N remaining)" for unlimited views#65
Open
Osamaali313 wants to merge 1 commit into
Open
Fix note detail showing "/ 0 (-N remaining)" for unlimited views#65Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
In the MyUploads TUI note-detail panel, the view counter renders:
{liveNote.viewCount} / {liveNote.maxViews}
<Text dimColor> ({liveNote.maxViews - liveNote.viewCount} remaining)</Text>
`maxViews === 0` means "unlimited" and is the default (server config
NOTE_DEFAULT_VIEWS = "0", and the server treats 0 as unlimited). So a
default note viewed 3 times shows `Views: 3 / 0 (-3 remaining)` — a
nonsensical `/ 0` and a negative "remaining", implying the link is
exhausted when it is not.
Every other place that renders view counts special-cases 0: the CLI
`list` (`maxViews === 0 ? \`${viewCount} / ∞\``), the web `NoteCard`, and
the client `note` command (`maxViews === 0 ? "unlimited"`). Mirror them:
show ∞ for unlimited and only show the "remaining" hint when there is a
finite limit. (The adjacent uploads panel uses the same `max - count`
pattern correctly because `maxDownloads` is schema-validated positive and
can never be 0.)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Owner
|
Hey @Osamaali313 Thanks for your contribution. Thanks :) |
Author
|
Thanks @Skyfay, glad it helps — happy to adjust anything if needed when you pull it into the next release. Appreciate the quick response! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the MyUploads TUI note-detail panel (
apps/client/src/tui/views/MyUploads.tsx), the view counter renders unconditionally:But
maxViews === 0means unlimited, and it's the default (NOTE_DEFAULT_VIEWS = "0"in the server config; the server treats0as unlimited throughout). So a default note that's been viewed 3 times renders:— a nonsensical
/ 0and a negative "remaining", implying the link is exhausted when it isn't.Evidence (siblings prove intent)
Every other place that renders view counts special-cases
0:list:n.maxViews === 0 ? \${n.viewCount} / ∞` : …`NoteCard:info.maxViews === 0 ? …notecommand:Views: ${maxViews === 0 ? "unlimited" : maxViews}Only this TUI panel doesn't. (The adjacent uploads panel uses the same
max - countpattern correctly, becausemaxDownloadsis schema-validated positive and can never be0.)Fix
Mirror the siblings — show
∞for unlimited and only show the "remaining" hint for a finite limit:Reproduction
Default (unlimited) note viewed 3×:
Views: 3 / 0 (-3 remaining)❌Views: 3 / ∞✅