simularium / simularium-viewer

NPM package to view Simularium trajectories in 3D
Apache License 2.0
2 stars 0 forks source link

onRecordedMovies should be optional #369

Closed interim17 closed 5 months ago

interim17 commented 6 months ago

Review Time

Small

Problem

Closes #368 onRecordedMovies should be optional for implementations where movie recording is not desired.

Note: snuck in a commit in the prettier config to prevent {" "} < ---- those from appearing, I think it works to prevent them showing up when not needed, can add to sim-website too

Solution

Made the recording and onRecordedMovie props optional. If onRecordedMovie is undefined, set recorder to null, and adjusted references to account for that.

When a callback is provided, the feature will be enabled, and if the prop is undefined then no FrameRecorder functions should be called even if recording is set to true.

Added a function in test-bed to check if recording is enabled or not and display a message if so.

To test you can comment out the prop assigment: // onRecordedMovie={this.onRecordedMovie} Recording buttons should be disabled but viewer should work.

For a further test provide a true value to isRecordingEnabled

                 <RecordMovieComponent
                    isRecording={this.state.isRecording}
                    setIsRecording={this.setIsRecording}
                    isRecordingEnabled={true}
                />

Buttons will be clickable but should have no effect.

github-actions[bot] commented 6 months ago

jest coverage report πŸ§ͺ

Total coverage

Status Category Percentage Covered / Total
πŸ”΄ Statements 40.39% 2046/5065
πŸ”΄ Branches 43.22% 845/1955
πŸ”΄ Functions 36.77% 417/1134
πŸ”΄ Lines 40.61% 1959/4823

Status of coverage: 🟒 - ok, 🟑 - slightly more than threshold, πŸ”΄ - under the threshold

Show files with reduced coverage πŸ”» ### Reduced coverage | Status | Filename | Statements | Branches | Functions | Lines | | :----: | :--------------- | :----------------- | :----------------- | :-------- | :----------------- | | πŸ”΄ | src/controller | 29.95% | 15.1% | 16.66% | 30.28% | | 🟑 | src/simularium | 60.26% | 57.88% | 49.01% | 61.13% | | πŸ”΄ | FrameRecorder.ts | 27.58% (-1.33% πŸ”») | 29.16% (-4.17% πŸ”») | 25% | 27.38% (-1.37% πŸ”») | | πŸ”΄ | src/viewport | 14.94% | 10.95% | 15% | 14.49% | | πŸ”΄ | index.tsx | 14.94% | 10.95% | 15% | 14.49% | > Status of coverage: 🟒 - ok, 🟑 - slightly more than threshold, πŸ”΄ - under the threshold
toloudis commented 5 months ago

Oops my thing says "requested changes" but I meant to do a "general comments".

interim17 commented 5 months ago

ok @toloudis this may constitute mission creep but I couldn't bring myself to write the comments on the recording flag because its just not how we handle this type of thing in the rest of the repo.

New changes:

meganrm commented 5 months ago

looks good, just FYI, there seems to be a slightly different behavior for me on safari than before: I can still hit the record button on safari in the test app but the resulting file won't play.

Hm, that is unfortunate, Safari on my machine still disables the feature. I think I'll merge this PR and maybe write an issue for Safari issues.