From be4eff70e3b5aa99124d747f035f80568170463e Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Tue, 9 Apr 2019 17:53:38 +0200 Subject: [PATCH] Fix scrollToNowPlaying (didn't work anymore if list changed) --- src/Applications/UI/Tracks.elm | 15 ++++++++++++++- .../Tracks/Collection/Internal/Harvest.elm | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Applications/UI/Tracks.elm b/src/Applications/UI/Tracks.elm index 58dc9276..f618ad8b 100644 --- a/src/Applications/UI/Tracks.elm +++ b/src/Applications/UI/Tracks.elm @@ -93,7 +93,20 @@ update msg model = ) ScrollToNowPlaying -> - case model.nowPlaying of + let + -- The index identifier might be out-of-date, + -- so we get the latest version. + it = + model.nowPlaying + |> Maybe.map (Tuple.second >> .id) + |> Maybe.andThen + (\id -> + List.find + (Tuple.second >> .id >> (==) id) + model.collection.harvested + ) + in + case it of Just identifiedTrack -> case model.scene of List -> diff --git a/src/Library/Tracks/Collection/Internal/Harvest.elm b/src/Library/Tracks/Collection/Internal/Harvest.elm index 488bbdb5..16a0f2c5 100644 --- a/src/Library/Tracks/Collection/Internal/Harvest.elm +++ b/src/Library/Tracks/Collection/Internal/Harvest.elm @@ -68,7 +68,7 @@ harvest ( deps, collection ) = else identity ) - |> List.indexedMap (\idx tup -> Tuple.mapFirst (\i -> { i | indexInList = idx }) tup) + |> List.indexedMap (\idx -> Tuple.mapFirst (\i -> { i | indexInList = idx })) |> (\h -> { collection | harvested = h }) |> (\c -> ( deps, c )) -- 2.51.2