fix: enforce adult profile pin visibility

This commit is contained in:
ShukeBta
2026-05-29 15:16:20 +08:00
parent 931db7a242
commit 633a8cf715
21 changed files with 839 additions and 39 deletions
+37
View File
@@ -0,0 +1,37 @@
import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'
interface PlayProfileState {
activeProfileId: string | null
activeProfilePinToken: string | null
setActiveProfile: (id: string | null, pinToken?: string | null) => void
setActiveProfileId: (id: string | null) => void
}
export const usePlayProfileStore = create<PlayProfileState>()(
persist(
(set) => ({
activeProfileId: null,
activeProfilePinToken: null,
setActiveProfile: (id, pinToken = null) =>
set({ activeProfileId: id || null, activeProfilePinToken: id ? pinToken || null : null }),
setActiveProfileId: (id) =>
set((state) => ({
activeProfileId: id || null,
activeProfilePinToken: id ? state.activeProfilePinToken : null,
})),
}),
{
name: 'mediastationgo-play-profile',
storage: createJSONStorage(() => sessionStorage),
},
),
)
export function getActivePlayProfileId(): string | null {
return usePlayProfileStore.getState().activeProfileId
}
export function getActivePlayProfilePinToken(): string | null {
return usePlayProfileStore.getState().activeProfilePinToken
}