Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ActivePage in viewPage function #47

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Richard Feldman
Copyright (c) 2017-2018 Richard Feldman and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ viewPage session isLoading page =

Settings subModel ->
Settings.view session subModel
|> frame Page.Other
|> frame Page.Settings
|> Html.map SettingsMsg

Home subModel ->
Expand All @@ -124,12 +124,12 @@ viewPage session isLoading page =

Login subModel ->
Login.view session subModel
|> frame Page.Other
|> frame Page.Login
|> Html.map LoginMsg

Register subModel ->
Register.view session subModel
|> frame Page.Other
|> frame Page.Register
|> Html.map RegisterMsg

Profile username subModel ->
Expand Down
19 changes: 14 additions & 5 deletions src/Page/Article/Editor.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type alias Model =
, body : String
, description : String
, tags : List String
, isSaving : Bool
}


Expand All @@ -38,6 +39,7 @@ initNew =
, body = ""
, description = ""
, tags = []
, isSaving = False
}


Expand All @@ -59,6 +61,7 @@ initEdit session slug =
, body = Article.bodyToMarkdownString article.body
, description = article.description
, tags = article.tags
, isSaving = False
}
)

Expand Down Expand Up @@ -121,7 +124,7 @@ viewForm model =
, defaultValue (String.join " " model.tags)
]
[]
, button [ class "btn btn-lg pull-xs-right btn-primary" ]
, button [ class "btn btn-lg pull-xs-right btn-primary", disabled model.isSaving ]
[ text saveButtonText ]
]
]
Expand Down Expand Up @@ -152,13 +155,13 @@ update user msg model =
user.token
|> Request.Article.create model
|> Http.send CreateCompleted
|> pair { model | errors = [] }
|> pair { model | errors = [], isSaving = True }

Just slug ->
user.token
|> Request.Article.update slug model
|> Http.send EditCompleted
|> pair { model | errors = [] }
|> pair { model | errors = [], isSaving = True }

errors ->
{ model | errors = errors } => Cmd.none
Expand All @@ -181,7 +184,10 @@ update user msg model =
|> pair model

CreateCompleted (Err error) ->
{ model | errors = model.errors ++ [ Form => "Server error while attempting to publish article" ] }
{ model
| errors = model.errors ++ [ Form => "Server error while attempting to publish article" ]
, isSaving = False
}
=> Cmd.none

EditCompleted (Ok article) ->
Expand All @@ -190,7 +196,10 @@ update user msg model =
|> pair model

EditCompleted (Err error) ->
{ model | errors = model.errors ++ [ Form => "Server error while attempting to save article" ] }
{ model
| errors = model.errors ++ [ Form => "Server error while attempting to save article" ]
, isSaving = False
}
=> Cmd.none


Expand Down
2 changes: 1 addition & 1 deletion src/Views/Article.elm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ view toggleFavorite article =
[ img [ UserPhoto.src author.image ] [] ]
, div [ class "info" ]
[ Views.Author.view author.username
, span [ class "date" ] [ text (formattedTimestamp article) ]
, viewTimestamp article
]
, Favorite.button
toggleFavorite
Expand Down