From 185a1b24a1b9aa1abc4dd0d98b81c11fd92668e3 Mon Sep 17 00:00:00 2001 From: Caley Date: Fri, 14 Apr 2023 18:12:02 -0500 Subject: [PATCH 1/2] fix(current_playlist_dialog): this PR adds a current playlist dialog to allow users to quickly see the current playlist that is saved in state. --- src/App.js | 79 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/src/App.js b/src/App.js index 71a37c4..4705e4d 100644 --- a/src/App.js +++ b/src/App.js @@ -11,7 +11,7 @@ class App extends Component { super(props); this.state = { discoveries: [], - groups: [], // Currently duscovered patterns and their controllers + groups: [], // Currently discovered patterns and their controllers runningPatternName: null, playlist: [], // Browser-persisted single playlist singleton playlistIndex: 0, @@ -19,9 +19,10 @@ class App extends Component { cloneSource: null, cloneDest: {}, cloneInProgress: false, - showDevControls: false + showDevControls: false, + showCurrentPlaylist: false, } - // The playlist is the only thing currently persisted and it is per-broswer + // The playlist is the only thing currently persisted, and it is per-browser this.state.playlist = JSON.parse(localStorage.getItem(PLAYLIST_KEY)) || [] if (this.state.playlist.length) { @@ -33,6 +34,7 @@ class App extends Component { this._playlistInterval = null this.cloneDialogRef = React.createRef(); + this.playlistDialogRef = React.createRef(); } async poll() { @@ -207,7 +209,20 @@ class App extends Component { this.cloneDialogRef.current && this.cloneDialogRef.current.scrollIntoView(true); }, 100) } - + openPlaylistDialog = async (event) => { + event.preventDefault(); + this.setState({ + showCurrentPlaylist: true + }); + setTimeout(() => { + this.playlistDialogRef.current && this.playlistDialogRef.current.scrollIntoView(true); + }, 100) + if( this.state.showCurrentPlaylist === true ) { + this.setState({ + showCurrentPlaylist: false + }); + } + } closeCloneDialog = async (event) => { event.preventDefault(); this.setState({ @@ -260,7 +275,6 @@ class App extends Component { } } - render() { let cloneDialog = null; if (this.state.cloneSource) { @@ -309,6 +323,46 @@ class App extends Component { ) } + let playlistDialog = null + if (this.state.showCurrentPlaylist) { + playlistDialog = ( +
+
+
+
+
Current Playlist
+
+
+

Pattern

+
+
+

Duration(seconds)

+
+
+ {(this.state.playlist).map( pattern => + <> +
+
+
+
+ {pattern.name} +
+
+
+
+ {pattern.duration} +
+
+
+
+ + )} +
+
+
+
+ ) + } return (
@@ -350,8 +404,15 @@ class App extends Component {
{cloneDialog} - -

Patterns

+ {playlistDialog} +

+ Patterns + +

{this.state.groups.map((pattern) => { const getStatus = () => { @@ -363,7 +424,7 @@ class App extends Component { return 'available' } } - const getDuraton = () => { + const getDuration = () => { const playlistIndex = _(this.state.playlist).findIndex(['name', pattern.name]) if (playlistIndex === -1) return '' return this.state.playlist[playlistIndex].duration @@ -378,7 +439,7 @@ class App extends Component { handleAddClick={this._handleAddClick} status={getStatus()} showDurations={(this.state.playlist.length > 1)} - duration={getDuraton()} + duration={getDuration()} /> ) })} From 6e009843a5bb7b27f2612ee8320fe1ff41bcfab7 Mon Sep 17 00:00:00 2001 From: Caley Date: Sun, 16 Apr 2023 22:28:23 -0500 Subject: [PATCH 2/2] fix(current_playlist_dialog): adding index to dialog for uniqueness --- src/App.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/App.js b/src/App.js index 4705e4d..7edfd9c 100644 --- a/src/App.js +++ b/src/App.js @@ -339,23 +339,21 @@ class App extends Component {

Duration(seconds)

- {(this.state.playlist).map( pattern => - <> -
-
-
-
- {pattern.name} -
+ {(this.state.playlist).map( (pattern, index) => +
+
+
+
+ {pattern.name}
-
-
- {pattern.duration} -
+
+
+
+ {pattern.duration}
- +
)}