Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: subscribe WIP #541

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions src/lib/components/Profile/ListSubscribe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
</script>

<div class="flex flex-row justify-center gap-5 mt-8">
<form action="?/search" method="GET">
{#await subscribers}
Loading...
{:then value}
{#if value}
<div class="card flex flex-col w-2/4 gap-2 bg-base-200 py-4 px-8">
<p class="text-start font-semibold">Subscribers ({$subscriber_count})</p>

{#await subscribers}
Loading...
{:then value}
{#if value}
<div class="card flex flex-col w-1/2 gap-2 bg-base-200 py-4 px-8">
<p class="text-start font-semibold">Subscribers ({$subscriber_count})</p>
<form action="?/search" method="get">
<div class="input-group relative">
<input
name="query"
Expand All @@ -29,19 +28,21 @@
<IconSearch />
</button>
</div>
</form>

{#each value as subscriberItem}
<SubscriberItem {subscriberItem} />
{/each}
</div>
{/if}
{/await}
{#await interests}
Loading...
{:then value}
{#if value}
<div class="card flex flex-col w-2/4 gap-2 bg-base-200 py-4 px-8">
<p class="text-start font-semibold">Interests ({$interest_count})</p>
{#each value as subscriberItem}
<SubscriberItem {subscriberItem} />
{/each}
</div>
{/if}
{/await}
{#await interests}
Loading...
{:then value}
{#if value}
<div class="card flex flex-col w-1/2 gap-2 bg-base-200 py-4 px-8">
<p class="text-start font-semibold">Interests ({$interest_count})</p>
<form action="?/search" method="get">
<div class="input-group relative">
<input
name="query"
Expand All @@ -53,12 +54,12 @@
<IconSearch />
</button>
</div>
</form>

{#each value as subscriberItem}
<SubscriberItem {subscriberItem} />
{/each}
</div>
{/if}
{/await}
</form>
{#each value as subscriberItem}
<SubscriberItem {subscriberItem} />
{/each}
</div>
{/if}
{/await}
</div>
16 changes: 8 additions & 8 deletions src/lib/components/Profile/TabSection.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
// import ListSubscribe from '$lib/components/Profile/ListSubscribe.svelte'
import ListSubscribe from '$lib/components/Profile/ListSubscribe.svelte'
import SectionTable from '$lib/components/Browse/Sections/SectionTable.svelte'
// import Stats from '$lib/components/Profile/Elements/Stats.svelte'
import Stats from '$lib/components/Profile/Elements/Stats.svelte'

export let profileId: string = '',
channels: Promise<any>,
subscribers: Promise<any>,
interests: Promise<any>

let tabs = ['Channels'] //['Stats', 'Channels', 'Subscribers']
let tabs = ['Stats', 'Channels', 'Subscribers']
let activeTab = 0
</script>

Expand All @@ -23,15 +23,15 @@
{/each}
</div>
<div class="w-full px-4">
<!-- <div class="grid h-full" class:hidden={activeTab != 0}>
<div class="grid h-full" class:hidden={activeTab != 0}>
<Stats />
</div> -->
<div class="flex-auto h-full text-left" class:hidden={activeTab != 0}>
</div>
<div class="flex-auto h-full text-left" class:hidden={activeTab != 1}>
<SectionTable {channels} {profileId} />
</div>
<!-- <div class="flex-auto h-full" class:hidden={activeTab != 2}>
<div class="flex-auto h-full" class:hidden={activeTab != 2}>
<ListSubscribe {subscribers} {interests} />
</div> -->
</div>
</div>
</div>
</div>
12 changes: 10 additions & 2 deletions src/lib/components/Profile/TopSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { page } from '$app/stores'
import { onMount } from 'svelte'
import { subscriber_count, interest_count } from '$lib/stores/profileStore'
import { enhance } from '$app/forms'

export let profile: any,
subscriberCount: Promise<any>,
Expand Down Expand Up @@ -35,15 +36,22 @@
</div>
<div class="w-full lg:w-4/12 px-4 lg:order-3 lg:text-right lg:self-center">
<div class="py-6 px-3 justify-center flex md:justify-end gap-4">
<form action="?/subscribe" method="post">
<form
action="?/subscribe"
method="post"
use:enhance={({ data }) => {
// data.append('isSubscribing', JSON.stringify(newChannel))
data.append('source1', profile._id)
data.append('source2', $page.data.user?.userId)
}}>
<div class="flex gap-4">
{#await isSubscribed}
<button class="btn btn-secondary" disabled>Unsubscribe</button>
{:then value}
<button
class="btn btn-secondary"
disabled={profile._id === $page.data.user?.userId || !currentUser}
>{value.isSubscriber ? 'Subscribe' : 'Unsubscribe'}</button>
>{value.isSubscriber ? 'Unsubscribe' : 'Subscribe'}</button>
{/await}
<!--TODO: open sponsor dialog-->
<button class="btn btn-primary" formaction="?/sponsor" disabled>Sponsor</button>
Expand Down
3 changes: 3 additions & 0 deletions src/routes/profile/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export const actions = {
await new Promise<any>((resolve) => setTimeout(resolve, 1000))
},
search: async ({ request, locals }: { request: any; locals: any }) => {
console.log('got here----324324234')
const data = await request.formData()
const search = data.get('query')
await new Promise<any>((resolve) => setTimeout(resolve, 1000))
}
} satisfies Actions
Expand Down