A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Mark faulty sources in list and fix notification transition

+114 -61
+8 -16
src/Applications/UI.elm
··· 553 553 ShowErrorNotification string -> 554 554 UI.Notifications.show (Notifications.stickyError string) model 555 555 556 + ShowErrorNotificationWithCode string code -> 557 + UI.Notifications.show (Notifications.errorWithCode string code []) model 558 + 556 559 ShowSuccessNotification string -> 557 560 UI.Notifications.show (Notifications.success string) model 558 561 ··· 627 630 model.sources 628 631 629 632 newSources = 630 - { sources | processingNotificationId = Just notificationId } 633 + { sources 634 + | processingError = Nothing 635 + , processingNotificationId = Just notificationId 636 + } 631 637 in 632 638 [ ( "origin" 633 639 , Json.Encode.string (Common.urlOrigin model.url) ··· 798 804 TracksMsg (Tracks.RemoveByPaths event.data) 799 805 800 806 Just Alien.ReportProcessingError -> 801 - case Json.Decode.decodeValue (Json.Decode.dict Json.Decode.string) event.data of 802 - Ok dict -> 803 - ShowNotification 804 - (Notifications.errorWithCode 805 - ("Could not process the _" 806 - ++ Dict.fetch "sourceName" "" dict 807 - ++ "_ source. I got the following response from the source:" 808 - ) 809 - (Dict.fetch "error" "missingError" dict) 810 - [] 811 - ) 812 - 813 - Err _ -> 814 - ShowNotification 815 - (Notifications.error "Could not decode processing error") 807 + SourcesMsg (Sources.ReportProcessingError event.data) 816 808 817 809 Just Alien.SearchTracks -> 818 810 TracksMsg (Tracks.SetSearchResults event.data)
+16 -7
src/Applications/UI/List.elm
··· 4 4 import Classes as C 5 5 import Color exposing (Color) 6 6 import Color.Ext as Color 7 + import Conditional exposing (..) 7 8 import Css exposing (px, solid) 8 9 import Html.Events.Extra.Mouse as Mouse exposing (onClick) 9 10 import Html.Styled as Html exposing (Html, fromUnstyled) 10 11 import Html.Styled.Attributes as Attributes exposing (css, style, title) 11 12 import Material.Icons exposing (Coloring(..)) 13 + import Maybe.Extra as Maybe 12 14 import Tachyons.Classes as T 13 15 import UI.Kit 14 16 import VirtualDom ··· 19 21 20 22 21 23 type alias Action msg = 22 - { icon : Int -> Coloring -> VirtualDom.Node msg 23 - , msg : Mouse.Event -> msg 24 + { color : Coloring 25 + , icon : Int -> Coloring -> VirtualDom.Node msg 26 + , msg : Maybe (Mouse.Event -> msg) 24 27 , title : String 25 28 } 26 29 ··· 64 67 (List.map 65 68 (\action -> 66 69 brick 67 - [ Attributes.fromUnstyled (onClick action.msg) 68 - , title action.title 69 - ] 70 + (case action.msg of 71 + Just msg -> 72 + [ Attributes.fromUnstyled (onClick msg) 73 + , title action.title 74 + ] 75 + 76 + Nothing -> 77 + [ title action.title ] 78 + ) 70 79 [ C.lh_0 71 80 , T.ml2 72 - , T.pointer 81 + , ifThenElse (Maybe.isJust action.msg) T.pointer "" 73 82 ] 74 - [ fromUnstyled (action.icon 16 Inherit) ] 83 + [ fromUnstyled (action.icon 16 action.color) ] 75 84 ) 76 85 actions 77 86 )
+15 -16
src/Applications/UI/Notifications.elm
··· 88 88 notificationView : Notification Msg -> Html Msg 89 89 notificationView notification = 90 90 let 91 + kind = 92 + Notifications.kind notification 93 + 91 94 options = 92 95 Notifications.options notification 93 96 in 94 97 brick 95 - [ css notificationStyles 96 - 97 - -- 98 - , case Notifications.kind notification of 98 + [ case kind of 99 99 Error -> 100 100 css errorStyles 101 101 ··· 118 118 , T.white_90 119 119 120 120 -- 121 - , case Notifications.kind notification of 121 + , case kind of 122 122 Error -> 123 123 T.measure_narrow 124 124 ··· 136 136 T.o_100 137 137 ] 138 138 [ contents notification 139 - , if options.sticky then 139 + , if options.sticky && kind /= Warning then 140 140 brick 141 141 [ css [ Css.disableUserSelection ] ] 142 142 [ T.f7, T.i, T.mt2, T.o_60, T.pointer ] ··· 168 168 ] 169 169 170 170 171 - notificationStyles : List Css.Style 172 - notificationStyles = 173 - [ transition 174 - [ Css.Transitions.opacity 450 ] 175 - ] 176 - 177 - 178 171 errorStyles : List Css.Style 179 172 errorStyles = 180 - [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colors.error) ] 173 + [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colors.error) 174 + , Css.Transitions.transition [ Css.Transitions.opacity 450 ] 175 + ] 181 176 182 177 183 178 successStyles : List Css.Style 184 179 successStyles = 185 - [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colors.success) ] 180 + [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colors.success) 181 + , Css.Transitions.transition [ Css.Transitions.opacity 450 ] 182 + ] 186 183 187 184 188 185 warningStyles : List Css.Style 189 186 warningStyles = 190 - [ Css.backgroundColor (Css.rgba 255 255 255 0.2) ] 187 + [ Css.backgroundColor (Css.rgba 255 255 255 0.2) 188 + , Css.Transitions.transition [ Css.Transitions.opacity 450 ] 189 + ]
+1
src/Applications/UI/Reply.elm
··· 29 29 ----------------------------------------- 30 30 | DismissNotification { id : Int } 31 31 | ShowErrorNotification String 32 + | ShowErrorNotificationWithCode String String 32 33 | ShowSuccessNotification String 33 34 | ShowWarningNotification String 34 35 -----------------------------------------
+73 -21
src/Applications/UI/Sources.elm
··· 7 7 import Html.Events.Extra.Mouse as Mouse 8 8 import Html.Styled as Html exposing (Html, text) 9 9 import Json.Decode as Json 10 + import Material.Icons exposing (Coloring(..)) 10 11 import Material.Icons.Action as Icons 12 + import Material.Icons.Alert as Icons 11 13 import Material.Icons.Content as Icons 12 14 import Material.Icons.Navigation as Icons 13 15 import Material.Icons.Notification as Icons ··· 33 35 , currentTime : Time.Posix 34 36 , form : Form.Model 35 37 , isProcessing : Bool 38 + , processingError : Maybe { error : String, sourceId : String } 36 39 , processingNotificationId : Maybe Int 37 40 } 38 41 ··· 43 46 , currentTime = Time.millisToPosix 0 44 47 , form = Form.initialModel 45 48 , isProcessing = False 49 + , processingError = Nothing 46 50 , processingNotificationId = Nothing 47 51 } 48 52 ··· 55 59 = Bypass 56 60 | FinishedProcessing 57 61 | Process 62 + | ReportProcessingError Json.Value 58 63 ----------------------------------------- 59 64 -- Children 60 65 ----------------------------------------- ··· 91 96 92 97 else 93 98 returnReplyWithModel { model | isProcessing = True } ProcessSources 99 + 100 + ReportProcessingError json -> 101 + case Json.decodeValue (Json.dict Json.string) json of 102 + Ok dict -> 103 + let 104 + args = 105 + { error = Dict.fetch "error" "" dict 106 + , sourceId = Dict.fetch "sourceId" "" dict 107 + } 108 + in 109 + dict 110 + |> Dict.fetch "error" "missingError" 111 + |> ShowErrorNotificationWithCode 112 + ("Could not process the _" 113 + ++ Dict.fetch "sourceName\n " "" dict 114 + ++ "_ source. I got the following response from the source:" 115 + ) 116 + |> returnReplyWithModel 117 + { model | processingError = Just args } 118 + 119 + Err _ -> 120 + "Could not decode processing error" 121 + |> ShowErrorNotification 122 + |> returnReplyWithModel model 94 123 95 124 ----------------------------------------- 96 125 -- Children ··· 264 293 |> List.map 265 294 (\source -> 266 295 { label = Html.text (Dict.fetch "name" "" source.data) 267 - , actions = sourceActions source 296 + , actions = sourceActions model.processingError source 268 297 } 269 298 ) 270 299 |> UI.List.view ··· 272 301 ] 273 302 274 303 275 - sourceActions : Source -> List (UI.List.Action Msg) 276 - sourceActions source = 277 - [ { icon = 278 - if source.enabled then 279 - Icons.check 304 + sourceActions : Maybe { error : String, sourceId : String } -> Source -> List (UI.List.Action Msg) 305 + sourceActions processingError source = 306 + List.append 307 + (case processingError of 308 + Just { error, sourceId } -> 309 + if sourceId == source.id then 310 + [ { color = Color UI.Kit.colors.error 311 + , icon = Icons.error_outline 312 + , msg = Nothing 313 + , title = error 314 + } 315 + ] 316 + 317 + else 318 + [] 280 319 281 - else 282 - Icons.block 283 - , msg = always (ToggleActivation { sourceId = source.id }) 284 - , title = 285 - if source.enabled then 286 - "Enabled (click to disable)" 320 + Nothing -> 321 + [] 322 + ) 323 + [ { color = Inherit 324 + , icon = 325 + if source.enabled then 326 + Icons.check 327 + 328 + else 329 + Icons.block 330 + , msg = 331 + { sourceId = source.id } 332 + |> ToggleActivation 333 + |> always 334 + |> Just 335 + , title = 336 + if source.enabled then 337 + "Enabled (click to disable)" 287 338 288 - else 289 - "Disabled (click to enable)" 290 - } 339 + else 340 + "Disabled (click to enable)" 341 + } 291 342 292 - -- 293 - , { icon = Icons.more_vert 294 - , msg = SourceContextMenu source 295 - , title = "Menu" 296 - } 297 - ] 343 + -- 344 + , { color = Inherit 345 + , icon = Icons.more_vert 346 + , msg = Just (SourceContextMenu source) 347 + , title = "Menu" 348 + } 349 + ]
+1 -1
src/Library/Notifications.elm
··· 137 137 Notification 138 138 Warning 139 139 (hashString 0 content) 140 - { sticky = False 140 + { sticky = True 141 141 , wasDismissed = False 142 142 } 143 143 (render content)