From ac3693562b635aaab4f43ad5d1343aae7ba5b7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 17 Jul 2019 21:29:00 -0700 Subject: [PATCH] Ask for confirmation before flushing history --- template/html/history_entries.html | 8 +++++++- template/views.go | 10 ++++++++-- ui/history_flush.go | 7 +++---- ui/ui.go | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/template/html/history_entries.html b/template/html/history_entries.html index 08887783..109e1a2d 100644 --- a/template/html/history_entries.html +++ b/template/html/history_entries.html @@ -6,7 +6,13 @@ {{ if .entries }} {{ end }} diff --git a/template/views.go b/template/views.go index af283f03..83006fd3 100644 --- a/template/views.go +++ b/template/views.go @@ -884,7 +884,13 @@ var templateViewsMap = map[string]string{ {{ if .entries }} {{ end }} @@ -1455,7 +1461,7 @@ var templateViewsMapChecksums = map[string]string{ "entry": "1626bf4dd3223b2f730865676162aa0a9f0a0e009cdea90f705230542922e0f4", "feed_entries": "4bb6b96ba4d13dbaf22dcf6dd95ae36b6e5a0c99175d502865a164dc68fd4bae", "feeds": "31acc253c547a6cce5710d72a6f6b3b396162ecd5e5af295b2cf47c1ff55bd06", - "history_entries": "b65ca1d85615caa7c314a33f1cb997aa3477a79e66b9894b2fd387271ad467d2", + "history_entries": "9763d2120cfaeb78d406fdc029197fed2f7cfa7682970eeedae82ae79be65519", "import": "8349e47a783bb40d8e9248b4771656e5f006185e11079e1c4680dd52633420ed", "integrations": "f85b4a48ab1fc13b8ca94bfbbc44bd5e8784f35b26a63ec32cbe82b96b45e008", "login": "2e72d2d4b9786641b696bedbed5e10b04bdfd68254ddbbdb0a53cca621d200c7", diff --git a/ui/history_flush.go b/ui/history_flush.go index d0b8f628..e74c5b97 100644 --- a/ui/history_flush.go +++ b/ui/history_flush.go @@ -8,16 +8,15 @@ import ( "net/http" "miniflux.app/http/request" - "miniflux.app/http/response/html" - "miniflux.app/http/route" + "miniflux.app/http/response/json" ) func (h *handler) flushHistory(w http.ResponseWriter, r *http.Request) { err := h.store.FlushHistory(request.UserID(r)) if err != nil { - html.ServerError(w, r, err) + json.ServerError(w, r, err) return } - html.Redirect(w, r, route.Path(h.router, "history")) + json.OK(w, r, "OK") } diff --git a/ui/ui.go b/ui/ui.go index 47383d20..b71abb22 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -45,7 +45,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool, feedHa // History pages. uiRouter.HandleFunc("/history", handler.showHistoryPage).Name("history").Methods("GET") uiRouter.HandleFunc("/history/entry/{entryID}", handler.showReadEntryPage).Name("readEntry").Methods("GET") - uiRouter.HandleFunc("/history/flush", handler.flushHistory).Name("flushHistory").Methods("GET") + uiRouter.HandleFunc("/history/flush", handler.flushHistory).Name("flushHistory").Methods("POST") // Bookmark pages. uiRouter.HandleFunc("/starred", handler.showStarredPage).Name("starred").Methods("GET")