mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
parse incoming connection
This commit is contained in:
@ -44,7 +44,8 @@ class SpaceModel {
|
|||||||
this.selectedProducts = const [],
|
this.selectedProducts = const [],
|
||||||
}) : internalId = internalId ?? const Uuid().v4();
|
}) : internalId = internalId ?? const Uuid().v4();
|
||||||
|
|
||||||
factory SpaceModel.fromJson(Map<String, dynamic> json, {String? parentInternalId}) {
|
factory SpaceModel.fromJson(Map<String, dynamic> json,
|
||||||
|
{String? parentInternalId}) {
|
||||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||||
|
|
||||||
final List<SpaceModel> children = json['children'] != null
|
final List<SpaceModel> children = json['children'] != null
|
||||||
@ -56,7 +57,7 @@ class SpaceModel {
|
|||||||
}).toList()
|
}).toList()
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
return SpaceModel(
|
final instance = SpaceModel(
|
||||||
internalId: internalId,
|
internalId: internalId,
|
||||||
uuid: json['uuid'] ?? '',
|
uuid: json['uuid'] ?? '',
|
||||||
spaceTuyaUuid: json['spaceTuyaUuid'],
|
spaceTuyaUuid: json['spaceTuyaUuid'],
|
||||||
@ -72,11 +73,14 @@ class SpaceModel {
|
|||||||
isPrivate: json['parent']?['isPrivate'] ?? false,
|
isPrivate: json['parent']?['isPrivate'] ?? false,
|
||||||
invitationCode: json['parent']?['invitationCode'],
|
invitationCode: json['parent']?['invitationCode'],
|
||||||
children: [],
|
children: [],
|
||||||
position: Offset(json['parent']?['x'] ?? 0, json['parent']?['y'] ?? 0),
|
position:
|
||||||
|
Offset(json['parent']?['x'] ?? 0, json['parent']?['y'] ?? 0),
|
||||||
icon: json['parent']?['icon'] ?? Assets.location,
|
icon: json['parent']?['icon'] ?? Assets.location,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
community: json['community'] != null ? CommunityModel.fromJson(json['community']) : null,
|
community: json['community'] != null
|
||||||
|
? CommunityModel.fromJson(json['community'])
|
||||||
|
: null,
|
||||||
children: children,
|
children: children,
|
||||||
icon: json['icon'] ?? Assets.location,
|
icon: json['icon'] ?? Assets.location,
|
||||||
position: Offset(json['x'] ?? 0, json['y'] ?? 0),
|
position: Offset(json['x'] ?? 0, json['y'] ?? 0),
|
||||||
@ -90,6 +94,20 @@ class SpaceModel {
|
|||||||
}).toList()
|
}).toList()
|
||||||
: [],
|
: [],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (json['incomingConnections'] != null &&
|
||||||
|
json['incomingConnections'] is List &&
|
||||||
|
(json['incomingConnections'] as List).isNotEmpty &&
|
||||||
|
instance.parent != null) {
|
||||||
|
final conn = json['incomingConnections'][0];
|
||||||
|
instance.incomingConnection = Connection(
|
||||||
|
startSpace: instance.parent ?? instance, // Parent space
|
||||||
|
endSpace: instance, // This space instance
|
||||||
|
direction: conn['direction'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
|
Reference in New Issue
Block a user