Skip to content

Feat/loggedout profile#6909

Open
Kota-Jagadeesh wants to merge 10 commits into
commons-app:mainfrom
Kota-Jagadeesh:feat/loggedout-profile
Open

Feat/loggedout profile#6909
Kota-Jagadeesh wants to merge 10 commits into
commons-app:mainfrom
Kota-Jagadeesh:feat/loggedout-profile

Conversation

@Kota-Jagadeesh

Copy link
Copy Markdown
Collaborator

Description (required)

Fixes #5754

What changes did you make and why?

This changes allows us to viewing another user's profile while logged out by using the profile username instead of the logged-in account when loading leaderboard data. and it also skips the unnecessary login checks for public profiles, preventing the "session expired" prompt and this allows the profile to remain accessible when navigating between the tabs.

Tests performed (required)

Tested Prodebug on Redmi Note 13 Pro with API level 35.

Screenshots (for UI changes only)

Screenrecorder-2026-06-28-11-31-31-52.mp4

dataSourceFactory.offset = offset
}

fun setUserName(userName: String?) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Could you check if we could leverage sessionManager.userName?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i initially looked into using that, but it represents the currently logged in user, but here we need the username of the profile being viewed. and those can be different when viewing another user's profile, so i passed the profile username through instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're setting this in the leaderboard fragment and not achievements fragment - is there any specific reason for it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're setting this in the leaderboard fragment and not achievements fragment - is there any specific reason for it?

yes there is a reason for that, the leaderboard flow goes through LeaderboardListViewModel and DataSourceFactory, so the viewed profile username wasn't available in the paging data source unless it was explicitly passed through. but the achievements flow already uses the fragment's userName directly when making the API call, so it didn't require the same change. please correct me if i am wrong :) Thanks

false
} else {
true
private fun checkAccount(): Boolean {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire function is a duplicate of what we have in the Achievements fragment, could you please raise a new issue for this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@chrisdebian

Copy link
Copy Markdown

checkAccount()'s new if (!userName.isNullOrBlank()) return true doesn't distinguish "viewing someone else's profile" from "viewing my own" — userName is populated from ProfileActivity.KEY_USERNAME for every profile view, including your own (confirmed in both AchievementsFragment.kt and LeaderboardFragment.kt). So this doesn't just skip the login check for public/other-user profiles as intended — it skips it unconditionally, including when viewing your own profile with an expired/invalid session, where the app should still prompt re-login. AchievementsFragment.kt already has the correct pattern nearby (line 91: sessionManager.userName == null || sessionManager.userName == userName) — worth using that same "is this actually my own profile" comparison instead of just checking userName is non-blank.

@Kota-Jagadeesh

Copy link
Copy Markdown
Collaborator Author

got it @chrisdebian, i'll update the condition to distinguish between the logged-in user's profile and another user's profile so the login check is only skipped for public profiles

@Kota-Jagadeesh

Copy link
Copy Markdown
Collaborator Author

@chrisdebian Made the required changes :)

@chrisdebian

Copy link
Copy Markdown

Nice fix on AchievementsFragment — that matches the pattern I flagged.

Looks like LeaderboardFragment.checkAccount() didn't get the same treatment though — it's still just if (!userName.isNullOrBlank()) return true, so it'll skip the login check unconditionally on your own profile too, same as before (userName is set from ProfileActivity.KEY_USERNAME on every profile view here as well). sessionManager.userName is already in scope a few lines below in this same function — worth comparing against it the same way AchievementsFragment.checkAccount() now does: userName != sessionManager.userName.

@Kota-Jagadeesh

Copy link
Copy Markdown
Collaborator Author

Looks like LeaderboardFragment.checkAccount() didn't get the same treatment though

Fixed it :)

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

✅ Generated APK variants!

@chrisdebian

Copy link
Copy Markdown

Confirmed — LeaderboardFragment.checkAccount() now matches the AchievementsFragment pattern exactly (userName != sessionManager.userName). That closes out both regressions I flagged. Nice work on a genuinely large PR.

@Kota-Jagadeesh

Copy link
Copy Markdown
Collaborator Author

Thanks @chrisdebian LMK if there are any changes to be made :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Provide the ability to view leaderboard of another user when logged out

3 participants