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:
parent
cb1575b890
commit
7e3c6c0b8f
2 changed files with 16 additions and 0 deletions
|
@ -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");
|
||||
|
|
|
@ -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}.
|
||||
|
|
Loading…
Reference in a new issue