Skip to content

Commit

Permalink
Merge pull request #672 from gagan-suie/dev
Browse files Browse the repository at this point in the history
Fix: profile redirect to live stream
  • Loading branch information
gagansuie authored Aug 15, 2023
2 parents 5bf44bb + 528c0b3 commit 30661cb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/routes/profile/[username]/[live]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import type { PageServerLoad } from '../$types'
import { get } from '$lib/api'
import { redirect } from '@sveltejs/kit'
import { getSectionUrl } from '$lib/utils'

export const load = (async ({ params }: { params: any }) => {
const profile = await get(`users/search/username?username=${params.username}`)
const channels = await get(
`${getSectionUrl({ sectionId: 'my', query: '', skip: 0, limit: 2 })}&userId=${profile._id}`
)
if (channels.length) {
throw redirect(303, `/channel/${channels[0]._id}`)
const channelId = await get(`channel/live?userId=${profile._id}`)
if (channelId) {
throw redirect(303, `/channel/${channelId}`)
} else {
throw redirect(303, `/profile/${params.username}`)
}
Expand Down

0 comments on commit 30661cb

Please sign in to comment.