Skip to content

Commit

Permalink
✨ Don't display "next" sessions with a start time of more than one ho…
Browse files Browse the repository at this point in the history
…ur in the future closes #73

Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Apr 6, 2024
1 parent 0b95760 commit b2f2fbd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.TextStyle;
import java.util.List;
import java.util.Map;
Expand All @@ -44,6 +45,7 @@ public final class ConferenceView extends Div {
public static final String LABEL_THEME = "badge";
private static final int MAX_ROOMS_IN_VIEW = 12;
private static final Duration UPDATE_FREQUENCY = Duration.ofMinutes(1);
private static final Duration TIME_LIMIT_NEXT_SESSION = Duration.ofHours(1);

private final transient ConferenceService conferenceService;
private final Div sessionContainer = new Div();
Expand Down Expand Up @@ -106,11 +108,14 @@ private Component createLegend() {
private static SessionView createSessionView(@NotNull final Map.Entry<Room, List<Session>> roomWithSession,
@NotNull final LocalDate today,
@NotNull final AtomicInteger roomCounter) {
final LocalDateTime timeLimitNextSession = LocalDateTime.now().plus(TIME_LIMIT_NEXT_SESSION);
final Room room = roomWithSession.getKey();
final List<Session> sessions = roomWithSession.getValue();
final Session session = sessions.isEmpty() ? null : sessions.getFirst();
final SessionView sessionView;
if (session != null && session.startDate().toLocalDate().isEqual(today)) {
if (session != null
&& session.startDate().toLocalDate().isEqual(today)
&& session.startDate().isBefore(timeLimitNextSession)) {
sessionView = new SessionView(session);
} else {
sessionView = new SessionView(room);
Expand Down

0 comments on commit b2f2fbd

Please sign in to comment.