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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111module Alfred exposing (..)
import List.Extra as Listimport Material.Icons.Types exposing (Coloring)import Svg exposing (Svg)
-- 🌳
type alias Alfred msg = { action : Action msg , focus : Int , index : List (Group msg) , indexFlattened : List (Item msg) , message : String , operation : Operation , results : List (Group msg) , searchTerm : Maybe String }
type alias Action msg = { result : Maybe (Item msg), searchTerm : Maybe String } -> List msg
type alias Group msg = { name : Maybe String, items : List (Item msg) }
type alias Item msg = { icon : Maybe (Coloring -> Svg msg) , title : String , value : ItemValue msg }
type ItemValue msg = Command msg | StringValue String
type Operation = Query | QueryOrMutation | Mutation
-- 🛳
create : { action : Action msg , index : List (Group msg) , message : String , operation : Operation } -> Alfred msgcreate { action, index, message, operation } = { action = action , focus = 0 , index = index , indexFlattened = List.concatMap .items index , message = message , operation = operation , results = index , searchTerm = Nothing }
-- 🛠
command : ItemValue msg -> Maybe msgcommand val = case val of Command cmd -> Just cmd
StringValue _ -> Nothing
stringValue : ItemValue msg -> Maybe StringstringValue val = case val of Command _ -> Nothing
StringValue string -> Just string
-- 🛠
getAt : Int -> Alfred msg -> Maybe (Item msg)getAt index alfred = alfred.results |> List.concatMap .items |> List.getAt index
length : Alfred msg -> Intlength { indexFlattened } = List.length indexFlattened