simulators

change from returning diff to returning a list of ui_elements by extracting the index out of the diff and pushing the item in the list
This commit is contained in:
2024-08-22 12:54:01 +02:00
parent 4f6b060c54
commit f4d8246bc8
+12 -2
View File
@@ -91,13 +91,23 @@ json Simulators::changed_UI_items()
json changed; json changed;
changed["event"] = "UI_changed"; changed["event"] = "UI_changed";
changed["diff"] = json::diff(m_before, after); json diff = json::diff(m_before, after);
if (changed["diff"].empty()) if (diff.empty())
{ {
return "{}"_json; return "{}"_json;
} }
// diff to ui items list
// get index out of each item in diff /UI_items/0/**
// Then push the ui_item at that index to the changed json
for (auto& item : diff)
{
std::string path = item["path"];
std::string index_s = path.substr(10, path.find("/", 10) - 10);
changed["UI_items"].push_back(after["UI_items"][std::stoul(index_s)]);
}
m_before = after; m_before = after;
return changed; return changed;
} }