Reworked if conditions in _load_state

This commit is contained in:
Jens Luetjen 2016-04-02 17:12:31 +02:00
parent 4693fa7f8e
commit 100d7dba7b
3 changed files with 12 additions and 18 deletions

View File

@ -73,6 +73,5 @@ class HistoryController(object):
return HistoryState(history=history_list) return HistoryState(history=history_list)
def _load_state(self, state, coverage): def _load_state(self, state, coverage):
if state: if state and 'history' in coverage:
if 'history' in coverage: self._history = [(h.timestamp, h.track) for h in state.history]
self._history = [(h.timestamp, h.track) for h in state.history]

View File

@ -106,8 +106,7 @@ class MixerController(object):
mute=self.get_mute()) mute=self.get_mute())
def _load_state(self, state, coverage): def _load_state(self, state, coverage):
if state: if state and 'mixer' in coverage:
if 'mixer' in coverage: self.set_mute(state.mute)
if state.volume: if state.volume:
self.set_volume(state.volume) self.set_volume(state.volume)
self.set_mute(state.mute)

View File

@ -606,13 +606,9 @@ class PlaybackController(object):
state=self.get_state()) state=self.get_state())
def _load_state(self, state, coverage): def _load_state(self, state, coverage):
if state: if state and 'play-last' in coverage and state.tlid is not None:
new_state = None if state.state == PlaybackState.PAUSED:
if 'play-last' in coverage: self._start_paused = True
new_state = state.state if state.state in (PlaybackState.PLAYING, PlaybackState.PAUSED):
if state.tlid is not None: self._start_at_position = state.time_position
if new_state == PlaybackState.PAUSED: self.play(tlid=state.tlid)
self._start_paused = True
if new_state in (PlaybackState.PLAYING, PlaybackState.PAUSED):
self._start_at_position = state.time_position
self.play(tlid=state.tlid)