better dummy data and error fix

This commit is contained in:
zmeyer44 2023-10-15 12:11:39 -04:00
parent e9a9ec90d8
commit b2ec3a5c03
8 changed files with 40 additions and 26 deletions

View File

@ -31,7 +31,11 @@ export default function BottomNav() {
<footer className="z-header- flex h-[var(--bottom-nav-height)] w-full sm:hidden"> <footer className="z-header- flex h-[var(--bottom-nav-height)] w-full sm:hidden">
<div className="bottom-tabs fixed inset-x-0 bottom-0 flex h-[var(--bottom-nav-height)] flex-1 items-stretch justify-between border-t bg-background px-4"> <div className="bottom-tabs fixed inset-x-0 bottom-0 flex h-[var(--bottom-nav-height)] flex-1 items-stretch justify-between border-t bg-background px-4">
{navigationItems.map((item) => ( {navigationItems.map((item) => (
<Link href={item.href} className="center group group flex-1"> <Link
key={item.name}
href={item.href}
className="center group group flex-1"
>
<item.icon <item.icon
className={cn( className={cn(
item.current item.current

View File

@ -28,6 +28,7 @@ import {
TooltipProvider, TooltipProvider,
TooltipTrigger, TooltipTrigger,
} from "@/components/ui/tooltip"; } from "@/components/ui/tooltip";
const LoginModal = dynamic(() => import("@/components/Modals/Login"), { const LoginModal = dynamic(() => import("@/components/Modals/Login"), {
ssr: false, ssr: false,
}); });
@ -36,7 +37,9 @@ export default function AuthActions() {
const modal = useModal(); const modal = useModal();
const { currentUser, logout, attemptLogin } = useCurrentUser(); const { currentUser, logout, attemptLogin } = useCurrentUser();
useEffect(() => { useEffect(() => {
attemptLogin(); if (!currentUser) {
void attemptLogin();
}
}, []); }, []);
if (currentUser) { if (currentUser) {
return ( return (

View File

@ -22,8 +22,8 @@ export default function Header() {
<div className="center hidden min-h-[var(--header-height)] lg:flex"> <div className="center hidden min-h-[var(--header-height)] lg:flex">
<ul className="font-condensed flex w-full max-w-xl items-center justify-between text-base font-semibold uppercase text-zinc-500 hover:text-zinc-600"> <ul className="font-condensed flex w-full max-w-xl items-center justify-between text-base font-semibold uppercase text-zinc-500 hover:text-zinc-600">
{navigation.slice(0, 2).map((item) => ( {navigation.slice(0, 2).map((item) => (
<li className=""> <li key={item.name} className="">
<Link key={item.name} href={item.href} className="flex p-1"> <Link href={item.href} className="flex p-1">
<div className="center w-full ">{item.label}</div> <div className="center w-full ">{item.label}</div>
</Link> </Link>
</li> </li>
@ -32,8 +32,8 @@ export default function Header() {
<Logo className="h-8 w-8 text-primary" /> <Logo className="h-8 w-8 text-primary" />
</Link> </Link>
{navigation.slice(2, 4).map((item) => ( {navigation.slice(2, 4).map((item) => (
<li className=""> <li key={item.name} className="">
<Link key={item.name} href={item.href} className="flex p-1"> <Link href={item.href} className="flex p-1">
<div className="center w-full">{item.label}</div> <div className="center w-full">{item.label}</div>
</Link> </Link>
</li> </li>
@ -60,8 +60,8 @@ export default function Header() {
<nav className="lg:hidden"> <nav className="lg:hidden">
<ul className="mb-5 flex w-full flex-col items-stretch border-t"> <ul className="mb-5 flex w-full flex-col items-stretch border-t">
{navigation.map((item) => ( {navigation.map((item) => (
<li className=""> <li key={item.name} className="">
<Link key={item.name} href={item.href} className="flex p-1"> <Link href={item.href} className="flex p-1">
<div className="center w-full rounded-sm bg-zinc-50 py-3 hover:bg-zinc-100"> <div className="center w-full rounded-sm bg-zinc-50 py-3 hover:bg-zinc-100">
{item.label} {item.label}
</div> </div>

View File

@ -37,8 +37,8 @@ export default function Kind1(props: Event) {
</CardDescription> </CardDescription>
{!!r.length && ( {!!r.length && (
<div className="mt-1.5 flex flex-wrap"> <div className="mt-1.5 flex flex-wrap">
{r.map((url) => ( {r.map((url, idx) => (
<LinkCard key={url} url={url} className="max-w-[250px]" /> <LinkCard key={idx} url={url} className="max-w-[250px]" />
))} ))}
</div> </div>
)} )}

View File

@ -46,7 +46,7 @@ export default function VideoCard({ className, card }: VideoCardProps) {
</div> </div>
<div className="-mt-1 flex gap-2 overflow-x-scroll"> <div className="-mt-1 flex gap-2 overflow-x-scroll">
{card.tags.map((tag) => ( {card.tags.map((tag) => (
<Badge>{tag}</Badge> <Badge key={tag}>{tag}</Badge>
))} ))}
</div> </div>
</div> </div>

View File

@ -5,7 +5,7 @@ export const DUMMY_1: Event = {
id: "test", id: "test",
content: "Time for nostr to take over twitter", content: "Time for nostr to take over twitter",
kind: 1, kind: 1,
pubkey: "235235", pubkey: "f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca",
sig: "wetwet", sig: "wetwet",
tags: [["t", "nostr"]], tags: [["t", "nostr"]],
created_at: unixTimeNowInSeconds() - 3600, created_at: unixTimeNowInSeconds() - 3600,
@ -32,7 +32,7 @@ export const DUMMY_30023: Event = {
"wss://relay.nostr.org", "wss://relay.nostr.org",
], ],
], ],
pubkey: "...", pubkey: "f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca",
id: "...", id: "...",
sig: "wetwet", sig: "wetwet",
}; };

View File

@ -40,18 +40,22 @@ export default function useCurrentUser() {
// }); // });
async function attemptLogin() { async function attemptLogin() {
const shouldReconnect = localStorage.getItem("shouldReconnect"); try {
if (!shouldReconnect || typeof window.nostr === "undefined") return; const shouldReconnect = localStorage.getItem("shouldReconnect");
const user = await loginWithNip07(); if (!shouldReconnect || typeof window.nostr === "undefined") return;
if (!user) { const user = await loginWithNip07();
throw new Error("NO auth"); if (!user) {
throw new Error("NO auth");
}
console.log("LOGIN", user);
await loginWithPubkey(nip19.decode(user.npub).data.toString());
if (typeof window.webln !== "undefined") {
await window.webln.enable();
}
console.log("connected ");
} catch (err) {
console.log("Error at attemptLogin", err);
} }
console.log("LOGIN", user);
await loginWithPubkey(nip19.decode(user.npub).data.toString());
if (typeof window.webln !== "undefined") {
await window.webln.enable();
}
console.log("connected ");
} }
function logout() { function logout() {
@ -75,7 +79,8 @@ export default function useCurrentUser() {
} }
async function loginWithPubkey(pubkey: string) { async function loginWithPubkey(pubkey: string) {
const user = ndk!.getUser({ hexpubkey: pubkey }); if (!ndk) return;
const user = ndk.getUser({ hexpubkey: pubkey });
console.log("user", user); console.log("user", user);
await user.fetchProfile(); await user.fetchProfile();
setCurrentUser(user); setCurrentUser(user);

View File

@ -14,7 +14,9 @@ export default function useProfile(key: string) {
key = nip19.decode(key).data.toString(); key = nip19.decode(key).data.toString();
} }
return () => { return () => {
void ndk.getUser({ hexpubkey: key }).fetchProfile(); if (ndk) {
void ndk.getUser({ hexpubkey: key }).fetchProfile();
}
}; };
}, [key, ndk]); }, [key, ndk]);