diff --git a/app/gui/oven_control/cookhistory.cpp b/app/gui/oven_control/cookhistory.cpp index 5cf8843..604689b 100644 --- a/app/gui/oven_control/cookhistory.cpp +++ b/app/gui/oven_control/cookhistory.cpp @@ -390,6 +390,27 @@ void appendRecent(RecentsEntry e) } } + recentList.append(e); + + while (recentList.size() > maxRecents) + recentList.takeFirst(); +} + +void prependRecent(RecentsEntry e) +{ + if (e.type == RecentsEntry::Auto) + { + for (int i = 0; i < recentList.size(); i++) + { + RecentsEntry entry = recentList.at(i); + if (entry.autoCook.root == e.autoCook.root) + { + recentList.removeAt(i); + break; + } + } + } + recentList.prepend(e); while (recentList.size() > maxRecents) @@ -1036,7 +1057,7 @@ void CookHistory::record(ManualCookSetting cook) e.manualCook.coreTemp = cook.coreTempEnabled ? cook.coreTemp : -1; e.manualCook.cookedTime = QDateTime::currentDateTime(); - appendRecent(e); + prependRecent(e); saveRecents.start(); } @@ -1052,7 +1073,7 @@ void CookHistory::record(AutoCookSetting cook) for (int i = 0; i < 5; i++) e.autoCook.configs[i] = cook.configs[i]; - appendRecent(e); + prependRecent(e); saveRecents.start(); if (countMap.contains(cook.root))