mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
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:
+12
-2
@@ -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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user