From 65283306a9a4085026d42736c161cc621aad6755 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Tue, 13 Jun 2023 23:36:02 -0300 Subject: [PATCH] fix: Make dropletIds field for DigitalOceanVolume optional --- lib/logic/models/json/digital_ocean_server_info.dart | 2 +- lib/logic/models/json/digital_ocean_server_info.g.dart | 2 +- lib/logic/providers/server_providers/digital_ocean.dart | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/logic/models/json/digital_ocean_server_info.dart b/lib/logic/models/json/digital_ocean_server_info.dart index 2a6ace8c..9351761d 100644 --- a/lib/logic/models/json/digital_ocean_server_info.dart +++ b/lib/logic/models/json/digital_ocean_server_info.dart @@ -15,7 +15,7 @@ class DigitalOceanVolume { final String name; @JsonKey(name: 'droplet_ids') - final List dropletIds; + final List? dropletIds; @JsonKey(name: 'size_gigabytes') final int sizeGigabytes; diff --git a/lib/logic/models/json/digital_ocean_server_info.g.dart b/lib/logic/models/json/digital_ocean_server_info.g.dart index a0e707c9..9610dbce 100644 --- a/lib/logic/models/json/digital_ocean_server_info.g.dart +++ b/lib/logic/models/json/digital_ocean_server_info.g.dart @@ -11,7 +11,7 @@ DigitalOceanVolume _$DigitalOceanVolumeFromJson(Map json) => json['id'] as String, json['name'] as String, json['size_gigabytes'] as int, - (json['droplet_ids'] as List).map((e) => e as int).toList(), + (json['droplet_ids'] as List?)?.map((e) => e as int).toList(), ); Map _$DigitalOceanVolumeToJson(DigitalOceanVolume instance) => diff --git a/lib/logic/providers/server_providers/digital_ocean.dart b/lib/logic/providers/server_providers/digital_ocean.dart index 98b67a90..209f33e5 100644 --- a/lib/logic/providers/server_providers/digital_ocean.dart +++ b/lib/logic/providers/server_providers/digital_ocean.dart @@ -647,7 +647,9 @@ class DigitalOceanServerProvider extends ServerProvider { name: volumeName, sizeByte: rawVolume.sizeGigabytes * 1024 * 1024 * 1024, serverId: - rawVolume.dropletIds.isNotEmpty ? rawVolume.dropletIds[0] : null, + (rawVolume.dropletIds != null && rawVolume.dropletIds!.isNotEmpty) + ? rawVolume.dropletIds![0] + : null, linuxDevice: 'scsi-0DO_Volume_$volumeName', uuid: rawVolume.id, );