@@ -195,17 +195,20 @@ recipeButtons.forEach((button) => {
195195 console . log ( "data.image" , eventData . image ) ;
196196
197197 if ( data . audio && data . image ) {
198- removeElements ( [ loadingContainer ] ) ;
199- const imageUrl = data . image . data [ 0 ] . url ;
200- // await cacheData(imageUrl, CACHE_NAME_URL, "image");
201- backgroundImg . src = imageUrl ;
198+
199+ createImage ( data )
200+
201+
202+
202203
203204
204205 ///
205-
206+
207+ // await cacheData(imageUrl, CACHE_NAME_URL, "image");
208+
206209 // const audio_data = createAudio(data.audio);
207210 // await cacheData(audio_data, CACHE_NAME_AUDIO, "audio");
208- const { speedBtn, speechBtns } = createTextToSpeech ( data ) ;
211+ const { speedBtn, speechBtns } = createTextToSpeech ( data ) ;
209212
210213 userWantAnotherRecipe . addEventListener ( "click" , ( ) => {
211214 displayElements ( [ headline , allergies , ...recipeButtons , mainElement ] ) ;
@@ -238,6 +241,14 @@ recipeButtons.forEach((button) => {
238241 } ) ;
239242} ) ;
240243
244+
245+ function createImage ( param ) {
246+ removeElements ( [ loadingContainer ] ) ;
247+ const imageUrl = param . image . data [ 0 ] . url ;
248+ backgroundImg . src = imageUrl ;
249+ return backgroundImg ;
250+ }
251+
241252function createTextToSpeech ( param ) {
242253 displayElementsFlex ( [ recording ] ) ;
243254 displayElements ( [ sendRecipeToUserInboxBtn , userWantAnotherRecipe ] ) ;
@@ -248,7 +259,7 @@ function createTextToSpeech(param) {
248259 this . pause ( ) ;
249260 this . currentTime = 0 ;
250261 } ;
251- return { speedBtn, speechBtns } ;
262+ return { speedBtn, speechBtns } ;
252263}
253264
254265// Picture section
0 commit comments