Skip to content

Commit

Permalink
fix(favicon): restore to original favicon when not on build page (#114)
Browse files Browse the repository at this point in the history
* forgot commit to update model on favicon tick

* revert filter change?

* revert another change
  • Loading branch information
plyr4 authored Feb 18, 2020
1 parent c31a3a3 commit d735b83
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ update msg model =
, repo = repo
}
, build = RemoteData.succeed build
, favicon = statusToFavicon build.status
}
, Interop.setFavicon <| Encode.string <| statusToFavicon build.status
)
Expand Down Expand Up @@ -904,7 +905,11 @@ update msg model =
Tick interval time ->
case interval of
OneSecond ->
( { model | time = time }, refreshFavicon model.page model.favicon model.build )
let
( favicon, cmd ) =
refreshFavicon model.page model.favicon model.build
in
( { model | time = time, favicon = favicon }, cmd )

FiveSecond data ->
( model, refreshPage model data )
Expand Down Expand Up @@ -1019,7 +1024,7 @@ refreshSubscriptions model =

{-| refreshFavicon : takes page and restores the favicon to the default when not viewing the build page
-}
refreshFavicon : Page -> Favicon -> WebData Build -> Cmd Msg
refreshFavicon : Page -> Favicon -> WebData Build -> ( Favicon, Cmd Msg )
refreshFavicon page currentFavicon build =
case page of
Pages.Build _ _ _ _ ->
Expand All @@ -1030,20 +1035,20 @@ refreshFavicon page currentFavicon build =
statusToFavicon b.status
in
if currentFavicon /= newFavicon then
Interop.setFavicon <| Encode.string newFavicon
( newFavicon, Interop.setFavicon <| Encode.string newFavicon )

else
Cmd.none
( currentFavicon, Cmd.none )

_ ->
Cmd.none
( currentFavicon, Cmd.none )

_ ->
if currentFavicon /= defaultFavicon then
Interop.setFavicon <| Encode.string defaultFavicon
( defaultFavicon, Interop.setFavicon <| Encode.string defaultFavicon )

else
Cmd.none
( currentFavicon, Cmd.none )


{-| refreshPage : refreshes Vela data based on current page and build status
Expand Down

0 comments on commit d735b83

Please sign in to comment.