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 <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Oct 10, 2024
1 parent cd18f1e commit d979129
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 19 deletions.
36 changes: 35 additions & 1 deletion src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-->

<template>
<div id="call-container">
<div id="call-container" :style="callContainerStyle">
<ViewerOverlayCallView v-if="isViewerOverlay"
:token="token"
:model="promotedParticipantModel"
Expand Down Expand Up @@ -137,6 +137,7 @@ import { provide, ref } from 'vue'
import { showMessage } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import Grid from './Grid/Grid.vue'
Expand All @@ -151,12 +152,16 @@ import ViewerOverlayCallView from './shared/ViewerOverlayCallView.vue'
import { placeholderImage, placeholderModel, placeholderName, placeholderSharedData } from './Grid/gridPlaceholders.ts'
import { SIMULCAST } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import { fetchPeers } from '../../services/callsService.js'
import { getTalkConfig } from '../../services/CapabilitiesManager.ts'
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
export default {
name: 'CallView',
Expand Down Expand Up @@ -196,11 +201,16 @@ export default {
const screenshotMode = ref(false)
provide('CallView:screenshotModeEnabled', screenshotMode)
const isBackgroundBlurred = ref(serverSupportsBackgroundBlurred
? null
: BrowserStorage.getItem('background-blurred') !== 'false')
return {
localMediaModel,
localCallParticipantModel,
callParticipantCollection,
devMode,
isBackgroundBlurred,
}
},
Expand Down Expand Up @@ -370,6 +380,19 @@ export default {
supportedReactions() {
return getTalkConfig(this.token, 'call', 'supported-reactions')
},
/**
* 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 @@ -461,6 +484,7 @@ export default {
callParticipantCollection.on('remove', this._lowerHandWhenParticipantLeaves)
subscribe('switch-screen-to-id', this._switchScreenToId)
subscribe('set-background-blurred', this.setBackgroundBlurred)
},
beforeDestroy() {
Expand All @@ -471,6 +495,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 @@ -739,6 +764,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) {
if (!callParticipantModel) {
return false
Expand Down Expand Up @@ -767,6 +800,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);
--grid-gap: calc(var(--default-grid-baseline) * 2);
}
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 @@ -92,20 +92,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 @@ -177,10 +187,12 @@
</template>

<script>
import { ref } from 'vue'
import axios from '@nextcloud/axios'
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 @@ -199,7 +211,12 @@ import { useCustomSettings } from '../../services/SettingsAPI.ts'
import { useSettingsStore } from '../../stores/settings.js'
import { useSoundsStore } from '../../stores/sounds.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 = getTalkConfig('local', 'chat', 'typing-privacy') !== undefined
export default {
Expand All @@ -218,12 +235,14 @@ export default {
const settingsStore = useSettingsStore()
const soundsStore = useSoundsStore()
const { customSettingsSections } = useCustomSettings()
const isBackgroundBlurred = ref(isBackgroundBlurredState)
return {
settingsStore,
soundsStore,
supportTypingStatus,
isBackgroundBlurred,
serverSupportsBackgroundBlurred,
customSettingsSections,
}
},
Expand Down Expand Up @@ -286,12 +305,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 @@ -347,6 +374,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 d979129

Please sign in to comment.