From e13f9439630f5eb183c7bf96444d370c2a929fb8 Mon Sep 17 00:00:00 2001 From: Gagan Suie Date: Mon, 21 Aug 2023 22:02:16 -0500 Subject: [PATCH] Feat: changed profile route to root --- package.json | 2 +- src/lib/components/Browse/DrawerCreateChannel.svelte | 2 +- src/lib/components/Browse/Sections/ItemTable.svelte | 3 +-- src/lib/components/Browse/Sections/ItemUser.svelte | 4 +--- src/lib/components/Channel/Chat/DrawerEditChannel.svelte | 2 +- src/lib/components/Channel/Chat/DropdownViewChannel.svelte | 5 ++--- src/lib/components/Channel/Chat/ProfilePopup.svelte | 2 +- src/lib/components/Global/DrawerMain.svelte | 2 +- src/lib/components/Profile/Elements/FollowItem.svelte | 2 +- src/lib/components/Search/ItemSearchChannel.svelte | 5 ++--- src/lib/components/Search/ItemSearchUser.svelte | 4 ++-- src/routes/{profile => }/[username]/+page.server.ts | 7 +++++-- src/routes/{profile => }/[username]/+page.svelte | 0 src/routes/{profile => }/[username]/[live]/+page.server.ts | 7 +++++-- 14 files changed, 24 insertions(+), 23 deletions(-) rename src/routes/{profile => }/[username]/+page.server.ts (95%) rename src/routes/{profile => }/[username]/+page.svelte (100%) rename src/routes/{profile => }/[username]/[live]/+page.server.ts (74%) diff --git a/package.json b/package.json index 5779a68c..5470d702 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mage-website", - "version": "0.0.16", + "version": "0.0.17", "license": "GPL-3.0", "private": true, "type": "module", diff --git a/src/lib/components/Browse/DrawerCreateChannel.svelte b/src/lib/components/Browse/DrawerCreateChannel.svelte index 38bea3e2..54e82986 100644 --- a/src/lib/components/Browse/DrawerCreateChannel.svelte +++ b/src/lib/components/Browse/DrawerCreateChannel.svelte @@ -148,7 +148,7 @@ {#if $tags && $tags.length > 0} {#each $tags as tag} addTag(tag.name)}>{tag.name} {/each} {:else} diff --git a/src/lib/components/Browse/Sections/ItemTable.svelte b/src/lib/components/Browse/Sections/ItemTable.svelte index 5200fc20..0a027c01 100644 --- a/src/lib/components/Browse/Sections/ItemTable.svelte +++ b/src/lib/components/Browse/Sections/ItemTable.svelte @@ -54,8 +54,7 @@ {/if} {#each channel.tags as tag}
- {tag}
{/each} diff --git a/src/lib/components/Browse/Sections/ItemUser.svelte b/src/lib/components/Browse/Sections/ItemUser.svelte index a21ce631..e7bf09ae 100644 --- a/src/lib/components/Browse/Sections/ItemUser.svelte +++ b/src/lib/components/Browse/Sections/ItemUser.svelte @@ -5,9 +5,7 @@ export let user: any = {} - +
diff --git a/src/lib/components/Channel/Chat/DrawerEditChannel.svelte b/src/lib/components/Channel/Chat/DrawerEditChannel.svelte index 2f6d4508..b8704a98 100644 --- a/src/lib/components/Channel/Chat/DrawerEditChannel.svelte +++ b/src/lib/components/Channel/Chat/DrawerEditChannel.svelte @@ -179,7 +179,7 @@ {#if $tags && $tags.length > 0} {#each $tags as tag} addTag(tag.name)}>{tag.name} {/each} diff --git a/src/lib/components/Channel/Chat/DropdownViewChannel.svelte b/src/lib/components/Channel/Chat/DropdownViewChannel.svelte index b203ee31..294f0ff6 100644 --- a/src/lib/components/Channel/Chat/DropdownViewChannel.svelte +++ b/src/lib/components/Channel/Chat/DropdownViewChannel.svelte @@ -106,8 +106,7 @@ {#if channel.tags && channel.tags.length} {#each channel.tags as tag}
- {tag}
{/each} @@ -116,7 +115,7 @@
  • - +
  • diff --git a/src/lib/components/Search/ItemSearchChannel.svelte b/src/lib/components/Search/ItemSearchChannel.svelte index 1c3ea548..789984d2 100644 --- a/src/lib/components/Search/ItemSearchChannel.svelte +++ b/src/lib/components/Search/ItemSearchChannel.svelte @@ -57,7 +57,7 @@
  • - @{item.userDetails.username || ''} {#if item.planDetails?.planTier > 1}
    @@ -70,8 +70,7 @@ {#if item.tags && item.tags.length} {#each item.tags as tag}
    - {tag}
    {/each} diff --git a/src/lib/components/Search/ItemSearchUser.svelte b/src/lib/components/Search/ItemSearchUser.svelte index 886909ba..68f014d7 100644 --- a/src/lib/components/Search/ItemSearchUser.svelte +++ b/src/lib/components/Search/ItemSearchUser.svelte @@ -6,7 +6,7 @@ export let item: any -
    +
    @@ -29,7 +29,7 @@ {item.displayName || ''}
    - @{item.username || ''}
    diff --git a/src/routes/profile/[username]/+page.server.ts b/src/routes/[username]/+page.server.ts similarity index 95% rename from src/routes/profile/[username]/+page.server.ts rename to src/routes/[username]/+page.server.ts index b795f918..8776e82c 100644 --- a/src/routes/profile/[username]/+page.server.ts +++ b/src/routes/[username]/+page.server.ts @@ -1,9 +1,12 @@ import type { Actions, PageServerLoad } from './$types' import { get, patch, putImage } from '$lib/api' -import { redirect, fail } from '@sveltejs/kit' +import { redirect, fail, error } from '@sveltejs/kit' export const load = (async ({ params }: { params: any }) => { const profile = await get(`users/search/username?username=${params.username}`) + if (profile.error) { + throw error(404) + } return { profile: profile, lazy: { @@ -68,7 +71,7 @@ export const actions = { } else { if (updatedUser._id) { locals.user.user = updatedUser - throw redirect(303, `/profile/${updatedUser.username}`) + throw redirect(303, `/${updatedUser.username}`) } else { throw redirect(303, 'browse') } diff --git a/src/routes/profile/[username]/+page.svelte b/src/routes/[username]/+page.svelte similarity index 100% rename from src/routes/profile/[username]/+page.svelte rename to src/routes/[username]/+page.svelte diff --git a/src/routes/profile/[username]/[live]/+page.server.ts b/src/routes/[username]/[live]/+page.server.ts similarity index 74% rename from src/routes/profile/[username]/[live]/+page.server.ts rename to src/routes/[username]/[live]/+page.server.ts index c098aad4..ce8b0df5 100644 --- a/src/routes/profile/[username]/[live]/+page.server.ts +++ b/src/routes/[username]/[live]/+page.server.ts @@ -1,13 +1,16 @@ import type { PageServerLoad } from '../$types' import { get } from '$lib/api' -import { redirect } from '@sveltejs/kit' +import { error, redirect } from '@sveltejs/kit' export const load = (async ({ params }: { params: any }) => { const profile = await get(`users/search/username?username=${params.username}`) + if (profile.error) { + throw error(404) + } const channelId = await get(`channel/live?userId=${profile._id}`) if (channelId) { throw redirect(303, `/channel/${channelId}`) } else { - throw redirect(303, `/profile/${params.username}`) + throw redirect(303, `/${params.username}`) } }) satisfies PageServerLoad