diff options
author | Yorhel <git@yorhel.nl> | 2020-08-24 15:16:34 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-08-24 15:18:59 +0200 |
commit | dda6647d207ea26800c5dbf3b326c88eccaa2c66 (patch) | |
tree | 72a4ca59beff201286363f1c6c3ae346c1a34ffb /elm | |
parent | 9bc568ac157590267b099b422c8a49b031ef7c2a (diff) |
reviews: Disallow voting on competing reviews + only use Elm when necessary
i.e. no need to spawn Elm when the user can't vote anyway.
Diffstat (limited to 'elm')
-rw-r--r-- | elm/Reviews/Vote.elm | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/elm/Reviews/Vote.elm b/elm/Reviews/Vote.elm index cf63fe71..717539c1 100644 --- a/elm/Reviews/Vote.elm +++ b/elm/Reviews/Vote.elm @@ -23,7 +23,6 @@ type alias Model = { state : Api.State , id : String , my : Maybe Bool - , can : Bool , up : Int , down : Int } @@ -33,7 +32,6 @@ init d = { state = Api.Normal , id = d.id , my = d.my - , can = d.can , up = d.up , down = d.down } @@ -62,16 +60,13 @@ update msg model = view : Model -> Html Msg view model = - let but opt lbl = - if not model.can - then span [] [ text lbl ] - else a [ href "#", onClickD (Vote opt), classList [("votebut", True), ("myvote", model.my == Just opt)] ] [ text lbl ] + let but opt lbl = a [ href "#", onClickD (Vote opt), classList [("votebut", True), ("myvote", model.my == Just opt)] ] [ text lbl ] in span [] [ case model.state of Api.Loading -> span [ class "spinner" ] [] Api.Error e -> b [ class "standout" ] [ text (Api.showResponse e) ] - Api.Normal -> if model.can && model.my == Nothing then text "Was this review helpful? " else text "" + Api.Normal -> if model.my == Nothing then text "Was this review helpful? " else text "" , but True ("👍 " ++ String.fromInt model.up) , text " " , but False ("👎 " ++ String.fromInt model.down) |