Fix ID used when listening to updates on new sites (#193)
This should avoid the errors we've been seeing in Sentry of: ``` MissingPluginException(No implementation found for method listen on channel net.defined.nebula/null) ``` To test, start up the mobile app in an android phone or emulator, tap the plus button to add a new site, and verify that no error log is shown. Note: we still get a similar error when tapping the "Good Site" or "Bad Site" in debug, but I believe that is because it's being created too quickly before the EventChannel has a chance to be set up. Adding a site manually does not trigger the error.
This commit is contained in:
parent
1ecd008824
commit
88aab16b52
|
@ -54,12 +54,11 @@ class MainActivity: FlutterActivity() {
|
|||
}
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
appContext = context
|
||||
//TODO: Initializing in the constructor leads to a context lacking info we need, figure out the right way to do this
|
||||
sites = Sites(flutterEngine)
|
||||
|
||||
GeneratedPluginRegistrant.registerWith(flutterEngine)
|
||||
|
||||
|
||||
ui = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
|
||||
ui!!.setMethodCallHandler { call, result ->
|
||||
when(call.method) {
|
||||
|
@ -99,7 +98,7 @@ class MainActivity: FlutterActivity() {
|
|||
|
||||
apiClient = APIClient(context)
|
||||
|
||||
ContextCompat.registerReceiver(context, refreshReceiver, IntentFilter(ACTION_REFRESH_SITES), RECEIVER_NOT_EXPORTED)
|
||||
ContextCompat.registerReceiver(context, refreshReceiver, IntentFilter(ACTION_REFRESH_SITES), ContextCompat.RECEIVER_NOT_EXPORTED)
|
||||
|
||||
enqueueDNUpdater()
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class Site {
|
|||
this.rawConfig = rawConfig;
|
||||
this.lastManagedUpdate = lastManagedUpdate;
|
||||
|
||||
_updates = EventChannel('net.defined.nebula/$id');
|
||||
_updates = EventChannel('net.defined.nebula/${this.id}');
|
||||
_updates.receiveBroadcastStream().listen((d) {
|
||||
try {
|
||||
_updateFromJson(d);
|
||||
|
|
Loading…
Reference in New Issue