@@ -238,6 +238,7 @@ Ext.define('Rambox.ux.WebView',{
238238
239239 return {
240240 xtype : 'statusbar'
241+ , id : me . id + 'statusbar'
241242 , hidden : ! me . record . get ( 'statusbar' )
242243 , keep : me . record . get ( 'statusbar' )
243244 , y : floating ? '-18px' : 'auto'
@@ -275,7 +276,8 @@ Ext.define('Rambox.ux.WebView',{
275276 if ( ! me . record . get ( 'enabled' ) ) return ;
276277
277278 var webview = me . getWebView ( ) ;
278- let googleLoginURLs = [ 'accounts.google.com/signin/oauth' , 'accounts.google.com/ServiceLogin' ]
279+ let googleLoginURLs = [ 'accounts.google.com/signin' , 'accounts.google.com/ServiceLogin' , ]
280+ me . errorCodeLog = [ ]
279281
280282 // Google Analytics Event
281283 ga_storage . _trackEvent ( 'Services' , 'load' , me . type , 1 , true ) ;
@@ -321,6 +323,60 @@ Ext.define('Rambox.ux.WebView',{
321323 me . onSearchText ( e . result )
322324 } ) ;
323325
326+ // On search text
327+ webview . addEventListener ( 'did-fail-load' , function ( e ) {
328+ console . info ( 'The service fail at loading' , me . src , e ) ;
329+ me . errorCodeLog . push ( e . errorCode )
330+
331+ var attempt = me . errorCodeLog . filter ( function ( code ) { return code === e . errorCode } ) ;
332+
333+ // Error codes: https://cs.chromium.org/chromium/src/net/base/net_error_list.h
334+ var msg = [ ]
335+ msg [ - 2 ] = 'NET error: failed.'
336+ msg [ - 3 ] = 'An operation was aborted (due to user action)'
337+ msg [ - 7 ] = 'Connection timeout.'
338+ msg [ - 21 ] = 'Network change.'
339+ msg [ - 100 ] = 'The connection was reset. Check your internet connection.'
340+ msg [ - 101 ] = 'The connection was reset. Check your internet connection.'
341+ msg [ - 105 ] = 'Name not resolved. Check your internet connection.'
342+ msg [ - 106 ] = 'There is no active internet connection.'
343+ msg [ - 118 ] = 'Connection timed out. Check your internet connection.'
344+ msg [ - 130 ] = 'Proxy connection failed. Please, check the proxy configuration.'
345+ msg [ - 300 ] = 'The URL is invalid.'
346+ msg [ - 324 ] = 'Empty response. Check your internet connection.'
347+
348+ switch ( e . errorCode ) {
349+ case 0 :
350+ break
351+ case - 3 : // An operation was aborted (due to user action) I think that gmail an other pages that use iframes stop some of them making this error fired
352+ if ( attempt . length <= 4 ) return
353+ setTimeout ( ( ) => me . reloadService ( me ) , 200 ) ;
354+ me . errorCodeLog = [ ]
355+ break ;
356+ case - 2 :
357+ case - 7 :
358+ case - 21 :
359+ case - 118 :
360+ case - 324 :
361+ case - 100 :
362+ case - 101 :
363+ case - 105 :
364+ attempt . length > 4 ? me . onFailLoad ( msg [ e . errorCode ] ) : setTimeout ( ( ) => me . reloadService ( me ) , 2000 ) ;
365+ break ;
366+ case - 106 :
367+ me . onFailLoad ( msg [ e . errorCode ] )
368+ break ;
369+ case - 130 :
370+ // Could not create a connection to the proxy server. An error occurred
371+ // either in resolving its name, or in connecting a socket to it.
372+ // Note that this does NOT include failures during the actual "CONNECT" method
373+ // of an HTTP proxy.
374+ case - 300 :
375+ attempt . length > 4 ? me . onFailLoad ( msg [ e . errorCode ] ) : me . reloadService ( me ) ;
376+ break ;
377+ }
378+ } ) ;
379+
324380 // Open links in default browser
325381 webview . addEventListener ( 'new-window' , function ( e ) {
326382 switch ( me . type ) {
@@ -691,6 +747,12 @@ Ext.define('Rambox.ux.WebView',{
691747 }
692748 }
693749
750+ , onFailLoad : function ( v ) {
751+ let me = this
752+ me . errorCodeLog = [ ]
753+ setTimeout ( ( ) => Ext . getCmp ( me . id + 'statusbar' ) . setStatus ( { text : '<i class="fa fa-warning fa-fw" aria-hidden="true"></i> The service failed at loading, Error: ' + v } ) , 1000 ) ;
754+ }
755+
694756 , showSearchBox : function ( v ) {
695757 var me = this ;
696758 if ( ! me . record . get ( 'enabled' ) ) return ;
0 commit comments