Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter article from cache when it was marked deleted #1835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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