radiodan/magic-button — pull request #9 by andrewn (2014-11-08 18:28:28+00:00)
Title: Fix bug where station is forgotten when using physical power button

This fixes a couple of issues that were causing the last service not to be remembered when the radio was put into standby and powered on again via the physical UI (tested and working on a running device).

The service id was only stored in settings when the station was changed via HTTP API. Now, any call to `ServiceManager#change` will store.

The `ServiceManager#default` property was loaded with the `serviceId` from settings on creation but wasn't tracking changes to the `serviceId`. It now subscribes to change events and updates `default` so it reflects that service id in settings. I found this to be easier to understand than `ServiceManager.revert()` because of the way `nulls` can be stored in the history array which are then ignored by revert.

Tests have been updated to reflect the changes, mainly ensuring that `settings` and `eventBus` are stubbed correctly.

Happy to discuss further if this isn't a great way to solve this.