File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
assets/admin/components/screen/util Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -142,20 +142,18 @@ function GridGenerationAndSelect({
142142 } ;
143143
144144 /**
145- * Removes playlist from list of playlists, and closes modal .
145+ * Removes playlist from list of playlists.
146146 *
147- * @param {object } inputPlaylist - InputPlaylist to remove
148- * @param {object } inputRegion - InputRegion to remove from
147+ * @param {object } inputPlaylistId - InputPlaylistId to remove
148+ * @param {object } inputRegionId - InputRegionId to remove from
149149 */
150- const removeFromList = ( inputPlaylist , inputRegion ) => {
151- const indexOfItemToRemove = selectedPlaylists . findIndex (
152- ( { "@id" : id , region } ) => {
153- return region === inputRegion && id === inputPlaylist ;
154- } ,
150+ const removeFromList = ( inputPlaylistId , inputRegionId ) => {
151+ setSelectedPlaylists ( ( prev ) =>
152+ prev . filter (
153+ ( { "@id" : id , region : regionId } ) =>
154+ ! ( regionId === inputRegionId && id === inputPlaylistId ) ,
155+ ) ,
155156 ) ;
156- const selectedPlaylistsCopy = [ ...selectedPlaylists ] ;
157- selectedPlaylistsCopy . splice ( indexOfItemToRemove , 1 ) ;
158- setSelectedPlaylists ( selectedPlaylistsCopy ) ;
159157 } ;
160158
161159 if ( regions ?. length === 0 ) return null ;
You can’t perform that action at this time.
0 commit comments