fix(console): persist desktop promo dismissal (#37121)
Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com>
This commit is contained in:
parent
453b61e27b
commit
1d2a7b4c86
1 changed files with 14 additions and 2 deletions
|
|
@ -7,12 +7,17 @@ import { useI18n } from "~/context/i18n"
|
|||
import { useLanguage } from "~/context/language"
|
||||
import { strip } from "~/lib/language"
|
||||
|
||||
const DISMISSED_COOKIE = "desktop_promo_dismissed"
|
||||
|
||||
export function DesktopPromo() {
|
||||
const i18n = useI18n()
|
||||
const language = useLanguage()
|
||||
const location = useLocation()
|
||||
const [visible, setVisible] = createSignal(true)
|
||||
const request = getRequestEvent()?.request
|
||||
const cookie = request?.headers.get("cookie") ?? (typeof document === "object" ? document.cookie : "")
|
||||
const [visible, setVisible] = createSignal(
|
||||
!cookie.split(";").some((value) => value.trim() === `${DISMISSED_COOKIE}=1`),
|
||||
)
|
||||
const hostname = request ? new URL(request.url).hostname : typeof window === "object" ? window.location.hostname : ""
|
||||
const primaryHost =
|
||||
hostname === "opencode.ai" || hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1"
|
||||
|
|
@ -36,7 +41,14 @@ export function DesktopPromo() {
|
|||
</span>
|
||||
</span>
|
||||
</A>
|
||||
<button type="button" data-slot="desktop-promo-close" onClick={() => setVisible(false)}>
|
||||
<button
|
||||
type="button"
|
||||
data-slot="desktop-promo-close"
|
||||
onClick={() => {
|
||||
document.cookie = `${DISMISSED_COOKIE}=1; Path=/; Max-Age=31536000; SameSite=Lax`
|
||||
setVisible(false)
|
||||
}}
|
||||
>
|
||||
<span class="sr-only">{i18n.t("home.promo.close")}</span>
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true">
|
||||
<path d="M5 5L15 15M15 5L5 15" stroke="currentColor" stroke-width="1.5" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue