diff options
Diffstat (limited to 'src/components/NewMessageForm')
-rw-r--r-- | src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue b/src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue index f65c9d6a5..74b31da29 100644 --- a/src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue +++ b/src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue @@ -238,8 +238,10 @@ export default { this.audioStream.getTracks().forEach(track => track.stop()) if (!this.aborted) { this.blob = new Blob(this.chunks, { 'type': 'audio/mpeg-3' }) + // Generate file name + const fileName = this.generateFileName() // Convert blob to file - const audioFile = new File([this.blob], `${Date.now()}.mp3`) + const audioFile = new File([this.blob], fileName) this.$emit('audioFile', audioFile) this.$emit('recording', false) this.URL = window.URL.createObjectURL(this.blob) @@ -270,6 +272,15 @@ export default { seconds: 0, } }, + + generateFileName() { + const token = this.$store.getters.getToken() + const conversation = this.$store.getters.conversation(token).name + const today = new Date() + let time = today.getFullYear() + '-' + ('0' + today.getMonth()).slice(-2) + '-' + ('0' + today.getDay()).slice(-2) + time += ' ' + ('0' + today.getHours()).slice(-2) + '-' + ('0' + today.getMinutes()).slice(-2) + '-' + ('0' + today.getSeconds()).slice(-2) + return t('spreed', 'Talk recording from {time} ({conversation})', { time, conversation }) + '.mp3' + }, }, } </script> |