Skip to content

Commit b8710f2

Browse files
committed
fix: add check for updating device with same token
1 parent 08402f7 commit b8710f2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Feat: [Web] Add Twilio Device [DeviceState] accessor protecting un/registration.
44
* Feat: [Web] Add Twilio Device `updateToken(String)` function to allow updating of active device tokens.
55
* Fix: [Web] Twilio Device does not unregister on `unregister()` method call due to 'device.off' not visible in js object causing device event listeners to remain attached on unregistered device.
6+
* Feat: [Web] Check unnecessary updating device with the same token.
67
* Feat: update example.
78
* Docs: update CHANGELOG
89

lib/_internal/twilio_voice_web.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,13 @@ class TwilioVoiceWeb extends MethodChannelTwilioVoice {
365365
try {
366366
final shouldUpdate = device != null && getDeviceState(device!) == DeviceState.registered;
367367
if (shouldUpdate) {
368+
if(device?.token == accessToken) {
369+
printDebug("Device token is the same, no need to update");
370+
return true;
371+
}
368372
device!.updateToken(accessToken);
369373
} else {
370-
/// opus set as primary code
374+
/// opus set as primary code
371375
/// https://www.twilio.com/blog/client-javascript-sdk-1-7-ga
372376
List<String> codecs = ["opus", "pcmu"];
373377
twilio_js.DeviceOptions options = twilio_js.DeviceOptions(

0 commit comments

Comments
 (0)