Skip to content

Commit

Permalink
feat(calls): add fullscreen support (#4439)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmcg committed Aug 24, 2022
1 parent e56a729 commit cbdb31b
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 41 deletions.
1 change: 0 additions & 1 deletion components/ui/Global/Global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export default Vue.extend({
* @example
*/
denyCall() {
this.$store.commit('ui/fullscreen', false)
iridium.webRTC.denyCall()
},
},
Expand Down
16 changes: 13 additions & 3 deletions components/views/media/Media.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div class="mediastream" data-cy="mediastream" :style="`height:${height}`">
<MediaHeading />
<div
class="mediastream"
ref="mediastream"
data-cy="mediastream"
:style="`height:${height}`"
>
<MediaHeading :isFullscreen="isFullscreen" @toggle="toggleFullscreen" />
<div class="media">
<MediaUser
id="local"
Expand Down Expand Up @@ -27,5 +32,10 @@
/>
<MediaActionsSettings />
<MediaActions />
<InteractablesDragBar side="bottom" showHandle @resize="(val)=> height=val" />
<InteractablesDragBar
v-if="!isFullscreen"
side="bottom"
showHandle
@resize="(val)=> height=val"
/>
</div>
11 changes: 11 additions & 0 deletions components/views/media/Media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default Vue.extend({
data() {
return {
webrtc: iridium.webRTC.state,
isFullscreen: false,
}
},
computed: {
Expand Down Expand Up @@ -60,6 +61,16 @@ export default Vue.extend({
this.$Sounds.changeLevels(volume / 100)
this.$store.commit('audio/setVolume', volume)
},
toggleFullscreen() {
if (!document.fullscreenElement) {
const media = this.$refs.mediastream as HTMLElement
media.requestFullscreen()
this.isFullscreen = true
} else if (document.exitFullscreen) {
document.exitFullscreen()
this.isFullscreen = false
}
},
},
})
</script>
Expand Down
8 changes: 4 additions & 4 deletions components/views/media/heading/Heading.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="heading">
<transition name="media-fullscreen" mode="out-in">
<button
:key="ui.fullscreen"
v-tooltip.left="ui.fullscreen ? $t('ui.exit_fullscreen') : $t('ui.fullscreen')"
@click="toggleFullscreen"
:key="isFullscreen"
v-tooltip.left="isFullscreen ? $t('ui.exit_fullscreen') : $t('ui.fullscreen')"
@click="$emit('toggle')"
>
<minimize-icon
v-if="ui.fullscreen"
v-if="isFullscreen"
data-cy="exit-fullscreen"
size="1.2x"
/>
Expand Down
21 changes: 6 additions & 15 deletions components/views/media/heading/Heading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<script lang="ts">
import Vue from 'vue'
import { MaximizeIcon, MinimizeIcon } from 'satellite-lucide-icons'
import { mapState } from 'vuex'
import iridium from '~/libraries/Iridium/IridiumManager'
import { useCallElapsedTime } from '~/libraries/Iridium/webrtc/hooks'
Expand All @@ -12,19 +11,21 @@ export default Vue.extend({
MaximizeIcon,
MinimizeIcon,
},
props: {
isFullscreen: {
type: Boolean,
required: true,
},
},
setup() {
const { elapsedTime, startInterval, clearTimer } = useCallElapsedTime()
return { elapsedTime, startInterval, clearTimer }
},
data() {
return {
webrtc: iridium.webRTC.state,
}
},
computed: {
...mapState(['ui']),
},
watch: {
'webrtc.createdAt': {
handler() {
Expand All @@ -36,16 +37,6 @@ export default Vue.extend({
beforeDestroy() {
this.clearTimer()
},
methods: {
/**
* @method toggleFullscreen
* @description Toggles fullscreen by committing the opposite of it's current value (this.ui.fullscreen) to fullscreen in state
* @example @click="toggleFullscreen"
*/
toggleFullscreen() {
this.$store.commit('ui/fullscreen', !this.ui.fullscreen)
},
},
})
</script>

Expand Down
2 changes: 1 addition & 1 deletion components/views/navigation/sidebar/live/Live.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="live" v-if="existLiveChat">
<div class="name-and-icon" @click="activeChat">
<div class="name-and-icon">
<radio-icon size="1.2x" class="green" />
<TypographySubtitle
:class="`sel-user-name ${existLiveChat ? 'is-exist' : 'is-non-exist'}`"
Expand Down
4 changes: 0 additions & 4 deletions components/views/navigation/sidebar/live/Live.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ export default Vue.extend({
},
methods: {
hangUp() {
this.$store.commit('ui/fullscreen', false)
this.webrtc.hangUp()
},
activeChat() {
this.$store.commit('ui/fullscreen', false)
},
async call(kinds: TrackKind[]) {
if (!this.enableRTC || !this.details) {
return
Expand Down
1 change: 0 additions & 1 deletion store/ui/__snapshots__/state.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Object {
"route": "emoji",
"show": false,
},
"fullscreen": false,
"glyphMarketplaceView": Object {
"shopId": null,
"view": "home",
Expand Down
6 changes: 0 additions & 6 deletions store/ui/mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,6 @@ describe('mutations', () => {
expect(localizedState.chatbarContent).toBe('string')
})

test('fullscreen', () => {
const localizedState = { ...initialState }
mutations.default.fullscreen(localizedState, true)
expect(localizedState.fullscreen).toBeTruthy()
})

test('setChatImageOverlay', () => {
const passedInImageOverlay = undefined
const localizedState = { ...initialState }
Expand Down
3 changes: 0 additions & 3 deletions store/ui/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ export default {
chatbarContent(state: UIState, content: string) {
state.chatbarContent = content
},
fullscreen(state: UIState, fullscreen: boolean) {
state.fullscreen = fullscreen
},
setChatImageOverlay(state: UIState, image: FileMessage | undefined) {
state.chatImageOverlay = image
},
Expand Down
1 change: 0 additions & 1 deletion store/ui/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const InitialUIState = (): UIState => ({
glyphModalPackId: undefined,
chatbarContent: '',
chatbarFocus: false,
fullscreen: false,
showPinned: false,
enhancers: {
show: false,
Expand Down
1 change: 0 additions & 1 deletion store/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export interface UIState {
chatbarContent: string
chatbarFocus: boolean
showPinned: boolean
fullscreen: boolean
enhancers: EnhancerInfo
messages: any[]
unreadMessage: number
Expand Down
1 change: 0 additions & 1 deletion store/webrtc/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ const webRTCActions = {
commit('setActiveCall', undefined)
commit('updateCreatedAt', 0)
commit('conversation/setCalling', false, { root: true })
commit('ui/fullscreen', false, { root: true })
call.off('INCOMING_CALL', onCallIncoming)
call.off('OUTGOING_CALL', onCallOutgoing)
call.off('CONNECTED', onCallConnected)
Expand Down

0 comments on commit cbdb31b

Please sign in to comment.