Skip to content
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
5 changes: 3 additions & 2 deletions src/components/MediaSettings/AdvancedAudioDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import NcRadioGroupButton from '@nextcloud/vue/components/NcRadioGroupButton'
import { useDevices } from '../../composables/useDevices.js'
import { useSettingsStore } from '../../stores/settings.ts'
import { isSafari } from '../../utils/browserCheck.ts'
import { isNoiseSuppressionModelSupported } from '../../utils/suppressNoise.ts'
import { localMediaModel } from '../../utils/webrtc/index.js'

const { container = undefined } = defineProps<{
Expand Down Expand Up @@ -53,7 +54,7 @@ const settingsStore = useSettingsStore()
const { audioPreviewAvailable, updateAudioStream } = useDevices()

const noiseSuppressionLevel = computed(() => {
if (settingsStore.noiseSuppressionWithModel === 'none') {
if (!isNoiseSuppressionModelSupported || settingsStore.noiseSuppressionWithModel === 'none') {
return settingsStore.noiseSuppression ? NOISE_LEVEL.BASIC : NOISE_LEVEL.OFF
}
return NOISE_LEVEL.ADVANCED
Expand Down Expand Up @@ -145,7 +146,7 @@ function onClosing(result?: unknown) {
@update:modelValue="setNoiseSuppressionLevel">
<NcRadioGroupButton :label="isSafari ? noiseSuppressionLevelLabelBasic : noiseSuppressionLevelLabelOff" :value="NOISE_LEVEL.OFF" />
<NcRadioGroupButton v-if="!isSafari" :label="noiseSuppressionLevelLabelBasic" :value="NOISE_LEVEL.BASIC" />
<NcRadioGroupButton :label="noiseSuppressionLevelLabelAdvanced" :value="NOISE_LEVEL.ADVANCED" />
<NcRadioGroupButton v-if="isNoiseSuppressionModelSupported" :label="noiseSuppressionLevelLabelAdvanced" :value="NOISE_LEVEL.ADVANCED" />
</NcRadioGroup>

<NcFormBox>
Expand Down
4 changes: 3 additions & 1 deletion src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ import {
selectRange,
} from '../../utils/selectionRange.ts'
import { parseSpecialSymbols } from '../../utils/textParse.ts'
import { mediaDevicesManager } from '../../utils/webrtc/index.js'

const supportScheduleMessages = hasTalkFeature('local', 'scheduled-messages')

Expand Down Expand Up @@ -670,7 +671,8 @@ export default {
},

showAudioRecorder() {
return !this.hasText && this.canUploadFiles && !this.broadcast && !this.upload
return mediaDevicesManager.isSupported()
&& !this.hasText && this.canUploadFiles && !this.broadcast && !this.upload
&& !this.messageToEdit && !this.threadCreating
&& !this.scheduleMessageTime && !this.showScheduledMessages
},
Expand Down
4 changes: 3 additions & 1 deletion src/stores/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { showError } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'
import { getUploader } from '@nextcloud/upload'
import { defineStore } from 'pinia'
import { v4 as uuidv4 } from 'uuid'
import { reactive, ref } from 'vue'
import { useStore } from 'vuex'
import { useTemporaryMessage } from '../composables/useTemporaryMessage.ts'
Expand Down Expand Up @@ -469,7 +470,8 @@ export const useUploadStore = defineStore('upload', () => {
// resolves the final name (and any conflicts) when postAttachment
// moves the file out of Draft.
for (const [index] of getInitialisedUploads(uploadId)) {
const tempName = crypto.randomUUID()
// crypto.randomUUID() is not available in insecure context
const tempName = crypto.randomUUID ? crypto.randomUUID() : uuidv4()
markFileAsPendingUpload({ uploadId, index, sharePath: '/' + draftFolderPath + '/' + tempName })
}
return
Expand Down
4 changes: 4 additions & 0 deletions src/utils/e2ee/encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Encryption {
throw new Error('stream transform is not supported')
}

if (!window.crypto?.subtle) {
throw new Error('crypto.subtle is not available in this context')
}

await initializeOlm()
return true
}
Expand Down
8 changes: 7 additions & 1 deletion src/utils/suppressNoise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { loadRnnoise, RnnoiseWorkletNode } from '@sapphi-red/web-noise-suppressor'
import type { RnnoiseWorkletNode } from '@sapphi-red/web-noise-suppressor'

// The rnnoise model relies on AudioWorkletNode, which only exists in a secure context
export const isNoiseSuppressionModelSupported = 'isSecureContext' in window && window.isSecureContext

let audioContext: AudioContext | null = null
let rnnoiseWorklet: RnnoiseWorkletNode | null = null
Expand Down Expand Up @@ -31,6 +34,9 @@ export async function registerNoiseSuppressionWorklet(): Promise<symbol | null>
}

try {
// Lazy load in try-catch block (AudioWorkletNode does not exist in an insecure context)
const { loadRnnoise, RnnoiseWorkletNode } = await import('@sapphi-red/web-noise-suppressor')

audioContext = new AudioContext()
const rnnoiseWasmBinary = await loadRnnoise({
url: new URL(
Expand Down
Loading