Skip to content

Commit

Permalink
Fix: reimplemented favorites and FCM
Browse files Browse the repository at this point in the history
  • Loading branch information
gagansuie committed Oct 7, 2023
1 parent 1bb3a6c commit 5513aca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 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

0 comments on commit 5513aca

Please sign in to comment.