From ee2ac7736f420b145fd0a4a02fc2f61f8e07c3b0 Mon Sep 17 00:00:00 2001
From: uhensler <urs.hensler@frentix.com>
Date: Wed, 5 Jun 2019 10:17:20 +0200
Subject: [PATCH] OO-4043: Sort live stream events in peek view

---
 .../nodes/livestream/ui/LiveStreamPeekviewController.java      | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamPeekviewController.java b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamPeekviewController.java
index a0c1a90ac5d..e91f153c3ef 100644
--- a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamPeekviewController.java
+++ b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamPeekviewController.java
@@ -21,6 +21,7 @@ package org.olat.course.nodes.livestream.ui;
 
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
@@ -73,6 +74,7 @@ public class LiveStreamPeekviewController extends BasicController implements Con
 		List<? extends LiveStreamEvent> runningEvents = liveStreamService.getRunningEvents(calendars, bufferBeforeMin, bufferAfterMin);
 		List<EventWrapper> events;
 		if (!runningEvents.isEmpty()) {
+			Collections.sort(runningEvents, (e1, e2) -> e1.getBegin().compareTo(e2.getBegin()));
 			events = wrapEvents(runningEvents, true);
 			nodeLink = LinkFactory.createLink("peekview.open.live", mainVC, this);
 			nodeLink.setIconRightCSS("o_icon o_icon_start");
@@ -80,6 +82,7 @@ public class LiveStreamPeekviewController extends BasicController implements Con
 		} else {
 			List<? extends LiveStreamEvent> upcomingEvents = liveStreamService.getUpcomingEvents(calendars, bufferBeforeMin);
 			if (!upcomingEvents.isEmpty()) {
+				Collections.sort(upcomingEvents, (e1, e2) -> e1.getBegin().compareTo(e2.getBegin()));
 				events = new ArrayList<>(1);
 				events.add(wrapEvent(upcomingEvents.get(0), false));
 				nodeLink = LinkFactory.createLink("peekview.open.upcoming", mainVC, this);
-- 
GitLab