diff --git a/src/Applications/UI.elm b/src/Applications/UI.elm index 2efdc42b..82da5bca 100644 --- a/src/Applications/UI.elm +++ b/src/Applications/UI.elm @@ -558,6 +558,12 @@ translateReply reply = Reply.SaveTracks -> Core.SaveTracks + Reply.ShowSuccessNotification string -> + ShowNotification (Notifications.success string) + + Reply.ShowWarningNotification string -> + ShowNotification (Notifications.warning string) + Reply.ShowTracksContextMenu coordinates tracks -> Core.ShowTracksContextMenu coordinates tracks @@ -642,9 +648,9 @@ translateAlienData event = Ok dict -> ShowNotification (Notifications.stickyError - ("Could not process the **" + ("Could not process the _" ++ Dict.fetch "sourceName" "" dict - ++ "** source. I got the following response from the source:" + ++ "_ source. I got the following response from the source:" ) (Dict.fetch "error" "missingError" dict) [] diff --git a/src/Applications/UI/Notifications.elm b/src/Applications/UI/Notifications.elm index b0b6589e..11ac7e18 100644 --- a/src/Applications/UI/Notifications.elm +++ b/src/Applications/UI/Notifications.elm @@ -107,11 +107,21 @@ notificationView notification = |> onDoubleClick ] [ T.br2 - , T.measure_narrow , T.mt2 , T.pa3 , T.white_90 + -- + , case Notifications.kind notification of + Error -> + T.measure_narrow + + Success -> + T.measure_wide + + Warning -> + "" + -- , if options.wasDismissed then T.o_0 @@ -137,13 +147,14 @@ notificationView notification = containerStyles : List Css.Style containerStyles = - [ Css.lineHeight (Css.num 1.35) + [ Css.fontSize (Css.px 13) + , Css.lineHeight (Css.num 1.35) , Css.Global.descendants [ Css.Global.p [ Css.margin Css.zero , Css.padding Css.zero ] - , Css.Global.strong + , Css.Global.em [ Css.borderBottom3 (Css.px 1) Css.solid (Css.rgba 255 255 255 0.45) , Css.fontWeight Css.inherit ] diff --git a/src/Applications/UI/Queue.elm b/src/Applications/UI/Queue.elm index 98840fc3..4e7493b7 100644 --- a/src/Applications/UI/Queue.elm +++ b/src/Applications/UI/Queue.elm @@ -43,7 +43,7 @@ update msg model = InjectFirstAndPlay identifiedTrack -> let ( a, b, _ ) = - update (InjectFirst [ identifiedTrack ]) model + update (InjectFirst { showNotification = False } [ identifiedTrack ]) model ( x, y, z ) = update Shift a @@ -56,7 +56,7 @@ update msg model = -- # InjectFirst -- > Add an item in front of the queue. -- - InjectFirst identifiedTracks -> + InjectFirst { showNotification } identifiedTracks -> let ( items, tracks ) = ( List.map (makeItem True) identifiedTracks @@ -73,14 +73,33 @@ update msg model = in ( { model | future = items ++ cleanedFuture } , Cmd.none - , Just [ FillQueue ] + -- Show notification + -------------------- + , (if showNotification then + [ case tracks of + [ t ] -> + ShowSuccessNotification ("__" ++ t.tags.title ++ "__ will be played next") + + list -> + list + |> List.length + |> String.fromInt + |> (\s -> "__" ++ s ++ " tracks__ will be played next") + |> ShowSuccessNotification + ] + + else + [] + ) + |> List.append [ FillQueue ] + |> Just ) -- # InjectLast -- > Add an item after the last manual entry -- (ie. after the last injected item). -- - InjectLast identifiedTracks -> + InjectLast { showNotification } identifiedTracks -> let ( items, tracks ) = ( List.map (makeItem True) identifiedTracks @@ -108,7 +127,26 @@ update msg model = ++ List.drop manualItems cleanedFuture } , Cmd.none - , Just [ FillQueue ] + -- Show notification + -------------------- + , (if showNotification then + [ case tracks of + [ t ] -> + ShowSuccessNotification ("__" ++ t.tags.title ++ "__ was added to the queue") + + list -> + list + |> List.length + |> String.fromInt + |> (\s -> "__" ++ s ++ " tracks__ were added to the queue") + |> ShowSuccessNotification + ] + + else + [] + ) + |> List.append [ FillQueue ] + |> Just ) ----------------------------------------- diff --git a/src/Applications/UI/Queue/Core.elm b/src/Applications/UI/Queue/Core.elm index 9627b6f0..863349f0 100644 --- a/src/Applications/UI/Queue/Core.elm +++ b/src/Applications/UI/Queue/Core.elm @@ -33,8 +33,8 @@ type Msg ------------------------------------ -- Future ------------------------------------ - | InjectFirst (List IdentifiedTrack) - | InjectLast (List IdentifiedTrack) + | InjectFirst { showNotification : Bool } (List IdentifiedTrack) + | InjectLast { showNotification : Bool } (List IdentifiedTrack) ------------------------------------ -- Position ------------------------------------ diff --git a/src/Applications/UI/Reply.elm b/src/Applications/UI/Reply.elm index 35cf3381..70f2433a 100644 --- a/src/Applications/UI/Reply.elm +++ b/src/Applications/UI/Reply.elm @@ -32,5 +32,7 @@ type Reply | SaveSettings | SaveSources | SaveTracks + | ShowSuccessNotification String + | ShowWarningNotification String | ShowTracksContextMenu Coordinates (List IdentifiedTrack) | ToggleLoadingScreen Switch diff --git a/src/Applications/UI/Tracks/ContextMenu.elm b/src/Applications/UI/Tracks/ContextMenu.elm index b3fa55bd..49fc0711 100644 --- a/src/Applications/UI/Tracks/ContextMenu.elm +++ b/src/Applications/UI/Tracks/ContextMenu.elm @@ -25,10 +25,10 @@ queueActions : List IdentifiedTrack -> ContextMenuItems Msg queueActions identifiedTracks = [ ( Icons.event_seat , "Play next" - , QueueMsg (Queue.InjectFirst identifiedTracks) + , QueueMsg (Queue.InjectFirst { showNotification = True } identifiedTracks) ) , ( Icons.event_seat , "Add to queue" - , QueueMsg (Queue.InjectLast identifiedTracks) + , QueueMsg (Queue.InjectLast { showNotification = True } identifiedTracks) ) ]