A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve search

+22 -19
+22 -19
src/Applications/UI/Tracks.elm
··· 77 77 -- Search 78 78 ----------------------------------------- 79 79 | ClearSearch 80 - | Search (Maybe String) 80 + | Search 81 81 | SetSearchResults Json.Value 82 82 | SetSearchTerm String 83 83 ··· 120 120 harvest 121 121 { model | searchResults = Nothing, searchTerm = Nothing } 122 122 123 - Search Nothing -> 124 - reviseCollection 125 - harvest 126 - { model | searchResults = Nothing, searchTerm = Nothing } 123 + Search -> 124 + case ( model.searchTerm, model.searchResults ) of 125 + ( Just term, _ ) -> 126 + ( model 127 + , Cmd.none 128 + , Just [ GiveBrain Alien.SearchTracks (Json.Encode.string term) ] 129 + ) 127 130 128 - Search (Just "") -> 129 - reviseCollection 130 - harvest 131 - { model | searchResults = Nothing, searchTerm = Nothing } 131 + ( Nothing, Just _ ) -> 132 + reviseCollection harvest { model | searchResults = Nothing } 132 133 133 - Search (Just term) -> 134 - { model | searchTerm = Just term } 135 - |> Return2.withNoCmd 136 - |> Return3.withReply [ GiveBrain Alien.SearchTracks (Json.Encode.string term) ] 134 + ( Nothing, Nothing ) -> 135 + Return3.withNothing model 137 136 138 137 SetSearchResults json -> 139 138 json ··· 142 141 |> (\results -> { model | searchResults = Just results }) 143 142 |> reviseCollection harvest 144 143 145 - SetSearchTerm "" -> 146 - Return3.withNothing { model | searchTerm = Nothing } 144 + SetSearchTerm term -> 145 + Return3.withNothing 146 + (case String.trim term of 147 + "" -> 148 + { model | searchTerm = Nothing } 147 149 148 - SetSearchTerm term -> 149 - Return3.withNothing { model | searchTerm = Just term } 150 + t -> 151 + { model | searchTerm = Just t } 152 + ) 150 153 151 154 152 155 ··· 232 235 slab 233 236 Html.input 234 237 [ css searchInputStyles 235 - , onBlur (Search searchTerm) 236 - , onEnterKey (Search searchTerm) 238 + , onBlur Search 239 + , onEnterKey Search 237 240 , onInput SetSearchTerm 238 241 , placeholder "Search" 239 242 , value (Maybe.withDefault "" searchTerm)