Skip to content

Commit

Permalink
Add link to mark everything as read
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Jan 5, 2018
1 parent efac11e commit c57cafb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
2 changes: 2 additions & 0 deletions daemon/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 4 additions & 3 deletions locale/translations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion locale/translations/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 13 additions & 0 deletions storage/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 3 additions & 0 deletions template/html/unread.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ <h1>{{ t "Unread" }} (<span class="unread-counter">{{ .countUnread }}</span>)</h
<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>
Expand Down
7 changes: 5 additions & 2 deletions template/views.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions ui/unread.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ui

import (
"github.com/miniflux/miniflux/http/handler"
"github.com/miniflux/miniflux/logger"
"github.com/miniflux/miniflux/model"
)

Expand Down Expand Up @@ -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"))
}

0 comments on commit c57cafb

Please sign in to comment.