tag to
tag for semantic
HTML on the top-most UI buttons for an active page
---
app/components/layout/index.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/components/layout/index.tsx b/app/components/layout/index.tsx
index b04831c4d..783e079f1 100644
--- a/app/components/layout/index.tsx
+++ b/app/components/layout/index.tsx
@@ -68,7 +68,7 @@ export const Layout = React.memo(function Layout({
)}
{children}
From 9d6c86b5abf380748296e55e6e147094ded4e866 Mon Sep 17 00:00:00 2001
From: Remmy Cat Stock <3317423+remmycat@users.noreply.github.com>
Date: Thu, 27 Oct 2022 22:28:56 +0200
Subject: [PATCH 19/21] Fix theme switching via cookie during development
---
app/modules/theme/session.server.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/modules/theme/session.server.ts b/app/modules/theme/session.server.ts
index 65e86d62c..fcae1a93c 100644
--- a/app/modules/theme/session.server.ts
+++ b/app/modules/theme/session.server.ts
@@ -14,7 +14,7 @@ const sessionSecret = process.env["SESSION_SECRET"] ?? "secret";
const themeStorage = createCookieSessionStorage({
cookie: {
name: "theme",
- secure: true,
+ secure: process.env.NODE_ENV === "production",
secrets: [sessionSecret],
sameSite: "lax",
path: "/",
From d5677cf7e80dc6393a50474441d42345259d34a9 Mon Sep 17 00:00:00 2001
From: Remmy Cat Stock <3317423+remmycat@users.noreply.github.com>
Date: Thu, 27 Oct 2022 23:12:48 +0200
Subject: [PATCH 20/21] Remove useOnce hook
---
app/components/MapPoolSelector.tsx | 15 +++++++++++----
app/hooks/useOnce.ts | 10 ----------
app/routes/maps.tsx | 5 +----
3 files changed, 12 insertions(+), 18 deletions(-)
delete mode 100644 app/hooks/useOnce.ts
diff --git a/app/components/MapPoolSelector.tsx b/app/components/MapPoolSelector.tsx
index d02d340a1..fa342f8a8 100644
--- a/app/components/MapPoolSelector.tsx
+++ b/app/components/MapPoolSelector.tsx
@@ -18,7 +18,6 @@ import type { CalendarEvent } from "~/db/types";
import type { SerializedMapPoolEvent } from "~/routes/calendar/map-pool-events";
import { assertType } from "~/utils/types";
import { MapPoolEventsCombobox } from "./Combobox";
-import { useOnce } from "~/hooks/useOnce";
export type MapPoolSelectorProps = {
mapPool: MapPool;
@@ -46,8 +45,8 @@ export function MapPoolSelector({
initialEvent ? "event" : detectTemplate(mapPool)
);
- const initialSerializedEvent: SerializedMapPoolEvent | undefined = useOnce(
- () =>
+ const [initialSerializedEvent, setInitialSerializedEvent] = React.useState(
+ (): SerializedMapPoolEvent | undefined =>
initialEvent && {
...initialEvent,
serializedMapPool: mapPool.serialized,
@@ -67,7 +66,15 @@ export function MapPoolSelector({
const handleTemplateChange = (template: MapPoolTemplateValue) => {
setTemplate(template);
- if (template === "none" || template === "event") {
+ if (template === "none") {
+ return;
+ }
+
+ if (template === "event") {
+ // If the user selected the "event" option, the _initial_ event passed via
+ // props is likely not the current state and should not be prefilled
+ // anymore.
+ setInitialSerializedEvent(undefined);
return;
}
diff --git a/app/hooks/useOnce.ts b/app/hooks/useOnce.ts
deleted file mode 100644
index 4296bf40a..000000000
--- a/app/hooks/useOnce.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { useMemo } from "react";
-
-/**
- * Utility hook for calling `useMemo(f, [])`, when you're sure it needs no
- * revalidation but feel bad for getting shamed by eslint everytime :D
- */
-export function useOnce
(factory: () => T) {
- // eslint-disable-next-line react-hooks/exhaustive-deps
- return useMemo(factory, []);
-}
diff --git a/app/routes/maps.tsx b/app/routes/maps.tsx
index 2123637f7..d1fbcebe7 100644
--- a/app/routes/maps.tsx
+++ b/app/routes/maps.tsx
@@ -30,7 +30,6 @@ import { calendarEventPage, ipLabsMaps } from "~/utils/urls";
import { type SendouRouteHandle } from "~/utils/remix";
import { MapPoolSelector, MapPoolStages } from "~/components/MapPoolSelector";
import { EditIcon } from "~/components/icons/Edit";
-import { useOnce } from "~/hooks/useOnce";
import { getUser } from "~/modules/auth";
import type { CalendarEvent } from "~/db/types";
@@ -145,7 +144,7 @@ function useSearchParamPersistedMapPool() {
const data = useLoaderData();
const [searchParams, setSearchParams] = useSearchParams();
- const initialMapPool = useOnce(() => {
+ const [mapPool, setMapPool] = React.useState(() => {
if (searchParams.has("pool")) {
return new MapPool(searchParams.get("pool")!);
}
@@ -157,8 +156,6 @@ function useSearchParamPersistedMapPool() {
return MapPool.ANARCHY;
});
- const [mapPool, setMapPool] = React.useState(initialMapPool);
-
const handleMapPoolChange = (
newMapPool: MapPool,
event?: Pick
From 6019b0f906b5bacfdd1b3b40ba7323d78e1fb3c7 Mon Sep 17 00:00:00 2001
From: Kalle <38327916+Sendouc@users.noreply.github.com>
Date: Fri, 28 Oct 2022 09:26:45 +0300
Subject: [PATCH 21/21] Perf optimization: prefetch pages without loader
---
app/components/layout/Menu.tsx | 1 +
app/components/layout/nav-items.json | 22 ++++++++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/app/components/layout/Menu.tsx b/app/components/layout/Menu.tsx
index 4486f0f4d..9a636973b 100644
--- a/app/components/layout/Menu.tsx
+++ b/app/components/layout/Menu.tsx
@@ -43,6 +43,7 @@ export function Menu({
onClick={closeMenu}
data-cy={`menu-link-${navItem.name}`}
tabIndex={!expanded ? -1 : undefined}
+ prefetch={navItem.prefetch ? "render" : undefined}
>