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.

Extract Alien stuff and clean up UI module

+170 -153
+9 -153
src/Applications/UI.elm
··· 10 10 import Css exposing (url) 11 11 import Debouncer.Basic as Debouncer 12 12 import Dict 13 - import Json.Decode 14 13 import Keyboard 15 14 import LastFm 16 15 import Maybe.Extra as Maybe ··· 27 26 import Tracks.Encoding as Tracks 28 27 import UI.Adjunct as Adjunct 29 28 import UI.Alfred.State as Alfred 29 + import UI.Alien as Alien 30 30 import UI.Audio.State as Audio 31 31 import UI.Authentication as Authentication 32 32 import UI.Authentication.ContextMenu as Authentication ··· 149 149 , sources = Sources.initialModel 150 150 , tracks = Tracks.initialModel 151 151 } 152 - |> update 153 - (PageChanged page) 152 + |> Routing.transition page 154 153 |> Return.command 155 - (if Maybe.isNothing maybePage then 156 - Routing.resetUrl key url page 157 - 158 - else 154 + (Maybe.unwrap 159 155 Cmd.none 156 + (Routing.resetUrl key url) 157 + maybePage 160 158 ) 161 159 |> Return.command 162 160 (Task.perform SetCurrentTime Time.now) ··· 441 439 subscriptions : Model -> Sub Msg 442 440 subscriptions model = 443 441 Sub.batch 444 - [ Ports.fromAlien alien 442 + [ Ports.fromAlien Alien.translate 445 443 446 444 ----------------------------------------- 447 445 -- Audio ··· 472 470 -- Queue 473 471 ----------------------------------------- 474 472 , Ports.activeQueueItemEnded (QueueMsg << always Queue.Shift) 475 - , Ports.requestNext <| always (QueueMsg Queue.Shift) 476 - , Ports.requestPrevious <| always (QueueMsg Queue.Rewind) 473 + , Ports.requestNext (\_ -> QueueMsg Queue.Shift) 474 + , Ports.requestPrevious (\_ -> QueueMsg Queue.Rewind) 477 475 478 476 ----------------------------------------- 479 477 -- Resize 480 478 ----------------------------------------- 481 - , Browser.Events.onResize 482 - (\w h -> 483 - ( w, h ) 484 - |> ResizedWindow 485 - |> Debouncer.provideInput 486 - |> Debounce 487 - ) 479 + , Browser.Events.onResize Interface.onResize 488 480 489 481 ----------------------------------------- 490 482 -- Services ··· 503 495 , Sub.map KeyboardMsg Keyboard.subscriptions 504 496 , Time.every (60 * 1000) SetCurrentTime 505 497 ] 506 - 507 - 508 - alien : Alien.Event -> Msg 509 - alien event = 510 - case event.error of 511 - Nothing -> 512 - translateAlienData event 513 - 514 - Just err -> 515 - translateAlienError event err 516 - 517 - 518 - translateAlienData : Alien.Event -> Msg 519 - translateAlienData event = 520 - case 521 - Alien.tagFromString event.tag 522 - of 523 - Just Alien.AddTracks -> 524 - TracksMsg (Tracks.Add event.data) 525 - 526 - Just Alien.AuthMethod -> 527 - -- My brain told me which auth method we're using, 528 - -- so we can tell the user in the UI. 529 - case decodeMethod event.data of 530 - Just method -> 531 - AuthenticationMsg (Authentication.SignedIn method) 532 - 533 - Nothing -> 534 - Bypass 535 - 536 - Just Alien.FinishedProcessingSource -> 537 - event.data 538 - |> Json.Decode.decodeValue Json.Decode.string 539 - |> Result.map (Sources.FinishedProcessingSource >> SourcesMsg) 540 - |> Result.withDefault Bypass 541 - 542 - Just Alien.FinishedProcessingSources -> 543 - SourcesMsg Sources.FinishedProcessing 544 - 545 - Just Alien.HideLoadingScreen -> 546 - UI.ToggleLoadingScreen Off 547 - 548 - Just Alien.ImportLegacyData -> 549 - "Imported data successfully!" 550 - |> Notifications.success 551 - |> ShowNotification 552 - 553 - Just Alien.LoadEnclosedUserData -> 554 - LoadEnclosedUserData event.data 555 - 556 - Just Alien.LoadHypaethralUserData -> 557 - LoadHypaethralUserData event.data 558 - 559 - Just Alien.MissingSecretKey -> 560 - MissingSecretKey event.data 561 - 562 - Just Alien.NotAuthenticated -> 563 - NotAuthenticated 564 - 565 - Just Alien.RemoveTracksByPath -> 566 - TracksMsg (Tracks.RemoveByPaths event.data) 567 - 568 - Just Alien.ReportProcessingError -> 569 - SourcesMsg (Sources.ReportProcessingError event.data) 570 - 571 - Just Alien.ReportProcessingProgress -> 572 - SourcesMsg (Sources.ReportProcessingProgress event.data) 573 - 574 - Just Alien.SearchTracks -> 575 - TracksMsg (Tracks.SetSearchResults event.data) 576 - 577 - Just Alien.StoreTracksInCache -> 578 - case 579 - Json.Decode.decodeValue 580 - (Json.Decode.list Json.Decode.string) 581 - event.data 582 - of 583 - Ok list -> 584 - FinishedStoringTracksInCache list 585 - 586 - Err err -> 587 - showErrorNotification (Json.Decode.errorToString err) 588 - 589 - Just Alien.UpdateSourceData -> 590 - SourcesMsg (Sources.UpdateSourceData event.data) 591 - 592 - _ -> 593 - Bypass 594 - 595 - 596 - translateAlienError : Alien.Event -> String -> Msg 597 - translateAlienError event err = 598 - case 599 - Alien.tagFromString event.tag 600 - of 601 - Just Alien.AuthAnonymous -> 602 - AuthenticationBootFailure err 603 - 604 - Just Alien.AuthBlockstack -> 605 - AuthenticationBootFailure err 606 - 607 - Just Alien.AuthDropbox -> 608 - AuthenticationBootFailure err 609 - 610 - Just Alien.AuthIpfs -> 611 - AuthenticationBootFailure err 612 - 613 - Just Alien.AuthRemoteStorage -> 614 - AuthenticationBootFailure err 615 - 616 - Just Alien.AuthTextile -> 617 - AuthenticationBootFailure err 618 - 619 - Just Alien.StoreTracksInCache -> 620 - case 621 - Json.Decode.decodeValue 622 - (Json.Decode.list Json.Decode.string) 623 - event.data 624 - of 625 - Ok trackIds -> 626 - FailedToStoreTracksInCache trackIds 627 - 628 - Err _ -> 629 - showErrorNotification err 630 - 631 - _ -> 632 - showErrorNotification err 633 - 634 - 635 - 636 - -- ⚗️ 637 - 638 - 639 - showErrorNotification : String -> Msg 640 - showErrorNotification = 641 - Notifications.error >> ShowNotification
+149
src/Applications/UI/Alien.elm
··· 1 + module UI.Alien exposing (..) 2 + 3 + import Alien 4 + import Common exposing (Switch(..)) 5 + import Json.Decode 6 + import Notifications 7 + import UI.Authentication as Authentication 8 + import UI.Sources as Sources 9 + import UI.Tracks as Tracks 10 + import UI.Types exposing (..) 11 + import User.Layer exposing (..) 12 + 13 + 14 + 15 + -- 📣 16 + 17 + 18 + translate : Alien.Event -> Msg 19 + translate event = 20 + case event.error of 21 + Nothing -> 22 + translateAlienData event 23 + 24 + Just err -> 25 + translateAlienError event err 26 + 27 + 28 + translateAlienData : Alien.Event -> Msg 29 + translateAlienData event = 30 + case 31 + Alien.tagFromString event.tag 32 + of 33 + Just Alien.AddTracks -> 34 + TracksMsg (Tracks.Add event.data) 35 + 36 + Just Alien.AuthMethod -> 37 + -- My brain told me which auth method we're using, 38 + -- so we can tell the user in the UI. 39 + case decodeMethod event.data of 40 + Just method -> 41 + AuthenticationMsg (Authentication.SignedIn method) 42 + 43 + Nothing -> 44 + Bypass 45 + 46 + Just Alien.FinishedProcessingSource -> 47 + event.data 48 + |> Json.Decode.decodeValue Json.Decode.string 49 + |> Result.map (Sources.FinishedProcessingSource >> SourcesMsg) 50 + |> Result.withDefault Bypass 51 + 52 + Just Alien.FinishedProcessingSources -> 53 + SourcesMsg Sources.FinishedProcessing 54 + 55 + Just Alien.HideLoadingScreen -> 56 + ToggleLoadingScreen Off 57 + 58 + Just Alien.ImportLegacyData -> 59 + ShowNotification (Notifications.success "Imported data successfully!") 60 + 61 + Just Alien.LoadEnclosedUserData -> 62 + LoadEnclosedUserData event.data 63 + 64 + Just Alien.LoadHypaethralUserData -> 65 + LoadHypaethralUserData event.data 66 + 67 + Just Alien.MissingSecretKey -> 68 + MissingSecretKey event.data 69 + 70 + Just Alien.NotAuthenticated -> 71 + NotAuthenticated 72 + 73 + Just Alien.RemoveTracksByPath -> 74 + TracksMsg (Tracks.RemoveByPaths event.data) 75 + 76 + Just Alien.ReportProcessingError -> 77 + SourcesMsg (Sources.ReportProcessingError event.data) 78 + 79 + Just Alien.ReportProcessingProgress -> 80 + SourcesMsg (Sources.ReportProcessingProgress event.data) 81 + 82 + Just Alien.SearchTracks -> 83 + TracksMsg (Tracks.SetSearchResults event.data) 84 + 85 + Just Alien.StoreTracksInCache -> 86 + case 87 + Json.Decode.decodeValue 88 + (Json.Decode.list Json.Decode.string) 89 + event.data 90 + of 91 + Ok list -> 92 + FinishedStoringTracksInCache list 93 + 94 + Err err -> 95 + showErrorNotification (Json.Decode.errorToString err) 96 + 97 + Just Alien.UpdateSourceData -> 98 + SourcesMsg (Sources.UpdateSourceData event.data) 99 + 100 + _ -> 101 + Bypass 102 + 103 + 104 + translateAlienError : Alien.Event -> String -> Msg 105 + translateAlienError event err = 106 + case 107 + Alien.tagFromString event.tag 108 + of 109 + Just Alien.AuthAnonymous -> 110 + AuthenticationBootFailure err 111 + 112 + Just Alien.AuthBlockstack -> 113 + AuthenticationBootFailure err 114 + 115 + Just Alien.AuthDropbox -> 116 + AuthenticationBootFailure err 117 + 118 + Just Alien.AuthIpfs -> 119 + AuthenticationBootFailure err 120 + 121 + Just Alien.AuthRemoteStorage -> 122 + AuthenticationBootFailure err 123 + 124 + Just Alien.AuthTextile -> 125 + AuthenticationBootFailure err 126 + 127 + Just Alien.StoreTracksInCache -> 128 + case 129 + Json.Decode.decodeValue 130 + (Json.Decode.list Json.Decode.string) 131 + event.data 132 + of 133 + Ok trackIds -> 134 + FailedToStoreTracksInCache trackIds 135 + 136 + Err _ -> 137 + showErrorNotification err 138 + 139 + _ -> 140 + showErrorNotification err 141 + 142 + 143 + 144 + -- ⚗️ 145 + 146 + 147 + showErrorNotification : String -> Msg 148 + showErrorNotification = 149 + Notifications.error >> ShowNotification
+12
src/Applications/UI/Interface/State.elm
··· 133 133 134 134 Off -> 135 135 Return.singleton { model | isLoading = False } 136 + 137 + 138 + 139 + -- MESSAGES 140 + 141 + 142 + onResize : Int -> Int -> Msg 143 + onResize w h = 144 + ( w, h ) 145 + |> ResizedWindow 146 + |> Debouncer.provideInput 147 + |> Debounce