Skip to content

Commit

Permalink
Merge pull request #576 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Fix: subscribe endpoints, input shift, and added stream timer
  • Loading branch information
gagansuie authored Jun 29, 2023
2 parents 357d471 + 94d493e commit fed6cc6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/Channel/Chat/ChatInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
}
}
}
} else if (e.key === 'Enter') {
} else if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault()
sendMessage()
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Channel/Chat/DropdownViewChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
userId: $page.data.user?.userId,
token: $page.data.user?.token
})
isSubscribing = relationship?.isSubscribing
isSubscribing = relationship?.isInterested
}
}
Expand Down
32 changes: 31 additions & 1 deletion src/lib/components/Channel/Stream/StreamContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
import VideoGrid from '$lib/components/Channel/Stream/VideoGrid.svelte'
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { createEventDispatcher } from 'svelte'
import { createEventDispatcher, onMount } from 'svelte'
import { video_items } from '$lib/stores/streamStore'
import { channel_connection } from '$lib/stores/websocketStore'
import CommandList from '$lib/components/Channel/Stream/CommandList.svelte'
import { is_feature_stats_enabled } from '$lib/stores/remoteConfigStore'
const dispatch = createEventDispatcher()
export let userCount: number = 1,
channel: any,
channels: any = [],
isHostOrGuest: boolean = false
let streamTime: number = 0,
timerInterval: any,
formattedTime: string = '00:00:00'
$: isChannelSocketConnected = $channel_connection === `open-${channel._id}`
$: if (is_feature_stats_enabled) {
toggleTimer()
}
function autoActive(node: Element) {
const observer = new IntersectionObserver(callback, { threshold: 0.5 })
Expand All @@ -41,6 +48,23 @@
return { destroy: () => observer.disconnect() }
}
const toggleTimer = () => {
if (timerInterval) {
clearInterval(timerInterval)
timerInterval = null
} else {
timerInterval = setInterval(() => {
streamTime++
const hours = Math.floor(streamTime / 3600)
const minutes = Math.floor((streamTime % 3600) / 60)
const seconds = streamTime % 60
formattedTime = `${hours.toString().padStart(2, '0')}:${minutes
.toString()
.padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
}, 1000)
}
}
</script>

<div class="flex justify-center h-full">
Expand All @@ -65,6 +89,12 @@
</label>
<DropdownViewers {channel} />
</div>
{#if $is_feature_stats_enabled}
<span
class="btn btn-sm btn-neutral font-medium text-white border-none flex items-center">
{formattedTime}
</span>
{/if}
</div>
{#if channel && nextchannel?._id === $page.params.channelId}
<VideoGrid {channel} />
Expand Down
4 changes: 1 addition & 3 deletions src/lib/components/Channel/Stream/StreamControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
video_items
} from '$lib/stores/streamStore'
import { channel_connection } from '$lib/stores/websocketStore'
import { onDestroy, onMount } from 'svelte';
import { onDestroy, onMount } from 'svelte'
export let isHostOrGuest: boolean = false,
channel: any
Expand Down Expand Up @@ -262,8 +262,6 @@
subs()
})
})
</script>

<div class="flex gap-4">
Expand Down
85 changes: 0 additions & 85 deletions src/lib/stores/subscribeStore.ts