diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/EventProcessor.java b/app/src/main/java/com/nutomic/syncthingandroid/service/EventProcessor.java index 69195cf6..550de46a 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/EventProcessor.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/EventProcessor.java @@ -94,6 +94,12 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene @Override public void onEvent(Event event) { switch (event.type) { + case "ConfigSaved": + if (mApi != null) { + Log.v(TAG, "Forwarding ConfigSaved event to RestApi to get the updated config."); + mApi.reloadConfig(); + } + break; case "DeviceRejected": String deviceId = (String) event.data.get("device"); Log.d(TAG, "Unknwon device " + deviceId + " wants to connect"); diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java b/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java index a814e3ca..35ede351 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java @@ -156,6 +156,16 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { }); } + public void reloadConfig() { + new GetRequest(mContext, mUrl, GetRequest.URI_CONFIG, mApiKey, null, result -> { + Log.v(TAG, "reloadConfig: " + result); + mConfig = new Gson().fromJson(result, Config.class); + if (mConfig == null) { + throw new RuntimeException("config is null: " + result); + } + }); + } + /** * Increments mAvailableCount by one, and, if it reached TOTAL_STARTUP_CALLS, * calls {@link SyncthingService#onApiChange}.