Skip to content

Commit

Permalink
use 'persistent' cookie for 'graphic content' blurring (rather than s…
Browse files Browse the repository at this point in the history
…ession cookie)
  • Loading branch information
twrichards committed Nov 9, 2023
1 parent 9195efe commit 5edbd35
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion kahuna/public/js/services/graphic-image-blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import angular from "angular";
import 'angular-cookies';

const COOKIE_SHOULD_BLUR_GRAPHIC_IMAGES = 'SHOULD_BLUR_GRAPHIC_IMAGES';
const cookieOptions = {domain: `.${window.location.host}`, path: '/'};
const sessionCookieOptions = {
domain: `.${window.location.host}`,
path: '/'
};
const cookieOptions = {
...sessionCookieOptions,
expires: new Date(Date.now() + 34473600000) //399 days from now (max cookie expiry time)
};

export const graphicImageBlurService = angular.module("kahuna.services.graphicImageBlur", ['ngCookies']).factory(
"graphicImageBlurService",
Expand All @@ -11,6 +18,9 @@ export const graphicImageBlurService = angular.module("kahuna.services.graphicIm
const shouldBlurGraphicImagesCookieValue = $cookies.get(COOKIE_SHOULD_BLUR_GRAPHIC_IMAGES);
const isYetToAcknowledgeBlurGraphicImages = defaultShouldBlurGraphicImages && !shouldBlurGraphicImagesCookieValue; // i.e. cookie not set, one way or the other
const shouldBlurGraphicImages = (shouldBlurGraphicImagesCookieValue || defaultShouldBlurGraphicImages.toString()) === "true";
if (!!shouldBlurGraphicImagesCookieValue){
$cookies.put(COOKIE_SHOULD_BLUR_GRAPHIC_IMAGES, shouldBlurGraphicImages.toString(), cookieOptions); // extend cookie expiry
}
return {
shouldBlurGraphicImages,
isYetToAcknowledgeBlurGraphicImages,
Expand Down

0 comments on commit 5edbd35

Please sign in to comment.