about summary refs log tree commit homepage
path: root/lib/dtas
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-10 06:36:21 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-10 08:08:08 +0000
commit064e91d9b334f544d5ac2ff57d06d338dfcdb3d8 (patch)
treeb5c1401e0a71975b1ba68383cd1dca6fb262069f /lib/dtas
parent4f1a73ed584f0f74d6b32241f02ae871f3415f4a (diff)
downloaddtas-064e91d9b334f544d5ac2ff57d06d338dfcdb3d8.tar.gz
We don't want to repeat tracks if a track was added to a spot
before the current position on the tracklist.
Diffstat (limited to 'lib/dtas')
-rw-r--r--lib/dtas/tracklist.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb
index 325db20..b6f02c3 100644
--- a/lib/dtas/tracklist.rb
+++ b/lib/dtas/tracklist.rb
@@ -91,10 +91,18 @@ class DTAS::Tracklist # :nodoc:
       idx = by_track_id[after_track_id] or
         raise ArgumentError, "after_track_id invalid"
       @list[idx, 1] = [ @list[idx], track ]
-      @pos = idx + 1 if set_as_current
+      if set_as_current
+        @pos = idx + 1
+      else
+        @pos += 1 if @pos >= idx
+      end
     else # nil = first_track
       @list.unshift(track)
-      @pos = 0 if set_as_current
+      if set_as_current
+        @pos = 0
+      else
+        @pos += 1 if @pos >= 0
+      end
     end
     track.object_id
   end