diff --git a/HISTORY b/HISTORY index 0baf45d..98e63f4 100644 --- a/HISTORY +++ b/HISTORY @@ -298,4 +298,5 @@ Version 0.4.3 - added strequal, strnotequal, strcontains, strnotcontains functions to compare strings in conditions +- fixed sort order in lastrecordings viewelement diff --git a/views/viewhelpers.c b/views/viewhelpers.c index 67216ad..294ac22 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -624,10 +625,31 @@ void cViewHelpers::SetTimers(map *intTokens, map *str } void cViewHelpers::SetLastRecordings(map *intTokens, map *stringTokens, vector > *lastRecordings) { - RecordingsSortMode = rsmTime; - Recordings.Sort(); + + list orderedRecs; + + for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) { + if (orderedRecs.size() == 0) { + orderedRecs.push_back(recording); + continue; + } + bool inserted = false; + for (list::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) { + const cRecording *orderedRec = *it; + if (recording->Start() >= orderedRec->Start()) { + orderedRecs.insert(it, recording); + inserted = true; + break; + } + } + if (!inserted) { + orderedRecs.push_back(recording); + } + } + int found = 0; - for (cRecording *recording = Recordings.Last(); recording; recording = Recordings.Prev(recording)) { + for (list::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) { + const cRecording *recording = *it; #if APIVERSNUM >= 20101 if (recording->IsInUse()) { continue;