mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
simulators
use diff instead of custom garbage
This commit is contained in:
+6
-16
@@ -90,24 +90,14 @@ json Simulators::changed_UI_items()
|
|||||||
json after = this->m_simulators.at(m_current_simulator)->get_UI_items();
|
json after = this->m_simulators.at(m_current_simulator)->get_UI_items();
|
||||||
json changed;
|
json changed;
|
||||||
changed["event"] = "UI_changed";
|
changed["event"] = "UI_changed";
|
||||||
if (m_before["UI_items"].empty())
|
|
||||||
|
changed["diff"] = json::diff(m_before, after);
|
||||||
|
|
||||||
|
if (changed["diff"].empty())
|
||||||
{
|
{
|
||||||
changed = after;
|
return "{}"_json;
|
||||||
return changed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const json& item : after["UI_items"])
|
m_before = after;
|
||||||
{
|
|
||||||
for (const json& before_item : m_before["UI_items"])
|
|
||||||
{
|
|
||||||
if (before_item["id"] == item["id"])
|
|
||||||
{
|
|
||||||
if (before_item != item)
|
|
||||||
{
|
|
||||||
changed["UI_items"].push_back(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user