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