Purge legacy mock state
cgen-3b2d4b3d2140486784ff46322272c16b
This commit is contained in:
parent
3db9b5bafa
commit
65d1262b2f
1 changed files with 24 additions and 1 deletions
|
|
@ -150,6 +150,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
const [session, setSession] = useState<Session | null>(null);
|
const [session, setSession] = useState<Session | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const rewardsActivatedRef = useRef(false);
|
const rewardsActivatedRef = useRef(false);
|
||||||
|
const storageClearedRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Add timeout to ensure loading doesn't get stuck
|
// Add timeout to ensure loading doesn't get stuck
|
||||||
|
|
@ -158,6 +159,22 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
if (!storageClearedRef.current && typeof window !== "undefined") {
|
||||||
|
try {
|
||||||
|
[
|
||||||
|
"mock_user",
|
||||||
|
"mock_profile",
|
||||||
|
"mock_linked_provider_map",
|
||||||
|
"demo_profiles",
|
||||||
|
"demo_posts",
|
||||||
|
"demo_seed_v1",
|
||||||
|
].forEach((key) => window.localStorage.removeItem(key));
|
||||||
|
storageClearedRef.current = true;
|
||||||
|
} catch {
|
||||||
|
storageClearedRef.current = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get initial session
|
// Get initial session
|
||||||
supabase.auth
|
supabase.auth
|
||||||
.getSession()
|
.getSession()
|
||||||
|
|
@ -531,8 +548,14 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
try {
|
try {
|
||||||
window.localStorage.removeItem("onboarding_complete");
|
window.localStorage.removeItem("onboarding_complete");
|
||||||
|
const shouldRemove = (key: string) =>
|
||||||
|
key.startsWith("sb-") ||
|
||||||
|
key.includes("supabase") ||
|
||||||
|
key.startsWith("mock_") ||
|
||||||
|
key.startsWith("demo_");
|
||||||
|
|
||||||
Object.keys(window.localStorage)
|
Object.keys(window.localStorage)
|
||||||
.filter((key) => key.startsWith("sb-") || key.includes("supabase"))
|
.filter(shouldRemove)
|
||||||
.forEach((key) => {
|
.forEach((key) => {
|
||||||
window.localStorage.removeItem(key);
|
window.localStorage.removeItem(key);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue