Skip to content
Permalink
Browse files
Remove cleanUrl and fragment hack
  • Loading branch information
turboMaCk committed Oct 27, 2020
1 parent adbb224 commit 2928b3ec41c6dab3b60ccfb6d15e3be5fdd71c35
Showing with 14 additions and 24 deletions.
  1. +9 −19 src/Main.elm
  2. +5 −5 src/Search.elm
@@ -162,29 +162,19 @@ changeRouteTo :
-> ( Model, Cmd Msg )
changeRouteTo model url =
let
cleanUrl =
if url.fragment == Just "disabled" then
{ url | fragment = Nothing }

else
url

newModel =
{ model | url = cleanUrl }

maybeRoute =
Route.fromUrl url
in
case maybeRoute of
Nothing ->
( { newModel
( { model
| page = NotFound
}
, Cmd.none
)

Just Route.NotFound ->
( { newModel
( { model
| page = NotFound
}
, Cmd.none
@@ -193,46 +183,46 @@ changeRouteTo model url =
Just Route.Home ->
-- Always redirect to /packages until we have something to show
-- on the home page
( newModel, Browser.Navigation.pushUrl newModel.navKey "/packages" )
( model, Browser.Navigation.pushUrl model.navKey "/packages" )

Just (Route.Packages channel query show from size sort) ->
let
modelPage =
case newModel.page of
case model.page of
Packages x ->
Just x

_ ->
Nothing
in
Page.Packages.init channel query show from size sort modelPage
|> updateWith Packages PackagesMsg newModel
|> updateWith Packages PackagesMsg model
|> (\x ->
if url.fragment == Just "disabled" then
( Tuple.first x, Cmd.none )

else
submitQuery newModel x
submitQuery model x
)

Just (Route.Options channel query show from size sort) ->
let
modelPage =
case newModel.page of
case model.page of
Options x ->
Just x

_ ->
Nothing
in
Page.Options.init channel query show from size sort modelPage
|> updateWith Options OptionsMsg newModel
|> updateWith Options OptionsMsg model
|> (\x ->
if url.fragment == Just "disabled" then
( Tuple.first x, Cmd.none )

else
submitQuery newModel x
submitQuery model x
)


@@ -270,7 +270,6 @@ update path navKey msg model =
model.from
model.size
model.sort
|> (\x -> x ++ "#disabled")
|> Browser.Navigation.pushUrl navKey
)

@@ -320,6 +319,7 @@ type Channel
| Release_20_03
| Release_20_09


type alias ChannelDetails =
{ id : String
, title : String
@@ -640,7 +640,7 @@ viewPager _ model result path =
]
[ a
[ if model.from == 0 then
href "#disabled"
href ""

else
href <|
@@ -663,7 +663,7 @@ viewPager _ model result path =
[ a
[ href <|
if model.from - model.size < 0 then
"#disabled"
""

else
createUrl
@@ -685,7 +685,7 @@ viewPager _ model result path =
[ a
[ href <|
if model.from + model.size >= result.hits.total.value then
"#disabled"
""

else
createUrl
@@ -707,7 +707,7 @@ viewPager _ model result path =
[ a
[ href <|
if model.from + model.size >= result.hits.total.value then
"#disabled"
""

else
let

0 comments on commit 2928b3e

Please sign in to comment.