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

Load existing DM instead of creating a new one #4157

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

Florian14
Copy link
Contributor

@Florian14 Florian14 commented Oct 4, 2021

In previous implementation, existing DM was checked only for QR code invites.
This PR moves this check in the ViewModel side (which makes more sense) and applies it for 1:1 in both cases (QR and user invites).

@Florian14 Florian14 requested a review from bmarty October 4, 2021 13:35
@Florian14 Florian14 force-pushed the feature/fre/create_dm_improvement branch from 71d551c to 17bcf90 Compare October 4, 2021 13:44
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.

LGTM

@github-actions
Copy link

github-actions bot commented Oct 4, 2021

Unit Test Results

  42 files  ±0    42 suites  ±0   42s ⏱️ ±0s
  83 tests ±0    83 ✔️ ±0  0 💤 ±0  0 ±0 
220 runs  ±0  220 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 94bbd37. ± Comparison against base commit 94bbd37.

♻️ This comment has been updated with latest results.

@bmarty
Copy link
Member

bmarty commented Oct 4, 2021

@Florian14 do you thing this can close #2893?

@Florian14
Copy link
Contributor Author

@Florian14 do you thing this can close #2893?

@bmarty I think so, just tested before and after my PR, work fine now.

@bmarty bmarty merged commit 94bbd37 into develop Oct 5, 2021
@bmarty bmarty deleted the feature/fre/create_dm_improvement branch October 5, 2021 10:26
@@ -71,10 +71,13 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
* If users already have a DM room then navigate to it instead of creating a new room.
*/
private fun onSubmitInvitees(action: CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers) {
if (action.existingDmRoomId != null) {
val existingRoomId = action.selections.singleOrNull()?.getMxId()?.let { userId ->
Copy link
Member

@BillCarsonFr BillCarsonFr Oct 5, 2021

Choose a reason for hiding this comment

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

This does not look right. If it's a request for a grouped DM this will just open the DM with the first user?

** Edit ** ok single or null would do the trick.
check getMxid it's not always returning mxid.
An improvment could be to check for existing grouped DM

Copy link
Member

Choose a reason for hiding this comment

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

singleOrNull() ≠ firstOrNull()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, agree to check for existing grouped DM, requires some more changes

fun getMxId(): String {
return when (this) {
is UserPendingSelection -> user.userId
is ThreePidPendingSelection -> threePid.value
Copy link
Member

Choose a reason for hiding this comment

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

this would be a mail or Pn but not a mxid

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but I think it will work, until the other user has not joined the room. @Florian14 do you confirm?

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 thought the user email was used as the mxId until the user has accepted the invite (is mxId != userId ?). This is probably a lack of knowledge of the protocol on my part.

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.

4 participants