If database empty, add releases feed

This commit is contained in:
relikd
2019-08-11 15:31:35 +02:00
parent a6c8198234
commit a1f191789d
6 changed files with 25 additions and 10 deletions

View File

@@ -17,7 +17,7 @@ and this project does adhere to [Semantic Versioning](https://semver.org/spec/v2
- *Settings, Feeds:* OPML export with selected items only
- *UI:* Accessibility hints for most UI elements
- *UI*: Show welcome message upon first usage (empty db)
- *DB*: Table for options. E.g., with what version was the db last used
- Welcome message also adds Github releases feed
- Associate OPML files (double click and right click actions in Finder)
- Quick Look preview for OPML files
@@ -37,6 +37,7 @@ and this project does adhere to [Semantic Versioning](https://semver.org/spec/v2
- *Settings, Feeds:* Always append new items at the end
- *Adding feed:* Display error reason if user cancels the creation of a new feed item
- *Adding feed:* Refresh interval hotkeys set to: `⌘1``⌘6`
- *DB*: New table for options. E.g., what app version modified the database
## [0.9.4] - 2019-04-02

View File

@@ -51,11 +51,12 @@
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[_statusItem asyncReloadUnreadCount];
[FeedDownload registerNetworkChangeNotification]; // will call update scheduler
if ([StoreCoordinator isEmpty]) {
[_statusItem showWelcomeMessage];
[FeedDownload autoDownloadAndParseUpdateURL];
}
[FeedDownload registerNetworkChangeNotification]; // will call update scheduler
[_statusItem asyncReloadUnreadCount];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
@@ -71,7 +72,7 @@
url = [url substringFromIndex:2];
}
if ([scheme isEqualToString:@"feed"]) {
[FeedDownload autoDownloadAndParseURL:url successBlock:nil];
[FeedDownload autoDownloadAndParseURL:url addAnyway:NO modify:nil];
}
}

View File

@@ -30,6 +30,8 @@
/// UTI type used for opml files
static NSPasteboardType const UTI_OPML = @"org.opml";
/// URL with newest baRSS releases. Automatically added when user starts baRSS for the first time.
static NSString* const versionUpdateURL = @"https://github.com/relikd/baRSS/releases.atom";
#pragma mark - NSImageName constants

View File

@@ -39,7 +39,8 @@
+ (void)forceUpdateAllFeeds;
// Downloading
+ (void)newFeed:(NSString *)urlStr askUser:(nonnull NSString*(^)(RSHTMLMetadata *meta))askUser block:(nonnull void(^)(RSParsedFeed *parsed, NSError *error, NSHTTPURLResponse *response))block;
+ (void)autoDownloadAndParseURL:(NSString*)urlStr successBlock:(nullable os_block_t)block;
+ (void)autoDownloadAndParseURL:(NSString*)urlStr addAnyway:(BOOL)flag modify:(nullable void(^)(Feed *feed))block;
+ (void)autoDownloadAndParseUpdateURL;
+ (void)batchDownloadFeeds:(NSArray<Feed*> *)list favicons:(BOOL)fav showErrorAlert:(BOOL)alert finally:(nullable os_block_t)block;
// Favicon image download
+ (void)downloadFavicon:(NSString*)urlStr finished:(void(^)(NSImage * _Nullable img))block;

View File

@@ -26,6 +26,7 @@
#import "Feed+Ext.h"
#import "FeedMeta+Ext.h"
#import "FeedGroup+Ext.h"
#import "NSDate+Ext.h"
#import <SystemConfiguration/SystemConfiguration.h>
@@ -342,24 +343,33 @@ static BOOL _nextUpdateIsForced = NO;
Creates new @c FeedGroup, @c Feed, @c FeedMeta and @c FeedArticle instances and saves them to the persistent store.
Update duration is set to the default of 30 minutes.
*/
+ (void)autoDownloadAndParseURL:(NSString*)url successBlock:(nullable os_block_t)block {
+ (void)autoDownloadAndParseURL:(NSString*)url addAnyway:(BOOL)flag modify:(nullable void(^)(Feed *feed))block {
NSManagedObjectContext *moc = [StoreCoordinator createChildContext];
Feed *f = [Feed appendToRootWithDefaultIntervalInContext:moc];
f.meta.url = url;
[self backgroundUpdateBoth:f favicon:YES alert:YES finally:^(BOOL successful){
if (!successful) {
[self backgroundUpdateBoth:f favicon:YES alert:!flag finally:^(BOOL successful){
if (!flag && !successful) {
[moc deleteObject:f.group];
} else if (block) {
block(f); // only on success
}
[StoreCoordinator saveContext:moc andParent:YES];
[moc reset];
if (successful) {
PostNotification(kNotificationGroupInserted, f.group.objectID);
[self scheduleUpdateForUpcomingFeeds];
if (block) block();
}
}];
}
/// Insert Github URL for version releases with update interval 2 days and rename @c FeedGroup item.
+ (void)autoDownloadAndParseUpdateURL {
[self autoDownloadAndParseURL:versionUpdateURL addAnyway:YES modify:^(Feed *feed) {
feed.group.name = NSLocalizedString(@"baRSS releases", nil);
[feed.meta setRefreshAndSchedule:2 * TimeUnitDays];
}];
}
/**
Start download of feed xml, then continue with favicon download (optional).

View File

@@ -60,7 +60,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>10158</string>
<string>10180</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.news</string>
<key>LSMinimumSystemVersion</key>