fix(consent): avoid banner flashing on reload
Initialize consent state from cookie synchronously so the banner only shows when no choice was made. fix(api): fail-soft when DB schema missing Return null/empty content for CMS endpoints when migrations are not applied instead of crashing with Prisma P2021/P2022. fix(n8n): parse status response defensively Handle empty/invalid JSON bodies from n8n to prevent activity feed from getting stuck. Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
||||
import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
|
||||
|
||||
export type ConsentState = {
|
||||
analytics: boolean;
|
||||
@@ -46,11 +46,8 @@ const ConsentContext = createContext<{
|
||||
});
|
||||
|
||||
export function ConsentProvider({ children }: { children: React.ReactNode }) {
|
||||
const [consent, setConsentState] = useState<ConsentState | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setConsentState(readConsentFromCookie());
|
||||
}, []);
|
||||
// Read cookie synchronously so we don't flash the banner on every reload.
|
||||
const [consent, setConsentState] = useState<ConsentState | null>(() => readConsentFromCookie());
|
||||
|
||||
const setConsent = useCallback((next: ConsentState) => {
|
||||
setConsentState(next);
|
||||
|
||||
Reference in New Issue
Block a user