@@ -61,14 +61,6 @@ function ScreenManager({
6161 { data : postData , error : saveErrorPost , isSuccess : isSaveSuccessPost } ,
6262 ] = usePostV2ScreensMutation ( ) ;
6363
64- /** If the screen is saved, display the success message */
65- useEffect ( ( ) => {
66- if ( isSaveSuccessPost || isSaveSuccessPut ) {
67- displaySuccess ( t ( "success-messages.saved-screen" ) ) ;
68- setSavingScreen ( false ) ;
69- }
70- } , [ isSaveSuccessPost , isSaveSuccessPut ] ) ;
71-
7264 /** If the screen is saved with error, display the error message */
7365 useEffect ( ( ) => {
7466 if ( saveErrorPut || saveErrorPost ) {
@@ -142,9 +134,7 @@ function ScreenManager({
142134 * @returns {Array | null } A mapped array with playlist ids and weight
143135 * filtered by region id or null
144136 */
145- function getPlaylistsByRegionId ( regionId ) {
146- const { playlists } = formStateObject ;
147-
137+ function getPlaylistsByRegionId ( playlists , regionId ) {
148138 return playlists
149139 . filter ( ( { region } ) => idFromUrl ( region ) === idFromUrl ( regionId ) )
150140 . map ( ( playlist , index ) => {
@@ -188,7 +178,7 @@ function ScreenManager({
188178
189179 // Add regionsId and connected playlists to the returnarray
190180 returnArray . push ( {
191- playlists : getPlaylistsByRegionId ( regionId ) ,
181+ playlists : getPlaylistsByRegionId ( playlists , regionId ) ,
192182 regionId : idFromUrl ( regionId ) ,
193183 } ) ;
194184 } ) ;
@@ -274,7 +264,8 @@ function ScreenManager({
274264
275265 /** Handle submitting is done. */
276266 useEffect ( ( ) => {
277- if ( isSaveSuccessPut || isSaveSuccessPost ) {
267+ if ( isSaveSuccessPost || isSaveSuccessPut ) {
268+ displaySuccess ( t ( "success-messages.saved-screen" ) ) ;
278269 setSavingScreen ( false ) ;
279270
280271 if ( saveWithoutClose ) {
0 commit comments