···11+module Tracks.Favourites exposing (match)
22+33+import Tracks exposing (Favourite, Track)
44+55+66+77+-- 🔱
88+99+1010+match : Favourite -> Favourite -> Bool
1111+match a b =
1212+ let
1313+ ( aa, at ) =
1414+ ( String.toLower a.artist
1515+ , String.toLower a.title
1616+ )
1717+1818+ ( ba, bt ) =
1919+ ( String.toLower b.artist
2020+ , String.toLower b.title
2121+ )
2222+ in
2323+ aa == ba && at == bt
+120
src/Library/Tracks/Sorting.elm
···11+module Tracks.Sorting exposing (sort)
22+33+import Tracks exposing (..)
44+55+66+77+-- 🔱
88+99+1010+sort : SortBy -> SortDirection -> List IdentifiedTrack -> List IdentifiedTrack
1111+sort property direction list =
1212+ let
1313+ sortFn =
1414+ case property of
1515+ Album ->
1616+ sortByAlbum
1717+1818+ Artist ->
1919+ sortByArtist
2020+2121+ PlaylistIndex ->
2222+ sortByPlaylistIndex
2323+2424+ Title ->
2525+ sortByTitle
2626+2727+ dirFn =
2828+ if direction == Desc then
2929+ List.reverse
3030+3131+ else
3232+ identity
3333+ in
3434+ list
3535+ |> List.sortWith sortFn
3636+ |> dirFn
3737+3838+3939+4040+-- BY
4141+4242+4343+sortByAlbum : IdentifiedTrack -> IdentifiedTrack -> Order
4444+sortByAlbum ( _, a ) ( _, b ) =
4545+ EQ
4646+ |> andThenCompare album a b
4747+ |> andThenCompare disc a b
4848+ |> andThenCompare nr a b
4949+ |> andThenCompare artist a b
5050+ |> andThenCompare title a b
5151+5252+5353+sortByArtist : IdentifiedTrack -> IdentifiedTrack -> Order
5454+sortByArtist ( _, a ) ( _, b ) =
5555+ EQ
5656+ |> andThenCompare artist a b
5757+ |> andThenCompare album a b
5858+ |> andThenCompare disc a b
5959+ |> andThenCompare nr a b
6060+ |> andThenCompare title a b
6161+6262+6363+sortByTitle : IdentifiedTrack -> IdentifiedTrack -> Order
6464+sortByTitle ( _, a ) ( _, b ) =
6565+ EQ
6666+ |> andThenCompare title a b
6767+ |> andThenCompare artist a b
6868+ |> andThenCompare album a b
6969+7070+7171+sortByPlaylistIndex : IdentifiedTrack -> IdentifiedTrack -> Order
7272+sortByPlaylistIndex ( a, _ ) ( b, _ ) =
7373+ andThenCompare (.indexInPlaylist >> Maybe.withDefault 0) a b EQ
7474+7575+7676+7777+-- TAGS
7878+7979+8080+album : Track -> String
8181+album =
8282+ .tags >> .album >> low
8383+8484+8585+artist : Track -> String
8686+artist =
8787+ .tags >> .artist >> low
8888+8989+9090+title : Track -> String
9191+title =
9292+ .tags >> .title >> low
9393+9494+9595+disc : Track -> Int
9696+disc =
9797+ .tags >> .disc
9898+9999+100100+nr : Track -> Int
101101+nr =
102102+ .tags >> .nr
103103+104104+105105+106106+-- COMMON
107107+108108+109109+andThenCompare : (ctx -> comparable) -> ctx -> ctx -> Order -> Order
110110+andThenCompare fn a b order =
111111+ if order == EQ then
112112+ compare (fn a) (fn b)
113113+114114+ else
115115+ order
116116+117117+118118+low : String -> String
119119+low =
120120+ String.toLower
+1-1
src/README.md
···66- Applications/UI
77- Library
8899-`UI` is the Elm application that'll be executed on the main thread (ie. the UI thread) and `Brain` is the Elm application that'll live inside a web worker. `UI` will be the main application and `Brain` does the heavy lifting. The code shared between these two applications lives in `Library`.
99+`UI` is the Elm application that'll be executed on the main thread (ie. the UI thread) and `Brain` is the Elm application that'll live inside a web worker. `UI` will be the main application and `Brain` does the heavy lifting. The code shared between these two applications lives in `Library`. The library also contains the more "generic", code that's not necessarily tied to one or the other.
101011111212