Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room member details presenter improvement #2721

Merged
merged 8 commits into from
Apr 17, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Apr 17, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

First commit: ensure that "ignore" user state is live by observing ignoredUsersFlow
Second commit: fallback to userProfile data, if the member is not a user of the room. (I am adding a test about it).

For instance, when clicking on https://matrix.to/#/@Giom:matrix.org when the user is not a member of the room:

Before After
image image

Motivation and context

Screenshots / GIFs

Tests

  • Send some user permalink to a room
  • Click on the links and see how the application behaves

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

bmarty added 2 commits April 17, 2024 13:21
This will also ensure that blocking a user will work even if the user is not a member of the room (preparatory work for user permalink)
… is not a member of the room.

This can be displayed when the user click on a non-member user permalink.
@bmarty bmarty requested a review from a team as a code owner April 17, 2024 11:30
@bmarty bmarty requested review from ganfra and removed request for a team April 17, 2024 11:30
Copy link
Contributor

github-actions bot commented Apr 17, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/NSkSh2

Copy link

codecov bot commented Apr 17, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.14%. Comparing base (e971218) to head (f9d3f94).

❗ Current head f9d3f94 differs from pull request most recent head 5b3a2d8. Consider uploading reports for the commit 5b3a2d8 to get more accurate results

Files Patch % Lines
...impl/members/details/RoomMemberDetailsPresenter.kt 69.23% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2721      +/-   ##
===========================================
- Coverage    73.15%   73.14%   -0.01%     
===========================================
  Files         1480     1480              
  Lines        35803    35799       -4     
  Branches      6876     6873       -3     
===========================================
- Hits         26192    26186       -6     
+ Misses        6052     6051       -1     
- Partials      3559     3562       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Some remarks otherwise LGTM

mutableStateOf(AsyncData.Success(isIgnored))
}
val isBlocked: MutableState<AsyncData<Boolean>> = remember { mutableStateOf(AsyncData.Uninitialized) }
LaunchedEffect(Unit) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd use collectAsState instead

@@ -56,21 +60,24 @@ class RoomMemberDetailsPresenter @AssistedInject constructor(
val coroutineScope = rememberCoroutineScope()
var confirmationDialog by remember { mutableStateOf<ConfirmationDialog?>(null) }
val roomMember by room.getRoomMemberAsState(roomMemberId)
var userProfile by remember { mutableStateOf<MatrixUser?>(null) }
Copy link
Member

Choose a reason for hiding this comment

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

Use produceByState :

val userProfile by produceState<MatrixUser?>(initialValue = null) {
            value = client.getProfile(roomMemberId).getOrNull()
}

room.userAvatarUrl(roomMemberId).onSuccess { avatarUrl ->
if (avatarUrl != null) value = avatarUrl
}
var userAvatar: String? by remember { mutableStateOf(roomMember?.avatarUrl ?: userProfile?.avatarUrl) }
Copy link
Member

Choose a reason for hiding this comment

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

Keep produceState as it makes the var a val (and it's cleaner IMO)

val userName by produceState(initialValue = roomMember?.displayName ?: userProfile?.displayName, roomMember, userProfile){
            value = room.userDisplayName(roomMemberId)
                .fold(
                    onSuccess = { it },
                    onFailure = { userProfile?.displayName }
                )
        }

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@bmarty bmarty merged commit e326824 into develop Apr 17, 2024
14 checks passed
@bmarty bmarty deleted the feature/bma/roomMemberDetailsPresenterImprovement branch April 17, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants