Skip to content

Commit

Permalink
Empty older articles' status before adding new ones
Browse files Browse the repository at this point in the history
This makes the "Last Refresh" filter to behave more like it did before
pull request ViennaRSS#1770 (cf. commit bb06760)
Significant difference though: "Last Refresh" refers to the last time
a particular feed was refreshed and got new articles, while previously
it referred to the last time "Refresh All Subscriptions" was triggered.
  • Loading branch information
barijaona committed Sep 12, 2024
1 parent 9781f3f commit e16edf1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Vienna/Sources/Fetching/OpenReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ -(void)feedRequestDone:(NSMutableURLRequest *)request response:(NSURLResponse *)

// Here's where we add the articles to the database
if (articleArray.count > 0) {
[refreshedFolder resetArticleStatuses];
NSArray *guidHistory = [dbManager guidHistoryForFolderId:refreshedFolder.itemId];

for (Article *article in articleArray) {
Expand Down
1 change: 1 addition & 0 deletions Vienna/Sources/Fetching/RefreshManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ -(void)finalizeFolderRefresh:(NSDictionary *)parameters

// Here's where we add the articles to the database
if (articleArray.count > 0u) {
[folder resetArticleStatuses];
NSArray *guidHistory = [dbManager guidHistoryForFolderId:folderId];
for (Article * article in articleArray) {
if ([folder createArticle:article
Expand Down
1 change: 1 addition & 0 deletions Vienna/Sources/Models/Folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ typedef NS_OPTIONS(NSUInteger, VNAFolderFlag) {
-(BOOL)createArticle:(Article *)article guidHistory:(NSArray *)guidHistory;
-(void)removeArticleFromCache:(NSString *)guid;
-(void)markArticlesInCacheRead;
-(void)resetArticleStatuses;
-(NSArray<ArticleReference *> *)arrayOfUnreadArticlesRefs;
-(NSComparisonResult)folderNameCompare:(Folder *)otherObject;
-(NSComparisonResult)folderIDCompare:(Folder *)otherObject;
Expand Down
15 changes: 15 additions & 0 deletions Vienna/Sources/Models/Folder.m
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,21 @@ -(void)markArticlesInCacheRead
} // synchronized
}

/* resetArticleStatuses
* iterate through the cache and empty the articles status
*/
-(void)resetArticleStatuses
{
for (NSString * guid in self.cachedGuids) {
Article * article = [self.cachedArticles objectForKey:guid];
if (article) {
[article beginContentAccess];
article.status = ArticleStatusEmpty;
[article endContentAccess];
}
}
}

/* arrayOfUnreadArticlesRefs
* Return an array of ArticleReference of all unread articles
*/
Expand Down

0 comments on commit e16edf1

Please sign in to comment.