Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show DI newsletter banner on top of cookie banner #3824

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/CookiePreferencesManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Preference {

export const POLICY_DATE: number = 20201009
export const DATE_FORMAT = "YYYYMMDD"
const COOKIE_NAME = "cookie_preferences"
export const COOKIE_NAME = "cookie_preferences"
rakyi marked this conversation as resolved.
Show resolved Hide resolved
const PREFERENCES_SEPARATOR = "|"
const DATE_SEPARATOR = "-"
const PREFERENCE_KEY_VALUE_SEPARATOR = ":"
Expand Down
4 changes: 3 additions & 1 deletion site/DataInsightsNewsletterBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react"
import { useState, useEffect } from "react"
import Cookies from "js-cookie"
import cx from "classnames"
import { COOKIE_NAME as PREFERENCES_COOKIE_NAME } from "./CookiePreferencesManager.js"
import { NewsletterSubscriptionContext } from "./newsletter.js"
import DataInsightsNewsletter from "./gdocs/components/DataInsightsNewsletter.js"

Expand All @@ -12,7 +13,8 @@ export default function DataInsightsNewsletterBanner() {
const [isHiding, setIsHiding] = useState(false)

useEffect(() => {
const keepHidden = Cookies.get(COOKIE_NAME)
const keepHidden =
Cookies.get(COOKIE_NAME) || !Cookies.get(PREFERENCES_COOKIE_NAME)
if (keepHidden) return
const timeoutId = setTimeout(() => {
setIsVisible(true)
Expand Down