From bce18a469ab7f6b2fc0656f32f75f369ebafab85 Mon Sep 17 00:00:00 2001 From: Mathias Magnusson Date: Fri, 10 May 2024 16:02:41 +0200 Subject: [PATCH] Remove uses of old `Reception{Repository,Mode}` --- .../calypso/controllers/admin/ActivityController.java | 11 +++-------- .../calypso/controllers/api/ApiController.java | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/se/datasektionen/calypso/controllers/admin/ActivityController.java b/src/main/java/se/datasektionen/calypso/controllers/admin/ActivityController.java index f0d0ea6..140f1ee 100644 --- a/src/main/java/se/datasektionen/calypso/controllers/admin/ActivityController.java +++ b/src/main/java/se/datasektionen/calypso/controllers/admin/ActivityController.java @@ -23,9 +23,8 @@ import se.datasektionen.calypso.auth.DAuthUserDetails; import se.datasektionen.calypso.exceptions.ResourceNotFoundException; import se.datasektionen.calypso.models.entities.Activity; -import se.datasektionen.calypso.models.entities.ReceptionMode; import se.datasektionen.calypso.models.repositories.ActivityRepository; -import se.datasektionen.calypso.models.repositories.ReceptionRepository; +import se.datasektionen.calypso.Darkmode; @Controller @PreAuthorize("hasAuthority('post')") @@ -36,7 +35,7 @@ public class ActivityController { private static final int PAGE_SIZE = 50; private final ActivityRepository activityRepository; - private final ReceptionRepository receptionRepository; + private final Darkmode darkmode; private final DateTimeFormatter formatter; private String showEditForm(Activity activity, Model model) { @@ -111,15 +110,11 @@ public String list(@RequestParam(name = "sortBy", defaultValue = "id") String so activities = activityRepository.findAllByAuthor(author, pageable); } - boolean receptionMode = Optional.ofNullable(receptionRepository.get()) - .map(ReceptionMode::getState) - .orElse(false); - // Populate model model.addAttribute("page", page); model.addAttribute("activities", activities); model.addAttribute("author", author); - model.addAttribute("receptionMode", receptionMode); + model.addAttribute("receptionMode", darkmode.getCurrent()); return "activities/list"; } diff --git a/src/main/java/se/datasektionen/calypso/controllers/api/ApiController.java b/src/main/java/se/datasektionen/calypso/controllers/api/ApiController.java index d86926a..8289ef7 100644 --- a/src/main/java/se/datasektionen/calypso/controllers/api/ApiController.java +++ b/src/main/java/se/datasektionen/calypso/controllers/api/ApiController.java @@ -11,7 +11,6 @@ import se.datasektionen.calypso.exceptions.ResourceNotFoundException; import se.datasektionen.calypso.models.entities.Activity; import se.datasektionen.calypso.models.entities.Item; -import se.datasektionen.calypso.models.entities.ReceptionMode; import se.datasektionen.calypso.models.enums.ItemType; import se.datasektionen.calypso.models.repositories.ActivityRepository; import se.datasektionen.calypso.models.repositories.ApiRepository; @@ -100,7 +99,7 @@ public Page listActivities(@RequestParam(name = "sortBy", defaultValue var pageable = PageRequest.of(page, PAGE_SIZE, Sort.by(sort, sortBy)); // Reception mode is on, filter sensitive events - if (Optional.ofNullable(receptionRepository.get()).map(ReceptionMode::getState).orElse(false)) { + if (darkmode.getCurrent()) { return activityRepository.findBySensitiveFalse(pageable); } else { return activityRepository.findAll(pageable);