correct factory reset handling after optimization

This commit is contained in:
andreas 2022-03-11 15:39:29 +01:00
parent 9d25ce8b7e
commit faadccd6cb
2 changed files with 10 additions and 15 deletions

View File

@ -91,7 +91,7 @@ bool GwConfigHandler::updateValue(String name, String value){
bool GwConfigHandler::reset(bool save){ bool GwConfigHandler::reset(bool save){
LOG_DEBUG(GwLog::LOG,"reset config"); LOG_DEBUG(GwLog::LOG,"reset config");
for (int i=0;i<getNumConfig();i++){ for (int i=0;i<getNumConfig();i++){
configs[i]->updateValue(configs[i]->getDefault(),true); configs[i]->updateValue(configs[i]->getDefault());
} }
if (!save) return true; if (!save) return true;
return saveConfig(); return saveConfig();

View File

@ -12,21 +12,16 @@ class GwConfigInterface{
bool secret=false; bool secret=false;
String changedValue; String changedValue;
bool hasChangedValue=false; bool hasChangedValue=false;
void updateValue(String value,bool cmpDefault=false){ void updateValue(String value)
hasChangedValue=false; {
if (cmpDefault){ hasChangedValue = false;
if (value != initialValue) { if (value != this->value)
changedValue=value; {
hasChangedValue=true; changedValue = value;
} hasChangedValue = true;
}
else{
if (value != this->value) {
changedValue=value;
hasChangedValue=true;
}
} }
} }
public: public:
GwConfigInterface(const String &name, const char * initialValue, bool secret=false){ GwConfigInterface(const String &name, const char * initialValue, bool secret=false){
this->name=name; this->name=name;