Skip to content

Commit

Permalink
fix: fix localUrl usage for voice messages
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy authored and backportbot[bot] committed Oct 23, 2024
1 parent 663eabb commit b231b7b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export default {
name: this.file.name,
path: this.file.path,
link: this.file.link,
localUrl: this.fallbackLocalUrl,
messageId: Number(this.messageId),
nextMessageId: Number(this.nextMessageId),
}
Expand Down
1 change: 0 additions & 1 deletion src/components/NewMessage/NewMessageAudioRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,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)
}
Expand Down
5 changes: 1 addition & 4 deletions src/components/NewMessage/NewMessageUploadEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand Down
12 changes: 5 additions & 7 deletions src/store/fileUploadStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 allowed image previews and voice messages uploads
const localUrl = (isVoiceMessage || SHARED_ITEM.MEDIA_ALLOWED_PREVIEW.includes(file.type))
? URL.createObjectURL(file)
: undefined

// Create a unique index for each file
const date = new Date()
const index = 'temp_' + date.getTime() + Math.random()
Expand Down

0 comments on commit b231b7b

Please sign in to comment.