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

ElementCall: Use ViewRoom dispatch action instead of react hoos to trigger call creation. #29195

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

toger5
Copy link
Contributor

@toger5 toger5 commented Feb 5, 2025

fixes: #29196

In strict mode there is a call create -> destroy -> create infinite loop wen pressing the call button.

This loop was a consequence of relying on component creation/destruction to handle creating and removing the call.
This logic:

  • destroying a call if it was in the lobby but leaving it if it is connected when the user stops viewing the room the call belongs to.
  • Creating an ElementCall if there is not yet once when the user starts viewing a call.

Belongs into the roomViewStore and not the components that are just a sideffect in the call livecycle. (view model separation)

One could argue that starting a call should not begin with dispatching a view call action to the roomViewStore but the dispatch should happen based on some intend but this PR wants to be a fix for the infinite loop in Strict mode and not a call livecycle refactor.

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • I have licensed the changes to Element by completing the Contributor License Agreement (CLA)

In strict mode there is a call create -> destroy -> create infinite loop wen pressing the call button.

This loop was a consequence of relying on component creation/destruction to handle creating and removing the call.
This logic:
 - destroying a call if it was in the lobby but leaving it if it is connected when the user stops viewing the room the call belongs to.
  - Creating an ElementCall if there is not yet once when the user starts viewing a call.

Belongs into the roomViewStore and not the components that are just a sideffect in the call livecycle. (view model separation)
Copy link
Member

@florianduros florianduros left a comment

Choose a reason for hiding this comment

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

Looks good, few nits and a question

src/stores/RoomViewStore.tsx Outdated Show resolved Hide resolved
Comment on lines 358 to 365
const currentRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
if (payload.view_call && room) {
if (!currentRoomCall) {
ElementCall.create(room, false);
}
}
// Destroy the call when leaving call view
const prevRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
Copy link
Member

Choose a reason for hiding this comment

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

CallStore.instance.getCall(this.state.roomId) is retuning a different call on line 358 & 365 ?

test/unit-tests/stores/RoomViewStore-test.ts Outdated Show resolved Hide resolved
@toger5
Copy link
Contributor Author

toger5 commented Feb 11, 2025

We discussed this more internally and we will fix this in another planned refactor/feature eventually so I put this back into draft.

@toger5 toger5 marked this pull request as draft February 11, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Element Call infinite loop on call start in strict mode
2 participants