From bf4b8a366936745eed7bde3a372bb080d0445458 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Sun, 2 Jun 2019 18:01:09 +0200 Subject: [PATCH] Show notification when adding tracks to a playlist --- src/Applications/UI.elm | 24 ++++++++++++++++++------ src/Library/Tracks.elm | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Applications/UI.elm b/src/Applications/UI.elm index afe18841..c3df8eb2 100644 --- a/src/Applications/UI.elm +++ b/src/Applications/UI.elm @@ -757,13 +757,25 @@ translateReply reply model = , tracks = tracks } playlistsModel.collection + + newModel = + { playlistsModel + | collection = newCollection + , lastModifiedPlaylist = Just properPlaylistName + } + |> (\m -> { model | playlists = m }) in - { playlistsModel - | collection = newCollection - , lastModifiedPlaylist = Just properPlaylistName - } - |> (\m -> { model | playlists = m }) - |> translateReply SavePlaylists + (case tracks of + [ t ] -> + "Added __" ++ t.title ++ "__" + + l -> + "Added __" ++ String.fromInt (List.length l) ++ " tracks__" + ) + |> (\s -> s ++ " to the __" ++ properPlaylistName ++ "__ playlist") + |> ShowSuccessNotification + |> (\r -> translateReply r newModel) + |> andThen (translateReply SavePlaylists) DeactivatePlaylist -> update (TracksMsg <| Tracks.DeselectPlaylist) model diff --git a/src/Library/Tracks.elm b/src/Library/Tracks.elm index 03e16956..51e492fa 100644 --- a/src/Library/Tracks.elm +++ b/src/Library/Tracks.elm @@ -182,6 +182,10 @@ emptyCollection = } + +-- MORE STUFF + + isNowPlaying : IdentifiedTrack -> IdentifiedTrack -> Bool isNowPlaying ( a, b ) ( x, y ) = a.indexInPlaylist == x.indexInPlaylist && b.id == y.id -- knotmirror 0.0.1