Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically stop recording after a minute #44

Merged
merged 14 commits into from
Aug 29, 2024

Conversation

jekuaitk
Copy link
Contributor

@jekuaitk jekuaitk commented Aug 28, 2024

  • Adds automatic recording stop after a minute
  • Adds messages

@jekuaitk jekuaitk requested a review from rimi-itk August 28, 2024 12:04
volumeInterval = setInterval(volumeCallback, 100);
}

setTimeout(durationChecker, 60 * 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a const with the timeout value.

Copy link
Contributor Author

@jekuaitk jekuaitk Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had not seen that it returned a (unique) number.

While wondering why it does so, it occurred to me that if a user manually stops a recording and for whatever reason decides to do it over the timeout will stop the next recording at essentially any random time.

So we do indeed need to keep this timeout value (id) - and clear it (cf. https://developer.mozilla.org/en-US/docs/Web/API/clearTimeout) if a user manually stops a recording.

durationChecker = () => {
// Check if recording is still going.
if (isRecording()) {
toggleButton.click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to tell the user that the recording has been stopped automatically. Our designer can design a message element that you can pass to showElement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

@jekuaitk jekuaitk force-pushed the feature/automatically-stop-recording branch from 4bf64b5 to 161eea8 Compare August 29, 2024 08:50
@jekuaitk jekuaitk requested a review from rimi-itk August 29, 2024 09:05
Comment on lines 97 to 98
hideElement(stopRecordingMessageElement);
showElement(automaticallyStoppedRecordingMessageElement);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure that more than one message is never shown, I suggest adding a showMessage function that hides all but one message:

const showMessage(message) {
  hideElement(startRecordingMessageElement);
  hideElement(stopRecordingMessageElement);
  
  showElement(message);
}

adding the message elements to an object (rather than having a variable for each) will make this much easier:

const messages = {
  'start_recording': document.querySelector("#start_recording_message"),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@jekuaitk jekuaitk requested a review from rimi-itk August 29, 2024 13:25
@rimi-itk rimi-itk merged commit c7a48d0 into develop Aug 29, 2024
8 checks passed
@rimi-itk rimi-itk deleted the feature/automatically-stop-recording branch August 29, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants