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

Fix: profile channels showing other channels #506

Merged
merged 1 commit into from
Jun 9, 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
8 changes: 5 additions & 3 deletions src/lib/components/Browse/Sections/SectionTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import LastItemInViewport from '$lib/actions/LastItemInViewport'
import { get } from '$lib/api'

export let channels: any = []
export let channels: any = [],
profile: any = null

let skip = 100
let limit = 100
let moreChannels: any[] = []
async function loadMore(): Promise<void> {
const infiniteChannels = await get(`channels?skip=${skip}&limit=${limit}`)
const loadMore = async () => {
let endpoint = profile._id ? `channels/user?userId=${profile._id}?` : 'channels?'
const infiniteChannels = await get(`${endpoint}skip=${skip}&limit=${limit}`)
if (infiniteChannels?.length) {
moreChannels = [...moreChannels, ...infiniteChannels]
skip += limit
Expand Down
11 changes: 5 additions & 6 deletions src/lib/components/Profile/TabSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import SectionTable from '$lib/components/Browse/Sections/SectionTable.svelte'
// import Stats from '$lib/components/Profile/Elements/Stats.svelte'

export let channels: Promise<any>, subscribers: Promise<any>, interests: Promise<any>
export let profile: any = null,
channels: Promise<any>,
subscribers: Promise<any>,
interests: Promise<any>

let tabs = ['Channels'] //['Stats', 'Channels', 'Subscribers']
let activeTab = 0
Expand All @@ -24,11 +27,7 @@
<Stats />
</div> -->
<div class="flex-auto h-full text-left" class:hidden={activeTab != 0}>
{#await channels}
<progress class="progress w-full" />
{:then value}
<SectionTable channels={value} />
{/await}
<SectionTable {channels} {profile} />
</div>
<!-- <div class="flex-auto h-full" class:hidden={activeTab != 1}>
<ListSubscribe {subscribers} {interests} />
Expand Down
2 changes: 1 addition & 1 deletion src/routes/profile/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const load = (async ({ params, locals }) => {

export const actions = {
'update-profile': async ({ request, locals }: { request: any; locals: any }) => {
const data = await request.formData()
const data: FormData = await request.formData()
const newUser: any = {}
addPropertyIfDefined(data, 'displayName', newUser)
addPropertyIfDefined(data, 'username', newUser)
Expand Down
1 change: 1 addition & 0 deletions src/routes/profile/[username]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
bind:showDrawer />
<UserDetails profile={data.profile} />
<TabSection
profile={data.profile}
channels={data.lazy.channels}
subscribers={data.lazy.subscribers}
interests={data.lazy.interests} />
Expand Down