forge
Explore
Log in

Don't you dare go Hollow

🐛 stop exam pages fetching junk ids while navigating away - anchor exam detail and exam room id parsing to their route shapes - keep the previous id during exit transitions instead of adopting the next page's last path segment - removes transient GET /exams/exams and GET /exams/events 404s on every navigation out of exam pages

Browse files at this commit

42fe896d7c50677eb75a6988817be2cec52adcdaAhmet Kaan GümüşParent: 4aecb40
  • fix
    • 🐛 stop exam pages fetching junk ids while navigating away - anchor exam detail and exam room id parsing to their route shapes - keep the previous id during exit transitions instead of adopting the next page's last path segment - removes transient GET /exams/exams and GET /exams/events 404s on every navigation out of exam pages
Show full message
fix: 🐛 stop exam pages fetching junk ids while navigating away - anchor exam detail and exam room id parsing to their route shapes - keep the previous id during exit transitions instead of adopting the next page's last path segment - removes transient GET /exams/exams and GET /exams/events 404s on every navigation out of exam pages
src/pages/exam-detail-page.tsxmodified+6 -1
@@ -62,7 +62,12 @@ function ExamDetailContent() {
6262 const t = useT();
6363 const { locale } = usePreferences();
6464 const now = createNow();
65- const id = createMemo(() => decodeURIComponent(location().pathname.split("/").pop() ?? ""));
65+ // Keep the previous id while navigating away, so the resource does not
66+ // fetch the next page's path segment (e.g. GET /exams/exams) mid-transition.
67+ const id = createMemo((prev: string) => {
68+ const match = /^\/exams\/([^/]+)$/.exec(location().pathname);
69+ return match ? decodeURIComponent(match[1]) : prev;
70+ }, "");
6671
6772 const [exam, { refetch: refetchExam }] = createResource(id, (examId) => getExamById(examId));
6873 const [settings] = createResource(() => getSettings());
src/pages/exam-room-page.tsxmodified+6 -1
@@ -25,7 +25,12 @@ function ExamRoomContent() {
2525 const location = useLocation();
2626 const auth = useAuth();
2727 const t = useT();
28- const id = createMemo(() => decodeURIComponent(location().pathname.split("/").pop() ?? ""));
28+ // Keep the previous id while navigating away, so the resource does not
29+ // fetch the next page's path segment (e.g. GET /exams/exams) mid-transition.
30+ const id = createMemo((prev: string) => {
31+ const match = /^\/exam-room\/([^/]+)$/.exec(location().pathname);
32+ return match ? decodeURIComponent(match[1]) : prev;
33+ }, "");
2934 const [exam] = createResource(id, (examId) => getExamById(examId));
3035 const [mine] = createResource(
3136 () => (auth.user()?.role === "student" ? true : null),