Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262module UI.Interface.State exposing (..)
import Alfredimport Debouncer.Basic as Debouncerimport Maybe.Extra as Maybeimport Notificationsimport Return exposing (return)import Return.Ext as Returnimport Themeimport Tracksimport UI.Alfred.State as Alfredimport UI.Common.State as Commonimport UI.Common.Types exposing (DebounceManager)import UI.DnD as DnDimport UI.Page as Pageimport UI.Playlists.State as Playlistsimport UI.Ports as Portsimport UI.Queue.State as Queueimport UI.Themeimport UI.Types exposing (..)import UI.User.State.Export exposing (saveEnclosedUserData)
-- 🔱
assistWithChangingTheme : ManagerassistWithChangingTheme model = { action = \{ result } -> case result of Just { value } -> value |> Alfred.command |> Maybe.map List.singleton |> Maybe.withDefault []
Nothing -> [] , index = [ { name = Just "Themes" , items = List.map (\theme -> { icon = Just (theme.icon 16) , title = theme.title , value = Alfred.Command (ChangeTheme { id = theme.id }) } ) UI.Theme.list } ] , message = "Choose a theme." , operation = Alfred.Query } |> Alfred.create |> (\a -> Alfred.assign a model)
blur : Managerblur model = Return.singleton { model | focusedOnInput = False, pressedKeys = [] }
changeTheme : Theme.Id -> ManagerchangeTheme id model = saveEnclosedUserData { model | theme = Just id }
contextMenuConfirmation : String -> Msg -> ManagercontextMenuConfirmation conf msg model = return { model | confirmation = Just conf } (Return.task msg)
copyToClipboard : String -> ManagercopyToClipboard string = string |> Ports.copyToClipboard |> Return.communicate
resizeDebounce : DebounceManagerresizeDebounce = Common.debounce .resizeDebouncer (\d m -> { m | resizeDebouncer = d }) ResizeDebounce
dnd : DnD.Msg Int -> Managerdnd dragMsg model = let ( d, { initiated } ) = DnD.update dragMsg model.dnd
m = if initiated then { model | dnd = d, isDragging = True }
else { model | dnd = d } in if DnD.hasDropped d then case m.page of Page.Queue _ -> let ( from, to ) = ( Maybe.withDefault 0 <| DnD.modelSubject d , Maybe.withDefault 0 <| DnD.modelTarget d )
newFuture = Queue.moveItem { from = from, to = to, shuffle = m.shuffle } m.playingNext in Queue.fill { m | playingNext = newFuture }
Page.Index -> let trackCanBeMoved = not m.favouritesOnly && Maybe.isNothing m.searchTerm in case m.scene of Tracks.Covers -> -- TODO Return.singleton m
Tracks.List -> if trackCanBeMoved then Playlists.moveTrackInSelected { to = Maybe.withDefault 0 (DnD.modelTarget d) } m
else "Can't move tracks in a playlist whilst using favourites-only mode, or while searching." |> Notifications.casual |> Common.showNotificationWithModel m
_ -> Return.singleton m
else Return.singleton m
focusedOnInput : ManagerfocusedOnInput model = Return.singleton { model | focusedOnInput = True }
hideOverlay : ManagerhideOverlay model = if Maybe.isJust model.contextMenu then Return.singleton { model | contextMenu = Nothing }
else if Maybe.isJust model.confirmation then Return.singleton { model | confirmation = Nothing }
else if Maybe.isJust model.alfred then Return.singleton { model | alfred = Nothing }
else Return.singleton model
lostWindowFocus : ManagerlostWindowFocus model = Return.singleton { model | focusedOnInput = False, pressedKeys = [] }
preferredColorSchemaChanged : { dark : Bool } -> ManagerpreferredColorSchemaChanged { dark } model = Return.singleton { model | darkMode = dark }
msgViaContextMenu : Msg -> ManagermsgViaContextMenu msg model = return (case msg of ContextMenuConfirmation _ _ -> model
_ -> { model | confirmation = Nothing, contextMenu = Nothing } ) (Return.task msg)
removeNotification : { id : Int } -> ManagerremoveNotification { id } model = model.notifications |> List.filter (Notifications.id >> (/=) id) |> (\n -> { model | notifications = n }) |> Return.singleton
removeQueueSelection : ManagerremoveQueueSelection model = Return.singleton { model | selectedQueueItem = Nothing }
removeTrackSelection : ManagerremoveTrackSelection model = Return.singleton { model | selectedTrackIndexes = [] }
resizedWindow : ( Int, Int ) -> ManagerresizedWindow ( width, height ) model = Return.singleton { model | contextMenu = Nothing , viewport = { height = toFloat height, width = toFloat width } }
searchDebounce : DebounceManagersearchDebounce = Common.debounce .searchDebouncer (\d m -> { m | searchDebouncer = d }) SearchDebounce
setIsTouchDevice : Bool -> ManagersetIsTouchDevice bool model = Return.singleton { model | isTouchDevice = bool }
stoppedDragging : ManagerstoppedDragging model = let notDragging = { model | isDragging = False } in -- Depending on where we stopped dragging something, -- do the appropriate thing. case model.page of Page.Queue _ -> dnd DnD.stoppedDragging notDragging
Page.Index -> dnd DnD.stoppedDragging notDragging
_ -> Return.singleton notDragging
-- MESSAGES
onResize : Int -> Int -> MsgonResize w h = ( w, h ) |> ResizedWindow |> Debouncer.provideInput |> ResizeDebounce