Refactoring.

This commit is contained in:
Martin Rotter 2016-05-06 07:44:32 +02:00
parent 2f530b5793
commit cbe64982c4
3 changed files with 10 additions and 17 deletions

View File

@ -59,7 +59,7 @@ bool OwnCloudFeed::canBeDeleted() const {
}
bool OwnCloudFeed::deleteViaGui() {
if (removeItself()) {
if (serviceRoot()->network()->deleteFeed(customId()) && removeItself()) {
serviceRoot()->requestItemRemoval(this);
return true;
}
@ -86,9 +86,7 @@ bool OwnCloudFeed::editItself(OwnCloudFeed *new_feed_data) {
bool OwnCloudFeed::removeItself() {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
return
serviceRoot()->network()->deleteFeed(customId()) &&
DatabaseQueries::deleteFeed(database, customId(), serviceRoot()->accountId());
return DatabaseQueries::deleteFeed(database, customId(), serviceRoot()->accountId());
}
bool OwnCloudFeed::markAsReadUnread(RootItem::ReadStatus status) {

View File

@ -112,11 +112,14 @@ bool TtRssFeed::canBeDeleted() const {
}
bool TtRssFeed::deleteViaGui() {
if (removeItself()) {
TtRssUnsubscribeFeedResponse response = serviceRoot()->network()->unsubscribeFeed(customId());
if (response.code() == UFF_OK && removeItself()) {
serviceRoot()->requestItemRemoval(this);
return true;
}
else {
qWarning("TT-RSS: Unsubscribing from feed failed, received JSON: '%s'", qPrintable(response.toString()));
return false;
}
}
@ -183,16 +186,7 @@ QList<Message> TtRssFeed::obtainNewMessages() {
}
bool TtRssFeed::removeItself() {
TtRssUnsubscribeFeedResponse response = serviceRoot()->network()->unsubscribeFeed(customId());
if (response.code() == UFF_OK) {
// Feed was removed online from server, remove local data.
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
return DatabaseQueries::deleteFeed(database, customId(), serviceRoot()->accountId());
}
else {
qWarning("TT-RSS: Unsubscribing from feed failed, received JSON: '%s'", qPrintable(response.toString()));
return false;
}
}

View File

@ -42,11 +42,12 @@ class TtRssFeed : public Feed {
bool markAsReadUnread(ReadStatus status);
bool cleanMessages(bool clear_only_read);
bool editItself(TtRssFeed *new_feed_data);
bool removeItself();
private:
QList<Message> obtainNewMessages();
bool removeItself();
};
#endif // TTRSSFEED_H