Remove ResultId
This commit is contained in:
@@ -9,7 +9,7 @@ import Auth
|
|||||||
import Task exposing (Task)
|
import Task exposing (Task)
|
||||||
import Json.Decode exposing (Decoder)
|
import Json.Decode exposing (Decoder)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import SearchResult exposing (ResultId)
|
import SearchResult
|
||||||
|
|
||||||
|
|
||||||
searchFeed : String -> Cmd Msg
|
searchFeed : String -> Cmd Msg
|
||||||
@@ -32,7 +32,7 @@ responseDecoder =
|
|||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ query : String
|
{ query : String
|
||||||
, results : Dict ResultId SearchResult.Model
|
, results : Dict Int SearchResult.Model
|
||||||
, errorMessage : Maybe String
|
, errorMessage : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ viewErrorMessage errorMessage =
|
|||||||
text ""
|
text ""
|
||||||
|
|
||||||
|
|
||||||
viewSearchResults : Dict ResultId SearchResult.Model -> List (Html Msg)
|
viewSearchResults : Dict Int SearchResult.Model -> List (Html Msg)
|
||||||
viewSearchResults results =
|
viewSearchResults results =
|
||||||
results
|
results
|
||||||
|> Dict.values
|
|> Dict.values
|
||||||
@@ -89,7 +89,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| UpdateSearchResult ResultId SearchResult.Msg
|
| UpdateSearchResult Int SearchResult.Msg
|
||||||
| HandleSearchResponse (List SearchResult.Model)
|
| HandleSearchResponse (List SearchResult.Model)
|
||||||
| HandleSearchError Http.Error
|
| HandleSearchError Http.Error
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ update msg model =
|
|||||||
|
|
||||||
HandleSearchResponse results ->
|
HandleSearchResponse results ->
|
||||||
let
|
let
|
||||||
resultsById : Dict ResultId SearchResult.Model
|
resultsById : Dict Int SearchResult.Model
|
||||||
resultsById =
|
resultsById =
|
||||||
results
|
results
|
||||||
|> List.map (\result -> ( result.id, result ))
|
|> List.map (\result -> ( result.id, result ))
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ type alias Model =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Expand
|
= Expand
|
||||||
| Collapse
|
| Collapse
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import Auth
|
|||||||
import Task exposing (Task)
|
import Task exposing (Task)
|
||||||
import Json.Decode exposing (Decoder)
|
import Json.Decode exposing (Decoder)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import SearchResult exposing (ResultId)
|
import SearchResult
|
||||||
|
|
||||||
|
|
||||||
searchFeed : String -> Cmd Msg
|
searchFeed : String -> Cmd Msg
|
||||||
@@ -32,7 +32,7 @@ responseDecoder =
|
|||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ query : String
|
{ query : String
|
||||||
, results : Dict ResultId SearchResult.Model
|
, results : Dict Int SearchResult.Model
|
||||||
, errorMessage : Maybe String
|
, errorMessage : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ viewErrorMessage errorMessage =
|
|||||||
text ""
|
text ""
|
||||||
|
|
||||||
|
|
||||||
viewSearchResults : Dict ResultId SearchResult.Model -> List (Html Msg)
|
viewSearchResults : Dict Int SearchResult.Model -> List (Html Msg)
|
||||||
viewSearchResults results =
|
viewSearchResults results =
|
||||||
results
|
results
|
||||||
|> Dict.values
|
|> Dict.values
|
||||||
@@ -95,7 +95,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| UpdateSearchResult ResultId SearchResult.Msg
|
| UpdateSearchResult Int SearchResult.Msg
|
||||||
| HandleSearchResponse (List SearchResult.Model)
|
| HandleSearchResponse (List SearchResult.Model)
|
||||||
| HandleSearchError Http.Error
|
| HandleSearchError Http.Error
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ update msg model =
|
|||||||
|
|
||||||
HandleSearchResponse results ->
|
HandleSearchResponse results ->
|
||||||
let
|
let
|
||||||
resultsById : Dict ResultId SearchResult.Model
|
resultsById : Dict Int SearchResult.Model
|
||||||
resultsById =
|
resultsById =
|
||||||
results
|
results
|
||||||
|> List.map (\result -> ( result.id, result ))
|
|> List.map (\result -> ( result.id, result ))
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ type alias Model =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Expand
|
= Expand
|
||||||
| Collapse
|
| Collapse
|
||||||
@@ -45,8 +41,8 @@ update msg model =
|
|||||||
|
|
||||||
view : Model -> Html Msg
|
view : Model -> Html Msg
|
||||||
view model =
|
view model =
|
||||||
li []
|
li [] <|
|
||||||
<| if model.expanded then
|
if model.expanded then
|
||||||
[ span [ class "star-count" ] [ text (toString model.stars) ]
|
[ span [ class "star-count" ] [ text (toString model.stars) ]
|
||||||
, a
|
, a
|
||||||
[ href
|
[ href
|
||||||
@@ -61,7 +57,7 @@ view model =
|
|||||||
, button [ class "hide-result", onClick Collapse ]
|
, button [ class "hide-result", onClick Collapse ]
|
||||||
[ text "X" ]
|
[ text "X" ]
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
[ button [ class "expand-result", onClick Expand ]
|
[ button [ class "expand-result", onClick Expand ]
|
||||||
[ text "Show" ]
|
[ text "Show" ]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import Auth
|
|||||||
import Task exposing (Task)
|
import Task exposing (Task)
|
||||||
import Json.Decode exposing (Decoder)
|
import Json.Decode exposing (Decoder)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import SearchResult exposing (ResultId)
|
import SearchResult
|
||||||
|
|
||||||
|
|
||||||
searchFeed : String -> Cmd Msg
|
searchFeed : String -> Cmd Msg
|
||||||
@@ -32,7 +32,7 @@ responseDecoder =
|
|||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ query : String
|
{ query : String
|
||||||
, results : Dict ResultId SearchResult.Model
|
, results : Dict Int SearchResult.Model
|
||||||
, errorMessage : Maybe String
|
, errorMessage : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ viewErrorMessage errorMessage =
|
|||||||
text ""
|
text ""
|
||||||
|
|
||||||
|
|
||||||
viewSearchResults : Dict ResultId SearchResult.Model -> List (Html Msg)
|
viewSearchResults : Dict Int SearchResult.Model -> List (Html Msg)
|
||||||
viewSearchResults results =
|
viewSearchResults results =
|
||||||
results
|
results
|
||||||
|> Dict.values
|
|> Dict.values
|
||||||
@@ -87,7 +87,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| UpdateSearchResult ResultId SearchResult.Msg
|
| UpdateSearchResult Int SearchResult.Msg
|
||||||
| HandleSearchResponse (List SearchResult.Model)
|
| HandleSearchResponse (List SearchResult.Model)
|
||||||
| HandleSearchError Http.Error
|
| HandleSearchError Http.Error
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ update msg model =
|
|||||||
|
|
||||||
HandleSearchResponse results ->
|
HandleSearchResponse results ->
|
||||||
let
|
let
|
||||||
resultsById : Dict ResultId SearchResult.Model
|
resultsById : Dict Int SearchResult.Model
|
||||||
resultsById =
|
resultsById =
|
||||||
results
|
results
|
||||||
|> List.map (\result -> ( result.id, result ))
|
|> List.map (\result -> ( result.id, result ))
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ type alias Model =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Expand
|
= Expand
|
||||||
| Collapse
|
| Collapse
|
||||||
@@ -45,15 +41,15 @@ update msg model =
|
|||||||
|
|
||||||
view : Model -> Html Msg
|
view : Model -> Html Msg
|
||||||
view model =
|
view model =
|
||||||
li []
|
li [] <|
|
||||||
<| if model.expanded then
|
if model.expanded then
|
||||||
[ span [ class "star-count" ] [ text (toString model.stars) ]
|
[ span [ class "star-count" ] [ text (toString model.stars) ]
|
||||||
, a [ href ("https://github.com/" ++ model.name), target "_blank" ]
|
, a [ href ("https://github.com/" ++ model.name), target "_blank" ]
|
||||||
[ text model.name ]
|
[ text model.name ]
|
||||||
, button [ class "hide-result", onClick Collapse ]
|
, button [ class "hide-result", onClick Collapse ]
|
||||||
[ text "X" ]
|
[ text "X" ]
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
[ button [ class "expand-result", onClick Expand ]
|
[ button [ class "expand-result", onClick Expand ]
|
||||||
[ text "Show" ]
|
[ text "Show" ]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -84,16 +84,12 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : Int
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
initialModel : Model
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
@@ -139,8 +135,7 @@ viewSearchResult result =
|
|||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= SetQuery String
|
= SetQuery String
|
||||||
| DeleteById ResultId
|
| DeleteById Int
|
||||||
| SetResults (List SearchResult)
|
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> Model
|
update : Msg -> Model -> Model
|
||||||
@@ -149,13 +144,6 @@ update msg model =
|
|||||||
SetQuery query ->
|
SetQuery query ->
|
||||||
{ model | query = query }
|
{ model | query = query }
|
||||||
|
|
||||||
SetResults results ->
|
|
||||||
let
|
|
||||||
newModel =
|
|
||||||
{ model | results = results }
|
|
||||||
in
|
|
||||||
newModel
|
|
||||||
|
|
||||||
DeleteById idToHide ->
|
DeleteById idToHide ->
|
||||||
let
|
let
|
||||||
newResults =
|
newResults =
|
||||||
|
|||||||
@@ -67,16 +67,12 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : Int
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
initialModel : Model
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
@@ -123,7 +119,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| DeleteById ResultId
|
| DeleteById Int
|
||||||
| HandleSearchResponse (List SearchResult)
|
| HandleSearchResponse (List SearchResult)
|
||||||
| HandleSearchError Http.Error
|
| HandleSearchError Http.Error
|
||||||
|
|
||||||
|
|||||||
@@ -39,16 +39,12 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : Int
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
initialModel : Model
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
@@ -95,7 +91,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| DeleteById ResultId
|
| DeleteById Int
|
||||||
| HandleSearchResponse (List SearchResult)
|
| HandleSearchResponse (List SearchResult)
|
||||||
| HandleSearchError (Maybe String)
|
| HandleSearchError (Maybe String)
|
||||||
|
|
||||||
|
|||||||
@@ -39,16 +39,12 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : Int
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
initialModel : Model
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
@@ -95,7 +91,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| DeleteById ResultId
|
| DeleteById Int
|
||||||
| HandleSearchResponse (List SearchResult)
|
| HandleSearchResponse (List SearchResult)
|
||||||
| HandleSearchError (Maybe String)
|
| HandleSearchError (Maybe String)
|
||||||
| DoNothing
|
| DoNothing
|
||||||
|
|||||||
@@ -45,16 +45,12 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : Int
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
|
||||||
Int
|
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
initialModel : Model
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
@@ -96,7 +92,7 @@ viewSearchResult result =
|
|||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| SetQuery String
|
| SetQuery String
|
||||||
| DeleteById ResultId
|
| DeleteById Int
|
||||||
| HandleSearchResponse (List SearchResult)
|
| HandleSearchResponse (List SearchResult)
|
||||||
| HandleSearchError Http.Error
|
| HandleSearchError Http.Error
|
||||||
| DoNothing
|
| DoNothing
|
||||||
|
|||||||
Reference in New Issue
Block a user