Parcourir la source

Add link to mark everything as read

Frédéric Guillot il y a 8 ans
Parent
commit
c57cafbef2

+ 2 - 0
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")

+ 4 - 3
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",
 }

+ 2 - 1
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"
 }

+ 13 - 0
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
+}

+ 3 - 0
template/html/unread.html

@@ -8,6 +8,9 @@
         <li>
             <a href="#" data-on-click="markPageAsRead">{{ t "Mark this page as read" }}</a>
         </li>
+        <li>
+            <a href="{{ route "markAllAsRead" }}">{{ t "Mark all as read" }}</a>
+        </li>
     </ul>
     {{ end }}
 </section>

+ 5 - 2
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{
         <li>
             <a href="#" data-on-click="markPageAsRead">{{ t "Mark this page as read" }}</a>
         </li>
+        <li>
+            <a href="{{ route "markAllAsRead" }}">{{ t "Mark all as read" }}</a>
+        </li>
     </ul>
     {{ end }}
 </section>
@@ -1351,6 +1354,6 @@ var templateViewsMapChecksums = map[string]string{
 	"sessions":            "878dbe8f8ea783b44130c495814179519fa5c3aa2666ac87508f94d58dd008bf",
 	"settings":            "ea2505b9d0a6d6bb594dba87a92079de19baa6d494f0651693a7685489fb7de9",
 	"starred":             "33dd40d1a24739e9d05f9cc4b66497cfdb8c86a7abb209a66ca65c2fbafc7d87",
-	"unread":              "f4eb7410925e174918f1b55414c9b0b81632f7e13ce649579c8593097bb0f1d7",
+	"unread":              "690bac794c4d21086f1a03588753088d7c26385de9a0c2723add6c7905b63f5e",
 	"users":               "44677e28bb5347799ed0020c90ec785aadec4b1454446d92411cfdaf6e32110b",
 }

+ 10 - 0
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"))
+}