Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(call): create background call component #3591

Merged
merged 12 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/styles/framework/framework.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@third-layer-zindex: 30;
@fourth-layer-zindex: 40;
@fifth-layer-zindex: 50;
@sixth-layer-zindex: 60;
@viewport-width: 100vw;

#__nuxt,
Expand Down Expand Up @@ -44,3 +45,6 @@
.fifth-layer {
z-index: @fifth-layer-zindex;
}
.sixth-layer {
z-index: @sixth-layer-zindex;
}
1 change: 1 addition & 0 deletions assets/styles/framework/ui.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@mobile-nav-size: 4.5rem;
@slimbar-size: 60px;
@chatbar-input-height: 48px;
@background-call-height: 36px;

// Popups
@enhancers-height: 30rem;
Expand Down
5 changes: 5 additions & 0 deletions components/ui/BackgroundCall/BackgroundCall.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="background-call" @click="navigateToActiveConversation">
{{$t('ui.background_call')}}&nbsp;
<span v-if="caller" class="background-call-name">{{caller.name}}</span>&nbsp;
<span v-if="elapsedTime">- {{elapsedTime}}</span>
</div>
24 changes: 24 additions & 0 deletions components/ui/BackgroundCall/BackgroundCall.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.background-call {
&:extend(.background-flair);
&:extend(.font-secondary);
&:extend(.absolute-coverage);
border-radius: 0 0 @corner-rounding @corner-rounding;
height: @background-call-height;
z-index: @fifth-layer-zindex;
font-size: @micro-text-size;
bottom: auto;
text-align: center;
box-shadow: 0px 0px 30px rgba(var(--flair-color-rgb), 0.35),
0px 0px 20px rgba(var(--flair-color-rgb), 0.4);
padding: 10px 10%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
white-space: nowrap;
&-name {
&:extend(.ellipsis);
&:extend(.font-primary);
font-weight: 700;
}
}
48 changes: 48 additions & 0 deletions components/ui/BackgroundCall/BackgroundCall.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template src="./BackgroundCall.html"></template>

<script lang="ts">
import Vue from 'vue'
import { mapState } from 'vuex'
import { Friend } from '~/types/ui/friends'
import { RootState } from '~/types/store/store'

export default Vue.extend({
computed: {
...mapState({
showSettings: (state) => (state as RootState).ui.showSettings,
friends: (state) => (state as RootState).friends.all,
elapsedTime: (state) => (state as RootState).webrtc.elapsedTime,
activeCall: (state) => (state as RootState).webrtc.activeCall,
}),
caller(): Friend | undefined {
return this.friends.find(
(f: Friend) => f.peerId === this.activeCall?.peerId,
)
},
},
methods: {
navigateToActiveConversation() {
if (!this.caller) {
return
}

if (this.$device.isMobile) {
// mobile, show slide 1 which is chat slide, set showSidebar flag false as css related
this.$store.commit('ui/setSwiperSlideIndex', 1)
this.$store.commit('ui/showSidebar', false)
}

this.$store.dispatch('conversation/setConversation', {
id: this.caller.peerId,
type: 'friend',
participants: [this.caller],
calling: false,
})

this.$router.push(`/chat/direct/${this.caller.address}`)
},
},
})
</script>

<style scoped lang="less" src="./BackgroundCall.less"></style>
1 change: 1 addition & 0 deletions components/ui/Global/Global.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@
<transition :name="$device.isMobile ? 'slide' : ''">
<InteractablesQuickProfile v-if="ui.quickProfile" :user="ui.quickProfile" />
</transition>
<UiBackgroundCall v-if="showBackgroundCall" />
</div>
9 changes: 8 additions & 1 deletion components/ui/Global/Global.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template src="./Global.html"></template>
<script lang="ts">
import Vue from 'vue'
import { mapState } from 'vuex'
import { mapGetters, mapState } from 'vuex'
import { TrackKind } from '~/libraries/WebRTC/types'
import { ModalWindows } from '~/store/ui/types'
import { Item } from '~/libraries/Files/abstracts/Item.abstract'
Expand All @@ -21,7 +21,14 @@ export default Vue.extend({
name: 'Global',
computed: {
...mapState(['ui', 'media', 'webrtc', 'conversation']),
...mapGetters('webrtc', ['isBackgroundCall', 'isActiveCall']),
ModalWindows: () => ModalWindows,
showBackgroundCall(): boolean {
if (!this.$device.isMobile) {
return this.isBackgroundCall
}
return this.isBackgroundCall || (this.isActiveCall && this.ui.showSidebar)
},
},
mounted() {
// This determines if we should show the
Expand Down
2 changes: 1 addition & 1 deletion components/ui/Modal/Modal.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

.modal {
&:extend(.first-layer);
&:extend(.sixth-layer);
position: absolute;
}
.close {
Expand Down
6 changes: 6 additions & 0 deletions components/views/friends/friend/Friend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ export default Vue.extend({
}
},
sendMessageRequest() {
this.$store.dispatch('conversation/setConversation', {
id: this.friend.peerId,
type: 'friend',
participants: [this.friend],
calling: false,
})
this.$router.push(`/chat/direct/${this.friend.address}`)
},
},
Expand Down
9 changes: 2 additions & 7 deletions components/views/media/Media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<script lang="ts">
import Vue, { PropType } from 'vue'
import { mapState } from 'vuex'
import { mapGetters, mapState } from 'vuex'
import { Friend } from '~/types/ui/friends'
import { User } from '~/types/ui/user'
import { Sounds } from '~/libraries/SoundManager/SoundManager'
Expand Down Expand Up @@ -49,12 +49,7 @@ export default Vue.extend({
'webrtc',
'conversation',
]),
isActiveCall() {
return (
this.webrtc.activeCall &&
this.webrtc.activeCall.peerId === this.conversation.id
)
},
...mapGetters('webrtc', ['isActiveCall']),
computedUsers() {
return this.fullscreen
? this.users.slice(0, this.fullscreenMaxViewableUsers)
Expand Down
50 changes: 24 additions & 26 deletions components/views/media/heading/Heading.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<div id="media-heading">
<TypographyTag
v-if="elapsedTimeLabel"
data-cy="elapsed-time"
stavares843 marked this conversation as resolved.
Show resolved Hide resolved
:text="elapsedTimeLabel"
/>
<div class="spacer"></div>
<transition name="media-fullscreen" mode="out-in">
<div
v-bind:key="ui.fullscreen"
v-tooltip.left="ui.fullscreen ? $t('ui.exit_fullscreen') : $t('ui.fullscreen')"
@click="toggleFullscreen"
>
<minimize-icon
data-cy="exit-fullscreen"
v-if="ui.fullscreen"
size="1.2x"
/>
<maximize-icon
data-cy="go-fullscreen"
v-else="ui.fullscreen"
size="1.2x"
/>
</div>
</transition>
</div>
<div id="media-heading">
<TypographyTag
v-if="elapsedTime"
data-cy="elapsed-time"
:text="$t('ui.live', {
time: elapsedTime
})"
/>
<div class="spacer"></div>
<transition name="media-fullscreen" mode="out-in">
<div
:key="ui.fullscreen"
v-tooltip.left="ui.fullscreen ? $t('ui.exit_fullscreen') : $t('ui.fullscreen')"
@click="toggleFullscreen"
>
<minimize-icon
v-if="ui.fullscreen"
data-cy="exit-fullscreen"
size="1.2x"
/>
<maximize-icon v-else data-cy="go-fullscreen" size="1.2x" />
</div>
</transition>
</div>
34 changes: 2 additions & 32 deletions components/views/media/heading/Heading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@ export default Vue.extend({
MaximizeIcon,
MinimizeIcon,
},
data() {
return {
elapsedTimeLabel: '',
timer: undefined as NodeJS.Timeout | undefined,
}
},
computed: {
...mapState(['ui', 'webrtc']),
},
mounted() {
this.setTimer()
},
beforeDestroy() {
this.clearTimer()
...mapState(['ui']),
...mapState('webrtc', ['elapsedTime']),
},
methods: {
/**
Expand All @@ -41,25 +30,6 @@ export default Vue.extend({
}
}
},
elapsedTime(start: number): void {
if (!this.webrtc.activeCall || !start) {
return
}
const duration = this.$dayjs.duration(Date.now() - start)
const hours = duration.hours()
this.elapsedTimeLabel = `${this.$t('ui.live')} ${
hours > 0 ? `${hours}:` : ''
}${duration.format('mm:ss')}`
},
setTimer() {
this.elapsedTime(this.webrtc.createdAt)
this.timer = setInterval(() => {
this.elapsedTime(this.webrtc.createdAt)
}, 1000)
},
clearTimer() {
clearInterval(this.timer)
},
},
})
</script>
Expand Down
2 changes: 1 addition & 1 deletion components/views/navigation/toolbar/Toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
/>
</div>
<!-- <div
:class="`control-button ${!enableRTC || webrtc.activeCall ? 'disabled' : ''}`"
:class="`control-button ${!enableRTC || webrtc.BackgroundCall ? 'disabled' : ''}`"
data-cy="toolbar-enable-video"
v-tooltip.bottom="enableRTC ? $t('controls.video') : $t('controls.not_connected')"
v-if="recipient"
Expand Down
5 changes: 5 additions & 0 deletions layouts/Layout.less
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
}
}
}

&.has-background-call {
position: relative;
padding-top: @background-call-height;
}
}

.desktop .dynamic-content.swiper-slide-next {
Expand Down
30 changes: 15 additions & 15 deletions layouts/chat.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<template>
<div
id="app-wrap"
:class="`${$store.state.ui.theme.base.class}
${showSidebar ? 'is-open' : 'is-collapsed chat-page'} ${
asidebar && selectedGroup ? 'is-open-aside' : 'is-collapsed-aside'
} ${selectedGroup ? 'active-group' : null}`"
:class="[
$store.state.ui.theme.base.class,
showSidebar ? 'is-open' : 'is-collapsed chat-page',
asidebar && selectedGroup ? 'is-open-aside' : 'is-collapsed-aside',
selectedGroup ? 'active-group' : null,
]"
>
<div
id="app"
:class="`${showSidebar ? 'is-open' : 'is-collapsed'} ${
asidebar && selectedGroup ? 'is-open-aside' : 'is-collapsed-aside'
} ${selectedGroup ? 'group' : 'direct'} ${
$device.isMobile ? 'mobile-app' : 'desktop'
}`"
:class="[
showSidebar ? 'is-open' : 'is-collapsed',
asidebar && selectedGroup ? 'is-open-aside' : 'is-collapsed-aside',
selectedGroup ? 'group' : 'direct',
$device.isMobile ? 'mobile-app' : 'desktop',
isBackgroundCall ? 'has-background-call' : '',
]"
>
<UiGlobal />
<swiper
Expand Down Expand Up @@ -181,6 +185,7 @@ export default Vue.extend({
...mapGetters('ui', ['showSidebar', 'swiperSlideIndex']),
...mapGetters('textile', ['getInitialized']),
...mapGetters('conversation', ['recipient']),
...mapGetters('webrtc', ['isBackgroundCall', 'isActiveCall']),
DataStateType: () => DataStateType,
selectedGroup(): string {
return this.$route.params.id // TODO: change with groupid - AP-400
Expand All @@ -197,12 +202,6 @@ export default Vue.extend({
!this.friends.all.length
)
},
isActiveCall() {
return (
this.webrtc.activeCall &&
this.webrtc.activeCall.callId === this.conversation.id
)
},
},
watch: {
showSidebar(newValue, oldValue) {
Expand All @@ -225,6 +224,7 @@ export default Vue.extend({
this.$store.commit('ui/setShowOlderMessagesInfo', false)
// reset active conversation on chat leave
this.$store.commit('textile/setActiveConversation', '')
this.$store.commit('conversation/resetConversation')
},
mounted() {
this.$Sounds.changeLevels(this.audio.volume / 100)
Expand Down
9 changes: 6 additions & 3 deletions layouts/files.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<template>
<div
id="app-wrap"
:class="`${showSidebar ? 'is-open' : 'is-collapsed'} ${
$store.state.ui.theme.base.class
}`"
:class="[
$store.state.ui.theme.base.class,
showSidebar ? 'is-open' : 'is-collapsed',
]"
>
<div
id="app"
:class="[
showSidebar ? 'is-open' : 'is-collapsed',
$device.isMobile ? 'mobile-app' : 'desktop',
isBackgroundCall ? 'has-background-call' : '',
]"
>
<UiGlobal />
Expand Down Expand Up @@ -109,6 +111,7 @@ export default Vue.extend({
}),
...mapGetters('ui', ['showSidebar', 'isFilesIndexLoading']),
...mapGetters('textile', ['getInitialized']),
...mapGetters('webrtc', ['isBackgroundCall']),
flairColor(): string {
return this.$store.state.ui.theme.flair.value
},
Expand Down
Loading