Skip to content

Commit

Permalink
fix: Do not fail to parse devices if necessary information is not pro…
Browse files Browse the repository at this point in the history
…videed

If not provided, it is marked as OFFLINE
  • Loading branch information
bdlukaa committed Apr 23, 2024
1 parent 3697975 commit 637ce60
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/models/device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ class Device {

factory Device.fromServerJson(Map map, Server server) {
return Device(
name: map['device_name'],
id: int.tryParse(map['id']) ?? 0,
name: map['device_name'] ?? map['device'] ?? 'Unkown Device',
id: int.tryParse('${map['id']}') ?? 0,
status: map['status'] == 'OK',
resolutionX: int.tryParse(map['resolutionX']),
resolutionY: int.tryParse(map['resolutionY']),
resolutionX: int.tryParse('${map['resolutionX']}'),
resolutionY: int.tryParse('${map['resolutionY']}'),
server: server,
hasPTZ: map['ptz_control_protocol'] != null,
);
Expand Down

0 comments on commit 637ce60

Please sign in to comment.