Only call SaveConfig once in ConfigUIHandler

This commit is contained in:
str4d
2012-08-03 03:49:46 +00:00
parent 9d29dc6b68
commit d147db3382

View File

@ -1,5 +1,10 @@
package net.i2p.router.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** set the theme */
public class ConfigUIHandler extends FormHandler {
private boolean _shouldSave;
@ -24,18 +29,18 @@ public class ConfigUIHandler extends FormHandler {
private void saveChanges() {
if (_config == null)
return;
Map<String, String> changes = new HashMap();
List<String> removes = new ArrayList();
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
boolean ok;
if (_config.equals("default")) // obsolete
ok = _context.router().saveConfig(CSSHelper.PROP_THEME_NAME, null);
removes.add(CSSHelper.PROP_THEME_NAME);
else
ok = _context.router().saveConfig(CSSHelper.PROP_THEME_NAME, _config);
if (ok) {
if (_universalTheming)
ok = _context.router().saveConfig(CSSHelper.PROP_UNIVERSAL_THEMING, "true");
else
ok = _context.router().saveConfig(CSSHelper.PROP_UNIVERSAL_THEMING, null);
}
changes.put(CSSHelper.PROP_THEME_NAME, _config);
if (_universalTheming)
changes.put(CSSHelper.PROP_UNIVERSAL_THEMING, "true");
else
removes.add(CSSHelper.PROP_UNIVERSAL_THEMING);
boolean ok = _context.router().saveConfig(changes, removes);
if (ok) {
if (!oldTheme.equals(_config))
addFormNotice(_("Theme change saved.") +