"use client"; import React, { useEffect, useState } from "react"; import LazyLoadedImage from "../util/LazyLoadedImage"; import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; import { OctagonXIcon } from "lucide-react"; import { RobloxPremiumSmall, RobloxVerifiedSmall } from "@/components/roblox/RobloxTooltips"; import { useCurrentAccount } from "@/hooks/roblox/useCurrentAccount"; import { Skeleton } from "../ui/skeleton"; import { useFriendsPresence } from "@/hooks/roblox/usePresence"; import { useAccountSettings } from "@/hooks/roblox/useAccountSettings"; import { loadThumbnails } from "@/lib/thumbnailLoader"; import { toast } from "sonner"; import Link from "next/link"; import { Button } from "../ui/button"; // chatgpt + human function randomGreeting(name: string): string { const greetings = [`Howdy, ${name}`]; const index = Math.floor(Math.random() * greetings.length); return greetings[index]; } export function HomeLoggedInHeader() { const profile = useCurrentAccount(); const accountSettings = useAccountSettings(); const [preferredName, setPreferredName] = useState(null); const profileId = profile ? profile.id : undefined; const presence = useFriendsPresence(profileId ? [profileId] : []); useEffect(() => { if (typeof window === "undefined") return; const storedName = window.localStorage.getItem("UserPreferredName"); if (storedName) setPreferredName(storedName); }, []); if (profile === false) { return (
Failed to fetch account info Please make sure .ROBLOSECURITY is set! Is Roblox having an outage?
); } const userActivity = presence.find((b) => b.userId === profile?.id); const userPresence = userActivity?.userPresenceType; const borderColor = userPresence === 1 ? "border-blue/25 bg-blue/25" : userPresence === 2 ? "border-green/25 bg-green/25" : userPresence === 3 ? "border-yellow/25 bg-yellow/25" : userPresence === 0 ? "border-surface2/25 bg-surface2/25" : "border-red/25 bg-red/25"; const isLoaded = !!profile && !!accountSettings; return ( <> {/* */}
{ if (e.button === 2) { toast("[debug] reloading user pfp"); console.log("[debug] reloading user pfp"); loadThumbnails([ { type: "AvatarHeadShot", targetId: profile ? profile.id : 1, format: "webp", size: "720x720" } ]).catch(() => {}); } }} > {!isLoaded ? ( ) : ( )}
{isLoaded ? ( {randomGreeting( preferredName || profile.displayName || "Robloxian!" )} ) : ( <> )} {!!accountSettings && accountSettings.IsPremium === true ? ( ) : ( <> )} {isLoaded ? ( ) : ( <> )} {isLoaded ? ( <> @{profile.name} {!!userActivity && userPresence === 2 ? ( <> - {userActivity.lastLocation} ) : ( <> )} ) : ( )}
); }