Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove cleanUrl and fragment hack
  • Loading branch information
turboMaCk committed Oct 27, 2020
1 parent adbb224 commit 2928b3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
28 changes: 9 additions & 19 deletions src/Main.elm
Expand Up @@ -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
Expand All @@ -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
)


Expand Down
10 changes: 5 additions & 5 deletions src/Search.elm
Expand Up @@ -270,7 +270,6 @@ update path navKey msg model =
model.from
model.size
model.sort
|> (\x -> x ++ "#disabled")
|> Browser.Navigation.pushUrl navKey
)

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


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

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

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

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

else
let
Expand Down

0 comments on commit 2928b3e

Please sign in to comment.