Revise 2.
This commit is contained in:
@@ -91,26 +91,19 @@ viewSearchResult address result =
|
|||||||
]
|
]
|
||||||
[ text result.name ]
|
[ text result.name ]
|
||||||
, button
|
, button
|
||||||
-- TODO add an onClick handler that sends a HideById action
|
-- TODO add an onClick handler that sends a HIDE_BY_ID action
|
||||||
[ class "hide-result" ]
|
[ class "hide-result" ]
|
||||||
[ text "X" ]
|
[ text "X" ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
type alias Action =
|
type alias Action =
|
||||||
{ actionType : String
|
{ -- TODO implement this type alias
|
||||||
, payload : Int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
update : Action -> Model -> Model
|
update : Action -> Model -> Model
|
||||||
update action model =
|
update action model =
|
||||||
if action.actionType == "HIDE_BY_ID" then
|
-- TODO if we receive a HIDE_BY_ID action,
|
||||||
let
|
-- build a new model without the given ID present anymore.
|
||||||
-- TODO build a new model without the given ID present anymore.
|
|
||||||
newModel =
|
|
||||||
model
|
|
||||||
in
|
|
||||||
newModel
|
|
||||||
else
|
|
||||||
model
|
model
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ update action model =
|
|||||||
HideById idToHide ->
|
HideById idToHide ->
|
||||||
let
|
let
|
||||||
newResults =
|
newResults =
|
||||||
model.results
|
List.filter (\{ id } -> id /= idToHide) model.results
|
||||||
|> List.filter (\{ id } -> id /= idToHide)
|
|
||||||
|
|
||||||
newModel =
|
newModel =
|
||||||
{ model | results = newResults }
|
{ model | results = newResults }
|
||||||
|
|||||||
Reference in New Issue
Block a user