From 11574264c8ae127e76aceb5310cff7bbea366183 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Wed, 23 Oct 2024 11:57:19 +0200 Subject: [PATCH] fixup! use localUrl for voice messages Signed-off-by: Maksim Sukharev --- .../NewMessage/NewMessageAudioRecorder.vue | 1 - src/components/NewMessage/NewMessageUploadEditor.vue | 5 +---- src/store/fileUploadStore.js | 12 +++++------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/NewMessage/NewMessageAudioRecorder.vue b/src/components/NewMessage/NewMessageAudioRecorder.vue index 13a87cf1a04a..125632dce291 100644 --- a/src/components/NewMessage/NewMessageAudioRecorder.vue +++ b/src/components/NewMessage/NewMessageAudioRecorder.vue @@ -248,7 +248,6 @@ export default { const fileName = this.generateFileName() // Convert blob to file const audioFile = new File([this.blob], fileName) - audioFile.localURL = window.URL.createObjectURL(this.blob) this.$emit('audio-file', audioFile) this.$emit('recording', false) } diff --git a/src/components/NewMessage/NewMessageUploadEditor.vue b/src/components/NewMessage/NewMessageUploadEditor.vue index 1f0ca98c4720..2da4e82a4a7c 100644 --- a/src/components/NewMessage/NewMessageUploadEditor.vue +++ b/src/components/NewMessage/NewMessageUploadEditor.vue @@ -164,10 +164,7 @@ export default { }, voiceMessageLocalURL() { - if (!this.firstFile?.file?.localURL) { - return '' - } - return this.firstFile.file.localURL + return this.$store.getters.getLocalUrl(this.firstFile.temporaryMessage.referenceId) }, }, diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index 7cd309d9557e..38429190771d 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -240,13 +240,11 @@ const actions = { + getFileExtension(file.name) } - // Get localurl for some image previews - let localUrl - if (SHARED_ITEM.MEDIA_ALLOWED_PREVIEW.includes(file.type)) { - localUrl = URL.createObjectURL(file) - } else if (isVoiceMessage) { - localUrl = file.localURL - } + // Get localUrl for uploaded allowed image previews and voice messages + const localUrl = (SHARED_ITEM.MEDIA_ALLOWED_PREVIEW.includes(file.type) || isVoiceMessage) + ? URL.createObjectURL(file) + : undefined + // Create a unique index for each file const date = new Date() const index = 'temp_' + date.getTime() + Math.random()