Skip to content

Commit

Permalink
Merge pull request #745 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Fix: new user urls crash and favorites/FCM
  • Loading branch information
gagansuie authored Oct 13, 2023
2 parents 7edaaf1 + ae56610 commit a7a7285
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/lib/components/Channel/Chat/DropdownViewChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down
49 changes: 40 additions & 9 deletions src/lib/components/Channel/Stream/StreamControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -103,6 +120,11 @@
video: liveInput
}
})
await sendFcm({
channelId: $page.params.channelId,
channelTitle: channel.title,
username: $page.data.user?.user?.username
})
}
const stopObsStream = async () => {
Expand Down Expand Up @@ -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,
Expand All @@ -152,6 +172,11 @@
video: liveInput
}
})
await sendFcm({
channelId: $page.params.channelId,
channelTitle: channel.title,
username: $page.data.user?.user?.username
})
}
const stopScreenStream = async () => {
Expand Down Expand Up @@ -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,
Expand All @@ -201,6 +224,11 @@
video: liveInput
}
})
await sendFcm({
channelId: $page.params.channelId,
channelTitle: channel.title,
username: $page.data.user?.user?.username
})
}
const stopWebcamStream = async () => {
Expand Down Expand Up @@ -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,
Expand All @@ -250,6 +276,11 @@
video: liveInput
}
})
await sendFcm({
channelId: $page.params.channelId,
channelTitle: channel.title,
username: $page.data.user?.user?.username
})
}
const stopAudioStream = async () => {
Expand Down
7 changes: 6 additions & 1 deletion src/lib/components/Profile/DrawerEditProfile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
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)
Expand Down
4 changes: 3 additions & 1 deletion src/routes/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7a7285

Please sign in to comment.