Skip to content

Extract IncomingCallToast ring/lifecycle logic into useIncomingCallToast hook#34199

Open
syphernl wants to merge 2 commits into
element-hq:developfrom
syphernl:refactor/extract-incoming-call-toast-hook
Open

Extract IncomingCallToast ring/lifecycle logic into useIncomingCallToast hook#34199
syphernl wants to merge 2 commits into
element-hq:developfrom
syphernl:refactor/extract-incoming-call-toast-hook

Conversation

@syphernl

@syphernl syphernl commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Pulls the ring/timeout/auto-dismiss lifecycle and join/decline actions out of IncomingCallToast into a reusable useIncomingCallToast hook. No behavioural change.

Split out of #34171 (prominent full-screen incoming-call notification) to keep that PR's diff reviewable. The hook is needed there to share ring/timeout/auto-dismiss logic between the existing toast and the new full-screen surface.

Test plan

  • Existing IncomingCallToast-test.tsx suite passes unchanged (20/20)
  • tsc --noEmit clean

…ast hook

No behavioural change: pulls the ring/timeout/auto-dismiss lifecycle and
join/decline actions out of IncomingCallToast into a reusable hook, so a
future prominent (full-screen) incoming-call surface can share the same
logic instead of duplicating it.

Signed-off-by: Frank Klaassen <639906+syphernl@users.noreply.github.com>
@syphernl syphernl requested a review from a team as a code owner July 9, 2026 06:25
@syphernl syphernl requested review from MidhunSureshR and t3chguy July 9, 2026 06:25
@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Jul 9, 2026

@Half-Shot Half-Shot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see there are a few minor changes beyond the extraction, but I think the extraction warrants a standalone test suite.

@@ -0,0 +1,247 @@
/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tests for this as a standalone thing wouldn't go amiss, if you could write a vitest format test (useIncomingCallToast.test.tsx) then that would help I think.

Also, does this need to be a TSX?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No it doesn't have to be TSX, changed it.

I kept the test in Jest because the MockedCall/useMockedCalls/WidgetMessagingStore still relies on the global jest object, which isn't available within the Vitest config of this repo. Hope that's fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ahhhhhhhhhh yes, I shan't ask you to start rewriting our tests for this :). Having it standalone means we can fix this up in the future anyway, so thanks!

Addresses review feedback on element-hq#34199: the extracted hook had no test
coverage of its own (only exercised indirectly via IncomingCallToast),
and did not need JSX so .tsx was unnecessary.

Signed-off-by: Frank Klaassen <639906+syphernl@users.noreply.github.com>
@syphernl syphernl requested a review from Half-Shot July 9, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants