whyred: light: update state after notification is handled

Change-Id: Ic36b112c58316da802a6dfd011cbd25a0e842eef
This commit is contained in:
Demon Singur 2018-04-22 03:38:15 +00:00 committed by Vasishath Kaushal
parent d76a0057be
commit ac9beafcbc

View file

@ -179,18 +179,22 @@ static std::vector<std::pair<Type, LightState>> notificationStates = {
}; };
static void handleNotification(Type type, const LightState& state) { static void handleNotification(Type type, const LightState& state) {
bool handled = false;
for(auto it : notificationStates) { for(auto it : notificationStates) {
if (it.first == type) { if (it.first == type) {
it.second = state; it.second = state;
} }
if (isLit(it.second)) { if (!handled && isLit(it.second)) {
setNotification(it.second); setNotification(it.second);
return; handled = true;
} }
} }
setNotification(offState); if (!handled) {
setNotification(offState);
}
} }
static std::map<Type, std::function<void(Type type, const LightState&)>> lights = { static std::map<Type, std::function<void(Type type, const LightState&)>> lights = {