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

Reverse change which got articles having discardable content #1853

Merged
merged 2 commits into from
Dec 6, 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
6 changes: 0 additions & 6 deletions Vienna/Sources/Database/Database.m
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,6 @@ -(void)markArticleRead:(NSInteger)folderId guid:(NSString *)guid isRead:(BOOL)is
Folder * folder = [self folderFromID:folderId];
if (folder != nil) {
Article * article = [folder articleFromGuid:guid];
[article beginContentAccess];
if (article != nil && isRead != article.read) {
// Mark an individual article read
FMDatabaseQueue *queue = self.databaseQueue;
Expand All @@ -2347,7 +2346,6 @@ -(void)markArticleRead:(NSInteger)folderId guid:(NSString *)guid isRead:(BOOL)is
[self setFolderUnreadCount:folder adjustment:adjustment];
}
}
[article endContentAccess];
}
}

Expand Down Expand Up @@ -2428,7 +2426,6 @@ -(void)markArticleFlagged:(NSInteger)folderId guid:(NSString *)guid isFlagged:(B
Folder * folder = [self folderFromID:folderId];
if (folder != nil) {
Article * article = [folder articleFromGuid:guid];
[article beginContentAccess];
if (article != nil && isFlagged != article.flagged) {
FMDatabaseQueue *queue = self.databaseQueue;
__block BOOL success;
Expand All @@ -2444,7 +2441,6 @@ -(void)markArticleFlagged:(NSInteger)folderId guid:(NSString *)guid isFlagged:(B
[article markFlagged:isFlagged];
}
}
[article endContentAccess];
}
}

Expand Down Expand Up @@ -2474,9 +2470,7 @@ -(void)markArticleDeleted:(Article *)article isDeleted:(BOOL)isDeleted
if (folder.countOfCachedArticles > 0) {
// If we're in a smart folder, the cached article may be different.
Article * cachedArticle = [folder articleFromGuid:guid];
[cachedArticle beginContentAccess];
[cachedArticle markDeleted:isDeleted];
[cachedArticle endContentAccess];
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions Vienna/Sources/Main window/ArticleController.m
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,13 @@ -(void)refilterArrayOfArticles
NSInteger filterMode = [Preferences standardPreferences].filterMode;
for (NSInteger index = filteredArray.count - 1; index >= 0; --index) {
Article * article = filteredArray[index];
[article beginContentAccess];
if (guidOfArticleToPreserve != nil
&& article.folderId == articleToPreserve.folderId
&& [article.guid isEqualToString:guidOfArticleToPreserve]) {
guidOfArticleToPreserve = nil;
} else if ([self filterArticle:article usingMode:filterMode] == false) {
[filteredArray removeObjectAtIndex:index];
}
[article endContentAccess];
}

if (guidOfArticleToPreserve != nil) {
Expand Down Expand Up @@ -752,7 +750,6 @@ -(void)markFlaggedByArray:(NSArray *)articleArray flagged:(BOOL)flagged
-(void)innerMarkFlaggedByArray:(NSArray *)articleArray flagged:(BOOL)flagged
{
for (Article * theArticle in articleArray) {
[theArticle beginContentAccess];
Folder *myFolder = [[Database sharedManager] folderFromID:theArticle.folderId];
if (myFolder.type == VNAFolderTypeOpenReader) {
[[OpenReader sharedManager] markStarred:theArticle starredFlag:flagged];
Expand All @@ -761,7 +758,6 @@ -(void)innerMarkFlaggedByArray:(NSArray *)articleArray flagged:(BOOL)flagged
guid:theArticle.guid
isFlagged:flagged];
[theArticle markFlagged:flagged];
[theArticle endContentAccess];
}
}

Expand Down Expand Up @@ -807,7 +803,6 @@ -(void)markReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag
-(void)innerMarkReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag
{
for (Article * theArticle in articleArray) {
[theArticle beginContentAccess];
NSInteger folderId = theArticle.folderId;
if (theArticle.read != readFlag) {
if ([[Database sharedManager] folderFromID:folderId].type == VNAFolderTypeOpenReader) {
Expand All @@ -817,7 +812,6 @@ -(void)innerMarkReadByArray:(NSArray *)articleArray readFlag:(BOOL)readFlag
[theArticle markRead:readFlag];
}
}
[theArticle endContentAccess];
}
}

Expand Down
2 changes: 0 additions & 2 deletions Vienna/Sources/Main window/ArticleConverter.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ - (instancetype)init
*/
-(NSString *)expandTagsOfArticle:(Article *)theArticle intoTemplate:(NSString *)theString withConditional:(BOOL)cond
{
NSAssert(theArticle.status != ArticleStatusDiscarded,
@"Attempting to access %@ with discarded elements", theArticle);
NSMutableString * newString = [NSMutableString stringWithString:SafeString(theString)];
NSUInteger tagStartIndex = 0;

Expand Down
5 changes: 2 additions & 3 deletions Vienna/Sources/Models/Article.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ typedef NS_ENUM(NSInteger, VNAArticleFieldTag) {
typedef NS_ENUM(NSInteger, ArticleStatus) {
ArticleStatusEmpty = 0,
ArticleStatusNew,
ArticleStatusUpdated,
ArticleStatusDiscarded
ArticleStatusUpdated
};

@interface Article : NSObject<NSDiscardableContent>
@interface Article : NSObject

// Accessor functions
-(instancetype _Nonnull)initWithGuid:(NSString * _Nonnull)theGuid /*NS_DESIGNATED_INITIALIZER*/;
Expand Down
29 changes: 0 additions & 29 deletions Vienna/Sources/Models/Article.m
Original file line number Diff line number Diff line change
Expand Up @@ -308,33 +308,4 @@ -(NSScriptObjectSpecifier *)objectSpecifier
return nil;
}

// MARK: - NSDiscardableContent

-(BOOL)beginContentAccess
{
return self.status != ArticleStatusDiscarded;
}

- (void)endContentAccess
{
// do nothing special,
// as we are not attempting to retrieve discarded content by ourself
// and don't manage any access count
}

-(void)discardContentIfPossible
{
self.status = ArticleStatusDiscarded;
[articleData removeObjectForKey:MA_Field_Text];
[articleData removeObjectForKey:MA_Field_Summary];
[articleData removeObjectForKey:MA_Field_Author];
[articleData removeObjectForKey:MA_Field_LastUpdate];
[articleData removeObjectForKey:MA_Field_PublicationDate];
}

- (BOOL)isContentDiscarded
{
return self.status == ArticleStatusDiscarded;
}

@end
Loading