1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-26 21:01:32 +00:00

Reread the config on configSaved event (fixes #1078)

This commit is contained in:
Catfriend1 2018-05-07 14:47:05 +02:00 committed by Audrius Butkevicius
parent cb1575b890
commit 7e3c6c0b8f
2 changed files with 16 additions and 0 deletions

View file

@ -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");

View file

@ -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}.