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:
co-authored by
David Hill
Dustin Deus
parent
453b61e27b
commit
1d2a7b4c86
@@ -7,12 +7,17 @@ import { useI18n } from "~/context/i18n"
|
|||||||
import { useLanguage } from "~/context/language"
|
import { useLanguage } from "~/context/language"
|
||||||
import { strip } from "~/lib/language"
|
import { strip } from "~/lib/language"
|
||||||
|
|
||||||
|
const DISMISSED_COOKIE = "desktop_promo_dismissed"
|
||||||
|
|
||||||
export function DesktopPromo() {
|
export function DesktopPromo() {
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const [visible, setVisible] = createSignal(true)
|
|
||||||
const request = getRequestEvent()?.request
|
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 hostname = request ? new URL(request.url).hostname : typeof window === "object" ? window.location.hostname : ""
|
||||||
const primaryHost =
|
const primaryHost =
|
||||||
hostname === "opencode.ai" || hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1"
|
hostname === "opencode.ai" || hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1"
|
||||||
@@ -36,7 +41,14 @@ export function DesktopPromo() {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</A>
|
</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>
|
<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">
|
<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" />
|
<path d="M5 5L15 15M15 5L5 15" stroke="currentColor" stroke-width="1.5" />
|
||||||
|
|||||||
Reference in New Issue
Block a user