Skip to content

Commit

Permalink
fix "avoid load old news" logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaYen-Kan committed Feb 16, 2024
1 parent 58292be commit 1dde8bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/addfeedwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,13 @@ void AddFeedWizard::addFeed()
}

// Insert feed
q.prepare("INSERT INTO feeds(xmlUrl, created, rowToParent, authentication, addSingleNewsAnyDateOn, avoidedOldSingleNewsDateOn, avoidedOldSingleNewsDate) "
"VALUES (:feedUrl, :feedCreateTime, :rowToParent, :authentication, :addSingleNewsAnyDateOn, :avoidedOldSingleNewsDateOn, :avoidedOldSingleNewsDate)");
q.prepare("INSERT INTO feeds(xmlUrl, created, rowToParent, authentication) "
"VALUES (:feedUrl, :feedCreateTime, :rowToParent, :authentication)");
q.bindValue(":feedUrl", feedUrlString_);
q.bindValue(":feedCreateTime",
QLocale::c().toString(QDateTime::currentDateTimeUtc(), "yyyy-MM-ddTHH:mm:ss"));
q.bindValue(":rowToParent", rowToParent);
q.bindValue(":authentication", auth);
q.bindValue(":addSingleNewsAnyDateOn", mainApp->mainWindow()->avoidOldNews_ ? "0":"1");
q.bindValue(":avoidedOldSingleNewsDateOn", mainApp->mainWindow()->avoidOldNews_ ? "1":"0");
q.bindValue(":avoidedOldSingleNewsDate", mainApp->mainWindow()->avoidedOldNewsDate_);
q.exec();

feedId_ = q.lastInsertId().toInt();
Expand Down
10 changes: 10 additions & 0 deletions src/parseobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ void ParseObject::slotParse(const QByteArray &xmlData, const int &feedId,
avoidedOldSingleNewsDate_ = q.value(4).toDate();
}

if (avoidedOldSingleNews_ == false)
{
if (mainApp->mainWindow()->avoidOldNews_ == true)
{
addSingleNewsAnyDate_ = !mainApp->mainWindow()->avoidOldNews_;
avoidedOldSingleNews_ = mainApp->mainWindow()->avoidOldNews_;
avoidedOldSingleNewsDate_ = mainApp->mainWindow()->avoidedOldNewsDate_;
}
}

// id not found (ex. feed deleted while updating)
if (feedUrl.isEmpty()) {
qWarning() << QString("Feed with id = '%1' not found").arg(parseFeedId_);
Expand Down
7 changes: 2 additions & 5 deletions src/updatefeeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ void UpdateObject::slotImportFeeds(QByteArray xmlData)
arg(parentIdsStack.top()));
if (q.next()) rowToParent = q.value(0).toInt();

q.prepare("INSERT INTO feeds(text, title, description, xmlUrl, htmlUrl, created, parentId, rowToParent, addSingleNewsAnyDateOn, avoidedOldSingleNewsDateOn, avoidedOldSingleNewsDate) "
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
q.prepare("INSERT INTO feeds(text, title, description, xmlUrl, htmlUrl, created, parentId, rowToParent) "
"VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
q.addBindValue(textString);
q.addBindValue(xml.attributes().value("title").toString());
q.addBindValue(xml.attributes().value("description").toString());
Expand All @@ -473,9 +473,6 @@ void UpdateObject::slotImportFeeds(QByteArray xmlData)
q.addBindValue(QDateTime::currentDateTimeUtc().toString(Qt::ISODate));
q.addBindValue(parentIdsStack.top());
q.addBindValue(rowToParent);
q.addBindValue(mainApp->mainWindow()->avoidOldNews_ ? 0 : 1);
q.addBindValue(mainApp->mainWindow()->avoidOldNews_ ? 1 : 0);
q.addBindValue(mainApp->mainWindow()->avoidedOldNewsDate_);
q.exec();

idsList.append(q.lastInsertId().toInt());
Expand Down

0 comments on commit 1dde8bc

Please sign in to comment.