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

Cancel ringing call notification on call cancellation #3047

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Jun 18, 2024

Content

Listen to active call state for DMs with ringing calls so if the other user hangs up before you've replied the ringing stops and the call is cancelled.

Motivation and context

Improve the call ringing implementation. Fixes #3014.

Tests

  • With a client using a session A, call a user in another client using session B from a DM.
  • The user in session B should see a ringing call notification.
  • From session A, hang up.
  • The ringing should stop soon after in session B.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14, 13.

Checklist

@jmartinesp jmartinesp mentioned this pull request Jun 18, 2024
14 tasks
Copy link

sonarcloud bot commented Jun 18, 2024

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

Copy link
Contributor

github-actions bot commented Jun 18, 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/S5dQsa

Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.

Project coverage is 76.15%. Comparing base (bf3bdbf) to head (d68e5e4).
Report is 8 commits behind head on develop.

Files Patch % Lines
...roid/features/call/impl/utils/ActiveCallManager.kt 85.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3047   +/-   ##
========================================
  Coverage    76.14%   76.15%           
========================================
  Files         1645     1645           
  Lines        38809    38829   +20     
  Branches      7516     7523    +7     
========================================
+ Hits         29552    29570   +18     
- Misses        5356     5357    +1     
- Partials      3901     3902    +1     

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

@bmarty
Copy link
Member

bmarty commented Jul 4, 2024

Hello @jmartinesp what is the status of the PR? I mean can it become "Ready for review" or does it need any update?

@jmartinesp
Copy link
Member Author

So I created this PR as a draft so everyone could test it (especially Timo, who suggested the implementation), it's functional and it could be merged (maybe after some cleanup, I can't remember) but we don't have a counterpart on iOS and I don't think we have a plan to do this work there any time soon.

It depends on whether we want this even if iOS doesn't have it or not. @manuroe ?

@manuroe
Copy link
Member

manuroe commented Jul 17, 2024

We (well @stefanceriu ) worked through this on iOS in this commit with the same approach as @jmartinesp here. We can merge this PR.

@jmartinesp jmartinesp force-pushed the misc/jme/cancel-ringing-on-room-info-changed branch from 1581573 to be4f0db Compare July 18, 2024 13:13
@jmartinesp jmartinesp added the PR-Change For updates to an existing feature label Jul 18, 2024
@jmartinesp jmartinesp force-pushed the misc/jme/cancel-ringing-on-room-info-changed branch from be4f0db to 0813fe9 Compare July 18, 2024 13:23
@jmartinesp jmartinesp marked this pull request as ready for review July 18, 2024 14:10
@jmartinesp jmartinesp requested a review from a team as a code owner July 18, 2024 14:10
@jmartinesp jmartinesp requested review from bmarty and removed request for a team July 18, 2024 14:10
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.

Just one remark, else LGTM!

.onEach { roomHasActiveCall ->
if (!roomHasActiveCall) {
// The call was cancelled
incomingCallTimedOut()
Copy link
Member

Choose a reason for hiding this comment

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

You may want to add timedOutCallJob?.cancel() too, even if it should not change anything.

// We only want to check if the room active call status changes
.distinctUntilChanged()
// Skip the first one, we're not interested in it (if the check below passes, it had to be active anyway)
.drop(1)
Copy link
Member

@bmarty bmarty Jul 19, 2024

Choose a reason for hiding this comment

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

I am a bit scared about this drop. If it is not mandatory, can we just remove it?
Or maybe replace by

            // We only want to check if the room active call status changes
            .distinctUntilChanged()
            .filter { roomHasActiveCall -> !roomHasActiveCall }
            .onEach {
                // The call was cancelled
                incomingCallTimedOut()
            }
            .launchIn(coroutineScope)

(Unit tests are still passing with this)

Copy link
Member Author

@jmartinesp jmartinesp Jul 19, 2024

Choose a reason for hiding this comment

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

IIRC we can't, because in a real life situation this flow will start before we get the room info, and by default the roomHasActiveCall will be false, instantly cancelling any incoming call as a result.

We could replace it by some operator that takes pairs of events instead so we can compare hadCall == true && newValue == false, but that's technically doing exactly the same as the drop as it wouldn't trigger until there are 2 elements in the flow.

Copy link
Member

Choose a reason for hiding this comment

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

ok

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Jul 19, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Jul 19, 2024
Copy link

sonarcloud bot commented Jul 19, 2024

@jmartinesp jmartinesp merged commit 344e07b into develop Jul 19, 2024
30 checks passed
@jmartinesp jmartinesp deleted the misc/jme/cancel-ringing-on-room-info-changed branch July 19, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Change For updates to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ringing does not stop in the room even when caller hangs up
3 participants