mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
fix(ui): reading preferences are reset if the form values are incorrect
This commit is contained in:
parent
6cbe8c3a9d
commit
f5fde36d45
4 changed files with 16 additions and 11 deletions
|
@ -16,7 +16,7 @@ import (
|
|||
// MarkReadBehavior list all possible behaviors for automatically marking an entry as read
|
||||
type MarkReadBehavior string
|
||||
|
||||
var (
|
||||
const (
|
||||
NoAutoMarkAsRead MarkReadBehavior = "no-auto"
|
||||
MarkAsReadOnView MarkReadBehavior = "on-view"
|
||||
MarkAsReadOnViewButWaitForPlayerCompletion MarkReadBehavior = "on-view-but-wait-for-player-completion"
|
||||
|
|
|
@ -63,8 +63,7 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) {
|
|||
sess := session.New(h.store, request.SessionID(r))
|
||||
view := view.New(h.tpl, r, sess)
|
||||
view.Set("form", settingsForm)
|
||||
// In order to keep the continuity between form and model, I pass adhoc constants to the view
|
||||
view.Set("const", map[string]interface{}{
|
||||
view.Set("readBehaviors", map[string]any{
|
||||
"NoAutoMarkAsRead": form.NoAutoMarkAsRead,
|
||||
"MarkAsReadOnView": form.MarkAsReadOnView,
|
||||
"MarkAsReadOnViewButWaitForPlayerCompletion": form.MarkAsReadOnViewButWaitForPlayerCompletion,
|
||||
|
|
|
@ -43,6 +43,12 @@ func (h *handler) updateSettings(w http.ResponseWriter, r *http.Request) {
|
|||
sess := session.New(h.store, request.SessionID(r))
|
||||
view := view.New(h.tpl, r, sess)
|
||||
view.Set("form", settingsForm)
|
||||
view.Set("readBehaviors", map[string]any{
|
||||
"NoAutoMarkAsRead": form.NoAutoMarkAsRead,
|
||||
"MarkAsReadOnView": form.MarkAsReadOnView,
|
||||
"MarkAsReadOnViewButWaitForPlayerCompletion": form.MarkAsReadOnViewButWaitForPlayerCompletion,
|
||||
"MarkAsReadOnlyOnPlayerCompletion": form.MarkAsReadOnlyOnPlayerCompletion,
|
||||
})
|
||||
view.Set("themes", model.Themes())
|
||||
view.Set("languages", locale.AvailableLanguages)
|
||||
view.Set("timezones", timezones)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue