diff --git a/daemon/routes.go b/daemon/routes.go index 0c266f4a..0d070694 100644 --- a/daemon/routes.go +++ b/daemon/routes.go @@ -86,6 +86,8 @@ func routes(cfg *config.Config, store *storage.Storage, feedHandler *feed.Handle router.Handle("/subscribe", uiHandler.Use(uiController.SubmitSubscription)).Name("submitSubscription").Methods("POST") router.Handle("/subscriptions", uiHandler.Use(uiController.ChooseSubscription)).Name("chooseSubscription").Methods("POST") + router.Handle("/mark-all-as-read", uiHandler.Use(uiController.MarkAllAsRead)).Name("markAllAsRead").Methods("GET") + router.Handle("/unread", uiHandler.Use(uiController.ShowUnreadPage)).Name("unread").Methods("GET") router.Handle("/history", uiHandler.Use(uiController.ShowHistoryPage)).Name("history").Methods("GET") router.Handle("/starred", uiHandler.Use(uiController.ShowStarredPage)).Name("starred").Methods("GET") diff --git a/locale/translations.go b/locale/translations.go index ac073c8e..533238e9 100644 --- a/locale/translations.go +++ b/locale/translations.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-01-02 21:59:10.103098936 -0800 PST m=+0.030474265 +// 2018-01-04 18:06:27.675886358 -0800 PST m=+0.027242794 package locale @@ -211,12 +211,13 @@ var translations = map[string]string{ "Close modal dialog": "Fermer la boite de dialogue", "Save article": "Sauvegarder l'article", "There is already someone associated with this provider!": "Il y a déjà quelqu'un d'associé avec ce provider !", - "There is already someone else with the same Fever username!": "Il y a déjà quelqu'un d'autre avec le même nom d'utilisateur Fever !" + "There is already someone else with the same Fever username!": "Il y a déjà quelqu'un d'autre avec le même nom d'utilisateur Fever !", + "Mark all as read": "Tout marquer comme lu" } `, } var translationsChecksums = map[string]string{ "en_US": "6fe95384260941e8a5a3c695a655a932e0a8a6a572c1e45cb2b1ae8baa01b897", - "fr_FR": "3d8c0e211eb96ab28e2fd8fced718b6348a63ea824e54d0729a56e4e3f26ba64", + "fr_FR": "d68bc2178505410615aa2624b3efbf704f80c17a8024e2866d11c3abda587de7", } diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json index 28ebe281..6bd4e4b1 100644 --- a/locale/translations/fr_FR.json +++ b/locale/translations/fr_FR.json @@ -195,5 +195,6 @@ "Close modal dialog": "Fermer la boite de dialogue", "Save article": "Sauvegarder l'article", "There is already someone associated with this provider!": "Il y a déjà quelqu'un d'associé avec ce provider !", - "There is already someone else with the same Fever username!": "Il y a déjà quelqu'un d'autre avec le même nom d'utilisateur Fever !" + "There is already someone else with the same Fever username!": "Il y a déjà quelqu'un d'autre avec le même nom d'utilisateur Fever !", + "Mark all as read": "Tout marquer comme lu" } diff --git a/storage/entry.go b/storage/entry.go index 3be6c92a..c6058d00 100644 --- a/storage/entry.go +++ b/storage/entry.go @@ -213,3 +213,16 @@ func (s *Storage) FlushHistory(userID int64) error { return nil } + +// MarkAllAsRead set all entries with the status "unread" to "read". +func (s *Storage) MarkAllAsRead(userID int64) error { + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:MarkAllAsRead] userID=%d", userID)) + + query := `UPDATE entries SET status=$1 WHERE user_id=$2 AND status=$3` + _, err := s.db.Exec(query, model.EntryStatusRead, userID, model.EntryStatusUnread) + if err != nil { + return fmt.Errorf("unable to mark all entries as read: %v", err) + } + + return nil +} diff --git a/template/html/unread.html b/template/html/unread.html index feb5beb5..7f285d01 100644 --- a/template/html/unread.html +++ b/template/html/unread.html @@ -8,6 +8,9 @@
  • {{ t "Mark this page as read" }}
  • +
  • + {{ t "Mark all as read" }} +
  • {{ end }} diff --git a/template/views.go b/template/views.go index 8bc5c792..50bfde0f 100644 --- a/template/views.go +++ b/template/views.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-01-02 21:59:10.091229271 -0800 PST m=+0.018604600 +// 2018-01-04 18:06:27.666788074 -0800 PST m=+0.018144510 package template @@ -1209,6 +1209,9 @@ var templateViewsMap = map[string]string{
  • {{ t "Mark this page as read" }}
  • +
  • + {{ t "Mark all as read" }} +
  • {{ end }} @@ -1351,6 +1354,6 @@ var templateViewsMapChecksums = map[string]string{ "sessions": "878dbe8f8ea783b44130c495814179519fa5c3aa2666ac87508f94d58dd008bf", "settings": "ea2505b9d0a6d6bb594dba87a92079de19baa6d494f0651693a7685489fb7de9", "starred": "33dd40d1a24739e9d05f9cc4b66497cfdb8c86a7abb209a66ca65c2fbafc7d87", - "unread": "f4eb7410925e174918f1b55414c9b0b81632f7e13ce649579c8593097bb0f1d7", + "unread": "690bac794c4d21086f1a03588753088d7c26385de9a0c2723add6c7905b63f5e", "users": "44677e28bb5347799ed0020c90ec785aadec4b1454446d92411cfdaf6e32110b", } diff --git a/ui/unread.go b/ui/unread.go index 75536ccc..41026d0e 100644 --- a/ui/unread.go +++ b/ui/unread.go @@ -6,6 +6,7 @@ package ui import ( "github.com/miniflux/miniflux/http/handler" + "github.com/miniflux/miniflux/logger" "github.com/miniflux/miniflux/model" ) @@ -47,3 +48,12 @@ func (c *Controller) ShowUnreadPage(ctx *handler.Context, request *handler.Reque "csrf": ctx.CSRF(), }) } + +// MarkAllAsRead marks all unread entries as read. +func (c *Controller) MarkAllAsRead(ctx *handler.Context, request *handler.Request, response *handler.Response) { + if err := c.store.MarkAllAsRead(ctx.UserID()); err != nil { + logger.Error("[MarkAllAsRead] %v", err) + } + + response.Redirect(ctx.Route("unread")) +}