fix(MessageEntriesModal): automatically load all pages
Build and Push Docker image / build-and-push (push) Successful in 5m15s Details

This commit is contained in:
Valentin Kolb 2024-06-21 16:41:20 +02:00
parent 329b5ba5ff
commit 90e30ed1ae
2 changed files with 11 additions and 3 deletions

View File

@ -70,7 +70,7 @@ export default function Announcement({announcement}: {
{", Zeitslot "} {", Zeitslot "}
{pprintDateRange(entry.slotStartDate, entry.slotEndDate)} {pprintDateRange(entry.slotStartDate, entry.slotEndDate)}
{", "} {", "}
{humanDeltaFromNow(entry.created).message} {humanDeltaFromNow(entry.slotStartDate).message}
</List.Item> </List.Item>
))} ))}
</List> </List>

View File

@ -9,6 +9,7 @@ import TextEditor from "@/components/input/Editor";
import ListSelect from "@/pages/events/e/:eventId/EventLists/ListSelect.tsx"; import ListSelect from "@/pages/events/e/:eventId/EventLists/ListSelect.tsx";
import {showSuccessNotification} from "@/components/util.tsx"; import {showSuccessNotification} from "@/components/util.tsx";
import {usePB} from "@/lib/pocketbase.tsx"; import {usePB} from "@/lib/pocketbase.tsx";
import {useEffect} from "react";
export default function MessageEntriesModal({opened, event, onClose, query}: { export default function MessageEntriesModal({opened, event, onClose, query}: {
@ -34,11 +35,18 @@ export default function MessageEntriesModal({opened, event, onClose, query}: {
selectedLists: [] as EventListModel[], selectedLists: [] as EventListModel[],
}, },
validate: { validate: {
subject: hasLength({max: 255}, "Der Betreff ist zu lang"), subject: hasLength({max: 255}, "Der Betreff ist zu lang (max. 255 Zeichen)"),
content: hasLength({min: 10, max: 5000}, "Die Nachricht muss zwischen 10 und 5000 Zeichen lang sein"), content: hasLength({min: 10, max: 10000}, "Die Nachricht muss zwischen 10 und 10000 Zeichen lang sein"),
} }
}) })
// Fetch all pages
useEffect(() => {
if (opened && query.hasNextPage && !query.isFetchingNextPage) {
query.fetchNextPage()
}
}, [opened, query])
const mutation = useMutation({ const mutation = useMutation({
mutationFn: async () => { mutationFn: async () => {
await pb.collection("messages").create({ await pb.collection("messages").create({