@ -512,15 +512,34 @@ const OpenweatherMenuButton = new Lang.Class({
} ,
_checkConnectionState : function ( ) {
this . _checkConnectionStateRetries = 3 ;
this . _oldConnected = this . _connected ;
this . _connected = false ;
this . _checkConnectionStateWithRetries ( 1250 ) ;
} ,
_checkConnectionStateRetry : function ( ) {
if ( this . _checkConnectionStateRetries > 0 ) {
let timeout ;
if ( this . _checkConnectionStateRetries == 3 )
timeout = 10000 ;
else if ( this . _checkConnectionStateRetries == 2 )
timeout = 30000 ;
else if ( this . _checkConnectionStateRetries == 1 )
timeout = 60000 ;
this . _checkConnectionStateRetries -= 1 ;
this . _checkConnectionStateWithRetries ( timeout ) ;
}
} ,
_checkConnectionStateWithRetries : function ( interval ) {
if ( this . _timeoutCheckConnectionState ) {
Mainloop . source _remove ( this . _timeoutCheckConnectionState ) ;
this . _timeoutCheckConnectionState = undefined ;
}
let interval = 1250 ;
this . _oldConnected = this . _connected ;
this . _connected = false ;
this . _timeoutCheckConnectionState = Mainloop . timeout _add ( interval , Lang . bind ( this , function ( ) {
// Delete (undefine) the variable holding the timeout-id, otherwise we can get errors, if we try to delete
// it manually, the timeout will be destroyed automatically if we return false.
@ -535,13 +554,21 @@ const OpenweatherMenuButton = new Lang.Class({
} catch ( err ) {
let title = _ ( "Can not connect to %s" ) . format ( url ) ;
log ( title + '\n' + err . message ) ;
this . _checkConnectionStateRetry ( ) ;
}
return false ;
} ) ) ;
} ,
_asyncReadyCallback : function ( nm , res ) {
try {
this . _connected = this . _network _monitor . can _reach _finish ( res ) ;
} catch ( err ) {
let title = _ ( "Can not connect to %s" ) . format ( this . getWeatherProviderURL ( ) ) ;
log ( title + '\n' + err . message ) ;
this . _checkConnectionStateRetry ( ) ;
return ;
}
if ( ! this . _oldConnected && this . _connected ) {
let now = new Date ( ) ;
if ( _timeCacheCurrentWeather &&