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

Feature/fga/mark room as favorite #2397

Merged
merged 17 commits into from
Feb 15, 2024
Merged

Conversation

ganfra
Copy link
Member

@ganfra ganfra commented Feb 15, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Add ways to mark a room as favourite from room list and room details.

Motivation and context

Closes #2208

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@ganfra ganfra added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Feb 15, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Feb 15, 2024
@ganfra ganfra marked this pull request as ready for review February 15, 2024 10:30
@ganfra ganfra requested a review from a team as a code owner February 15, 2024 10:30
@ganfra ganfra requested review from jmartinesp and removed request for a team February 15, 2024 10:30
Copy link
Contributor

github-actions bot commented Feb 15, 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/nVrSpp

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

A couple of comments, otherwise LGTM!

hasNewContent = event.roomListRoomSummary.hasNewContent
)
contextMenuState.value = initialState
client.getRoom(event.roomListRoomSummary.roomId)?.use { room ->
Copy link
Member

Choose a reason for hiding this comment

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

I think instead of returning a job to be manually cancelled, you could create a Flow<RoomListState.ContextMenu> with snapshowFlow here and use .takeWhile { ... }. I'm not sure if it's more convoluted, but it looks a bit less error-prone to me.

Copy link
Member

Choose a reason for hiding this comment

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

Let me know if you want me to take a look at it while you're (in theory 😅 ) away.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've pushed the changes, let me know!

Copy link
Member

Choose a reason for hiding this comment

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

It feels a bit weird the takeWhile is after the onEach, but it works well enough and it's simpler than using combine() and passing an extra parameter everywhere. LGTM!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I don't know if it's better or worse actually, but I guess the result is almost the same.

Copy link
Member Author

@ganfra ganfra Feb 15, 2024

Choose a reason for hiding this comment

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

This is how it looks with combine instead :

            val isContextMenuShownFlow = snapshotFlow { contextMenuState.value is RoomListState.ContextMenu.Shown }
                .distinctUntilChanged()

            val isFavoriteFlow = room.roomInfoFlow
                .map { it.isFavorite }
                .distinctUntilChanged()

            combine(isContextMenuShownFlow, isFavoriteFlow) { isContextMenuShown, isFavorite ->
                isContextMenuShown to isFavorite
            }
                .takeWhile { (isShowingContextMenu, _) -> isShowingContextMenu }
                .onEach { (_, isFavorite) ->
                    contextMenuState.value = initialState.copy(
                        isFavorite = isFavorite,
                    )
                }
                .collect()
        }

Let me know which one you prefer :P

Copy link
Member

Choose a reason for hiding this comment

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

This is what I had tested locally. The previous version seems simpler, right? It's a bit harder to understand why it's after the onEach, but as long as we have at least 1 item emitted by the room info flow it should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you put it before it doesn't work because it won't cancel the stream because of the flatMapLatest creating a new stream.

Also the statement "as long as we have at least 1 item emitted by the room info flow it should be fine" is true also for the combine operator

@@ -20,4 +20,5 @@ sealed interface RoomDetailsEvent {
data object LeaveRoom : RoomDetailsEvent
data object MuteNotification : RoomDetailsEvent
data object UnmuteNotification : RoomDetailsEvent
data class SetIsFavorite(val isFavorite: Boolean) : RoomDetailsEvent
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd use SetFavorite instead

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (6adff9a) 72.13% compared to head (3893db3) 72.16%.

Files Patch % Lines
...droid/features/roomdetails/impl/RoomDetailsView.kt 50.00% 2 Missing and 4 partials ⚠️
...ndroid/features/roomlist/impl/RoomListPresenter.kt 85.18% 0 Missing and 4 partials ⚠️
...roid/features/roomlist/impl/RoomListContextMenu.kt 85.71% 1 Missing and 1 partial ⚠️
.../features/roomdetails/impl/RoomDetailsPresenter.kt 80.00% 0 Missing and 1 partial ⚠️
...droid/libraries/matrix/test/room/FakeMatrixRoom.kt 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2397      +/-   ##
===========================================
+ Coverage    72.13%   72.16%   +0.02%     
===========================================
  Files         1359     1359              
  Lines        32123    32196      +73     
  Branches      6277     6289      +12     
===========================================
+ Hits         23173    23233      +60     
- Misses        5696     5700       +4     
- Partials      3254     3263       +9     

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

@ganfra ganfra added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Feb 15, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Feb 15, 2024
@ganfra ganfra disabled auto-merge February 15, 2024 12:33
@ganfra
Copy link
Member Author

ganfra commented Feb 15, 2024

Not sure why, but something is wrong with the kover

Rule 'Global minimum code coverage.' violated: instructions covered percentage is 83.333300, but expected minimum is 65

Copy link

sonarcloud bot commented Feb 15, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

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

See analysis details on SonarCloud

@ganfra ganfra added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Feb 15, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Feb 15, 2024
@ganfra ganfra merged commit 34ab25e into develop Feb 15, 2024
18 checks passed
@ganfra ganfra deleted the feature/fga/mark_room_as_favorite branch February 15, 2024 16:18
present()
}
}.test(validate = validate)
}
Copy link
Member

Choose a reason for hiding this comment

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

❤️

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.

[Task] Mark a room or dm as favourite
3 participants