better dummy data and error fix
This commit is contained in:
parent
e9a9ec90d8
commit
b2ec3a5c03
@ -31,7 +31,11 @@ export default function BottomNav() {
|
||||
<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">
|
||||
{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
|
||||
className={cn(
|
||||
item.current
|
||||
|
@ -28,6 +28,7 @@ import {
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
|
||||
const LoginModal = dynamic(() => import("@/components/Modals/Login"), {
|
||||
ssr: false,
|
||||
});
|
||||
@ -36,7 +37,9 @@ export default function AuthActions() {
|
||||
const modal = useModal();
|
||||
const { currentUser, logout, attemptLogin } = useCurrentUser();
|
||||
useEffect(() => {
|
||||
attemptLogin();
|
||||
if (!currentUser) {
|
||||
void attemptLogin();
|
||||
}
|
||||
}, []);
|
||||
if (currentUser) {
|
||||
return (
|
||||
|
@ -22,8 +22,8 @@ export default function Header() {
|
||||
<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">
|
||||
{navigation.slice(0, 2).map((item) => (
|
||||
<li className="">
|
||||
<Link key={item.name} href={item.href} className="flex p-1">
|
||||
<li key={item.name} className="">
|
||||
<Link href={item.href} className="flex p-1">
|
||||
<div className="center w-full ">{item.label}</div>
|
||||
</Link>
|
||||
</li>
|
||||
@ -32,8 +32,8 @@ export default function Header() {
|
||||
<Logo className="h-8 w-8 text-primary" />
|
||||
</Link>
|
||||
{navigation.slice(2, 4).map((item) => (
|
||||
<li className="">
|
||||
<Link key={item.name} href={item.href} className="flex p-1">
|
||||
<li key={item.name} className="">
|
||||
<Link href={item.href} className="flex p-1">
|
||||
<div className="center w-full">{item.label}</div>
|
||||
</Link>
|
||||
</li>
|
||||
@ -60,8 +60,8 @@ export default function Header() {
|
||||
<nav className="lg:hidden">
|
||||
<ul className="mb-5 flex w-full flex-col items-stretch border-t">
|
||||
{navigation.map((item) => (
|
||||
<li className="">
|
||||
<Link key={item.name} href={item.href} className="flex p-1">
|
||||
<li key={item.name} className="">
|
||||
<Link href={item.href} className="flex p-1">
|
||||
<div className="center w-full rounded-sm bg-zinc-50 py-3 hover:bg-zinc-100">
|
||||
{item.label}
|
||||
</div>
|
||||
|
@ -37,8 +37,8 @@ export default function Kind1(props: Event) {
|
||||
</CardDescription>
|
||||
{!!r.length && (
|
||||
<div className="mt-1.5 flex flex-wrap">
|
||||
{r.map((url) => (
|
||||
<LinkCard key={url} url={url} className="max-w-[250px]" />
|
||||
{r.map((url, idx) => (
|
||||
<LinkCard key={idx} url={url} className="max-w-[250px]" />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
@ -46,7 +46,7 @@ export default function VideoCard({ className, card }: VideoCardProps) {
|
||||
</div>
|
||||
<div className="-mt-1 flex gap-2 overflow-x-scroll">
|
||||
{card.tags.map((tag) => (
|
||||
<Badge>{tag}</Badge>
|
||||
<Badge key={tag}>{tag}</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -5,7 +5,7 @@ export const DUMMY_1: Event = {
|
||||
id: "test",
|
||||
content: "Time for nostr to take over twitter",
|
||||
kind: 1,
|
||||
pubkey: "235235",
|
||||
pubkey: "f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca",
|
||||
sig: "wetwet",
|
||||
tags: [["t", "nostr"]],
|
||||
created_at: unixTimeNowInSeconds() - 3600,
|
||||
@ -32,7 +32,7 @@ export const DUMMY_30023: Event = {
|
||||
"wss://relay.nostr.org",
|
||||
],
|
||||
],
|
||||
pubkey: "...",
|
||||
pubkey: "f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca",
|
||||
id: "...",
|
||||
sig: "wetwet",
|
||||
};
|
||||
|
@ -40,18 +40,22 @@ export default function useCurrentUser() {
|
||||
// });
|
||||
|
||||
async function attemptLogin() {
|
||||
const shouldReconnect = localStorage.getItem("shouldReconnect");
|
||||
if (!shouldReconnect || typeof window.nostr === "undefined") return;
|
||||
const user = await loginWithNip07();
|
||||
if (!user) {
|
||||
throw new Error("NO auth");
|
||||
try {
|
||||
const shouldReconnect = localStorage.getItem("shouldReconnect");
|
||||
if (!shouldReconnect || typeof window.nostr === "undefined") return;
|
||||
const user = await loginWithNip07();
|
||||
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() {
|
||||
@ -75,7 +79,8 @@ export default function useCurrentUser() {
|
||||
}
|
||||
|
||||
async function loginWithPubkey(pubkey: string) {
|
||||
const user = ndk!.getUser({ hexpubkey: pubkey });
|
||||
if (!ndk) return;
|
||||
const user = ndk.getUser({ hexpubkey: pubkey });
|
||||
console.log("user", user);
|
||||
await user.fetchProfile();
|
||||
setCurrentUser(user);
|
||||
|
@ -14,7 +14,9 @@ export default function useProfile(key: string) {
|
||||
key = nip19.decode(key).data.toString();
|
||||
}
|
||||
return () => {
|
||||
void ndk.getUser({ hexpubkey: key }).fetchProfile();
|
||||
if (ndk) {
|
||||
void ndk.getUser({ hexpubkey: key }).fetchProfile();
|
||||
}
|
||||
};
|
||||
}, [key, ndk]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user