diff --git a/.env.example b/.env.example deleted file mode 100644 index 815d6d0..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -PUBLIC_SUPABASE_URL="" -PUBLIC_SUPABASE_ANON_KEY="" \ No newline at end of file diff --git a/src/lib/components/FollowButton.svelte b/src/lib/components/FollowButton.svelte index ef82a37..1224e85 100644 --- a/src/lib/components/FollowButton.svelte +++ b/src/lib/components/FollowButton.svelte @@ -10,7 +10,7 @@ {#if isFollowed} @@ -18,7 +18,7 @@ {:else} diff --git a/src/lib/components/LoginButton.svelte b/src/lib/components/LoginButton.svelte index 7d13a40..bd47d02 100644 --- a/src/lib/components/LoginButton.svelte +++ b/src/lib/components/LoginButton.svelte @@ -4,6 +4,6 @@ Open Holopass diff --git a/src/lib/components/PassCard.svelte b/src/lib/components/PassCard.svelte index a028568..0faf53c 100644 --- a/src/lib/components/PassCard.svelte +++ b/src/lib/components/PassCard.svelte @@ -7,10 +7,17 @@ import { htmlifyLinks } from '../../html'; import * as profiles from '../../profiles'; import Oshi from './Oshi.svelte'; + import {profileRedirectURL} from "../../profiles"; + import LoginButton from "$lib/components/LoginButton.svelte"; + import FollowButton from "$lib/components/FollowButton.svelte"; + import {invalidateAll} from "$app/navigation"; export let profile: Tables<'profiles'>; + export let pass: Tables<'profiles'>; export let oshi: Promise[]>; export let badges: Promise[]>; + export let isFollowed: boolean; + export let myPass: boolean; export let following: Promise<{ following: Tables<'profiles'>[]; count: number }> = { following: [], count: 0 @@ -20,16 +27,31 @@ count: 0 }; - let nickname = profile.nickname ?? ''; - let nicknameJP = profile.nickname_jp ?? ''; - $: avatarURL = profile.avatar_url ?? ''; - let location = profile.location ?? ''; - let bio = profile.bio ?? ''; - let favStream = profile.fav_stream ?? ''; + if (!pass) pass = profile; + + let nickname = pass.nickname ?? ''; + let nicknameJP = pass.nickname_jp ?? ''; + $: avatarURL = pass.avatar_url ?? ''; + let location = pass.location ?? ''; + let bio = pass.bio ?? ''; + let favStream = pass.fav_stream ?? ''; + + async function handleFollow(profile: Tables<'profiles'>, pass: Tables<'profiles'>) { + const resp = await fetch(`/pass/${pass?.id}/follow`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ profile }) + }); + if (resp.ok) { + invalidateAll(); + } else { + console.error('Failed to follow user with status:', resp.status); + } + } holopass + {#if !myPass} + + {#if profile && pass} + profile && pass && handleFollow(profile, pass)} + /> + {:else} + + + Login or Signup to follow + + + + {/if} + + {/if} @@ -78,11 +119,11 @@ {#await following then { count }} - + {/await} {#await followers then { count }} - + {/await} diff --git a/src/routes/pass/[id]/+page.svelte b/src/routes/pass/[id]/+page.svelte index 09facef..1f1de4f 100644 --- a/src/routes/pass/[id]/+page.svelte +++ b/src/routes/pass/[id]/+page.svelte @@ -4,32 +4,14 @@ import { MetaTags } from 'svelte-meta-tags'; import PassCard from '$lib/components/PassCard.svelte'; - import FollowButton from '$lib/components/FollowButton.svelte'; import type { PageData } from './$types'; - import type { Tables } from '$lib/database.types'; - import { invalidateAll } from '$app/navigation'; - import LoginButton from '$lib/components/LoginButton.svelte'; - import { profileRedirectURL } from '../../../profiles'; export let data: PageData; // in this context pass is another user's "profile" // and profile is the current user's profile $: ({ pass, oshi, badges, profile, following, followers, isFollowed } = data); - - async function handleFollow(profile: Tables<'profiles'>, pass: Tables<'profiles'>) { - const resp = await fetch(`/pass/${pass?.id}/follow`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ profile }) - }); - if (resp.ok) { - invalidateAll(); - } else { - console.error('Failed to follow user with status:', resp.status); - } - } - - - - {#if profile && pass} - profile && pass && handleFollow(profile, pass)} - /> - {:else} - - - Login or Signup to follow - - - - {/if} - +
holopass
+ Login or Signup to follow +
- Login or Signup to follow -