Skip to content

🐞[Bug]: article detail screen does not display view count correctly #1351

Description

@Aarushiprajapati

Related Area

Frontend

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Bug description

The article detail screen renders a boolean expression for viewCount instead of a readable view-count label.

In frontend/src/screens/article/ArticleScreen.tsx, the view count is currently rendered like this:

{article?.viewCount
  ? article.viewCount > 1
  : `${article.viewCount} view`}  

When article.viewCount is greater than 0, the expression returns true or false instead of text such as 1 view or 12 views. React Native does not render booleans as useful user-facing text, so the article view count can appear missing or incorrect.

Steps to reproduce

  1. Open the UltimateHealth mobile app.
  2. Navigate to any published article that has viewCount > 0.
  3. Look at the view-count text near the top of the article detail screen.

Actual behavior

The UI evaluates article.viewCount > 1 and does not show a proper view-count label for articles with views.

Expected behavior

The article detail screen should show a readable count:

0 views
1 view
2 views
125 views

Add ScreenShots

Suggested fix
Replace the boolean expression with formatted text:

{`${article.viewCount ?? 0} ${(article.viewCount ?? 0) === 1 ? 'view' : 'views'}`}
Optional improvement: move this into a small helper such as formatViewCount(count?: number) and add a unit test for 0, 1, and plural counts.

What browsers are you seeing the problem on?

No response

Record

  • I have read the Contributing Guidelines
  • I'm a GSSOC'24 contributor
  • I'm a GSSOC'26 contributor
  • I'm a IEEE IGDTUW contributor
  • I want to work on this issue

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions