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

[VBLOCKS 3456] feat: hold resume #14

Merged
merged 2 commits into from
Oct 16, 2024
Merged

[VBLOCKS 3456] feat: hold resume #14

merged 2 commits into from
Oct 16, 2024

Conversation

kpchoy
Copy link
Contributor

@kpchoy kpchoy commented Oct 15, 2024

VBLOCKS-3540
VBLOCKS-3546

  • OutgoingCall event
  • Hold and Resume Button implementation with conference

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

@kpchoy kpchoy requested a review from mhuynh5757 October 15, 2024 23:00
@kpchoy kpchoy force-pushed the VBLOCKS-3456-hold-resume branch from a5f37ed to 8e7c595 Compare October 16, 2024 18:59
twilioVoiceDialer.addEventListener('tokenWillExpire', async (e) => {
const device = e.detail.device;

const updateTokenResponse = await fetch(`/twilio-voice-dialer/token`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const updateTokenResponse = await fetch(`/twilio-voice-dialer/token`);
const updateTokenResponse = await fetch('/twilio-voice-dialer/token');

Comment on lines +2 to +4
#call;
#callSid;
#conferenceSid;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like there are two different "unset" values for these. Later we set them to null, but here they are undefined. We should settle on undefined IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Any reason for undefined over null?

Copy link
Contributor

Choose a reason for hiding this comment

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

Purely because leaving it "blank" sets the value to undefined. Consider the following:

const foo = null;
const bar = undefined;

typeof foo === 'object'; // confusing
typeof bar === 'undefined'; // less confusing

if (foo === null) { ... } // works
if (bar === undefined) { ... } // does not work, very confusing

So both of them have pretty confusing cons, and the benefit is that we just don't have to set things to null by hand things will be implicit undefined.

this.#setHold(false);
}

#messageReceivedHandler(message) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: since all the other handlers are handleX, let's call this one handleCallMessageReceived?

@@ -7,7 +7,7 @@ const { accountSid, apiKeySid, apiKeySecret } = config;
const client = Twilio(apiKeySid, apiKeySecret, { accountSid });

router.post('/conferences/:conferenceSid/participants/:callSid', async (req, res) => {
const { hold } = req.body;
const { hold } = JSON.parse(req.body);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you set the headers to application/json in the fetch, you don't need to do JSON.parse here.

@@ -9,7 +9,9 @@
<body>
<h1>Twilio Voice Dialer</h1>

<twilio-voice-dialer recipient register></twilio-voice-dialer>
<twilio-voice-dialer recipient register>
<twilio-voice-basic-call-control></twilio-voice-basic-call-control>
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want this reference to have the hold and resume functionality right? This is the voice dialer without any conference/call control stuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. must have missed this in my rebase

@kpchoy kpchoy requested a review from mhuynh5757 October 16, 2024 21:39
@kpchoy kpchoy merged commit a602146 into main Oct 16, 2024
@kpchoy kpchoy deleted the VBLOCKS-3456-hold-resume branch October 16, 2024 21:55
Copy link
Contributor

@charliesantos charliesantos left a comment

Choose a reason for hiding this comment

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

@kpchoy I left a couple of comments. I understand this has already been merged. Please add a new ticket to address the comments later 🙇
fyi @mhuynh5757

<h1>Twilio Voice Dialer</h1>

<twilio-voice-dialer recipient register>
<twilio-voice-basic-call-control></twilio-voice-basic-call-control>
Copy link
Contributor

Choose a reason for hiding this comment

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

Will a self closing tag work? <twilio-voice-basic-call-control/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sadly Custom elements cannot be self closing
WICG/webcomponents#624

this.#render();
this.#showButtons();

const twilioVoiceDialer = document.querySelector('twilio-voice-dialer');
Copy link
Contributor

Choose a reason for hiding this comment

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

This will query the whole document. We should only query the child nodes of this component. Can you try this.shadowRoot.querySelector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue here is that this.shadowRoot is scoped to this component. So it has no reference of parent element, where the event is dispatched. Hence why we need to query the whole document for the parent element.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was confused for a bit. Yeah this is the child element, and the dialer is the parent. In this case, this is still a problem because what if you have multiple dialers in the document?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Valid point. Ok, created this follow up ticket to "pass down UUID from Dialer to child components"

https://twilio-engineering.atlassian.net/browse/VBLOCKS-3743

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@charliesantos 1 line fix: #20

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! Approved. I remember you created a jira ticket to pass the id. Can we close that now since it's not applicable anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup closed it

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.

3 participants