From 1b680f0b124c0fe7b2aae48543643090c967ad44 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 5 Oct 2013 22:20:00 +0000 Subject: player: add factor out redundant condition check The addition of a "need_to_queue" method should reduce the amount of cognitive overhead required to parse these conditions --- lib/dtas/player/client_handler.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/dtas/player/client_handler.rb') diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 5c6653c..75e490d 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -552,7 +552,7 @@ module DTAS::Player::ClientHandler # :nodoc: _tl_skip if set_as_current # start playing if we're the only track - if @tl.size == 1 && !(@current || @queue[0] || @paused) + if @tl.size == 1 && ! need_to_queue next_source(_next) end io.emit("#{track_id}") @@ -589,9 +589,7 @@ module DTAS::Player::ClientHandler # :nodoc: offset = msg.shift # may be nil if @tl.go_to(track_id.to_i, offset) _tl_skip - if !(@current || @queue[0] || @paused) - next_source(_next) - end + next_source(_next) unless need_to_queue io.emit("OK") else io.emit("MISSING") -- cgit v1.2.3-24-ge0c7