Commit 301df7f9 authored by André Espaze's avatar André Espaze
Browse files

Make search every second for improving writing experience

parent a4f306521fb1
......@@ -11,6 +11,7 @@
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"justgage/tachyons-elm": "4.1.3",
"rtfeldman/elm-css": "16.0.1",
"tripokey/elm-fuzzy": "5.2.1"
......@@ -19,7 +20,6 @@
"Skinney/murmur3": "2.0.8",
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"rtfeldman/elm-hex": "1.0.0"
......
......@@ -21,10 +21,12 @@ import Html.Styled.Events exposing (onInput, onMouseDown)
import Http
import Json.Decode as Decode
import Tachyons.Classes as T
import Time
type alias Model =
{ series : List String
, searchString : String
, searchedSeries : List String
, selectedSeries : List String
, status : Maybe String
......@@ -39,6 +41,7 @@ type Msg
= CatalogReceived (Result Http.Error SeriesCatalog)
| ToggleItem String
| SearchSeries String
| MakeSearch
classes : List String -> Attribute msg
......@@ -81,7 +84,10 @@ update msg model =
newModel { model | selectedSeries = toggleItem x model.selectedSeries }
SearchSeries x ->
newModel { model | searchedSeries = fuzzyMatch x model.series }
newModel { model | searchString = x }
MakeSearch ->
newModel { model | searchedSeries = fuzzyMatch model.searchString model.series }
view : Model -> Html Msg
......@@ -141,11 +147,14 @@ main =
}
init _ =
( Model [] [] [] Nothing, initialGet )
( Model [] "" [] [] Nothing, initialGet )
sub model =
Time.every 1000 (always MakeSearch)
in
Browser.element
{ init = init
, view = view >> toUnstyled
, update = update
, subscriptions = \_ -> Sub.none
, subscriptions = sub
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment