Skip to content

Commit

Permalink
[FIX] Treating loading on the audio message done (RocketChat#21078)
Browse files Browse the repository at this point in the history
Signed-off-by: matheus rodrigues <matheus.1nascimento58@gmail.com>
Co-authored-by: Guilherme Banci <guibanci@gmail.com>
  • Loading branch information
matheus-rn and gdeusdara committed Mar 11, 2021
1 parent 4f05c55 commit 0e34e29
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/ui-message/client/messageBox/messageBoxAudioMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import './messageBoxAudioMessage.html';
const startRecording = () => new Promise((resolve, reject) =>
AudioRecorder.start((result) => (result ? resolve() : reject())));

const stopRecording = () => new Promise((resolve) => AudioRecorder.stop(resolve));
const stopRecording = () => new Promise((resolve, reject) => AudioRecorder.stop((result) => (result ? resolve() : reject())));

const recordingInterval = new ReactiveVar(null);
const recordingRoomId = new ReactiveVar(null);
Expand Down Expand Up @@ -132,12 +132,16 @@ Template.messageBoxAudioMessage.events({

instance.time.set('00:00');

const blob = await stopRecording();
try {
const blob = await stopRecording();

instance.state.set(null);
const { rid, tmid } = this;

const { rid, tmid } = this;
await uploadFileWithMessage(rid, tmid, { file: { file: blob }, fileName: `${ t('Audio record') }.mp3` });

await uploadFileWithMessage(rid, tmid, { file: { file: blob }, fileName: `${ t('Audio record') }.mp3` });
instance.state.set(null);
} catch (error) {
instance.state.set('recording');
}
},
});

0 comments on commit 0e34e29

Please sign in to comment.