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

Add setting to control "Saving" list behavior #1263

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type User struct {
KeyboardShortcuts bool `json:"keyboard_shortcuts"`
ShowReadingTime bool `json:"show_reading_time"`
EntrySwipe bool `json:"entry_swipe"`
ToggleStatusWait bool `json:"toggle_status_wait"`
LastLoginAt *time.Time `json:"last_login_at"`
DisplayMode string `json:"display_mode"`
}
Expand Down Expand Up @@ -68,6 +69,7 @@ type UserModificationRequest struct {
KeyboardShortcuts *bool `json:"keyboard_shortcuts"`
ShowReadingTime *bool `json:"show_reading_time"`
EntrySwipe *bool `json:"entry_swipe"`
ToggleStatusWait *bool `json:"toggle_status_wait"`
DisplayMode *string `json:"display_mode"`
}

Expand Down
5 changes: 5 additions & 0 deletions database/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,9 @@ var migrations = []func(tx *sql.Tx) error{
_, err = tx.Exec(sql)
return err
},
func(tx *sql.Tx) (err error) {
sql := `ALTER TABLE users ADD COLUMN toggle_status_wait boolean default 't'`
_, err = tx.Exec(sql)
return err
},
}
1 change: 1 addition & 0 deletions locale/translations/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Eintrag erstellt Zeit",
"form.prefs.label.keyboard_shortcuts": "Tastaturkürzel aktivieren",
"form.prefs.label.entry_swipe": "Wischgeste für Einträge auf dem Handy aktivieren",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Geschätzte Lesezeit für Artikel anzeigen",
"form.prefs.label.custom_css": "Benutzerdefiniertes CSS",
"form.prefs.label.entry_order": "Eintrag Sortierspalte",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/el_EL.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Χρόνος δημιουργίας καταχώρησης",
"form.prefs.label.keyboard_shortcuts": "Ενεργοποίηση συντομεύσεων πληκτρολογίου",
"form.prefs.label.entry_swipe": "Ενεργοποιήστε τη χειρονομία σάρωσης στις καταχωρήσεις στο κινητό",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Εμφάνιση εκτιμώμενου χρόνου ανάγνωσης για άρθρα",
"form.prefs.label.custom_css": "Προσαρμοσμένο CSS",
"form.prefs.label.entry_order": "Στήλη ταξινόμησης εισόδου",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Entry created time",
"form.prefs.label.keyboard_shortcuts": "Enable keyboard shortcuts",
"form.prefs.label.entry_swipe": "Enable swipe gesture on entries on mobile",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Show estimated reading time for articles",
"form.prefs.label.custom_css": "Custom CSS",
"form.prefs.label.entry_order": "Entry Sorting Column",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Hora de creación de la entrada",
"form.prefs.label.keyboard_shortcuts": "Habilitar atajos de teclado",
"form.prefs.label.entry_swipe": "Habilitar el gesto de deslizar el dedo en las entradas en el móvil",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Mostrar el tiempo estimado de lectura de los artículos",
"form.prefs.label.custom_css": "CSS personalizado",
"form.prefs.label.entry_order": "Columna de clasificación de entradas",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Heure de création de l'entrée",
"form.prefs.label.keyboard_shortcuts": "Activer les raccourcis clavier",
"form.prefs.label.entry_swipe": "Activer le geste de balayage sur les entrées sur mobile",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Afficher le temps de lecture estimé des articles",
"form.prefs.label.custom_css": "CSS personnalisé",
"form.prefs.label.entry_order": "Colonne de tri des entrées",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Tempo di creazione dell'entrata",
"form.prefs.label.keyboard_shortcuts": "Abilita le scorciatoie da tastiera",
"form.prefs.label.entry_swipe": "Abilita il gesto di scorrimento sulle voci sul cellulare",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Mostra il tempo di lettura stimato per gli articoli",
"form.prefs.label.custom_css": "CSS personalizzati",
"form.prefs.label.entry_order": "Colonna di ordinamento delle voci",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "エントリー作成時間",
"form.prefs.label.keyboard_shortcuts": "キーボード・ショートカットを有効にする",
"form.prefs.label.entry_swipe": "モバイルのエントリでスワイプジェスチャーを有効にする",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "記事の推定読書時間を表示する",
"form.prefs.label.custom_css": "カスタムCSS",
"form.prefs.label.entry_order": "エントリーソートカラム",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/nl_NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Tijdstip van binnenkomst",
"form.prefs.label.keyboard_shortcuts": "Schakel sneltoetsen in",
"form.prefs.label.entry_swipe": "Schakel veegbewegingen in voor items op mobiel",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Toon geschatte leestijd voor artikelen",
"form.prefs.label.custom_css": "Aangepaste CSS",
"form.prefs.label.entry_order": "Ingang Sorteerkolom",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
"form.prefs.select.older_first": "Najstarsze wpisy jako pierwsze",
"form.prefs.label.keyboard_shortcuts": "Włącz skróty klawiaturowe",
"form.prefs.label.entry_swipe": "Włącz gest przesuwania na wpisach na telefonie komórkowym",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Pokaż szacowany czas czytania artykułów",
"form.prefs.select.recent_first": "Najnowsze wpisy jako pierwsze",
"form.prefs.select.fullscreen": "Pełny ekran",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Entrada tempo criado",
"form.prefs.label.keyboard_shortcuts": "Habilitar atalhos do teclado",
"form.prefs.label.entry_swipe": "Ativar gesto de deslizar nas entradas no celular",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Mostrar tempo estimado de leitura de artigos",
"form.prefs.label.custom_css": "CSS customizado",
"form.prefs.label.entry_order": "Coluna de Ordenação de Entrada",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
"form.prefs.select.created_time": "Время создания записи",
"form.prefs.label.keyboard_shortcuts": "Включить сочетания клавиш",
"form.prefs.label.entry_swipe": "Включить жест смахивания для записей на мобильном устройстве",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Показать примерное время чтения статей",
"form.prefs.label.custom_css": "Пользовательские CSS",
"form.prefs.label.entry_order": "Колонка сортировки ввода",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/tr_TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"form.prefs.select.created_time": "Girişin oluşturulma zamanı",
"form.prefs.label.keyboard_shortcuts": "Klavye kısayollarını etkinleştir",
"form.prefs.label.entry_swipe": "Mobil cihazlarda iletiler için kaydırma hareketlerini etkinleştir",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "Makaleler için tahmini okuma süresini göster",
"form.prefs.label.custom_css": "Özel CSS",
"form.prefs.label.entry_order": "Giriş Sıralama Sütunu",
Expand Down
1 change: 1 addition & 0 deletions locale/translations/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
"form.prefs.select.created_time": "文章创建时间",
"form.prefs.label.keyboard_shortcuts": "启用键盘快捷键",
"form.prefs.label.entry_swipe": "在移动设备上启用滑动手势",
"form.prefs.label.toggle_status_wait": "Delay removing items from lists until server responds",
"form.prefs.label.show_reading_time": "显示文章的预计阅读时间",
"form.prefs.label.custom_css": "自定义 CSS",
"form.prefs.label.entry_order": "文章排序依据",
Expand Down
6 changes: 6 additions & 0 deletions model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type User struct {
KeyboardShortcuts bool `json:"keyboard_shortcuts"`
ShowReadingTime bool `json:"show_reading_time"`
EntrySwipe bool `json:"entry_swipe"`
ToggleStatusWait bool `json:"toggle_status_wait"`
LastLoginAt *time.Time `json:"last_login_at"`
DisplayMode string `json:"display_mode"`
}
Expand Down Expand Up @@ -58,6 +59,7 @@ type UserModificationRequest struct {
KeyboardShortcuts *bool `json:"keyboard_shortcuts"`
ShowReadingTime *bool `json:"show_reading_time"`
EntrySwipe *bool `json:"entry_swipe"`
ToggleStatusWait *bool `json:"toggle_status_wait"`
DisplayMode *string `json:"display_mode"`
}

Expand Down Expand Up @@ -123,6 +125,10 @@ func (u *UserModificationRequest) Patch(user *User) {
user.EntrySwipe = *u.EntrySwipe
}

if u.ToggleStatusWait != nil {
user.ToggleStatusWait = *u.ToggleStatusWait
}

if u.DisplayMode != nil {
user.DisplayMode = *u.DisplayMode
}
Expand Down
37 changes: 25 additions & 12 deletions storage/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (s *Storage) CreateUser(userCreationRequest *model.UserCreationRequest) (*m
keyboard_shortcuts,
show_reading_time,
entry_swipe,
toggle_status_wait,
stylesheet,
google_id,
openid_connect_id,
Expand Down Expand Up @@ -113,6 +114,7 @@ func (s *Storage) CreateUser(userCreationRequest *model.UserCreationRequest) (*m
&user.KeyboardShortcuts,
&user.ShowReadingTime,
&user.EntrySwipe,
&user.ToggleStatusWait,
&user.Stylesheet,
&user.GoogleID,
&user.OpenIDConnectID,
Expand Down Expand Up @@ -164,13 +166,14 @@ func (s *Storage) UpdateUser(user *model.User) error {
keyboard_shortcuts=$9,
show_reading_time=$10,
entry_swipe=$11,
stylesheet=$12,
google_id=$13,
openid_connect_id=$14,
display_mode=$15,
entry_order=$16
toggle_status_wait=$12,
stylesheet=$13,
google_id=$14,
openid_connect_id=$15,
display_mode=$16,
entry_order=$17
WHERE
id=$17
id=$18
`

_, err = s.db.Exec(
Expand All @@ -186,6 +189,7 @@ func (s *Storage) UpdateUser(user *model.User) error {
user.KeyboardShortcuts,
user.ShowReadingTime,
user.EntrySwipe,
user.ToggleStatusWait,
user.Stylesheet,
user.GoogleID,
user.OpenIDConnectID,
Expand All @@ -209,13 +213,14 @@ func (s *Storage) UpdateUser(user *model.User) error {
keyboard_shortcuts=$8,
show_reading_time=$9,
entry_swipe=$10,
stylesheet=$11,
google_id=$12,
openid_connect_id=$13,
display_mode=$14,
entry_order=$15
toggle_status_wait=$11,
stylesheet=$12,
google_id=$13,
openid_connect_id=$14,
display_mode=$15,
entry_order=$16
WHERE
id=$16
id=$17
`

_, err := s.db.Exec(
Expand All @@ -230,6 +235,7 @@ func (s *Storage) UpdateUser(user *model.User) error {
user.KeyboardShortcuts,
user.ShowReadingTime,
user.EntrySwipe,
user.ToggleStatusWait,
user.Stylesheet,
user.GoogleID,
user.OpenIDConnectID,
Expand Down Expand Up @@ -271,6 +277,7 @@ func (s *Storage) UserByID(userID int64) (*model.User, error) {
keyboard_shortcuts,
show_reading_time,
entry_swipe,
toggle_status_wait,
last_login_at,
stylesheet,
google_id,
Expand Down Expand Up @@ -300,6 +307,7 @@ func (s *Storage) UserByUsername(username string) (*model.User, error) {
keyboard_shortcuts,
show_reading_time,
entry_swipe,
toggle_status_wait,
last_login_at,
stylesheet,
google_id,
Expand Down Expand Up @@ -329,6 +337,7 @@ func (s *Storage) UserByField(field, value string) (*model.User, error) {
keyboard_shortcuts,
show_reading_time,
entry_swipe,
toggle_status_wait,
last_login_at,
stylesheet,
google_id,
Expand Down Expand Up @@ -365,6 +374,7 @@ func (s *Storage) UserByAPIKey(token string) (*model.User, error) {
u.keyboard_shortcuts,
u.show_reading_time,
u.entry_swipe,
u.toggle_status_wait,
u.last_login_at,
u.stylesheet,
u.google_id,
Expand Down Expand Up @@ -395,6 +405,7 @@ func (s *Storage) fetchUser(query string, args ...interface{}) (*model.User, err
&user.KeyboardShortcuts,
&user.ShowReadingTime,
&user.EntrySwipe,
&user.ToggleStatusWait,
&user.LastLoginAt,
&user.Stylesheet,
&user.GoogleID,
Expand Down Expand Up @@ -487,6 +498,7 @@ func (s *Storage) Users() (model.Users, error) {
keyboard_shortcuts,
show_reading_time,
entry_swipe,
toggle_status_wait,
last_login_at,
stylesheet,
google_id,
Expand Down Expand Up @@ -518,6 +530,7 @@ func (s *Storage) Users() (model.Users, error) {
&user.KeyboardShortcuts,
&user.ShowReadingTime,
&user.EntrySwipe,
&user.ToggleStatusWait,
&user.LastLoginAt,
&user.Stylesheet,
&user.GoogleID,
Expand Down
3 changes: 2 additions & 1 deletion template/templates/common/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
{{ if .csrf }}data-csrf-token="{{ .csrf }}"{{ end }}
data-entries-status-url="{{ route "updateEntriesStatus" }}"
data-refresh-all-feeds-url="{{ route "refreshAllFeeds" }}"
{{ if .user }}{{ if not .user.KeyboardShortcuts }}data-disable-keyboard-shortcuts="true"{{ end }}{{ end }}>
{{ if .user }}{{ if not .user.KeyboardShortcuts }}data-disable-keyboard-shortcuts="true"{{ end }}{{ end }}
{{ if .user }}{{ if .user.ToggleStatusWait }}data-toggle-status-wait="true"{{ end }}{{ end }}>

{{ if .user }}
<header class="header">
Expand Down
2 changes: 2 additions & 0 deletions template/templates/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ <h1>{{ t "page.settings.title" }}</h1>

<label><input type="checkbox" name="entry_swipe" value="1" {{ if .form.EntrySwipe }}checked{{ end }}> {{ t "form.prefs.label.entry_swipe" }}</label>

<label><input type="checkbox" name="toggle_status_wait" value="1" {{ if .form.ToggleStatusWait }}checked{{ end }}> {{ t "form.prefs.label.toggle_status_wait" }}</label>

<label>{{t "form.prefs.label.custom_css" }}</label><textarea name="custom_css" cols="40" rows="8" spellcheck="false">{{ .form.CustomCSS }}</textarea>
<div class="buttons">
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button>
Expand Down
15 changes: 11 additions & 4 deletions tests/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

//go:build integration
// +build integration

package tests
Expand Down Expand Up @@ -297,13 +298,15 @@ func TestUpdateUserFields(t *testing.T) {

stylesheet := "body { color: red }"
swipe := false
toggleStatusWait := false
entriesPerPage := 5
displayMode := "fullscreen"
user, err = client.UpdateUser(user.ID, &miniflux.UserModificationRequest{
Stylesheet: &stylesheet,
EntrySwipe: &swipe,
EntriesPerPage: &entriesPerPage,
DisplayMode: &displayMode,
Stylesheet: &stylesheet,
EntrySwipe: &swipe,
ToggleStatusWait: &toggleStatusWait,
EntriesPerPage: &entriesPerPage,
DisplayMode: &displayMode,
})
if err != nil {
t.Fatal(err)
Expand All @@ -317,6 +320,10 @@ func TestUpdateUserFields(t *testing.T) {
t.Fatalf(`Unable to update user EntrySwipe: got %v instead of %v`, user.EntrySwipe, swipe)
}

if user.ToggleStatusWait != toggleStatusWait {
t.Fatalf(`Unable to update user ToggleStatusWait: got %v instead of %v`, user.ToggleStatusWait, toggleStatusWait)
}

if user.EntriesPerPage != entriesPerPage {
t.Fatalf(`Unable to update user EntriesPerPage: got %q instead of %q`, user.EntriesPerPage, entriesPerPage)
}
Expand Down
3 changes: 3 additions & 0 deletions ui/form/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type SettingsForm struct {
ShowReadingTime bool
CustomCSS string
EntrySwipe bool
ToggleStatusWait bool
DisplayMode string
}

Expand All @@ -43,6 +44,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {
user.ShowReadingTime = s.ShowReadingTime
user.Stylesheet = s.CustomCSS
user.EntrySwipe = s.EntrySwipe
user.ToggleStatusWait = s.ToggleStatusWait
user.DisplayMode = s.DisplayMode

if s.Password != "" {
Expand Down Expand Up @@ -92,6 +94,7 @@ func NewSettingsForm(r *http.Request) *SettingsForm {
ShowReadingTime: r.FormValue("show_reading_time") == "1",
CustomCSS: r.FormValue("custom_css"),
EntrySwipe: r.FormValue("entry_swipe") == "1",
ToggleStatusWait: r.FormValue("toggle_status_wait") == "1",
DisplayMode: r.FormValue("display_mode"),
}
}
1 change: 1 addition & 0 deletions ui/settings_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) {
ShowReadingTime: user.ShowReadingTime,
CustomCSS: user.Stylesheet,
EntrySwipe: user.EntrySwipe,
ToggleStatusWait: user.ToggleStatusWait,
DisplayMode: user.DisplayMode,
}

Expand Down