From ade32fa91407452c4d4fc16b66522fdf348e7180 Mon Sep 17 00:00:00 2001 From: Guy Scharf Date: Sat, 12 Sep 2020 09:53:36 -0700 Subject: [PATCH] Change Profiles page and Daily Records box in right sidebar to show data for most recently used machine. - Changed Profile::GetMachine() to find machine with latest lastImportDate when there were multiple machines in a profile. - Previously, OSCAR would shown the "first" machine in its list, without clarity about how a machine was designated "first". --- oscar/SleepLib/profiles.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oscar/SleepLib/profiles.cpp b/oscar/SleepLib/profiles.cpp index 11d80312..16ce3fb2 100644 --- a/oscar/SleepLib/profiles.cpp +++ b/oscar/SleepLib/profiles.cpp @@ -941,7 +941,14 @@ Machine *Profile::GetMachine(MachineType t) return nullptr; } - return vec[0]; + // Find most recently imported machine + int idx = 0; + + for (int i=1; i < vec.size(); i++) { + if (vec[i]->lastImported() > vec[idx]->lastImported()) + idx = i; + } + return vec[idx]; } //bool Profile::trashMachine(Machine * mach)