From 9ee10eafba2ceb018270c0db010a8467a9ff90f6 Mon Sep 17 00:00:00 2001 From: Fabian Emilius Date: Tue, 27 Aug 2024 15:06:08 +0200 Subject: [PATCH] Email fixes --- .../src/components/GanttChart/GanttChart.tsx | 26 ++++++++++++------- client/src/pages/TopicPage/TopicPage.tsx | 2 +- server/mail-templates/thesis-closed.html | 2 -- server/mail-templates/thesis-created.html | 1 - server/mail-templates/thesis-final-grade.html | 2 -- .../thesistrack/ls1/utility/MailBuilder.java | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/src/components/GanttChart/GanttChart.tsx b/client/src/components/GanttChart/GanttChart.tsx index 5de0b74d..30ef6280 100644 --- a/client/src/components/GanttChart/GanttChart.tsx +++ b/client/src/components/GanttChart/GanttChart.tsx @@ -9,6 +9,7 @@ import { useState, useEffect, CSSProperties, + useRef, } from 'react' import { Button, Collapse, Group, Popover, RangeSlider, Text } from '@mantine/core' import { formatDate } from '../../utils/format' @@ -75,7 +76,7 @@ const GanttChart = (props: IGanttChartProps) => { const [hoveredTimelineItem, setHoveredTimelineItem] = useState() const [hoveredEventItem, setHoveredEventItem] = useState() - const [initialTouchDistance, setInitialTouchDistance] = useState() + const initialTouch = useRef<{ initialDistance: number; initialRange: DateRange } | null>(null) const currentTime = useMemo(() => Date.now(), []) @@ -135,12 +136,12 @@ const GanttChart = (props: IGanttChartProps) => { ) // Touch events for pinch to zoom - const zoomRange = (zoomFactor: number) => { - const center = (filteredRange[0] + filteredRange[1]) / 2 + const zoomRange = (zoomFactor: number, currentRange: DateRange) => { + const center = (currentRange[0] + currentRange[1]) / 2 setRange([ - Math.max(center - (center - filteredRange[0]) * zoomFactor, totalRange[0]), - Math.min(center + (filteredRange[1] - center) * zoomFactor, totalRange[1]), + Math.max(center - (center - currentRange[0]) * zoomFactor, totalRange[0]), + Math.min(center + (currentRange[1] - center) * zoomFactor, totalRange[1]), ]) } @@ -152,15 +153,21 @@ const GanttChart = (props: IGanttChartProps) => { const handleTouchStart = (e: TouchEvent) => { if (e.touches.length === 2) { - setInitialTouchDistance(getTouchDistance(e.touches[0], e.touches[1])) + initialTouch.current = { + initialDistance: getTouchDistance(e.touches[0], e.touches[1]), + initialRange: filteredRange, + } } } const handleTouchMove = (e: TouchEvent) => { - if (e.touches.length === 2 && initialTouchDistance) { + if (e.touches.length === 2 && initialTouch.current) { const currentDistance = getTouchDistance(e.touches[0], e.touches[1]) - zoomRange(currentDistance / initialTouchDistance) + zoomRange( + currentDistance / initialTouch.current.initialDistance, + initialTouch.current.initialRange, + ) } } @@ -168,7 +175,7 @@ const GanttChart = (props: IGanttChartProps) => { if (e.ctrlKey) { e.preventDefault() - zoomRange(e.deltaY < 0 ? 1.05 : 0.95) + zoomRange(e.deltaY < 0 ? 1.05 : 0.95, filteredRange) } } @@ -299,7 +306,6 @@ const GanttChart = (props: IGanttChartProps) => { onTouchStart={handleTouchStart} onTouchMove={handleTouchMove} onWheel={handleWheel} - style={{ touchAction: 'none' }} > {groups.map((group) => (
diff --git a/client/src/pages/TopicPage/TopicPage.tsx b/client/src/pages/TopicPage/TopicPage.tsx index 1c581a53..015becc2 100644 --- a/client/src/pages/TopicPage/TopicPage.tsx +++ b/client/src/pages/TopicPage/TopicPage.tsx @@ -37,7 +37,7 @@ const TopicPage = () => { Manage Topics )} - diff --git a/server/mail-templates/thesis-closed.html b/server/mail-templates/thesis-closed.html index 5e27d71d..532b830d 100644 --- a/server/mail-templates/thesis-closed.html +++ b/server/mail-templates/thesis-closed.html @@ -8,5 +8,3 @@

Full Details: {{thesisUrl}}

- -{{config.signature}} \ No newline at end of file diff --git a/server/mail-templates/thesis-created.html b/server/mail-templates/thesis-created.html index b45aa82c..95aac104 100644 --- a/server/mail-templates/thesis-created.html +++ b/server/mail-templates/thesis-created.html @@ -15,4 +15,3 @@ The next step is that you write a proposal and submit it on {{thesisUrl}}

-{{config.signature}} diff --git a/server/mail-templates/thesis-final-grade.html b/server/mail-templates/thesis-final-grade.html index abd26fe5..7bb084c3 100644 --- a/server/mail-templates/thesis-final-grade.html +++ b/server/mail-templates/thesis-final-grade.html @@ -16,5 +16,3 @@

Full Details: {{thesisUrl}}

- -{{config.signature}} \ No newline at end of file diff --git a/server/src/main/java/thesistrack/ls1/utility/MailBuilder.java b/server/src/main/java/thesistrack/ls1/utility/MailBuilder.java index bbe974f5..e9e60b18 100644 --- a/server/src/main/java/thesistrack/ls1/utility/MailBuilder.java +++ b/server/src/main/java/thesistrack/ls1/utility/MailBuilder.java @@ -218,7 +218,7 @@ public void send(JavaMailSender mailSender, UploadService uploadService) throws } for (User recipient : primaryRecipients) { - if (primarySenders.contains(recipient)) { + if (primarySenders.contains(recipient) && secondaryRecipients.isEmpty()) { continue; }