From 100d7dba7b390a7dc4b557f075598162b27f65fd Mon Sep 17 00:00:00 2001 From: Jens Luetjen Date: Sat, 2 Apr 2016 17:12:31 +0200 Subject: [PATCH] Reworked if conditions in _load_state --- mopidy/core/history.py | 5 ++--- mopidy/core/mixer.py | 9 ++++----- mopidy/core/playback.py | 16 ++++++---------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/mopidy/core/history.py b/mopidy/core/history.py index 7f7e4fe9..22adb4a9 100644 --- a/mopidy/core/history.py +++ b/mopidy/core/history.py @@ -73,6 +73,5 @@ class HistoryController(object): return HistoryState(history=history_list) def _load_state(self, state, coverage): - if state: - if 'history' in coverage: - self._history = [(h.timestamp, h.track) for h in state.history] + if state and 'history' in coverage: + self._history = [(h.timestamp, h.track) for h in state.history] diff --git a/mopidy/core/mixer.py b/mopidy/core/mixer.py index 15fafad1..8707c096 100644 --- a/mopidy/core/mixer.py +++ b/mopidy/core/mixer.py @@ -106,8 +106,7 @@ class MixerController(object): mute=self.get_mute()) def _load_state(self, state, coverage): - if state: - if 'mixer' in coverage: - if state.volume: - self.set_volume(state.volume) - self.set_mute(state.mute) + if state and 'mixer' in coverage: + self.set_mute(state.mute) + if state.volume: + self.set_volume(state.volume) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index aa5c8e01..1c809656 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -606,13 +606,9 @@ class PlaybackController(object): state=self.get_state()) def _load_state(self, state, coverage): - if state: - new_state = None - if 'play-last' in coverage: - new_state = state.state - if state.tlid is not None: - if new_state == PlaybackState.PAUSED: - self._start_paused = True - if new_state in (PlaybackState.PLAYING, PlaybackState.PAUSED): - self._start_at_position = state.time_position - self.play(tlid=state.tlid) + if state and 'play-last' in coverage and state.tlid is not None: + if state.state == PlaybackState.PAUSED: + self._start_paused = True + if state.state in (PlaybackState.PLAYING, PlaybackState.PAUSED): + self._start_at_position = state.time_position + self.play(tlid=state.tlid)