mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Fix cookie consent reappearing on desktop builds (#5780)
# Description of Changes Fix #5779. Cookie consent persistance doesn't work on desktop (on Mac at least, not sure about Windows) because of permission differences with Tauri. We are allowed to store things in local storage fine, so this switches the cookie consent module to store in local storage for desktop, and leaves it alone for web, where it already worked correctly.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Optional overrides for cookie consent config.
|
||||||
|
*/
|
||||||
|
export function getCookieConsentOverrides(): Record<string, unknown> {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { BASE_PATH } from '@app/constants/app';
|
import { BASE_PATH } from '@app/constants/app';
|
||||||
import { useAppConfig } from '@app/contexts/AppConfigContext';
|
import { useAppConfig } from '@app/contexts/AppConfigContext';
|
||||||
import { TOUR_STATE_EVENT, type TourStatePayload } from '@app/constants/events';
|
import { TOUR_STATE_EVENT, type TourStatePayload } from '@app/constants/events';
|
||||||
|
import { getCookieConsentOverrides } from '@app/extensions/cookieConsentConfig';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -112,9 +113,11 @@ export const useCookieConsent = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const overrides = getCookieConsentOverrides();
|
||||||
window.CookieConsent.run({
|
window.CookieConsent.run({
|
||||||
autoShow: true,
|
autoShow: true,
|
||||||
hideFromBots: false,
|
hideFromBots: false,
|
||||||
|
...overrides,
|
||||||
guiOptions: {
|
guiOptions: {
|
||||||
consentModal: {
|
consentModal: {
|
||||||
layout: "bar",
|
layout: "bar",
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export function getCookieConsentOverrides(): Record<string, unknown> {
|
||||||
|
return {
|
||||||
|
cookie: {
|
||||||
|
useLocalStorage: true, // Cookies don't reliably persist on desktop, but localStorage does
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user