From be03c7fa73a7d9456380644d1ef08334b8587dfc Mon Sep 17 00:00:00 2001 From: Carlo Venusino Date: Wed, 19 May 2021 17:29:43 +0200 Subject: [PATCH] TT#122353 CallRecordings - Lazy load audio files - TT#123301 If file is loaded once, the file must not be refetched from the server - TT#123300 Loads the audio file not before the user has clicked the play button - TT#123302 Make sure not breaking all other player integrations Change-Id: Ieb37bea2f9ca648e12afffe9f908743319416da4 --- src/pages/CscPageCallRecording.vue | 10 +++++++--- src/store/call-recordings.js | 24 +++++++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/pages/CscPageCallRecording.vue b/src/pages/CscPageCallRecording.vue index 4c958fb9..3ce52501 100644 --- a/src/pages/CscPageCallRecording.vue +++ b/src/pages/CscPageCallRecording.vue @@ -137,10 +137,13 @@ class="row justify-end table-td-action-cont" > rec.id === data.recId)[0] recording.files = data.streams + }, + callRecordingStream (state, { recId, streamId, url }) { + const recording = state.recordings.filter(rec => rec.id === recId)[0] + const stream = recording.files.filter((file) => file.id === streamId)[0] + stream.url = url } }, actions: { @@ -38,15 +48,19 @@ export default { }, async fetchStreams (context, recId) { const streams = await getRecordingStreams(recId) - await Promise.all(streams.map(async stream => { - const blob = await getRecordingStream(stream.id) - stream.url = blob - })) context.commit('callRecordingStreams', { recId: recId, streams: streams }) }, + async fetchFile (context, { recId, streamId }) { + const blob = await getRecordingStream(streamId) + context.commit('callRecordingStream', { + recId: recId, + streamId: streamId, + url: blob + }) + }, async deleteRecording (context, recId) { await Vue.http.delete('api/callrecordings/' + recId + '?force_delete=1') },