mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-04 02:20:19 +01: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:
6
frontend/src/core/extensions/cookieConsentConfig.ts
Normal file
6
frontend/src/core/extensions/cookieConsentConfig.ts
Normal file
@@ -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 { useAppConfig } from '@app/contexts/AppConfigContext';
|
||||
import { TOUR_STATE_EVENT, type TourStatePayload } from '@app/constants/events';
|
||||
import { getCookieConsentOverrides } from '@app/extensions/cookieConsentConfig';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -112,9 +113,11 @@ export const useCookieConsent = ({
|
||||
}
|
||||
|
||||
try {
|
||||
const overrides = getCookieConsentOverrides();
|
||||
window.CookieConsent.run({
|
||||
autoShow: true,
|
||||
hideFromBots: false,
|
||||
...overrides,
|
||||
guiOptions: {
|
||||
consentModal: {
|
||||
layout: "bar",
|
||||
|
||||
7
frontend/src/desktop/extensions/cookieConsentConfig.ts
Normal file
7
frontend/src/desktop/extensions/cookieConsentConfig.ts
Normal file
@@ -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