Skip to content

Deferred DM - Add a loading wheel while creating the DM #7125

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

Merged
merged 6 commits into from
Sep 19, 2022

Conversation

Florian14
Copy link
Contributor

@Florian14 Florian14 commented Sep 14, 2022

Type of change

  • WIP Feature
  • Bugfix
  • Technical
  • Other :

Content

While creating the DM (ie. after sending the first message), a loading wheel is now displayed until switching to the created room.
In case of failure, the loading wheel is hidden to unblock the UI.

Motivation and context

close #6970

Screenshots / GIFs

Tests

  • Create a DM on first message
  • Verify that a loading wheel is shown during the process creation

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Florian14 Florian14 requested review from a team and ganfra and removed request for a team September 14, 2022 14:54
@ElementBot
Copy link

ElementBot commented Sep 14, 2022

Warnings
⚠️

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt#L1127 - Prefer "SHOW_AS_ACTION_IF_ROOM" instead of "SHOW_AS_ACTION_ALWAYS"

⚠️

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt#L1127 - Prefer "SHOW_AS_ACTION_IF_ROOM" instead of "SHOW_AS_ACTION_ALWAYS"

Generated by 🚫 dangerJS against eac74bd

@Florian14 Florian14 requested a review from bmarty September 14, 2022 15:58
@Florian14 Florian14 changed the title Start DM - Add a loading wheel while creating the DM Deferred DM - Add a loading wheel while creating the DM Sep 16, 2022
@Florian14 Florian14 added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Sep 16, 2022
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.

Nice work, (didn't test it).
One small remark

private suspend fun createRoom(localRoomSummary: LocalRoomSummary): String {
updateCreationState(localRoomSummary.roomId, LocalRoomCreationState.CREATING)
val replacementRoomId = runCatching {
createRoomTask.execute(localRoomSummary.createRoomParams!!)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe check if createRoomParams is not null? Not sure it's possible
And throw a specific error if any?

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 checked at line 60, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I improved the code to avoid the use of !! eac74bd

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks, small remarks, else LGTM!

private suspend fun createRoom(localRoomSummary: LocalRoomSummary): String {
updateCreationState(localRoomSummary.roomId, LocalRoomCreationState.CREATING)
val replacementRoomId = runCatching {
createRoomTask.execute(localRoomSummary.createRoomParams!!)
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 checked at line 60, no?

?.replacementRoomId
val localRoomSummary = roomSummaryDataSource.getLocalRoomSummary(params.localRoomId)
?.takeIf { it.createRoomParams != null && it.roomSummary != null }
?: error("Invalid LocalRoomSummary for ${params.localRoomId}")
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the rework :)

LocalRoomCreationState.CREATING ->
_viewEvents.post(RoomDetailViewEvents.ShowWaitingView(stringProvider.getString(R.string.creating_direct_room)))
LocalRoomCreationState.FAILURE -> {
_viewEvents.post(RoomDetailViewEvents.HideWaitingView)
Copy link
Member

Choose a reason for hiding this comment

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

Can we provide some detail of the failure to the user? (maybe not blocking).
Also, not tested, but maybe try to create a DM in airplane mode to ensure that there is no crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried, sometimes the loading wheel is shown before being hidden, sometimes not, depending on the event position in the events queue. There is no crash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of error (network or server), we just have the same feedback as for a normal message. We should probably sync with the product to show more details:
image

@Florian14 Florian14 force-pushed the feature/fre/start_dm_loading branch from 821292a to eac74bd Compare September 19, 2022 07:38
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

34.6% 34.6% Coverage
0.0% 0.0% Duplication

@Florian14 Florian14 merged commit b4ca167 into develop Sep 19, 2022
@Florian14 Florian14 deleted the feature/fre/start_dm_loading branch September 19, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Start DM] Add a spinner when sending the first message
4 participants