From 4ecb5d1ebdbbcf7d0e3c9d0994e54596b81a3f5a Mon Sep 17 00:00:00 2001 From: Marcus Fihlon Date: Fri, 11 Oct 2024 16:46:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20hide=20empty=20rooms=20set?= =?UTF-8?q?ting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcus Fihlon --- .../java/swiss/fihlon/apus/plugin/event/EventService.java | 5 ----- src/main/java/swiss/fihlon/apus/ui/view/EventView.java | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/swiss/fihlon/apus/plugin/event/EventService.java b/src/main/java/swiss/fihlon/apus/plugin/event/EventService.java index 66db3dd..1e7c9bf 100644 --- a/src/main/java/swiss/fihlon/apus/plugin/event/EventService.java +++ b/src/main/java/swiss/fihlon/apus/plugin/event/EventService.java @@ -45,7 +45,6 @@ public final class EventService { private final List eventPlugins; private final ScheduledFuture updateScheduler; private final Period dateAdjust; - private final boolean showClosedRooms; private Map> roomsWithSessions = new TreeMap<>(); public EventService(@NotNull final TaskScheduler taskScheduler, @@ -53,7 +52,6 @@ public EventService(@NotNull final TaskScheduler taskScheduler, @NotNull final List eventPlugins) { this.eventPlugins = eventPlugins; this.dateAdjust = configuration.getEvent().dateAdjust(); - this.showClosedRooms = configuration.getEvent().showClosedRooms(); if (isEnabled()) { updateSessions(); final var updateFrequency = Duration.ofMinutes(configuration.getEvent().updateFrequency()); @@ -103,9 +101,6 @@ private void updateSessions() { } synchronized (this) { - if (!showClosedRooms) { - newRoomsWithSessions.entrySet().removeIf(entry -> entry.getValue().isEmpty()); - } roomsWithSessions = newRoomsWithSessions; } } catch (final SessionImportException e) { diff --git a/src/main/java/swiss/fihlon/apus/ui/view/EventView.java b/src/main/java/swiss/fihlon/apus/ui/view/EventView.java index eea6b2e..2b0cb6b 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/EventView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/EventView.java @@ -51,6 +51,7 @@ public final class EventView extends Div { private final transient EventService eventService; private final Duration nextSessionTimeout; private final boolean showLegend; + private final boolean showClosedRooms; private final Div roomContainer = new Div(); private final Span legend = new Span(); @@ -60,6 +61,7 @@ public EventView(@NotNull final EventService eventService, this.eventService = eventService; this.nextSessionTimeout = Duration.ofMinutes(configuration.getEvent().nextSessionTimeout()); this.showLegend = configuration.getEvent().showLegend(); + this.showClosedRooms = configuration.getEvent().showClosedRooms(); setId("event-view"); add(createTitle()); if (showLegend) { @@ -91,6 +93,9 @@ private void updateConferenceSessions() { final var roomStylesInUse = new HashSet(); for (final Map.Entry> roomWithSession : roomsWithSessions) { final RoomView roomView = createRoomView(roomWithSession, today); + if (!showClosedRooms && RoomStyle.EMPTY.equals(roomView.getRoomStyle())) { + continue; // don't show empty rooms when configured to do so + } roomStylesInUse.add(roomView.getRoomStyle()); roomContainer.add(roomView); }