Skip to content

Commit

Permalink
Bring back Twilio recordings overlay (#1672)
Browse files Browse the repository at this point in the history
  • Loading branch information
GPaoloni authored Sep 21, 2023
1 parent 9e46230 commit 043cdcc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
13 changes: 10 additions & 3 deletions plugin-hrm-form/src/components/contact/ContactDetailsHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,15 @@ const ContactDetailsHome: React.FC<Props> = function ({
(twilioStoredTranscript || externalStoredTranscript),
);

const twilioStoredRecording =
featureFlags.enable_voice_recordings && savedContact.details.conversationMedia?.find(isTwilioStoredMedia);
const externalStoredRecording = savedContact.details.conversationMedia?.find(isS3StoredRecording);
const showRecordingSection = Boolean(
isVoiceChannel(channel) &&
savedContact.details.conversationMedia?.length &&
can(PermissionActions.VIEW_RECORDING) &&
savedContact.details.conversationMedia?.find(isS3StoredRecording),
(twilioStoredRecording || externalStoredRecording),
);
const externalStoredRecording = savedContact.details.conversationMedia?.find(isS3StoredRecording);

const csamReportEnabled = featureFlags.enable_csam_report && featureFlags.enable_csam_clc_report;

Expand Down Expand Up @@ -421,7 +424,11 @@ const ContactDetailsHome: React.FC<Props> = function ({
showEditButton={false}
>
<Flex justifyContent="center" flexDirection="row" paddingTop="20px">
<RecordingSection contactId={contactId} externalStoredRecording={externalStoredRecording} />{' '}
<RecordingSection
contactId={contactId}
externalStoredRecording={externalStoredRecording}
loadConversationIntoOverlay={loadConversationIntoOverlay}
/>{' '}
</Flex>
</ContactDetailsSection>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ import { S3StoredRecording } from '../../../types/types';
import { generateExternalMediaPath } from '../../../services/ContactService';
import fetchHrmApi from '../../../services/fetchHrmApi';

type OwnProps = { contactId: string; externalStoredRecording: S3StoredRecording };
type OwnProps = {
contactId: string;
externalStoredRecording?: S3StoredRecording;
loadConversationIntoOverlay: () => Promise<void>;
};

const RecordingSection: React.FC<OwnProps> = ({ contactId, externalStoredRecording }) => {
const RecordingSection: React.FC<OwnProps> = ({ contactId, externalStoredRecording, loadConversationIntoOverlay }) => {
const [voiceRecording, setVoiceRecording] = useState(null);
const [loading, setLoading] = useState(false);
const [showButton, setShowButton] = useState(true);
Expand All @@ -35,16 +39,21 @@ const RecordingSection: React.FC<OwnProps> = ({ contactId, externalStoredRecordi
setLoading(true);
setShowButton(false);

// TODO: this won't currently work for local dev env
const { media_url: recordingPreSignedUrl } = await fetchHrmApi(
generateExternalMediaPath(
contactId,
externalStoredRecording.location.bucket,
externalStoredRecording.location.key,
),
);
if (externalStoredRecording) {
// TODO: this won't currently work for local dev env
const { media_url: recordingPreSignedUrl } = await fetchHrmApi(
generateExternalMediaPath(
contactId,
externalStoredRecording.location.bucket,
externalStoredRecording.location.key,
),
);

setVoiceRecording(recordingPreSignedUrl);
setVoiceRecording(recordingPreSignedUrl);
} else {
await loadConversationIntoOverlay();
setShowButton(true);
}

setLoading(false);
} catch (error) {
Expand Down

0 comments on commit 043cdcc

Please sign in to comment.