mirror of
https://github.com/usetrmnl/terminus.git
synced 2026-08-13 14:29:27 -07:00
Fixed screen rotator to check playlist mode
Necessary to ensure we immediately answer the current item of the playlist if manual. Only when the playlist is automatic, do we advance to the next item. Milestone: patch
This commit is contained in:
@@ -18,7 +18,7 @@ module Terminus
|
||||
if device.asleep?
|
||||
sleeper.call device
|
||||
else
|
||||
find_playlist(device.playlist_id).fmap { |playlist| auto_update_current_item playlist }
|
||||
find_playlist(device.playlist_id).fmap { |playlist| advance_current_item playlist }
|
||||
.bind { |item| obtain_screen item }
|
||||
end
|
||||
end
|
||||
@@ -33,11 +33,12 @@ module Terminus
|
||||
Failure "Unable to obtain next screen. Can't find playlist with ID: #{id.inspect}."
|
||||
end
|
||||
|
||||
def auto_update_current_item playlist
|
||||
# :reek:FeatureEnvy
|
||||
def advance_current_item playlist
|
||||
return playlist.current_item if playlist.manual?
|
||||
|
||||
item_repository.next_item(after: playlist.current_item_position, playlist_id: playlist.id)
|
||||
.tap do |item|
|
||||
playlist_repository.auto_update_current_item playlist, item.id if item
|
||||
end
|
||||
.tap { |item| playlist_repository.update_current_item playlist, item }
|
||||
end
|
||||
|
||||
def obtain_screen item
|
||||
|
||||
@@ -53,7 +53,7 @@ RSpec.describe "Playlists", :db do
|
||||
|
||||
expect(page).to have_content("No screens found.")
|
||||
|
||||
(1..3).each do |position|
|
||||
items = (1..3).map do |position|
|
||||
Factory[
|
||||
:playlist_item,
|
||||
playlist_id: playlist.id,
|
||||
@@ -62,6 +62,8 @@ RSpec.describe "Playlists", :db do
|
||||
]
|
||||
end
|
||||
|
||||
Terminus::Repositories::Playlist.new.update playlist.id, current_item_id: items.first.id
|
||||
|
||||
visit routes.path(:playlists)
|
||||
click_link "Play"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user