Skip to content

Commit

Permalink
Cache management is none of ArticleController business
Browse files Browse the repository at this point in the history
  • Loading branch information
barijaona committed Aug 29, 2015
1 parent 89b298d commit c6e2d50
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/ArticleController.h
Expand Up @@ -76,7 +76,6 @@
-(void)ensureSelectedArticle:(BOOL)singleSelection;
-(void)sortByIdentifier:(NSString *)columnName;
-(void)sortAscending:(BOOL)newAscending;
-(BOOL)currentCacheContainsFolder:(int)folderId;
-(void)deleteArticlesByArray:(NSArray *)articleArray;
-(void)markReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag;
-(void)markAllReadByReferencesArray:(NSArray *)refArray readFlag:(BOOL)readFlag;
Expand Down
22 changes: 0 additions & 22 deletions src/ArticleController.m
Expand Up @@ -314,7 +314,6 @@ -(void)displayFolder:(int)newFolderId
{
if (currentFolderId != newFolderId && newFolderId != 0)
{
[[[Database sharedManager] folderFromID:currentFolderId] clearCache];
currentFolderId = newFolderId;
[self reloadArrayOfArticles];
[self sortArticles];
Expand Down Expand Up @@ -374,8 +373,6 @@ -(NSArray *)applyFilter:(NSArray *)unfilteredArray
Folder * folder = [[Database sharedManager] folderFromID:folderIdOfArticleToPreserve];
if (folder != nil)
{
[folder clearCache];
[folder articles];
articleToAdd = [folder articleFromGuid:guidOfArticleToPreserve];
}
if (articleToAdd == nil)
Expand Down Expand Up @@ -733,25 +730,6 @@ -(NSArray *)wrappedMarkAllReadInArray:(NSArray *)folderArray withUndo:(BOOL)undo
return refArray;
}

/* currentCacheContainsFolder
* Scans the current article cache to determine if any article is a member of the specified
* folder and returns YES if so.
*/
-(BOOL)currentCacheContainsFolder:(int)folderId
{
int count = [currentArrayOfArticles count];
int index = 0;

while (index < count)
{
Article * anArticle = [currentArrayOfArticles objectAtIndex:index];
if ([anArticle folderId] == folderId)
return YES;
++index;
}
return NO;
}

/* markAllReadByReferencesArray
* Given an array of references, mark all those articles read or unread.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Folder.m
Expand Up @@ -492,7 +492,8 @@ -(unsigned)indexOfArticle:(Article *)article
*/
-(Article *)articleFromGuid:(NSString *)guid
{
NSAssert(isCached, @"Folder's cache of articles should be initialized before articleFromGuid can be used");
if (!isCached)
[[Database sharedManager] arrayOfArticles:itemId filterString:nil];
return [cachedArticles objectForKey:guid];
}

Expand Down

0 comments on commit c6e2d50

Please sign in to comment.