-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1810 from barijaona/articleCache
Improve management of folder's caches of articles After PR 1770 <#1770> was merged, I noticed that the "Last Refresh" filter did not always have the expected behavior. Investigation led to various discoveries regarding the use of NSCache and parts of the code where article's status was lost. This PR solves these issues and gives back a functional "Last Refresh" filter, with a difference though: "Last Refresh" now refers to the last time each feed was refreshed and got new articles, while previously it referred to the last time "Refresh All Subscriptions" was triggered.ent of folder's caches of articles
- Loading branch information
Showing
11 changed files
with
244 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Article+Tags.h | ||
// Vienna | ||
// | ||
// Copyright 2024 Eitot | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "Article.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface Article (Tags) | ||
|
||
// The following methods are called dynamically by the ArticleConverter class, | ||
// specifically -expandTagsOfArticle:intoTemplate:withConditional:. It creates | ||
// selectors by appending a tag name to the string "tag", e.g. $ArticleAuthor$ | ||
// becomes tagArticleAuthor. The method signatures must not be changed without | ||
// changing the corresponding tag names elsewhere. | ||
|
||
- (NSString *)tagArticleTitle; | ||
- (NSString *)tagArticleAuthor; | ||
- (NSString *)tagArticleBody; | ||
- (NSString *)tagArticleDate; | ||
- (NSString *)tagArticleLink; | ||
- (NSString *)tagArticleEnclosureLink; | ||
- (NSString *)tagArticleEnclosureFilename; | ||
- (NSString *)tagFeedTitle; | ||
- (NSString *)tagFeedDescription; | ||
- (NSString *)tagFeedLink; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// Article+Tags.m | ||
// Vienna | ||
// | ||
// Copyright 2024 Eitot | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "Article+Tags.h" | ||
|
||
#import "Database.h" | ||
#import "DateFormatterExtension.h" | ||
#import "Folder.h" | ||
#import "HelperFunctions.h" | ||
#import "StringExtensions.h" | ||
|
||
@implementation Article (Tags) | ||
|
||
- (NSString *)tagArticleTitle | ||
{ | ||
NSMutableString *articleTitle = [NSMutableString stringWithString:SafeString(self.title)]; | ||
[articleTitle vna_replaceString:@"$Article" withString:@"$_%$%_Article"]; | ||
[articleTitle vna_replaceString:@"$Feed" withString:@"$_%$%_Feed"]; | ||
return [NSString vna_stringByConvertingHTMLEntities:articleTitle]; | ||
} | ||
|
||
- (NSString *)tagArticleAuthor | ||
{ | ||
return SafeString(self.author); | ||
} | ||
|
||
- (NSString *)tagArticleBody | ||
{ | ||
NSMutableString *articleBody = [NSMutableString stringWithString:SafeString(self.body)]; | ||
[articleBody vna_replaceString:@"$Article" withString:@"$_%$%_Article"]; | ||
[articleBody vna_replaceString:@"$Feed" withString:@"$_%$%_Feed"]; | ||
[articleBody vna_fixupRelativeImgTags:self.link]; | ||
[articleBody vna_fixupRelativeIframeTags:self.link]; | ||
[articleBody vna_fixupRelativeAnchorTags:self.link]; | ||
return articleBody; | ||
} | ||
|
||
- (NSString *)tagArticleDate | ||
{ | ||
return [NSDateFormatter vna_relativeDateStringFromDate:self.lastUpdate]; | ||
} | ||
|
||
- (NSString *)tagArticleLink | ||
{ | ||
return cleanedUpUrlFromString(self.link).absoluteString; | ||
} | ||
|
||
- (NSString *)tagArticleEnclosureLink | ||
{ | ||
return cleanedUpUrlFromString(self.enclosure).absoluteString; | ||
} | ||
|
||
- (NSString *)tagArticleEnclosureFilename | ||
{ | ||
return self.enclosure.lastPathComponent.stringByRemovingPercentEncoding; | ||
} | ||
|
||
- (NSString *)tagFeedTitle | ||
{ | ||
Folder *folder = [Database.sharedManager folderFromID:self.folderId]; | ||
return [NSString vna_stringByConvertingHTMLEntities:SafeString(folder.name)]; | ||
} | ||
|
||
- (NSString *)tagFeedDescription | ||
{ | ||
Folder *folder = [Database.sharedManager folderFromID:self.folderId]; | ||
return folder.feedDescription; | ||
} | ||
|
||
- (NSString *)tagFeedLink | ||
{ | ||
Folder *folder = [Database.sharedManager folderFromID:self.folderId]; | ||
return cleanedUpUrlFromString(folder.homePage).absoluteString; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.