@@ -173,31 +173,9 @@ window.IonicDevServer = {
173173
174174 if ( msg . type === 'started' ) {
175175 status = 'active' ;
176-
177- var toastEle = document . getElementById ( 'ion-diagnostics-toast' ) ;
178- if ( ! toastEle ) {
179- toastEle = document . createElement ( 'div' ) ;
180- toastEle . id = 'ion-diagnostics-toast' ;
181- var c = [ ]
182- c . push ( '<div class="ion-diagnostics-toast-content">' ) ;
183- c . push ( ' <div class="ion-diagnostics-toast-message">Building...</div>' ) ;
184- c . push ( ' <div class="ion-diagnostics-toast-spinner">' ) ;
185- c . push ( ' <svg viewBox="0 0 64 64"><circle transform="translate(32,32)" r="26"></circle></svg>' ) ;
186- c . push ( ' </div>' ) ;
187- c . push ( '</div>' ) ;
188- toastEle . innerHTML = c . join ( '' ) ;
189- document . body . insertBefore ( toastEle , document . body . firstChild ) ;
190- }
191-
192- this . toastTimerId = setTimeout ( function ( ) {
193- var toastEle = document . getElementById ( 'ion-diagnostics-toast' ) ;
194- if ( toastEle ) {
195- toastEle . classList . add ( 'ion-diagnostics-toast-active' ) ;
196- }
197- } , 50 ) ;
176+ this . buildingNotification ( true ) ;
198177
199178 } else {
200- clearTimeout ( this . toastTimerId ) ;
201179
202180 if ( msg . data . reloadApp ) {
203181 this . reloadApp ( ) ;
@@ -206,10 +184,7 @@ window.IonicDevServer = {
206184
207185 status = msg . data . diagnosticsHtml ? 'error' : 'success' ;
208186
209- var toastEle = document . getElementById ( 'ion-diagnostics-toast' ) ;
210- if ( toastEle ) {
211- toastEle . classList . remove ( 'ion-diagnostics-toast-active' ) ;
212- }
187+ this . buildingNotification ( false ) ;
213188
214189 var diagnosticsEle = document . getElementById ( 'ion-diagnostics' ) ;
215190 if ( diagnosticsEle && ! msg . data . diagnosticsHtml ) {
@@ -272,6 +247,38 @@ window.IonicDevServer = {
272247 }
273248 } ,
274249
250+ buildingNotification : function ( showToast ) {
251+ clearTimeout ( this . toastTimerId ) ;
252+
253+ var toastEle = document . getElementById ( 'ion-diagnostics-toast' ) ;
254+
255+ if ( showToast ) {
256+ if ( ! toastEle ) {
257+ toastEle = document . createElement ( 'div' ) ;
258+ toastEle . id = 'ion-diagnostics-toast' ;
259+ var c = [ ]
260+ c . push ( '<div class="ion-diagnostics-toast-content">' ) ;
261+ c . push ( ' <div class="ion-diagnostics-toast-message">Building...</div>' ) ;
262+ c . push ( ' <div class="ion-diagnostics-toast-spinner">' ) ;
263+ c . push ( ' <svg viewBox="0 0 64 64"><circle transform="translate(32,32)" r="26"></circle></svg>' ) ;
264+ c . push ( ' </div>' ) ;
265+ c . push ( '</div>' ) ;
266+ toastEle . innerHTML = c . join ( '' ) ;
267+ document . body . insertBefore ( toastEle , document . body . firstChild ) ;
268+ }
269+
270+ this . toastTimerId = setTimeout ( function ( ) {
271+ var toastEle = document . getElementById ( 'ion-diagnostics-toast' ) ;
272+ if ( toastEle ) {
273+ toastEle . classList . add ( 'ion-diagnostics-toast-active' ) ;
274+ }
275+ } , 16 ) ;
276+
277+ } else if ( ! showToast && toastEle ) {
278+ toastEle . classList . remove ( 'ion-diagnostics-toast-active' ) ;
279+ }
280+ } ,
281+
275282 toggleOptionsMenu : function ( ) {
276283 var optsEle = document . getElementById ( 'ion-diagnostics-options' ) ;
277284 this . optionsMenu ( ! optsEle ) ;
0 commit comments