From 26986616c7f82084a7341c33d2d4cb371a7d4a23 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Fri, 9 Apr 2021 20:28:36 +0200 Subject: [PATCH] Only mark episodes as read/new on new feeds, not on existing ones --- src/fetcher.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/fetcher.cpp b/src/fetcher.cpp index d78c5eab..ca28a486 100644 --- a/src/fetcher.cpp +++ b/src/fetcher.cpp @@ -140,20 +140,22 @@ void Fetcher::processFeed(Syndication::FeedPtr feed, const QString &url) processEntry(entry, url, isNewFeed); } - // Now mark the appropriate number of recent entries "new" and "read" for new feeds - query.prepare(QStringLiteral("SELECT * FROM Entries WHERE feed=:feed ORDER BY updated DESC LIMIT :recentNew;")); - query.bindValue(QStringLiteral(":feed"), url); - query.bindValue(QStringLiteral(":recentNew"), AlligatorSettings::self()->numberNewEpisodes()); - Database::instance().execute(query); - QSqlQuery updateQuery; - while (query.next()) { - qDebug() << "new" << query.value(QStringLiteral("id")).toString(); - updateQuery.prepare(QStringLiteral("UPDATE Entries SET read=:read, new=:new WHERE id=:id AND feed=:feed;")); - updateQuery.bindValue(QStringLiteral(":read"), false); - updateQuery.bindValue(QStringLiteral(":new"), true); - updateQuery.bindValue(QStringLiteral(":feed"), url); - updateQuery.bindValue(QStringLiteral(":id"), query.value(QStringLiteral("id")).toString()); - Database::instance().execute(updateQuery); + // Now mark the appropriate number of recent entries "new" and "read" for new feeds only + if (isNewFeed) { + query.prepare(QStringLiteral("SELECT * FROM Entries WHERE feed=:feed ORDER BY updated DESC LIMIT :recentNew;")); + query.bindValue(QStringLiteral(":feed"), url); + query.bindValue(QStringLiteral(":recentNew"), AlligatorSettings::self()->numberNewEpisodes()); + Database::instance().execute(query); + QSqlQuery updateQuery; + while (query.next()) { + qDebug() << "Marked as new:" << query.value(QStringLiteral("id")).toString(); + updateQuery.prepare(QStringLiteral("UPDATE Entries SET read=:read, new=:new WHERE id=:id AND feed=:feed;")); + updateQuery.bindValue(QStringLiteral(":read"), false); + updateQuery.bindValue(QStringLiteral(":new"), true); + updateQuery.bindValue(QStringLiteral(":feed"), url); + updateQuery.bindValue(QStringLiteral(":id"), query.value(QStringLiteral("id")).toString()); + Database::instance().execute(updateQuery); + } } Q_EMIT feedUpdated(url);