Skip to content

Commit

Permalink
Use this.id
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Oct 29, 2024
1 parent 60dd6da commit 9e403b8
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions lib/models/Site.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,20 @@ class Site {
this.rawConfig = rawConfig;
this.lastManagedUpdate = lastManagedUpdate;

if (id != null) {
_updates = EventChannel('net.defined.nebula/$id');
_updates.receiveBroadcastStream().listen((d) {
try {
_updateFromJson(d);
_change.add(null);
} catch (err) {
//TODO: handle the error
print(err);
}
}, onError: (err) {
_updateFromJson(err.details);
var error = err as PlatformException;
_change.addError(error.message ?? 'An unexpected error occurred');
});
}
_updates = EventChannel('net.defined.nebula/${this.id}');
_updates.receiveBroadcastStream().listen((d) {
try {
_updateFromJson(d);
_change.add(null);
} catch (err) {
//TODO: handle the error
print(err);
}
}, onError: (err) {
_updateFromJson(err.details);
var error = err as PlatformException;
_change.addError(error.message ?? 'An unexpected error occurred');
});
}

factory Site.fromJson(Map<String, dynamic> json) {
Expand Down

0 comments on commit 9e403b8

Please sign in to comment.