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

Fix confusion between Article and ArticleReference #1802

Merged
merged 1 commit into from
Aug 27, 2024
Merged
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: 3 additions & 2 deletions Vienna/Sources/Database/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@class Folder;
@class Field;
@class Article;
@class ArticleReference;
@class CriteriaTree;

typedef NS_OPTIONS(NSInteger, VNAQueryScope) {
Expand Down Expand Up @@ -109,8 +110,8 @@ extern NSNotificationName const VNADatabaseDidDeleteFolderNotification;
-(BOOL)addArticle:(Article *)article toFolder:(NSInteger)folderID;
-(BOOL)updateArticle:(Article *)existingArticle ofFolder:(NSInteger)folderID withArticle:(Article *)article;
-(BOOL)deleteArticle:(Article *)article;
-(NSArray *)arrayOfUnreadArticlesRefs:(NSInteger)folderId;
-(NSArray *)arrayOfArticles:(NSInteger)folderId filterString:(NSString *)filterString;
-(NSArray<ArticleReference *> *)arrayOfUnreadArticlesRefs:(NSInteger)folderId;
-(NSArray<Article *> *)arrayOfArticles:(NSInteger)folderId filterString:(NSString *)filterString;
-(void)markArticleRead:(NSInteger)folderId guid:(NSString *)guid isRead:(BOOL)isRead;
-(void)markArticleFlagged:(NSInteger)folderId guid:(NSString *)guid isFlagged:(BOOL)isFlagged;
-(void)markArticleDeleted:(Article *)article isDeleted:(BOOL)isDeleted;
Expand Down
2 changes: 1 addition & 1 deletion Vienna/Sources/Database/Database.m
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ -(CriteriaTree *)criteriaForFolder:(NSInteger)folderId
* articles in the specified folder.
* Note : when possible, you should use the interface provided by the Folder class instead of this
*/
-(NSArray *)arrayOfUnreadArticlesRefs:(NSInteger)folderId
-(NSArray<ArticleReference *> *)arrayOfUnreadArticlesRefs:(NSInteger)folderId
{
Folder * folder = [self folderFromID:folderId];
if (folder != nil) {
Expand Down
13 changes: 7 additions & 6 deletions Vienna/Sources/Main window/ArticleController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

@interface ArticleController ()

-(NSArray *)applyFilter:(NSArray *)unfilteredArray;
-(NSArray<Article *> *)applyFilter:(NSArray<Article *> *)unfilteredArray;
-(void)setSortColumnIdentifier:(NSString *)str;
-(void)innerMarkReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag;
-(void)innerMarkFlaggedByArray:(NSArray *)articleArray flagged:(BOOL)flagged;
Expand Down Expand Up @@ -521,7 +521,7 @@ -(void)refilterArrayOfArticles
* Apply the active filter to unfilteredArray and return the filtered array.
* This is done here rather than in the folder management code for simplicity.
*/
-(NSArray *)applyFilter:(NSArray *)unfilteredArray
-(NSArray<Article *> *)applyFilter:(NSArray<Article *> *)unfilteredArray
{
NSMutableArray * filteredArray = [NSMutableArray arrayWithArray:unfilteredArray];

Expand Down Expand Up @@ -875,7 +875,7 @@ -(void)markAllFoldersReadByArray:(NSArray *)folderArray
* Given an array of folders, mark all the articles in those folders as read and
* return a reference array listing all the articles that were actually marked.
*/
-(NSArray *)wrappedMarkAllFoldersReadInArray:(NSArray *)folderArray
-(NSArray<ArticleReference *> *)wrappedMarkAllFoldersReadInArray:(NSArray *)folderArray
{
NSMutableArray * refArray = [NSMutableArray array];

Expand All @@ -887,15 +887,16 @@ -(NSArray *)wrappedMarkAllFoldersReadInArray:(NSArray *)folderArray
[refArray addObjectsFromArray:[folder arrayOfUnreadArticlesRefs]];
[[Database sharedManager] markFolderRead:folderId];
} else if (folder.type == VNAFolderTypeOpenReader) {
NSArray * articleArray = [folder arrayOfUnreadArticlesRefs];
[refArray addObjectsFromArray:articleArray];
[refArray addObjectsFromArray:[folder arrayOfUnreadArticlesRefs]];
[[OpenReader sharedManager] markAllReadInFolder:folder];
} else {
// For smart folders, we only mark read articles which should be visible with current filters
NSString *filterString = APPCONTROLLER.filterString;
NSArray * articleArray = [self applyFilter:[folder articlesWithFilter:filterString]];
[refArray addObjectsFromArray:articleArray];
[self innerMarkReadByArray:articleArray readFlag:YES];
for (id article in articleArray) {
[refArray addObject:[ArticleReference makeReference:(Article *)article]];
}
}
}
return [refArray copy];
Expand Down
3 changes: 2 additions & 1 deletion Vienna/Sources/Models/Folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@import Cocoa;

@class Article;
@class ArticleReference;

/**
Folder types
Expand Down Expand Up @@ -116,7 +117,7 @@ typedef NS_OPTIONS(NSUInteger, VNAFolderFlag) {
-(void)removeArticleFromCache:(NSString *)guid;
-(void)restoreArticleToCache:(Article *)article;
-(void)markArticlesInCacheRead;
-(NSArray *)arrayOfUnreadArticlesRefs;
-(NSArray<ArticleReference *> *)arrayOfUnreadArticlesRefs;
-(NSComparisonResult)folderNameCompare:(Folder *)otherObject;
-(NSComparisonResult)folderIDCompare:(Folder *)otherObject;
@property (readonly, nonatomic) NSString *feedSourceFilePath;
Expand Down
2 changes: 1 addition & 1 deletion Vienna/Sources/Models/Folder.m
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ -(void)markArticlesInCacheRead
/* arrayOfUnreadArticlesRefs
* Return an array of ArticleReference of all unread articles
*/
-(NSArray *)arrayOfUnreadArticlesRefs
-(NSArray<ArticleReference *> *)arrayOfUnreadArticlesRefs
{
@synchronized(self) {
if (self.isCached) {
Expand Down