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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293module Tracks.Collection exposing (add, arrange, harvest, identifiedTracksChanged, identify, map, replace, tracksChanged)
import Tracks exposing (IdentifiedTrack, Parcel, Track, emptyCollection)import Tracks.Collection.Internal as Internal
-- 🔱
identify : Parcel -> Parcelidentify = Internal.identify >> Internal.arrange >> Internal.harvest
arrange : Parcel -> Parcelarrange = Internal.arrange >> Internal.harvest
harvest : Parcel -> Parcelharvest = Internal.harvest
map : (List IdentifiedTrack -> List IdentifiedTrack) -> Parcel -> Parcelmap fn ( model, collection ) = ( model , { collection | identified = fn collection.identified , arranged = fn collection.arranged , harvested = fn collection.harvested } )
-- ⚗️
add : List Track -> Parcel -> Parceladd tracks ( deps, { untouched } ) = identify ( deps , { emptyCollection | untouched = untouched ++ tracks } )
replace : List Track -> Parcel -> Parcelreplace tracks ( deps, { untouched } ) = identify ( deps , { emptyCollection | untouched = tracks } )
-- ⚗️
tracksChanged : List Track -> List Track -> BooltracksChanged listA listB = case ( listA, listB ) of ( [], [] ) -> False
( a :: restA, b :: restB ) -> if a.id /= b.id then True
else tracksChanged restA restB
_ -> True
identifiedTracksChanged : List IdentifiedTrack -> List IdentifiedTrack -> BoolidentifiedTracksChanged listA listB = case ( listA, listB ) of ( [], [] ) -> False
( ( _, a ) :: restA, ( _, b ) :: restB ) -> if a.id /= b.id then True
else identifiedTracksChanged restA restB
_ -> True