Fix widget offline mode (fixes #740)

This makes sure that:

* remote.online gets set to false and to true at the right time
* The widget state follows this
* remote.connected is not set to false unless we know we need to refresh
  the bearer token