From d8609b36bb03e0b97b049dbd955bf74b2ccdcd30 Mon Sep 17 00:00:00 2001 From: Marcus Fihlon Date: Sun, 31 Mar 2024 14:06:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20the=20localization=20feature=20o?= =?UTF-8?q?f=20Vaadin=20has=20problems=20with=20injected=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fihlon/apus/ui/view/ConferenceView.java | 8 ------- .../fihlon/apus/ui/view/MessageView.java | 7 ------ .../fihlon/apus/ui/view/SessionView.java | 4 ---- .../swiss/fihlon/apus/ui/view/SocialView.java | 10 -------- .../fihlon/apus/ui/view/SocialWallView.java | 23 ++++++++----------- 5 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java b/src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java index 6a5f3c6..8aad0bd 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java @@ -17,7 +17,6 @@ */ package swiss.fihlon.apus.ui.view; -import com.vaadin.flow.component.AttachEvent; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.UI; import com.vaadin.flow.component.dependency.CssImport; @@ -39,7 +38,6 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicInteger; -@org.springframework.stereotype.Component @CssImport(value = "./themes/apus/views/conference-view.css") public final class ConferenceView extends Div { @@ -48,17 +46,11 @@ public final class ConferenceView extends Div { private static final Duration UPDATE_FREQUENCY = Duration.ofMinutes(1); private final transient ConferenceService conferenceService; - private final transient TaskScheduler taskScheduler; private final Div sessionContainer = new Div(); public ConferenceView(@NotNull final ConferenceService conferenceService, @NotNull final TaskScheduler taskScheduler) { this.conferenceService = conferenceService; - this.taskScheduler = taskScheduler; - } - - @Override - protected void onAttach(@NotNull final AttachEvent attachEvent) { setId("conference-view"); add(new H2(String.format(getTranslation("conference.heading"), LocalDate.now().getDayOfWeek().getDisplayName(TextStyle.FULL, UI.getCurrent().getLocale())))); diff --git a/src/main/java/swiss/fihlon/apus/ui/view/MessageView.java b/src/main/java/swiss/fihlon/apus/ui/view/MessageView.java index b695453..44e250a 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/MessageView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/MessageView.java @@ -17,7 +17,6 @@ */ package swiss.fihlon.apus.ui.view; -import com.vaadin.flow.component.AttachEvent; import com.vaadin.flow.component.Html; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.html.Div; @@ -31,14 +30,8 @@ public final class MessageView extends Div { private static final int MAX_LENGTH = 500; private static final String TRUNC_INDICATOR = " […]"; - private final transient Message message; public MessageView(@NotNull final Message message) { - this.message = message; - } - - @Override - protected void onAttach(@NotNull final AttachEvent attachEvent) { addClassName("message-view"); final String messageText = Jsoup.parse(message.html()).text(); add(new Html(String.format("
%s
", diff --git a/src/main/java/swiss/fihlon/apus/ui/view/SessionView.java b/src/main/java/swiss/fihlon/apus/ui/view/SessionView.java index e950d79..021235a 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/SessionView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/SessionView.java @@ -17,7 +17,6 @@ */ package swiss.fihlon.apus.ui.view; -import com.vaadin.flow.component.AttachEvent; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Html; import com.vaadin.flow.component.Text; @@ -74,10 +73,7 @@ public SessionView(@NotNull final Room room, this.startTime = startTime; this.endTime = endTime; this.language = language; - } - @Override - protected void onAttach(@NotNull final AttachEvent attachEvent) { addClassName("session-view"); add(createTitleComponent()); add(createSpeakersComponent()); diff --git a/src/main/java/swiss/fihlon/apus/ui/view/SocialView.java b/src/main/java/swiss/fihlon/apus/ui/view/SocialView.java index ba490ab..24c6d03 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/SocialView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/SocialView.java @@ -17,13 +17,11 @@ */ package swiss.fihlon.apus.ui.view; -import com.vaadin.flow.component.AttachEvent; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.H2; import org.jetbrains.annotations.NotNull; import org.springframework.scheduling.TaskScheduler; -import org.springframework.stereotype.Component; import swiss.fihlon.apus.configuration.Configuration; import swiss.fihlon.apus.service.SocialService; import swiss.fihlon.apus.social.Message; @@ -31,27 +29,19 @@ import java.time.Duration; import java.util.concurrent.ScheduledFuture; -@Component @CssImport(value = "./themes/apus/views/social-view.css") public final class SocialView extends Div { private static final Duration UPDATE_FREQUENCY = Duration.ofMinutes(1); private final transient SocialService socialService; - private final transient TaskScheduler taskScheduler; - private final transient Configuration configuration; private final Div messageContainer = new Div(); public SocialView(@NotNull final SocialService socialService, @NotNull final TaskScheduler taskScheduler, @NotNull final Configuration configuration) { this.socialService = socialService; - this.taskScheduler = taskScheduler; - this.configuration = configuration; - } - @Override - protected void onAttach(@NotNull final AttachEvent attachEvent) { setId("social-view"); add(new H2(String.format(getTranslation("social.heading"), configuration.getMastodon().hashtag()))); add(messageContainer); diff --git a/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java b/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java index 3e1e8a1..53ca597 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java @@ -17,28 +17,25 @@ */ package swiss.fihlon.apus.ui.view; -import com.vaadin.flow.component.AttachEvent; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; import org.jetbrains.annotations.NotNull; +import org.springframework.scheduling.TaskScheduler; +import swiss.fihlon.apus.configuration.Configuration; +import swiss.fihlon.apus.service.ConferenceService; +import swiss.fihlon.apus.service.SocialService; @Route("") @CssImport(value = "./themes/apus/views/social-wall-view.css") public final class SocialWallView extends Div { - private final ConferenceView conferenceView; - private final SocialView socialView; - - public SocialWallView(@NotNull final ConferenceView conferenceView, - @NotNull final SocialView socialView) { - this.conferenceView = conferenceView; - this.socialView = socialView; - } - - @Override - protected void onAttach(@NotNull final AttachEvent attachEvent) { + public SocialWallView(@NotNull final ConferenceService conferenceService, + @NotNull final SocialService socialService, + @NotNull final TaskScheduler taskScheduler, + @NotNull final Configuration configuration) { setId("social-wall-view"); - add(conferenceView, socialView); + add(new ConferenceView(conferenceService, taskScheduler)); + add(new SocialView(socialService, taskScheduler, configuration)); } }