···2020-- 📣
212122222323-authenticationBootFailure : String -> UI.Manager
2323+authenticationBootFailure : String -> Manager
2424authenticationBootFailure err model =
2525 model
2626 |> showNotification (Notifications.error err)
2727 |> andThen (Reply.translate LoadDefaultBackdrop)
282829293030-missingSecretKey : Json.Value -> UI.Manager
3030+missingSecretKey : Json.Value -> Manager
3131missingSecretKey _ model =
3232 "There seems to be existing data that's encrypted, I will need the passphrase (ie. encryption key) to continue."
3333 |> Notifications.error
···3636 |> andThen (Reply.translate <| Reply.ToggleLoadingScreen Off)
373738383939-notAuthenticated : UI.Manager
3939+notAuthenticated : Manager
4040notAuthenticated model =
4141 -- This is the message we get when the app initially
4242 -- finds out we're not authenticated.
···5757 )
585859596060-remoteStorageWebfinger : RemoteStorage.Attributes -> Result Http.Error String -> UI.Manager
6060+remoteStorageWebfinger : RemoteStorage.Attributes -> Result Http.Error String -> Manager
6161remoteStorageWebfinger remoteStorage result model =
6262 case result of
6363 Ok oauthOrigin ->
···3232-- 📣
333334343535-setIsOnline : Bool -> UI.Manager
3535+setIsOnline : Bool -> Manager
3636setIsOnline bool model =
3737 if bool then
3838 -- We're caching the user's data in the browser while offline.
···6565 )
666667676868-setCurrentTime : Time.Posix -> UI.Manager
6868+setCurrentTime : Time.Posix -> Manager
6969setCurrentTime time model =
7070 model
7171 |> (\m -> { m | currentTime = time })
···7777-- ⚗️
787879798080-syncHypaethralData : UI.Manager
8080+syncHypaethralData : Manager
8181syncHypaethralData model =
8282 model
8383 |> Common.showNotification (Notifications.warning "Syncing")
+13-13
src/Applications/UI/Interface/State.elm
···3232-- 📣
333334343535-blur : UI.Manager
3535+blur : Manager
3636blur model =
3737 Return.singleton { model | focusedOnInput = False }
383839394040-debounce : (Msg -> Model -> ( Model, Cmd Msg )) -> Debouncer.Msg Msg -> UI.Manager
4040+debounce : (Msg -> Model -> ( Model, Cmd Msg )) -> Debouncer.Msg Msg -> Manager
4141debounce update debouncerMsg model =
4242 let
4343 ( subModel, subCmd, emittedMsg ) =
···5959 return updatedModel mappedCmd
606061616262-focusedOnInput : UI.Manager
6262+focusedOnInput : Manager
6363focusedOnInput model =
6464 Return.singleton { model | focusedOnInput = True }
656566666767-hideOverlay : UI.Manager
6767+hideOverlay : Manager
6868hideOverlay model =
6969 Return.singleton
7070 { model
7171- | alfred = { instance = Nothing }
7171+ | alfred = Nothing
7272 , confirmation = Nothing
7373 , contextMenu = Nothing
7474 }
757576767777-keyboardMsg : Keyboard.Msg -> UI.Manager
7777+keyboardMsg : Keyboard.Msg -> Manager
7878keyboardMsg msg model =
7979 (\m ->
8080 let
···128128 { model | pressedKeys = Keyboard.update msg model.pressedKeys }
129129130130131131-preferredColorSchemaChanged : { dark : Bool } -> UI.Manager
131131+preferredColorSchemaChanged : { dark : Bool } -> Manager
132132preferredColorSchemaChanged { dark } model =
133133 Return.singleton { model | darkMode = dark }
134134135135136136-removeQueueSelection : UI.Manager
136136+removeQueueSelection : Manager
137137removeQueueSelection =
138138 modifySingleton Queue.lens (\q -> { q | selection = Nothing })
139139140140141141-removeTrackSelection : UI.Manager
141141+removeTrackSelection : Manager
142142removeTrackSelection =
143143 modifySingleton Tracks.lens (\t -> { t | selectedTrackIndexes = [] })
144144145145146146-resizedWindow : ( Int, Int ) -> UI.Manager
146146+resizedWindow : ( Int, Int ) -> Manager
147147resizedWindow ( width, height ) model =
148148 Return.singleton
149149 { model
···152152 }
153153154154155155-setIsTouchDevice : Bool -> UI.Manager
155155+setIsTouchDevice : Bool -> Manager
156156setIsTouchDevice bool model =
157157 Return.singleton { model | isTouchDevice = bool }
158158159159160160-stoppedDragging : UI.Manager
160160+stoppedDragging : Manager
161161stoppedDragging model =
162162 let
163163 notDragging =
···187187 Return.singleton notDragging
188188189189190190-toggleLoadingScreen : Switch -> UI.Manager
190190+toggleLoadingScreen : Switch -> Manager
191191toggleLoadingScreen switch model =
192192 case switch of
193193 On ->
+13-5
src/Applications/UI/Playlists/Alfred.elm
···33import Alfred exposing (..)
44import Playlists exposing (..)
55import Tracks exposing (IdentifiedTrack)
66-import UI.Reply exposing (Reply(..))
66+import UI.Types as UI
7788991010-- 🔱
111112121313-create : List IdentifiedTrack -> List Playlist -> Alfred Reply
1313+create : List IdentifiedTrack -> List Playlist -> Alfred UI.Msg
1414create tracks playlists =
1515 let
1616 playlistNames =
···3232 }
333334343535-action : List IdentifiedTrack -> { result : Maybe String, searchTerm : Maybe String } -> List Reply
3535+action : List IdentifiedTrack -> { result : Maybe String, searchTerm : Maybe String } -> List UI.Msg
3636action tracks maybe =
3737 let
3838 playlistTracks =
···4242 Just result ->
4343 -- Add to playlist
4444 --
4545- [ AddTracksToPlaylist { playlistName = result, tracks = playlistTracks } ]
4545+ [ UI.AddTracksToPlaylist
4646+ { playlistName = result
4747+ , tracks = playlistTracks
4848+ }
4949+ ]
46504751 Nothing ->
4852 -- Create playlist,
···5054 --
5155 case maybe.searchTerm of
5256 Just searchTerm ->
5353- [ AddTracksToPlaylist { playlistName = searchTerm, tracks = playlistTracks } ]
5757+ [ UI.AddTracksToPlaylist
5858+ { playlistName = searchTerm
5959+ , tracks = playlistTracks
6060+ }
6161+ ]
54625563 Nothing ->
5664 []
+67
src/Applications/UI/Playlists/State.elm
···11+module UI.Playlists.State exposing (..)
22+33+import List.Extra as List
44+import Management
55+import Monocle.Lens as Lens
66+import Notifications
77+import Playlists exposing (PlaylistTrack)
88+import Return exposing (andThen, return)
99+import Return.Ext as Return exposing (communicate)
1010+import UI.Common.State as Common
1111+import UI.Reply exposing (Reply(..))
1212+import UI.Reply.Translate as Reply
1313+import UI.Types as UI exposing (Manager, Msg(..))
1414+1515+1616+1717+-- 🔱
1818+1919+2020+addTracksToPlaylist : { playlistName : String, tracks : List PlaylistTrack } -> Manager
2121+addTracksToPlaylist { playlistName, tracks } model =
2222+ let
2323+ properPlaylistName =
2424+ String.trim playlistName
2525+2626+ playlistIndex =
2727+ List.findIndex
2828+ (\p -> p.autoGenerated == False && p.name == properPlaylistName)
2929+ model.playlists.collection
3030+3131+ playlistsModel =
3232+ model.playlists
3333+3434+ newCollection =
3535+ case playlistIndex of
3636+ Just idx ->
3737+ List.updateAt
3838+ idx
3939+ (\p -> { p | tracks = p.tracks ++ tracks })
4040+ playlistsModel.collection
4141+4242+ Nothing ->
4343+ (::)
4444+ { autoGenerated = False
4545+ , name = properPlaylistName
4646+ , tracks = tracks
4747+ }
4848+ playlistsModel.collection
4949+5050+ newModel =
5151+ { playlistsModel
5252+ | collection = newCollection
5353+ , lastModifiedPlaylist = Just properPlaylistName
5454+ }
5555+ |> (\m -> { model | playlists = m })
5656+ in
5757+ (case tracks of
5858+ [ t ] ->
5959+ "Added __" ++ t.title ++ "__"
6060+6161+ l ->
6262+ "Added __" ++ String.fromInt (List.length l) ++ " tracks__"
6363+ )
6464+ |> (\s -> s ++ " to the __" ++ properPlaylistName ++ "__ playlist")
6565+ |> Notifications.success
6666+ |> Common.showNotificationWithModel newModel
6767+ |> andThen (Reply.translate SavePlaylists)
+5-51
src/Applications/UI/Reply/Translate.elm
···11module UI.Reply.Translate exposing (..)
2233-import Alfred exposing (Alfred)
43import Alien
54import Browser
65import Browser.Dom
···4645import Time
4746import Tracks
4847import Tracks.Encoding as Tracks
4949-import UI.Alfred as Alfred
4848+import UI.Alfred.Types as Alfred
5049import UI.Audio.State as Audio
5150import UI.Audio.Types as Audio
5251import UI.Authentication as Authentication
···9291-- 📣 ░░ REPLIES
939294939595-translate : Reply -> UI.Manager
9494+translate : Reply -> Manager
9695translate reply model =
9796 case reply of
9897 Shunt ->
···355354 |> TracksMsg
356355 |> Return.performanceF model
357356358358- AddTracksToPlaylist { playlistName, tracks } ->
359359- let
360360- properPlaylistName =
361361- String.trim playlistName
362362-363363- playlistIndex =
364364- List.findIndex
365365- (\p -> p.autoGenerated == False && p.name == properPlaylistName)
366366- model.playlists.collection
367367-368368- playlistsModel =
369369- model.playlists
370370-371371- newCollection =
372372- case playlistIndex of
373373- Just idx ->
374374- List.updateAt
375375- idx
376376- (\p -> { p | tracks = p.tracks ++ tracks })
377377- playlistsModel.collection
378378-379379- Nothing ->
380380- (::)
381381- { autoGenerated = False
382382- , name = properPlaylistName
383383- , tracks = tracks
384384- }
385385- playlistsModel.collection
386386-387387- newModel =
388388- { playlistsModel
389389- | collection = newCollection
390390- , lastModifiedPlaylist = Just properPlaylistName
391391- }
392392- |> (\m -> { model | playlists = m })
393393- in
394394- (case tracks of
395395- [ t ] ->
396396- "Added __" ++ t.title ++ "__"
397397-398398- l ->
399399- "Added __" ++ String.fromInt (List.length l) ++ " tracks__"
400400- )
401401- |> (\s -> s ++ " to the __" ++ properPlaylistName ++ "__ playlist")
402402- |> Notifications.success
403403- |> showNotificationWithModel newModel
404404- |> andThen (translate SavePlaylists)
357357+ Reply.AddTracksToPlaylist a ->
358358+ Return.performance (UI.AddTracksToPlaylist a) model
405359406360 DeactivatePlaylist ->
407361 Tracks.DeselectPlaylist
···480434 |> List.filterNot .autoGenerated
481435 |> UI.Playlists.Alfred.create tracks
482436 |> Alfred.Assign
483483- |> AlfredMsg
437437+ |> Alfred
484438 |> Return.performanceF model
485439486440 -----------------------------------------
+6-6
src/Applications/UI/Routing/State.elm
···1313import UI.Sources.Form
1414import UI.Sources.Page
1515import UI.Sources.State as Sources
1616-import UI.Types as UI
1616+import UI.Types as UI exposing (Manager)
1717import Url exposing (Url)
18181919···2121-- 📣
222223232424-changeUrlUsingPage : Page -> UI.Manager
2424+changeUrlUsingPage : Page -> Manager
2525changeUrlUsingPage page model =
2626 page
2727 |> Page.toString
···2929 |> return model
303031313232-linkClicked : UrlRequest -> UI.Manager
3232+linkClicked : UrlRequest -> Manager
3333linkClicked urlRequest model =
3434 case urlRequest of
3535 Browser.Internal urlWithFragment ->
···5151 return model (Nav.load href)
525253535454-urlChanged : Url -> UI.Manager
5454+urlChanged : Url -> Manager
5555urlChanged url model =
5656 let
5757 rewrittenUrl =
···7272-- TRANSITIONING
737374747575-transition : Page -> UI.Manager
7575+transition : Page -> Manager
7676transition page model =
7777 case page of
7878 -----------------------------------------
···137137-- ㊙️
138138139139140140-loadSourceForForm : String -> UI.Manager
140140+loadSourceForForm : String -> Manager
141141loadSourceForForm sourceId model =
142142 let
143143 isLoading =
+2-2
src/Applications/UI/Services/State.elm
···1616-- 📣
171718181919-gotLastFmSession : Result Http.Error String -> UI.Manager
1919+gotLastFmSession : Result Http.Error String -> Manager
2020gotLastFmSession result model =
2121 case result of
2222 Err _ ->
···3232 (Return.performance <| Reply SaveSettings)
333334343535-scrobble : { duration : Int, timestamp : Int, trackId : String } -> UI.Manager
3535+scrobble : { duration : Int, timestamp : Int, trackId : String } -> Manager
3636scrobble { duration, timestamp, trackId } model =
3737 case model.tracks.nowPlaying of
3838 Just ( _, track ) ->
+3-3
src/Applications/UI/Tracks/State.elm
···3030-- 📣
313132323333-downloadTracksFinished : UI.Manager
3333+downloadTracksFinished : Manager
3434downloadTracksFinished model =
3535 case model.downloading of
3636 Just { notificationId } ->
···4343 Return.singleton model
444445454646-failedToStoreTracksInCache : List String -> UI.Manager
4646+failedToStoreTracksInCache : List String -> Manager
4747failedToStoreTracksInCache trackIds model =
4848 model
4949 |> Lens.modify lens
···5252 (Notifications.error "Failed to store track in cache")
535354545555-finishedStoringTracksInCache : List String -> UI.Manager
5555+finishedStoringTracksInCache : List String -> Manager
5656finishedStoringTracksInCache trackIds model =
5757 model
5858 |> Lens.modify lens
+10-6
src/Applications/UI/Types.elm
···3434import Management
3535import Maybe.Extra as Maybe
3636import Notifications exposing (Notification)
3737+import Playlists exposing (PlaylistTrack)
3738import Playlists.Encoding as Playlists
3839import Process
3940import Queue
···4950import Time
5051import Tracks
5152import Tracks.Encoding as Tracks
5252-import UI.Alfred as Alfred
5353+import UI.Alfred.Types as Alfred
5354import UI.Audio.Types as Audio
5455import UI.Authentication as Authentication
5556import UI.Authentication.ContextMenu as Authentication
···6364import UI.Notifications
6465import UI.Page as Page exposing (Page)
6566import UI.Playlists as Playlists
6666-import UI.Playlists.Alfred
6767import UI.Playlists.ContextMenu as Playlists
6868import UI.Playlists.Directory
6969import UI.Ports as Ports
···104104105105106106type alias Model =
107107- { contextMenu : Maybe (ContextMenu Reply)
107107+ { alfred : Maybe (Alfred Msg)
108108+ , contextMenu : Maybe (ContextMenu Reply)
108109 , confirmation : Maybe String
109110 , currentTime : Time.Posix
110111 , darkMode : Bool
···128129 -----------------------------------------
129130 -- Children
130131 -----------------------------------------
131131- , alfred : Alfred.Model
132132 , authentication : Authentication.Model
133133 , backdrop : Backdrop.Model
134134 , equalizer : Equalizer.Model
···152152 = Bypass
153153 | Reply Reply
154154 --
155155+ | Alfred (Alfred.Msg Msg)
155156 | Audio Audio.Msg
156157 -----------------------------------------
157158 -- Authentication
···161162 | NotAuthenticated
162163 | RemoteStorageWebfinger RemoteStorage.Attributes (Result Http.Error String)
163164 -----------------------------------------
164164- -- Children
165165+ -- Children (TODO)
165166 -----------------------------------------
166166- | AlfredMsg Alfred.Msg
167167 | AuthenticationMsg Authentication.Msg
168168 | BackdropMsg Backdrop.Msg
169169 | EqualizerMsg Equalizer.Msg
···187187 | SetIsTouchDevice Bool
188188 | StoppedDragging
189189 | ToggleLoadingScreen Switch
190190+ -----------------------------------------
191191+ -- Playlists
192192+ -----------------------------------------
193193+ | AddTracksToPlaylist { playlistName : String, tracks : List PlaylistTrack }
190194 -----------------------------------------
191195 -- Routing
192196 -----------------------------------------