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.

Refactor harvest

+64 -45
+2 -2
src/Applications/UI/Tracks/Scene/List.elm
··· 209 209 let 210 210 shouldRenderGroup = 211 211 i.group 212 - |> Maybe.map (.index >> (==) 0) 212 + |> Maybe.map (.firstInGroup >> (==) True) 213 213 |> Maybe.withDefault False 214 214 in 215 215 if shouldRenderGroup then ··· 248 248 let 249 249 shouldRenderGroup = 250 250 identifiers.group 251 - |> Maybe.map (.index >> (==) 0) 251 + |> Maybe.map (.firstInGroup >> (==) True) 252 252 |> Maybe.withDefault False 253 253 in 254 254 Html.toUnstyled <|
+17 -12
src/Library/Tracks.elm
··· 1 - module Tracks exposing (Collection, CollectionDependencies, Favourite, Grouping(..), IdentifiedTrack, Identifiers, Parcel, SortBy(..), SortDirection(..), Tags, Track, emptyCollection, emptyIdentifiedTrack, emptyTags, emptyTrack, isNowPlaying, makeTrack, missingId) 1 + module Tracks exposing (Collection, CollectionDependencies, Favourite, Grouping(..), IdentifiedTrack, Identifiers, Parcel, SortBy(..), SortDirection(..), Tags, Track, emptyCollection, emptyIdentifiedTrack, emptyIdentifiers, emptyTags, emptyTrack, isNowPlaying, makeTrack, missingId) 2 2 3 3 import Base64 4 4 import String.Ext as String ··· 60 60 , isSelected : Bool 61 61 62 62 -- 63 - , group : Maybe { name : String, index : Int } 63 + , group : Maybe { name : String, firstInGroup : Bool } 64 64 , indexInList : Int 65 65 , indexInPlaylist : Maybe Int 66 66 } ··· 152 152 153 153 emptyIdentifiedTrack : IdentifiedTrack 154 154 emptyIdentifiedTrack = 155 - ( { isFavourite = False 156 - , isMissing = False 157 - , isNowPlaying = False 158 - , isSelected = False 159 - 160 - -- 161 - , group = Nothing 162 - , indexInList = 0 163 - , indexInPlaylist = Nothing 164 - } 155 + ( emptyIdentifiers 165 156 , emptyTrack 166 157 ) 158 + 159 + 160 + emptyIdentifiers : Identifiers 161 + emptyIdentifiers = 162 + { isFavourite = False 163 + , isMissing = False 164 + , isNowPlaying = False 165 + , isSelected = False 166 + 167 + -- 168 + , group = Nothing 169 + , indexInList = 0 170 + , indexInPlaylist = Nothing 171 + } 167 172 168 173 169 174 emptyCollection : Collection
+4 -11
src/Library/Tracks/Collection/Internal/Arrange.elm
··· 53 53 |> List.foldl folder Dict.empty 54 54 |> Dict.values 55 55 |> ifThenElse reversed List.reverse identity 56 - |> List.concatMap (Sorting.sort deps.sortBy deps.sortDirection >> List.indexedMap setIndexInGroup) 56 + |> List.concatMap (Sorting.sort deps.sortBy deps.sortDirection) 57 57 |> (\arranged -> { collection | arranged = arranged }) 58 58 59 - 60 - setIndexInGroup : Int -> IdentifiedTrack -> IdentifiedTrack 61 - setIndexInGroup idx ( i, t ) = 62 - ( { i | group = Maybe.map (\g -> { g | index = idx }) i.group } 63 - , t 64 - ) 65 59 66 60 67 - 68 61 -- GROUPING ░░ INSERTED AT 69 62 70 63 ··· 83 76 84 77 group = 85 78 { name = insertedAtGroupName year month 86 - , index = 0 79 + , firstInGroup = False 87 80 } 88 81 89 82 item = ··· 138 131 139 132 group = 140 133 { name = directory 141 - , index = 0 134 + , firstInGroup = False 142 135 } 143 136 144 137 item = ··· 165 158 let 166 159 group = 167 160 { name = Maybe.unwrap "0000 - Unknown" String.fromInt t.tags.year 168 - , index = 0 161 + , firstInGroup = False 169 162 } 170 163 171 164 item =
+41 -20
src/Library/Tracks/Collection/Internal/Harvest.elm
··· 1 1 module Tracks.Collection.Internal.Harvest exposing (harvest) 2 2 3 + import Dict 3 4 import List.Extra as List 4 5 import Maybe.Extra as Maybe 5 6 import Tracks exposing (..) ··· 48 49 filters 49 50 in 50 51 harvested 51 - |> List.filter theFilter 52 - |> (if deps.hideDuplicates then 53 - List.foldr 54 - (\( i, t ) ( seen, acc ) -> 55 - let 56 - s = 57 - String.toLower (t.tags.artist ++ "/" ++ t.tags.title) 58 - in 59 - if List.member s seen then 60 - ( seen, acc ) 52 + |> List.foldl 53 + (\( i, t ) ( dict, ( idx, prevIdentifiers ), acc ) -> 54 + let 55 + s = 56 + String.toLower (t.tags.artist ++ t.tags.title) 57 + in 58 + if theFilter ( i, t ) == False then 59 + ( dict, ( idx, prevIdentifiers ), acc ) 61 60 62 - else 63 - ( s :: seen, ( i, t ) :: acc ) 64 - ) 65 - ( [], [] ) 66 - >> Tuple.second 61 + else if deps.hideDuplicates && Dict.member s dict then 62 + ( dict, ( idx, prevIdentifiers ), acc ) 67 63 68 - else 69 - identity 70 - ) 71 - |> List.indexedMap (\idx -> Tuple.mapFirst (\i -> { i | indexInList = idx })) 72 - |> (\h -> { collection | harvested = h }) 64 + else 65 + let 66 + prevGroup = 67 + Maybe.unwrap 68 + "" 69 + .name 70 + prevIdentifiers.group 71 + 72 + newIdentifiers = 73 + { i 74 + | group = 75 + Maybe.map 76 + (\g -> { g | firstInGroup = prevGroup /= g.name }) 77 + i.group 78 + , indexInList = idx 79 + } 80 + in 81 + ( if deps.hideDuplicates then 82 + Dict.insert s () dict 83 + 84 + else 85 + dict 86 + -- 87 + , ( idx + 1, newIdentifiers ) 88 + , ( newIdentifiers, t ) :: acc 89 + ) 90 + ) 91 + ( Dict.empty, ( 0, Tracks.emptyIdentifiers ), [] ) 92 + |> (\( a, b, c ) -> c) 93 + |> (\h -> { collection | harvested = List.reverse h }) 73 94 |> (\c -> ( deps, c )) 74 95 75 96