Skip to content

Commit 9b6e5c8

Browse files
committed
feat(web): use enum.values for call status mapping, defaulting to closed
1 parent bbf4628 commit 9b6e5c8

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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.
66
* Feat: [Web] Check unnecessary updating device with the same token.
7+
* Feat: [Web] Update internal [CallStatus] mapping method.
78
* Feat: update example.
89
* Docs: update CHANGELOG
910

lib/_internal/js/call/call_status.dart

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,9 @@ enum CallStatus {
3131
}
3232

3333
CallStatus parseCallStatus(String status) {
34-
switch (status) {
35-
case "closed":
36-
return CallStatus.closed;
37-
case "connecting":
38-
return CallStatus.connecting;
39-
case "open":
40-
return CallStatus.open;
41-
case "connected":
42-
return CallStatus.connected;
43-
case "reconnecting":
44-
return CallStatus.reconnecting;
45-
case "reconnected":
46-
return CallStatus.reconnected;
47-
case "ringing":
48-
return CallStatus.ringing;
49-
case "pending":
50-
return CallStatus.pending;
51-
case "rejected":
52-
return CallStatus.rejected;
53-
case "answer":
54-
return CallStatus.answer;
55-
default:
56-
return CallStatus.closed;
57-
}
34+
final lower = status.toLowerCase();
35+
return CallStatus.values.firstWhere(
36+
(e) => e.name.toLowerCase() == lower,
37+
orElse: () => CallStatus.closed,
38+
);
5839
}

0 commit comments

Comments
 (0)