|
|
@@ -667,7 +667,7 @@ const updateSolutions = (solutions) => {
|
|
|
|
|
|
if (solutions?.length) {
|
|
|
const solutionsHistory = GAMES.Solutions;
|
|
|
- const updateIds = { add: [], update: [], retain: [] }
|
|
|
+ const updateIds = { add: [], update: [], retain: [], remove: [] }
|
|
|
solutions.forEach(item => {
|
|
|
const { sid, cpr, sol: { win_average } } = item;
|
|
|
|
|
|
@@ -689,15 +689,24 @@ const updateSolutions = (solutions) => {
|
|
|
updateIds.retain.push(sid);
|
|
|
});
|
|
|
|
|
|
+ const solutionsMap = new Map(solutions.map(item => [item.sid, item]));
|
|
|
+ Object.keys(solutionsHistory).forEach(sid => {
|
|
|
+ if (!solutionsMap.has(sid)) {
|
|
|
+ delete solutionsHistory[sid];
|
|
|
+ updateIds.remove.push(sid);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
const solutionUpdate = {};
|
|
|
Object.keys(updateIds).forEach(key => {
|
|
|
- if (key == 'retain') {
|
|
|
+ if (key == 'retain' || key == 'remove') {
|
|
|
solutionUpdate[key] = updateIds[key];
|
|
|
}
|
|
|
else {
|
|
|
solutionUpdate[key] = updateIds[key].map(sid => solutionsHistory[sid]);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
syncSolutions(solutionUpdate);
|
|
|
|
|
|
}
|