Confirm beforeunload when a recording is in progress

This commit is contained in:
metalex9
2019-04-26 13:28:53 -05:00
parent 6fa154f824
commit e83e3e76b4
2 changed files with 9 additions and 2 deletions

View File

@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Shuffle removed from mobile devices to make room for timer button
### Fixed
- Desktop users will be asked to confirm when navigating away from the site while a recording is in progress
## [0.14.0] - 2019-04-21
### Added

View File

@@ -11,8 +11,11 @@ const beforeUnloadMiddleware = store => next => {
if (isProduction) {
return action => {
const result = next(action);
const { isPlaying } = store.getState();
if (isPlaying) {
const { isPlaying, generatedRecordings } = store.getState();
const isRecordingInProgress = Reflect.ownKeys(generatedRecordings).some(
recordingId => generatedRecordings[recordingId].isInProgress
);
if (isPlaying || isRecordingInProgress) {
if (!isListening) {
isListening = true;
window.addEventListener('beforeunload', handleBeforeUnload);