diff --git a/backend/src/main/java/com/github/binpastes/paste/api/PasteController.java b/backend/src/main/java/com/github/binpastes/paste/api/PasteController.java index 554540b..c4e7b11 100644 --- a/backend/src/main/java/com/github/binpastes/paste/api/PasteController.java +++ b/backend/src/main/java/com/github/binpastes/paste/api/PasteController.java @@ -6,7 +6,7 @@ import com.github.binpastes.paste.api.model.SearchView.SearchItemView; import com.github.binpastes.paste.api.model.SingleView; import com.github.binpastes.paste.domain.Paste; -import com.github.binpastes.paste.domain.PasteService; +import com.github.binpastes.paste.application.PasteService; import jakarta.validation.ConstraintViolationException; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; diff --git a/backend/src/main/java/com/github/binpastes/paste/domain/PasteService.java b/backend/src/main/java/com/github/binpastes/paste/application/PasteService.java similarity index 92% rename from backend/src/main/java/com/github/binpastes/paste/domain/PasteService.java rename to backend/src/main/java/com/github/binpastes/paste/application/PasteService.java index 7ac8789..efec282 100644 --- a/backend/src/main/java/com/github/binpastes/paste/domain/PasteService.java +++ b/backend/src/main/java/com/github/binpastes/paste/application/PasteService.java @@ -1,6 +1,8 @@ -package com.github.binpastes.paste.domain; +package com.github.binpastes.paste.application; -import com.github.binpastes.paste.business.tracking.TrackingService; +import com.github.binpastes.paste.application.tracking.TrackingService; +import com.github.binpastes.paste.domain.Paste; +import com.github.binpastes.paste.domain.PasteRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/src/main/java/com/github/binpastes/paste/business/tracking/MessagingClient.java b/backend/src/main/java/com/github/binpastes/paste/application/tracking/MessagingClient.java similarity index 98% rename from backend/src/main/java/com/github/binpastes/paste/business/tracking/MessagingClient.java rename to backend/src/main/java/com/github/binpastes/paste/application/tracking/MessagingClient.java index 2b056e7..356354d 100644 --- a/backend/src/main/java/com/github/binpastes/paste/business/tracking/MessagingClient.java +++ b/backend/src/main/java/com/github/binpastes/paste/application/tracking/MessagingClient.java @@ -1,4 +1,4 @@ -package com.github.binpastes.paste.business.tracking; +package com.github.binpastes.paste.application.tracking; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; diff --git a/backend/src/main/java/com/github/binpastes/paste/business/tracking/MessagingConfig.java b/backend/src/main/java/com/github/binpastes/paste/application/tracking/MessagingConfig.java similarity index 98% rename from backend/src/main/java/com/github/binpastes/paste/business/tracking/MessagingConfig.java rename to backend/src/main/java/com/github/binpastes/paste/application/tracking/MessagingConfig.java index f1ba16f..fd6a3f3 100644 --- a/backend/src/main/java/com/github/binpastes/paste/business/tracking/MessagingConfig.java +++ b/backend/src/main/java/com/github/binpastes/paste/application/tracking/MessagingConfig.java @@ -1,4 +1,4 @@ -package com.github.binpastes.paste.business.tracking; +package com.github.binpastes.paste.application.tracking; import org.apache.activemq.artemis.api.core.QueueConfiguration; import org.apache.activemq.artemis.api.core.RoutingType; diff --git a/backend/src/main/java/com/github/binpastes/paste/business/tracking/TrackingService.java b/backend/src/main/java/com/github/binpastes/paste/application/tracking/TrackingService.java similarity index 97% rename from backend/src/main/java/com/github/binpastes/paste/business/tracking/TrackingService.java rename to backend/src/main/java/com/github/binpastes/paste/application/tracking/TrackingService.java index 1382fac..37c8c81 100644 --- a/backend/src/main/java/com/github/binpastes/paste/business/tracking/TrackingService.java +++ b/backend/src/main/java/com/github/binpastes/paste/application/tracking/TrackingService.java @@ -1,4 +1,4 @@ -package com.github.binpastes.paste.business.tracking; +package com.github.binpastes.paste.application.tracking; import com.github.binpastes.paste.domain.PasteRepository; import jakarta.annotation.PostConstruct; diff --git a/backend/src/main/resources/application-dev.properties b/backend/src/main/resources/application-dev.properties index f1b1798..3a06073 100644 --- a/backend/src/main/resources/application-dev.properties +++ b/backend/src/main/resources/application-dev.properties @@ -2,7 +2,7 @@ #logging.level.io.r2dbc=TRACE #logging.level.org.apache.activemq.artemis.core.server=INFO #logging.level.org.flywaydb.core.internal.license.VersionPrinter=INFO -logging.level.com.github.binpastes.paste.business.tracking=DEBUG +logging.level.com.github.binpastes.paste.application.tracking=DEBUG spring.flyway.enabled=true spring.flyway.driver-class-name=org.h2.Driver diff --git a/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java b/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java index e7c585a..e7308ee 100644 --- a/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java +++ b/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java @@ -1,6 +1,6 @@ package com.github.binpastes.paste.api; -import com.github.binpastes.paste.domain.PasteService; +import com.github.binpastes.paste.application.PasteService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/backend/src/test/java/com/github/binpastes/paste/api/TrackingIT.java b/backend/src/test/java/com/github/binpastes/paste/api/TrackingIT.java index c91ed56..41d3be3 100644 --- a/backend/src/test/java/com/github/binpastes/paste/api/TrackingIT.java +++ b/backend/src/test/java/com/github/binpastes/paste/api/TrackingIT.java @@ -1,7 +1,7 @@ package com.github.binpastes.paste.api; -import com.github.binpastes.paste.business.tracking.MessagingClient; -import com.github.binpastes.paste.business.tracking.TrackingService; +import com.github.binpastes.paste.application.tracking.MessagingClient; +import com.github.binpastes.paste.application.tracking.TrackingService; import com.github.binpastes.paste.domain.Paste; import com.github.binpastes.paste.domain.Paste.PasteExposure; import com.github.binpastes.paste.domain.PasteRepository; diff --git a/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java b/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java index 51da4c1..cc7e81f 100644 --- a/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java +++ b/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java @@ -58,13 +58,13 @@ void trackPasteViewCount() { @DisplayName("track paste - updates lastViewed timestamp to most recent one") void trackPasteLastViewed() { var newPaste = Paste.newInstance(null, "someContent", null, false, PasteExposure.PUBLIC, null); - var now = LocalDateTime.now(); - var yesterday = now.minusDays(1); + var today = LocalDateTime.now(); + var yesterday = today.minusDays(1); - newPaste.trackView(now); + newPaste.trackView(today); newPaste.trackView(yesterday); - assertThat(newPaste.getLastViewed()).isEqualTo(now); + assertThat(newPaste.getLastViewed()).isEqualTo(today); assertThat(newPaste.getViews()).isEqualTo(2); } diff --git a/frontend/pom.xml b/frontend/pom.xml index b7423ba..64519e4 100644 --- a/frontend/pom.xml +++ b/frontend/pom.xml @@ -49,21 +49,28 @@ - org.apache.maven.plugins - maven-surefire-plugin + maven-resources-plugin - default-test + generate-resources + + resources + + + + + dist + + + ${project.build.outputDirectory}/static + + + + default-resources none - - - - org.apache.maven.plugins - maven-failsafe-plugin - - default-test + default-testResources none @@ -83,21 +90,22 @@ - maven-resources-plugin + org.apache.maven.plugins + maven-surefire-plugin - generate-resources - - resources - - - - - dist - - - ${project.build.outputDirectory}/static - + default-test + none + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + default + none diff --git a/frontend/src/components/CreatePaste/CreatePaste.tsx b/frontend/src/components/CreatePaste/CreatePaste.tsx index 4e5f4f1..c41233d 100644 --- a/frontend/src/components/CreatePaste/CreatePaste.tsx +++ b/frontend/src/components/CreatePaste/CreatePaste.tsx @@ -35,6 +35,9 @@ const CreatePaste: Component = ({onCreatePaste, initialPaste}) const [lastPasteUrl, setLastPasteUrl] = createSignal(); + let creationForm: HTMLFormElement + let submitInput: HTMLInputElement + onMount(() => { window.addEventListener("keydown", globalSubmitPaste); }) @@ -43,9 +46,6 @@ const CreatePaste: Component = ({onCreatePaste, initialPaste}) window.removeEventListener("keydown", globalSubmitPaste); }) - let creationForm: HTMLFormElement - let submitInput: HTMLInputElement - function globalSubmitPaste(e: KeyboardEvent) { if (e.altKey || e.shiftKey) { return; diff --git a/frontend/src/components/ReadPaste/ReadPaste.tsx b/frontend/src/components/ReadPaste/ReadPaste.tsx index 4499bbf..24a0466 100644 --- a/frontend/src/components/ReadPaste/ReadPaste.tsx +++ b/frontend/src/components/ReadPaste/ReadPaste.tsx @@ -16,11 +16,11 @@ const ReadPaste: Component = ({paste, onClonePaste, onDeletePast const [clearText, setClearText] = createSignal(); - createEffect(on(clearText, () => linkifyContent())); - let keyInput: HTMLInputElement; let contentElement: HTMLPreElement; + createEffect(on(clearText, () => linkifyContent())); + onMount(() => { window.addEventListener("keydown", globalSelectContent); }) diff --git a/frontend/src/components/RecentPastes/RecentPastes.tsx b/frontend/src/components/RecentPastes/RecentPastes.tsx index 2f46d84..4d539fb 100644 --- a/frontend/src/components/RecentPastes/RecentPastes.tsx +++ b/frontend/src/components/RecentPastes/RecentPastes.tsx @@ -11,10 +11,14 @@ const RecentPastes: () => JSX.Element = () => { const [pastes, { mutate, refetch }] = createResource(ApiClient.findAll); + let refetchSchedule; + onMount(() => { startSchedule(); AppContext.onPasteCreated((paste) => { + restartSchedule(); + const newItem: PasteListView = { id: paste.id, title: paste.title, @@ -23,9 +27,7 @@ const RecentPastes: () => JSX.Element = () => { isEncrypted: paste.isEncrypted, sizeInBytes: paste.sizeInBytes }; - - restartSchedule(); - mutate(prev => [newItem].concat(prev)) + mutate(prev => prev.concat([newItem])); }); AppContext.onPasteDeleted((paste) => { @@ -36,8 +38,6 @@ const RecentPastes: () => JSX.Element = () => { onCleanup(() => stopSchedule()); - let refetchSchedule; - function manualRefetch() { restartSchedule(); refetch(); diff --git a/frontend/src/pages/Create.tsx b/frontend/src/pages/Create.tsx index bb047b5..282c3c0 100644 --- a/frontend/src/pages/Create.tsx +++ b/frontend/src/pages/Create.tsx @@ -9,7 +9,7 @@ const Create: () => JSX.Element = () => { const navigate = useNavigate(); - const onCreatePaste = (cmd: PasteCreateCmd): Promise => { + function onCreatePaste(cmd: PasteCreateCmd): Promise { return ApiClient.createPaste(cmd) .then(paste => { const path = '/paste/' + paste.id; diff --git a/frontend/src/pages/Read.tsx b/frontend/src/pages/Read.tsx index 38a671d..7bfe76e 100644 --- a/frontend/src/pages/Read.tsx +++ b/frontend/src/pages/Read.tsx @@ -14,7 +14,7 @@ const Read: Component = (): JSX.Element => { const [paste] = createResource(() => params.id, (id) => AppContext.popPasteCreated() || ApiClient.findOne(id)); - const clonePaste = () => { + function clonePaste() { AppContext.pushPasteCloned({ title: paste().title, content: paste().content @@ -22,7 +22,7 @@ const Read: Component = (): JSX.Element => { navigate('/') } - const deletePaste = () => { + function deletePaste() { ApiClient.deletePaste(paste().id) .then(_ => { AppContext.pushPasteDeleted(paste()); diff --git a/pom.xml b/pom.xml index 8609197..738e74c 100644 --- a/pom.xml +++ b/pom.xml @@ -157,8 +157,8 @@ - scm:git:https://github.com/querwurzel/binpastes.git - scm:git:https://github.com/querwurzel/binpastes.git + scm:git:https://github.com/querwurzel/BinPastes.git + scm:git:https://github.com/querwurzel/BinPastes.git HEAD