Skip to content

Commit

Permalink
fix: handle background blur in Talk if server doesn't support it
Browse files Browse the repository at this point in the history
- partially reverts ed39a6b

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Oct 10, 2024
1 parent 29325d6 commit 0546fc5
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 19 deletions.
37 changes: 36 additions & 1 deletion src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->

<template>
<div id="call-container">
<div id="call-container" :style="callContainerStyle">
<ViewerOverlayCallView v-if="isViewerOverlay"
:token="token"
:model="promotedParticipantModel"
Expand Down Expand Up @@ -136,10 +136,12 @@
<script>
import debounce from 'debounce'
import { ref } from 'vue'
import { getCapabilities } from '@nextcloud/capabilities'
import { showMessage } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import Grid from './Grid/Grid.vue'
import EmptyCallView from './shared/EmptyCallView.vue'
Expand All @@ -151,11 +153,15 @@ import VideoVue from './shared/VideoVue.vue'
import ViewerOverlayCallView from './shared/ViewerOverlayCallView.vue'
import { SIMULCAST } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import { fetchPeers } from '../../services/callsService.js'
import { EventBus } from '../../services/EventBus.js'
import { localMediaModel, localCallParticipantModel, callParticipantCollection } from '../../utils/webrtc/index.js'
import RemoteVideoBlocker from '../../utils/webrtc/RemoteVideoBlocker.js'
const serverVersion = loadState('core', 'config', {}).versionstring ?? '29.0.0'
const serverSupportsBackgroundBlurred = '29.0.4'.localeCompare(serverVersion) < 1
const supportedReactions = getCapabilities()?.spreed?.config?.call?.['supported-reactions']
export default {
Expand Down Expand Up @@ -190,11 +196,16 @@ export default {
},
setup() {
const isBackgroundBlurred = ref(serverSupportsBackgroundBlurred
? null
: BrowserStorage.getItem('background-blurred') !== 'false')
return {
supportedReactions,
localMediaModel,
localCallParticipantModel,
callParticipantCollection,
isBackgroundBlurred,
}
},
Expand Down Expand Up @@ -344,6 +355,19 @@ export default {
presenterVideoBlockerEnabled() {
return this.sharedDatas[this.shownRemoteScreenPeerId]?.remoteVideoBlocker?.isVideoEnabled()
},
/**
* Fallback style for versions before v29.0.4
*/
callContainerStyle() {
if (serverSupportsBackgroundBlurred) {
return
}
return {
'backdrop-filter': this.isBackgroundBlurred ? 'blur(25px)' : 'none',
}
}
},
watch: {
Expand Down Expand Up @@ -442,6 +466,7 @@ export default {
callParticipantCollection.on('remove', this._lowerHandWhenParticipantLeaves)
subscribe('switch-screen-to-id', this._switchScreenToId)
subscribe('set-background-blurred', this.setBackgroundBlurred)
},
beforeDestroy() {
Expand All @@ -451,6 +476,7 @@ export default {
callParticipantCollection.off('remove', this._lowerHandWhenParticipantLeaves)
unsubscribe('switch-screen-to-id', this._switchScreenToId)
unsubscribe('set-background-blurred', this.setBackgroundBlurred)
},
methods: {
Expand Down Expand Up @@ -714,6 +740,14 @@ export default {
}
},
/**
* Fallback method for versions before v29.0.4
* @param {boolean} value whether background should be blurred
*/
setBackgroundBlurred(value) {
this.isBackgroundBlurred = value
},
isModelWithVideo(callParticipantModel) {
return callParticipantModel.attributes.videoAvailable
&& this.sharedDatas[callParticipantModel.attributes.peerId].remoteVideoBlocker.isVideoEnabled()
Expand Down Expand Up @@ -746,6 +780,7 @@ export default {
width: 100%;
height: 100%;
background-color: $color-call-background;
// Default value has changed since v29.0.4: 'blur(25px)' => 'none'
backdrop-filter: var(--filter-background-blur);
}
Expand Down
72 changes: 54 additions & 18 deletions src/components/SettingsDialog/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,30 @@
<NcAppSettingsSection id="performance"
:name="t('spreed', 'Performance')"
class="app-settings-section">
<NcCheckboxRadioSwitch id="blur-call-background"
:checked="isBackgroundBlurred === 'yes'"
:indeterminate="isBackgroundBlurred === ''"
type="checkbox"
<template v-if="serverSupportsBackgroundBlurred">
<NcCheckboxRadioSwitch id="blur-call-background"
:checked="isBackgroundBlurred === 'yes'"
:indeterminate="isBackgroundBlurred === ''"
type="checkbox"
class="checkbox"
disabled>
{{ t('spreed', 'Blur background image in the call (may increase GPU load)') }}
</NcCheckboxRadioSwitch>
<a :href="themingUrl"
target="_blank"
rel="noreferrer nofollow"
class="external">
{{ t('spreed', 'Background blur for Nextcloud instance can be adjusted in the theming settings.') }} ↗
</a>
</template>
<NcCheckboxRadioSwitch v-else
id="blur-call-background"
:checked="isBackgroundBlurred !== 'false'"
type="switch"
class="checkbox"
disabled>
@update:checked="toggleBackgroundBlurred">
{{ t('spreed', 'Blur background image in the call (may increase GPU load)') }}
</NcCheckboxRadioSwitch>
<a :href="themingUrl"
target="_blank"
rel="noreferrer nofollow"
class="external">
{{ t('spreed', 'Background blur for Nextcloud instance can be adjusted in the theming settings.') }} ↗
</a>
</NcAppSettingsSection>
<NcAppSettingsSection v-if="!disableKeyboardShortcuts"
id="shortcuts"
Expand Down Expand Up @@ -186,11 +196,13 @@
</template>

<script>
import { ref } from 'vue'
import axios from '@nextcloud/axios'
import { getCapabilities } from '@nextcloud/capabilities'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { FilePickerVue } from '@nextcloud/dialogs/filepicker.js'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
Expand All @@ -206,7 +218,12 @@ import { PRIVACY } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import { useSettingsStore } from '../../stores/settings.js'
const isBackgroundBlurred = loadState('spreed', 'force_enable_blur_filter', '')
const serverVersion = loadState('core', 'config', {}).versionstring ?? '29.0.0'
const serverSupportsBackgroundBlurred = '29.0.4'.localeCompare(serverVersion) < 1
const isBackgroundBlurredState = serverSupportsBackgroundBlurred
? loadState('spreed', 'force_enable_blur_filter', '') // 'yes', 'no', ''
: BrowserStorage.getItem('background-blurred') // 'true', 'false', null
const supportTypingStatus = getCapabilities()?.spreed?.config?.chat?.['typing-privacy'] !== undefined
export default {
Expand All @@ -223,11 +240,13 @@ export default {
setup() {
const settingsStore = useSettingsStore()
const isBackgroundBlurred = ref(isBackgroundBlurredState)
return {
settingsStore,
supportTypingStatus,
isBackgroundBlurred,
serverSupportsBackgroundBlurred,
}
},
Expand Down Expand Up @@ -293,12 +312,20 @@ export default {
created() {
const blurred = BrowserStorage.getItem('background-blurred')
if (blurred === 'false' && isBackgroundBlurred === '') {
console.debug('Blur was disabled intentionally, propagating last choice to server')
axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/theming/force_enable_blur_filter'),
{ configValue: 'no' })
if (serverSupportsBackgroundBlurred) {
// Blur is handled by theming app, migrating
if (blurred === 'false' && isBackgroundBlurredState === '') {
console.debug('Blur was disabled intentionally, propagating last choice to server')
axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/theming/force_enable_blur_filter'),
{ configValue: 'no' })
}
BrowserStorage.removeItem('background-blurred')
} else {
// Fallback to BrowserStorage
if (blurred === null) {
BrowserStorage.setItem('background-blurred', 'true')
}
}
BrowserStorage.removeItem('background-blurred')
},
mounted() {
Expand Down Expand Up @@ -353,6 +380,15 @@ export default {
this.privacyLoading = false
},
toggleBackgroundBlurred(value) {
if (serverSupportsBackgroundBlurred) {
return
}
this.isBackgroundBlurred = value ? 'true' : 'false'
BrowserStorage.setItem('background-blurred', value)
emit('set-background-blurred', value)
},
async togglePlaySounds() {
this.playSoundsLoading = true
try {
Expand Down

0 comments on commit 0546fc5

Please sign in to comment.