Skip to content

Commit

Permalink
Merge pull request #776 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Fix: enabling and disabling restream
  • Loading branch information
gagansuie authored Oct 30, 2023
2 parents 665e452 + f99d7df commit 3bad156
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage-website",
"version": "0.1.07",
"version": "0.1.08",
"license": "GPL-3.0",
"private": true,
"type": "module",
Expand Down
22 changes: 4 additions & 18 deletions src/lib/components/Channel/Chat/DrawerRestream.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { get, put, del } from '$lib/api.js'
import { page } from '$app/stores'
import { isValidURL } from '$lib/utils'
import IconRestream from '$lib/assets/icons/channel/IconRestream.svelte'
import { is_restream_drawer_open } from '$lib/stores/channelStore'
$: auth = {
userId: $page.data.user?.userId,
Expand Down Expand Up @@ -76,22 +76,8 @@
</script>

<div class="drawer drawer-end">
<input id="restream-drawer" type="checkbox" class="drawer-toggle" />
<div class="drawer-content">
<!-- Page content here -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<label
for="restream-drawer"
class="btn text-white border-none tooltip font-normal normal-case items-center flex {restream_drawer
? 'btn-primary'
: 'btn-neutral'}"
data-tip="Restream"
on:click={() => {
restream_drawer = !restream_drawer
}}>
<IconRestream />
</label>
</div>
<input id="restream-drawer" type="checkbox" class="drawer-toggle" bind:checked={$is_restream_drawer_open}/>

<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="drawer-side z-50" on:click={overlayClick}>
<label id="overlay" for="restream-drawer" aria-label="close sidebar" class="drawer-overlay" />
Expand Down Expand Up @@ -205,7 +191,7 @@
class="btn btn-neutral text-white grow w-full"
on:click={() => {
document.getElementById('overlay')?.click()
}}>Cancel</button>
}}>Close</button>
</div>
</ul>
</div>
Expand Down
22 changes: 19 additions & 3 deletions src/lib/components/Channel/Stream/StreamControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import IconShareScreen from '$lib/assets/icons/channel/IconShareScreen.svelte'
import IconShareWebcam from '$lib/assets/icons/channel/IconShareWebcam.svelte'
import IconShareAudio from '$lib/assets/icons/channel/IconShareAudio.svelte'
import IconRestream from '$lib/assets/icons/channel/IconRestream.svelte'
import { del, post, put } from '$lib/api'
import { page } from '$app/stores'
import { emitAction } from '$lib/websocket'
Expand All @@ -19,7 +20,7 @@
is_feature_apps_enabled,
is_feature_restream_enabled
} from '$lib/stores/remoteConfigStore'
import DrawerRestream from '$lib/components/Channel/Chat/DrawerRestream.svelte'
import { is_restream_drawer_open } from '$lib/stores/channelStore'
export let isHostOrGuest: boolean = false,
channel: any,
Expand Down Expand Up @@ -413,9 +414,24 @@
!videoItemIsActive}>
<IconShareObs />
</button>

{#if $is_feature_restream_enabled}
<DrawerRestream />
<button
class="flex items-center btn text-white border-none tooltip font-normal normal-case {$is_restream_drawer_open
? 'btn-primary'
: 'btn-neutral'}"
data-tip="Restream"
on:click={() => {
$is_restream_drawer_open = !$is_restream_drawer_open
}}
disabled={$is_sharing_obs ||
$is_sharing_screen ||
$is_sharing_webcam ||
$is_sharing_audio ||
!isHostOrGuest ||
!isChannelSocketConnected ||
!videoItemIsActive}>
<IconRestream />
</button>
{/if}
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/lib/stores/channelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ export const is_chat_drawer_destroy: Writable<boolean> = writable(false)
export const was_chat_drawer_closed: Writable<boolean> = writable(false)

export const is_restream_drawer_open: Writable<boolean> = writable(false)
export const is_restream_drawer_destroy: Writable<boolean> = writable(false)
export const was_restream_drawer_closed: Writable<boolean> = writable(false)
8 changes: 7 additions & 1 deletion src/routes/channel/[channelId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import DrawerChat from '$lib/components/Channel/Chat/DrawerChat.svelte'
import StreamContainer from '$lib/components/Channel/Stream/StreamContainer.svelte'
import { onDestroy, onMount } from 'svelte'
import { get, del, post, put, patch } from '$lib/api'
import { get, del, post } from '$lib/api'
import {
emitChatHistoryToChannel,
initChannelSocket,
Expand All @@ -22,6 +22,8 @@
is_sharing_audio,
updateVideoItems
} from '$lib/stores/streamStore'
import { is_feature_restream_enabled } from '$lib/stores/remoteConfigStore'
import DrawerRestream from '$lib/components/Channel/Chat/DrawerRestream.svelte'
let channel: any,
isDeleteModalOpen = false,
Expand Down Expand Up @@ -297,6 +299,10 @@
})
</script>

{#if $is_feature_restream_enabled && !$is_sharing_screen && !$is_sharing_webcam && !$is_sharing_audio && isHostOrGuest}
<DrawerRestream />
{/if}

{#if channel && channel._id === $page.params.channelId}
<div class="relative h-full bg-base-200 overflow-hidden flex">
<div
Expand Down

0 comments on commit 3bad156

Please sign in to comment.