bugfix: remove box contains check due to regulary cleaning box before update
parent
1f52c7971a
commit
722dff965b
|
@ -8,8 +8,11 @@ List<Food> castDynamicToListFood(List<dynamic> dynamicList) {
|
||||||
return foodList;
|
return foodList;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String,List<Food>> castDynamicMap(Map<dynamic,dynamic> dynamicMap){
|
Map<String,List<Food>> castDynamicMap(dynamic dynamicMap){
|
||||||
Map<String,List<Food>> foodMap = {};
|
Map<String,List<Food>> foodMap = {};
|
||||||
|
if(dynamicMap == null){
|
||||||
|
return foodMap;
|
||||||
|
}
|
||||||
for(dynamic key in dynamicMap.keys){
|
for(dynamic key in dynamicMap.keys){
|
||||||
foodMap.putIfAbsent(key as String , () => castDynamicToListFood(dynamicMap[key]));
|
foodMap.putIfAbsent(key as String , () => castDynamicToListFood(dynamicMap[key]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,7 @@ class StatisticsService {
|
||||||
void addValuesToList(Box box, String key, List<Food> newValues){
|
void addValuesToList(Box box, String key, List<Food> newValues){
|
||||||
List<Food> existingList = castDynamicToListFood(box.get(key));
|
List<Food> existingList = castDynamicToListFood(box.get(key));
|
||||||
for(int i = 0; i < newValues.length;i++){
|
for(int i = 0; i < newValues.length;i++){
|
||||||
if(!existingList.contains(newValues[i])){
|
|
||||||
existingList.add(newValues[i]);
|
existingList.add(newValues[i]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
box.put(key, existingList);
|
box.put(key, existingList);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +151,7 @@ class StatisticsService {
|
||||||
if(matchingTimestamp != null){
|
if(matchingTimestamp != null){
|
||||||
newTimestamp = matchingTimestamp;
|
newTimestamp = matchingTimestamp;
|
||||||
}
|
}
|
||||||
Map<String, List<Food>>? valueMap = castDynamicMap(box.get(newTimestamp));
|
Map<String, List<Food>> valueMap = castDynamicMap(box.get(newTimestamp));
|
||||||
List<Food> values = [];
|
List<Food> values = [];
|
||||||
if(valueMap.containsKey(mealType)){
|
if(valueMap.containsKey(mealType)){
|
||||||
values = valueMap[mealType]!;
|
values = valueMap[mealType]!;
|
||||||
|
|
Loading…
Reference in New Issue