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.

Major perf improvement

+60 -75
+2 -15
src/Applications/UI/Tracks.elm
··· 214 214 { model | enabledSourceIds = sourceIds } 215 215 216 216 SetNowPlaying maybeIdentifiedTrack -> 217 - -- TODO: 218 - -- Improve performance 219 - let 220 - mapFn = 221 - case maybeIdentifiedTrack of 222 - Just a -> 223 - \( i, t ) -> Tuple.pair { i | isNowPlaying = isNowPlaying a ( i, t ) } t 224 - 225 - Nothing -> 226 - \( i, t ) -> Tuple.pair { i | isNowPlaying = False } t 227 - in 228 - reviseCollection 229 - (map <| List.map mapFn) 230 - { model | nowPlaying = maybeIdentifiedTrack } 217 + return { model | nowPlaying = maybeIdentifiedTrack } 231 218 232 219 ToggleCachedOnly -> 233 220 { model | cachedOnly = not model.cachedOnly } ··· 537 524 , favouritesOnly = model.favouritesOnly 538 525 , grouping = model.grouping 539 526 , hideDuplicates = model.hideDuplicates 540 - , nowPlaying = model.nowPlaying 541 527 , searchResults = model.searchResults 542 528 , selectedPlaylist = model.selectedPlaylist 543 529 , sortBy = model.sortBy ··· 917 903 model.collection.harvested 918 904 model.listScene.infiniteList 919 905 model.favouritesOnly 906 + model.nowPlaying 920 907 model.searchTerm 921 908 model.sortBy 922 909 model.sortDirection
+50 -22
src/Applications/UI/Tracks/Scene/List.elm
··· 113 113 } 114 114 115 115 116 - view : Dependencies -> List IdentifiedTrack -> InfiniteList.Model -> Bool -> Maybe String -> SortBy -> SortDirection -> List Int -> Maybe (DnD.Model Int) -> Html.Styled.Html Msg 117 - view deps harvest infiniteList favouritesOnly searchTerm sortBy sortDirection selectedTrackIndexes maybeDnD = 116 + view : Dependencies -> List IdentifiedTrack -> InfiniteList.Model -> Bool -> Maybe IdentifiedTrack -> Maybe String -> SortBy -> SortDirection -> List Int -> Maybe (DnD.Model Int) -> Html.Styled.Html Msg 117 + view deps harvest infiniteList favouritesOnly nowPlaying searchTerm sortBy sortDirection selectedTrackIndexes maybeDnD = 118 118 brick 119 119 ((::) 120 120 (Html.Styled.Attributes.tabindex (ifThenElse deps.isVisible 0 -1)) ··· 164 164 infiniteList 165 165 favouritesOnly 166 166 searchTerm 167 - selectedTrackIndexes 167 + ( nowPlaying, selectedTrackIndexes ) 168 168 maybeDnD 169 169 ] 170 170 ··· 174 174 "diffuse__track-list" 175 175 176 176 177 - infiniteListView : Dependencies -> List IdentifiedTrack -> InfiniteList.Model -> Bool -> Maybe String -> List Int -> Maybe (DnD.Model Int) -> Html.Styled.Html Msg 178 - infiniteListView deps harvest infiniteList favouritesOnly searchTerm selectedTrackIndexes maybeDnD = 177 + infiniteListView : Dependencies -> List IdentifiedTrack -> InfiniteList.Model -> Bool -> Maybe String -> ( Maybe IdentifiedTrack, List Int ) -> Maybe (DnD.Model Int) -> Html.Styled.Html Msg 178 + infiniteListView deps harvest infiniteList favouritesOnly searchTerm ( nowPlaying, selectedTrackIndexes ) maybeDnD = 179 179 Html.Styled.fromUnstyled 180 180 (InfiniteList.view 181 181 (InfiniteList.withCustomContainer ··· 186 186 Just dnd -> 187 187 playlistItemView 188 188 favouritesOnly 189 + nowPlaying 189 190 searchTerm 190 191 selectedTrackIndexes 191 192 dnd ··· 194 195 _ -> 195 196 defaultItemView 196 197 favouritesOnly 198 + nowPlaying 197 199 selectedTrackIndexes 198 200 deps.showAlbum 199 201 ··· 413 415 -- INFINITE LIST ITEM 414 416 415 417 416 - defaultItemView : Bool -> List Int -> Bool -> Int -> Int -> IdentifiedTrack -> Html Msg 417 - defaultItemView favouritesOnly selectedTrackIndexes showAlbum _ idx identifiedTrack = 418 + defaultItemView : Bool -> Maybe IdentifiedTrack -> List Int -> Bool -> Int -> Int -> IdentifiedTrack -> Html Msg 419 + defaultItemView favouritesOnly nowPlaying selectedTrackIndexes showAlbum _ idx identifiedTrack = 418 420 let 419 421 ( identifiers, track ) = 420 422 identifiedTrack ··· 426 428 427 429 isSelected = 428 430 List.member idx selectedTrackIndexes 431 + 432 + rowIdentifiers = 433 + { isMissing = identifiers.isMissing 434 + , isNowPlaying = Maybe.unwrap False (isNowPlaying identifiedTrack) nowPlaying 435 + , isSelected = isSelected 436 + } 437 + 438 + favIdentifiers = 439 + { indexInList = identifiers.indexInList 440 + , isFavourite = identifiers.isFavourite 441 + , isNowPlaying = rowIdentifiers.isNowPlaying 442 + , isSelected = isSelected 443 + } 429 444 in 430 445 Html.div 431 446 [] ··· 438 453 -- 439 454 , Html.div 440 455 (List.concat 441 - [ rowStyles idx isSelected identifiers 456 + [ rowStyles idx rowIdentifiers 442 457 443 458 -- 444 459 , List.append ··· 466 481 ] 467 482 ) 468 483 (if showAlbum then 469 - [ favouriteColumn favouritesOnly isSelected identifiers 484 + [ favouriteColumn favouritesOnly favIdentifiers 470 485 , otherColumn "37.5%" False track.tags.title 471 486 , otherColumn "29.0%" False track.tags.artist 472 487 , otherColumn "29.0%" True track.tags.album 473 488 ] 474 489 475 490 else 476 - [ favouriteColumn favouritesOnly isSelected identifiers 491 + [ favouriteColumn favouritesOnly favIdentifiers 477 492 , otherColumn "52%" False track.tags.title 478 493 , otherColumn "43.5%" False track.tags.artist 479 494 ] ··· 481 496 ] 482 497 483 498 484 - playlistItemView : Bool -> Maybe String -> List Int -> DnD.Model Int -> Bool -> Int -> Int -> IdentifiedTrack -> Html Msg 485 - playlistItemView favouritesOnly searchTerm selectedTrackIndexes dnd showAlbum _ idx identifiedTrack = 499 + playlistItemView : Bool -> Maybe IdentifiedTrack -> Maybe String -> List Int -> DnD.Model Int -> Bool -> Int -> Int -> IdentifiedTrack -> Html Msg 500 + playlistItemView favouritesOnly nowPlaying searchTerm selectedTrackIndexes dnd showAlbum _ idx identifiedTrack = 486 501 let 487 502 ( identifiers, track ) = 488 503 identifiedTrack ··· 497 512 498 513 isSelected = 499 514 List.member idx selectedTrackIndexes 515 + 516 + rowIdentifiers = 517 + { isMissing = identifiers.isMissing 518 + , isNowPlaying = Maybe.unwrap False (isNowPlaying identifiedTrack) nowPlaying 519 + , isSelected = isSelected 520 + } 521 + 522 + favIdentifiers = 523 + { indexInList = identifiers.indexInList 524 + , isFavourite = identifiers.isFavourite 525 + , isNowPlaying = rowIdentifiers.isNowPlaying 526 + , isSelected = isSelected 527 + } 500 528 in 501 529 Html.div 502 530 (List.concat 503 - [ rowStyles idx isSelected identifiers 531 + [ rowStyles idx rowIdentifiers 504 532 505 533 -- 506 534 , List.append ··· 544 572 ] 545 573 ) 546 574 (if showAlbum then 547 - [ favouriteColumn favouritesOnly isSelected identifiers 575 + [ favouriteColumn favouritesOnly favIdentifiers 548 576 , playlistIndexColumn (Maybe.withDefault 0 identifiers.indexInPlaylist) 549 577 , otherColumn "36.0%" False track.tags.title 550 578 , otherColumn "27.5%" False track.tags.artist ··· 552 580 ] 553 581 554 582 else 555 - [ favouriteColumn favouritesOnly isSelected identifiers 583 + [ favouriteColumn favouritesOnly favIdentifiers 556 584 , playlistIndexColumn (Maybe.withDefault 0 identifiers.indexInPlaylist) 557 585 , otherColumn "49.75%" False track.tags.title 558 586 , otherColumn "41.25%" False track.tags.artist ··· 707 735 35 708 736 709 737 710 - rowStyles : Int -> Bool -> Identifiers -> List (Html.Attribute msg) 711 - rowStyles idx isSelected { isMissing, isNowPlaying } = 738 + rowStyles : Int -> { isMissing : Bool, isNowPlaying : Bool, isSelected : Bool } -> List (Html.Attribute msg) 739 + rowStyles idx { isMissing, isNowPlaying, isSelected } = 712 740 let 713 741 bgColor = 714 742 if isNowPlaying then ··· 747 775 "28px" 748 776 749 777 750 - favouriteColumn : Bool -> Bool -> Identifiers -> Html Msg 751 - favouriteColumn favouritesOnly isSelected identifiers = 778 + favouriteColumn : Bool -> { isFavourite : Bool, indexInList : Int, isNowPlaying : Bool, isSelected : Bool } -> Html Msg 779 + favouriteColumn favouritesOnly identifiers = 752 780 Html.div 753 781 ((++) 754 782 [ Html.Events.onClick (Reply <| ToggleFavourite identifiers.indexInList) 755 783 , Tachyons.classes [ T.flex_shrink_0, T.fw4, T.pl3 ] 756 784 ] 757 - (favouriteColumnStyles favouritesOnly isSelected identifiers) 785 + (favouriteColumnStyles favouritesOnly identifiers) 758 786 ) 759 787 [ if identifiers.isFavourite then 760 788 text "t" ··· 764 792 ] 765 793 766 794 767 - favouriteColumnStyles : Bool -> Bool -> Identifiers -> List (Html.Attribute msg) 768 - favouriteColumnStyles favouritesOnly isSelected { isFavourite, isNowPlaying } = 795 + favouriteColumnStyles : Bool -> { isFavourite : Bool, indexInList : Int, isNowPlaying : Bool, isSelected : Bool } -> List (Html.Attribute msg) 796 + favouriteColumnStyles favouritesOnly { isFavourite, isNowPlaying, isSelected } = 769 797 let 770 798 color = 771 799 if isNowPlaying && isFavourite then
+1 -4
src/Library/Tracks.elm
··· 58 58 type alias Identifiers = 59 59 { isFavourite : Bool 60 60 , isMissing : Bool 61 - , isNowPlaying : Bool 62 61 63 62 -- 64 63 , group : Maybe { name : String, firstInGroup : Bool } ··· 77 76 -- `Track`s with `Identifiers` 78 77 , identified : List IdentifiedTrack 79 78 80 - -- Sorted and filtered by playlist (if not auto-generated) 79 + -- Sorted, grouped and filtered by playlist (if not auto-generated) 81 80 , arranged : List IdentifiedTrack 82 81 83 82 -- Filtered by search results, favourites, etc. ··· 93 92 , favouritesOnly : Bool 94 93 , grouping : Maybe Grouping 95 94 , hideDuplicates : Bool 96 - , nowPlaying : Maybe IdentifiedTrack 97 95 , selectedPlaylist : Maybe Playlist 98 96 , searchResults : Maybe (List String) 99 97 , sortBy : SortBy ··· 166 164 emptyIdentifiers = 167 165 { isFavourite = False 168 166 , isMissing = False 169 - , isNowPlaying = False 170 167 171 168 -- 172 169 , group = Nothing
+4 -18
src/Library/Tracks/Collection/Internal/Arrange.elm
··· 273 273 (\( pi, pt ) -> 274 274 if imaginaryPlaylistTrack == pt then 275 275 Tuple.mapBoth 276 - ((::) ( playlistTrackIdentifiers deps.nowPlaying i t pi, t )) 276 + ((::) ( playlistTrackIdentifiers i pi, t )) 277 277 identity 278 278 279 279 else ··· 293 293 ) 294 294 295 295 296 - playlistTrackIdentifiers : Maybe IdentifiedTrack -> Tracks.Identifiers -> Track -> Playlists.Identifiers -> Tracks.Identifiers 297 - playlistTrackIdentifiers nowPlaying i t pi = 298 - let 299 - identifiersWithPlaylistIndex = 300 - { i | indexInPlaylist = Just pi.index } 301 - in 302 - case nowPlaying of 303 - Just ( ni, nt ) -> 304 - if nt.id == t.id && ni.indexInPlaylist == Just pi.index then 305 - { identifiersWithPlaylistIndex | isNowPlaying = True } 306 - 307 - else 308 - identifiersWithPlaylistIndex 309 - 310 - Nothing -> 311 - identifiersWithPlaylistIndex 296 + playlistTrackIdentifiers : Tracks.Identifiers -> Playlists.Identifiers -> Tracks.Identifiers 297 + playlistTrackIdentifiers i pi = 298 + { i | indexInPlaylist = Just pi.index } 312 299 313 300 314 301 dealWithMissingPlaylistTracks : ( List IdentifiedTrack, List IdentifiedPlaylistTrack ) -> List IdentifiedTrack ··· 336 323 , indexInPlaylist = Just identifiers.index 337 324 , isFavourite = False 338 325 , isMissing = True 339 - , isNowPlaying = False 340 326 } 341 327 { tags = tags 342 328 , id = missingId
+3 -16
src/Library/Tracks/Collection/Internal/Identify.elm
··· 33 33 (identifyTrack 34 34 deps.enabledSourceIds 35 35 simplifiedFavourites 36 - deps.nowPlaying 37 36 ) 38 37 ( [], simplifiedFavourites ) 39 38 collection.untouched ··· 64 63 identifyTrack : 65 64 List String 66 65 -> List String 67 - -> Maybe IdentifiedTrack 68 66 -> Track 69 67 -> ( List IdentifiedTrack, List String ) 70 68 -> ( List IdentifiedTrack, List String ) 71 - identifyTrack enabledSourceIds favourites nowPlaying track = 69 + identifyTrack enabledSourceIds favourites track = 72 70 case List.member track.sourceId enabledSourceIds of 73 71 True -> 74 - partTwo favourites nowPlaying track 72 + partTwo favourites track 75 73 76 74 False -> 77 75 identity ··· 79 77 80 78 partTwo : 81 79 List String 82 - -> Maybe IdentifiedTrack 83 80 -> Track 84 81 -> ( List IdentifiedTrack, List String ) 85 82 -> ( List IdentifiedTrack, List String ) 86 - partTwo favourites nowPlaying track ( acc, remainingFavourites ) = 83 + partTwo favourites track ( acc, remainingFavourites ) = 87 84 let 88 - isNP = 89 - case nowPlaying of 90 - Just ( _, { id } ) -> 91 - track.id == id 92 - 93 - Nothing -> 94 - False 95 - 96 85 isFavourite_ = 97 86 isFavourite track 98 87 ··· 102 91 identifiedTrack = 103 92 ( { isFavourite = isFav 104 93 , isMissing = False 105 - , isNowPlaying = isNP 106 94 107 95 -- 108 96 , group = Nothing ··· 158 146 in 159 147 ( { isFavourite = True 160 148 , isMissing = True 161 - , isNowPlaying = False 162 149 163 150 -- 164 151 , group = Nothing