From 6742a96e6eb8e1341be1a2196f81a481c8d0f44b Mon Sep 17 00:00:00 2001 From: sitara-dev Date: Wed, 4 Oct 2023 17:49:55 +0530 Subject: [PATCH 1/3] fixed new user urls crash --- .../components/Profile/DrawerEditProfile.svelte | 14 +++++++++++--- src/routes/[username]/+page.server.ts | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib/components/Profile/DrawerEditProfile.svelte b/src/lib/components/Profile/DrawerEditProfile.svelte index 5f842876..85fee1b2 100644 --- a/src/lib/components/Profile/DrawerEditProfile.svelte +++ b/src/lib/components/Profile/DrawerEditProfile.svelte @@ -8,9 +8,14 @@ export let showDrawer: boolean export let profile: any - + let isProfileUpdated = objectMonitor($page.data.profile) - $: inputFields = profile.urls ? [...profile.urls] : [] + + let inputFields = [...profile.urls] + + $: if(!inputFields.length){ + inputFields = [""] + } const removeInputField = (index: number) => { inputFields = inputFields.filter((_, i) => i !== index) @@ -84,11 +89,14 @@ }, [$page.params]) $: useOueryEffect(() => { - if (isProfileUpdated($page.data.profile)) { + if(isProfileUpdated($page.data.profile)){ if (submitBtn) submitBtn.disabled = false toggleDrawer() } }, [$page.data.profile]) + + $: console.log(profile) +
diff --git a/src/routes/[username]/+page.server.ts b/src/routes/[username]/+page.server.ts index 7879b571..1b031a4f 100644 --- a/src/routes/[username]/+page.server.ts +++ b/src/routes/[username]/+page.server.ts @@ -33,13 +33,15 @@ export const load = (async ({ params }: { params: any }) => { export const actions = { 'update-profile': async ({ request, locals }: { request: any; locals: any }) => { const data: FormData = await request.formData() - const newUser: any = {} + let newUser: any = {} addPropertyIfDefined(data, 'displayName', newUser) addPropertyIfDefined(data, 'username', newUser) addPropertyIfDefined(data, 'category', newUser) addPropertyIfDefined(data, 'bio', newUser) addPropertyIfDefined(data, 'urls', newUser, true) + newUser.urls = newUser.urls.filter((i:string) => i) + const avatar = data.get('avatar') as File const banner = data.get('banner') as File From 5513acacc23b6f762db499ad60e1be5ebe0d80fe Mon Sep 17 00:00:00 2001 From: Gagan Suie Date: Fri, 6 Oct 2023 19:53:18 -0500 Subject: [PATCH 2/3] Fix: reimplemented favorites and FCM --- .../Channel/Chat/DropdownViewChannel.svelte | 3 +- .../Channel/Stream/StreamControls.svelte | 49 +++++++++++++++---- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/lib/components/Channel/Chat/DropdownViewChannel.svelte b/src/lib/components/Channel/Chat/DropdownViewChannel.svelte index c21e25a2..de4e8dbf 100644 --- a/src/lib/components/Channel/Chat/DropdownViewChannel.svelte +++ b/src/lib/components/Channel/Chat/DropdownViewChannel.svelte @@ -21,11 +21,10 @@ onMount(async () => { if ($page.data.user?.userId) { - const favorites = await get(`favorites?channelId=${channel._id}`, { + isFavorite = await get(`favorite?channelId=${channel._id}`, { userId: $page.data.user?.userId, token: $page.data.user?.token }) - isFavorite = favorites?.length > 0 } }) diff --git a/src/lib/components/Channel/Stream/StreamControls.svelte b/src/lib/components/Channel/Stream/StreamControls.svelte index de5811d6..ad899808 100644 --- a/src/lib/components/Channel/Stream/StreamControls.svelte +++ b/src/lib/components/Channel/Stream/StreamControls.svelte @@ -8,7 +8,7 @@ is_chat_drawer_destroy, was_chat_drawer_closed } from '$lib/stores/channelStore' - import { del, put } from '$lib/api' + import { del, post, put } from '$lib/api' import { page } from '$app/stores' import { emitAction } from '$lib/websocket' import { @@ -59,6 +59,25 @@ }) } + const sendFcm = async ({ + channelId, + channelTitle, + username + }: { + channelId: string + channelTitle: string + username: string + }) => { + return await post( + `firebase/send-fcm`, + { channelId, channelTitle, username }, + { + userId: $page.data.user?.userId, + token: $page.data.user?.token + } + ) + } + const deleteLiveInput = async ({ channelId, userId, @@ -82,8 +101,6 @@ const startObsStream = async () => { const liveInput = await createLiveInput({ channelId: `${$page.params.channelId}`, - channelTitle: `${channel.title}`, - username: `${$page.data.user?.user?.username}`, userId: $page.data.user?.userId, trackType: 'obs', isTrackActive: true, @@ -103,6 +120,11 @@ video: liveInput } }) + await sendFcm({ + channelId: $page.params.channelId, + channelTitle: channel.title, + username: $page.data.user?.user?.username + }) } const stopObsStream = async () => { @@ -131,8 +153,6 @@ const startScreenStream = async () => { const liveInput = await createLiveInput({ channelId: `${$page.params.channelId}`, - channelTitle: `${channel.title}`, - username: `${$page.data.user?.user?.username}`, userId: $page.data.user?.userId, trackType: 'screen', isTrackActive: true, @@ -152,6 +172,11 @@ video: liveInput } }) + await sendFcm({ + channelId: $page.params.channelId, + channelTitle: channel.title, + username: $page.data.user?.user?.username + }) } const stopScreenStream = async () => { @@ -180,8 +205,6 @@ const startWebcamStream = async () => { const liveInput = await createLiveInput({ channelId: `${$page.params.channelId}`, - channelTitle: `${channel.title}`, - username: `${$page.data.user?.user?.username}`, userId: $page.data.user?.userId, trackType: 'webcam', isTrackActive: true, @@ -201,6 +224,11 @@ video: liveInput } }) + await sendFcm({ + channelId: $page.params.channelId, + channelTitle: channel.title, + username: $page.data.user?.user?.username + }) } const stopWebcamStream = async () => { @@ -229,8 +257,6 @@ const startAudioStream = async () => { const liveInput = await createLiveInput({ channelId: `${$page.params.channelId}`, - channelTitle: `${channel.title}`, - username: `${$page.data.user?.user?.username}`, userId: $page.data.user?.userId, trackType: 'audio', isTrackActive: true, @@ -250,6 +276,11 @@ video: liveInput } }) + await sendFcm({ + channelId: $page.params.channelId, + channelTitle: channel.title, + username: $page.data.user?.user?.username + }) } const stopAudioStream = async () => { From 6d00d1765fd46b2a1f1d9bcf44d4fc49fc674105 Mon Sep 17 00:00:00 2001 From: Gagan Suie Date: Sat, 7 Oct 2023 17:28:22 -0500 Subject: [PATCH 3/3] Fix: removed comments --- src/lib/components/Profile/DrawerEditProfile.svelte | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/lib/components/Profile/DrawerEditProfile.svelte b/src/lib/components/Profile/DrawerEditProfile.svelte index 85fee1b2..906d9f18 100644 --- a/src/lib/components/Profile/DrawerEditProfile.svelte +++ b/src/lib/components/Profile/DrawerEditProfile.svelte @@ -8,13 +8,13 @@ export let showDrawer: boolean export let profile: any - + let isProfileUpdated = objectMonitor($page.data.profile) let inputFields = [...profile.urls] - $: if(!inputFields.length){ - inputFields = [""] + $: if (!inputFields.length) { + inputFields = [''] } const removeInputField = (index: number) => { @@ -89,14 +89,11 @@ }, [$page.params]) $: useOueryEffect(() => { - if(isProfileUpdated($page.data.profile)){ + if (isProfileUpdated($page.data.profile)) { if (submitBtn) submitBtn.disabled = false toggleDrawer() } }, [$page.data.profile]) - - $: console.log(profile) -