From afb95e53b025554aade539e842dc6c0c8b164011 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 10 Apr 2019 10:21:14 -0400 Subject: [PATCH] Initial implementation of read-undo --- lib/REST/Fever/API.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/REST/Fever/API.php b/lib/REST/Fever/API.php index d472b11..2d0f984 100644 --- a/lib/REST/Fever/API.php +++ b/lib/REST/Fever/API.php @@ -290,7 +290,19 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler { } protected function setUnread() { - // stub + $lastUnread = Arsse::$db->articleList(Arsse::$user->id, (new Context)->limit(1), ["marked_date"], ["marked_date desc"])->getValue(); + if (!$lastUnread) { + // there are no articles + return; + } + // Fever takes the date of the last read article less fifteen seconds as a cut-off. + // We take the date of last mark (whether it be read, unread, saved, unsaved), which + // not actually signify a mark, but we'll otherwise also count back fifteen seconds + $c = new Context; + $lastUnread = Date::normalize($lastUnread, "sql"); + $since = Date::sub("DT15S", $lastUnread); + $c->unread(false)->markedSince($since); + Arsse::$db->articleMark(Arsse::$user->id, ['read' => false], $c); } protected function getRefreshTime() {