Skip to content

Commit

Permalink
Merge pull request #1835 from TAKeanice/remove_deleted_articles_from_…
Browse files Browse the repository at this point in the history
…cache

Filter article from cache when it was marked deleted
  • Loading branch information
barijaona authored Oct 26, 2024
2 parents fd467d5 + f7ac919 commit a108bb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Vienna/Sources/Database/Database.m
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ -(void)markArticleDeleted:(Article *)article isDeleted:(BOOL)isDeleted
NSString * guid = article.guid;
Folder * folder = [self folderFromID:folderId];
if (folder !=nil) {
if (isDeleted && !article.read) {
if (isDeleted && !article.read) {
[self markArticleRead:folderId guid:guid isRead:YES];
}
FMDatabaseQueue *queue = self.databaseQueue;
Expand All @@ -2483,6 +2483,9 @@ -(void)markArticleDeleted:(Article *)article isDeleted:(BOOL)isDeleted
guid];
}];
[article markDeleted:isDeleted];
//TODO this should all move to the folder implementation, to make this less of a god object.
// Or even better: when marking an article as deleted it triggers the deletion from its folder itself, and that in turn triggers the db update.
// The same also applies to deleteArticle and probably many other parts of this class.
if (folder.countOfCachedArticles > 0) {
// If we're in a smart folder, the cached article may be different.
Article * cachedArticle = [folder articleFromGuid:guid];
Expand Down
5 changes: 4 additions & 1 deletion Vienna/Sources/Models/Folder.m
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,10 @@ -(void)resetArticleStatuses
for (id object in self.cachedGuids) {
Article * theArticle = [self.cachedArticles objectForKey:object];
if (theArticle != nil) {
[articles addObject:theArticle];
// deleted articles are not removed from cache any more
if (!theArticle.isDeleted) {
[articles addObject:theArticle];
}
} else {
// some problem
NSLog(@"Bug retrieving from cache in folder %li : after %lu insertions of %lu, guid %@",(long)self.itemId, (unsigned long)articles.count,(unsigned long)self.cachedGuids.count,object);
Expand Down

0 comments on commit a108bb2

Please sign in to comment.