Feed icons! '/favicon.ico' download, storage and display.
This commit is contained in:
@@ -110,14 +110,21 @@
|
||||
Set @c scheduled to a new date if refresh interval was changed.
|
||||
*/
|
||||
- (void)applyChangesToCoreDataObject {
|
||||
FeedMeta *meta = self.feedGroup.feed.meta;
|
||||
Feed *feed = self.feedGroup.feed;
|
||||
FeedMeta *meta = feed.meta;
|
||||
BOOL intervalChanged = [meta setURL:self.previousURL refresh:self.refreshNum.intValue unit:(int16_t)self.refreshUnit.indexOfSelectedItem];
|
||||
if (intervalChanged)
|
||||
[meta calculateAndSetScheduled]; // updateTimer will be scheduled once preferences is closed
|
||||
[self.feedGroup setName:self.name.stringValue andRefreshString:[meta readableRefreshString]];
|
||||
if (self.didDownloadFeed) {
|
||||
[meta setEtag:self.httpEtag modified:self.httpDate];
|
||||
[self.feedGroup.feed updateWithRSS:self.feedResult postUnreadCountChange:YES];
|
||||
[feed updateWithRSS:self.feedResult postUnreadCountChange:YES];
|
||||
}
|
||||
if (!feed.icon) {
|
||||
NSString *faviconURL = feed.link;
|
||||
if (faviconURL.length == 0)
|
||||
faviconURL = meta.url;
|
||||
[FeedDownload backgroundDownloadFavicon:faviconURL forFeed:feed];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +159,6 @@
|
||||
self.httpEtag = [response allHeaderFields][@"Etag"];
|
||||
self.httpDate = [response allHeaderFields][@"Date"]; // @"Expires", @"Last-Modified"
|
||||
[self updateTextFieldURL:response.URL.absoluteString andTitle:result.title];
|
||||
// TODO: add icon download
|
||||
// TODO: play error sound?
|
||||
[self.spinnerURL stopAnimation:nil];
|
||||
[self.spinnerName stopAnimation:nil];
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#import "SettingsFeeds.h"
|
||||
#import "Constants.h"
|
||||
#import "DrawImage.h"
|
||||
#import "StoreCoordinator.h"
|
||||
#import "ModalFeedEdit.h"
|
||||
#import "Feed+Ext.h"
|
||||
@@ -52,12 +51,31 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
|
||||
|
||||
self.dataStore.managedObjectContext = [StoreCoordinator createChildContext];
|
||||
self.dataStore.managedObjectContext.undoManager = self.undoManager;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(faviconDownloadFinished:) name:kNotificationFaviconDownloadFinished object:nil];
|
||||
}
|
||||
|
||||
- (void)saveChanges {
|
||||
[StoreCoordinator saveContext:self.dataStore.managedObjectContext andParent:YES];
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
/**
|
||||
Called when the backgroud download of a favicon finished.
|
||||
Notification object contains the updated @c Feed (object id).
|
||||
*/
|
||||
- (void)faviconDownloadFinished:(NSNotification*)notify {
|
||||
if ([notify.object isKindOfClass:[NSManagedObjectID class]]) {
|
||||
// TODO: Bug: Freshly ownloaded images are deleted on undo. Remove delete cascade rule?
|
||||
NSManagedObject *mo = [self.dataStore.managedObjectContext objectWithID:notify.object];
|
||||
if (!mo) return;
|
||||
[self.dataStore.managedObjectContext refreshObject:mo mergeChanges:YES];
|
||||
[self.dataStore rearrangeObjects];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UI Button Interaction
|
||||
|
||||
|
||||
- (IBAction)addFeed:(id)sender {
|
||||
[self showModalForFeedGroup:nil isGroupEdit:NO];
|
||||
}
|
||||
@@ -95,9 +113,14 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Insert & Edit Feed Items
|
||||
#pragma mark - Insert & Edit Feed Items / Modal Dialog
|
||||
|
||||
|
||||
/// Save core data changes of current object context to persistent store
|
||||
- (void)saveChanges {
|
||||
[StoreCoordinator saveContext:self.dataStore.managedObjectContext andParent:YES];
|
||||
}
|
||||
|
||||
/**
|
||||
Open a new modal window to edit the selected @c FeedGroup.
|
||||
@note isGroupEdit @c flag will be overwritten if @c FeedGroup parameter is not @c nil.
|
||||
@@ -134,9 +157,6 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Helper -
|
||||
|
||||
/// Insert @c FeedGroup item either after current selection or inside selected folder (if expanded)
|
||||
- (FeedGroup*)insertFeedGroupAtSelection:(FeedGroupType)type {
|
||||
FeedGroup *fg = [FeedGroup newGroup:type inContext:self.dataStore.managedObjectContext];
|
||||
@@ -270,16 +290,7 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
|
||||
return cellView; // the refresh cell is already skipped with the above if condition
|
||||
} else {
|
||||
cellView.textField.objectValue = fg.name;
|
||||
if (fg.typ == GROUP) {
|
||||
cellView.imageView.image = [NSImage imageNamed:NSImageNameFolder];
|
||||
} else {
|
||||
// TODO: load icon
|
||||
static NSImage *defaultRSSIcon;
|
||||
if (!defaultRSSIcon)
|
||||
defaultRSSIcon = [RSSIcon iconWithSize:cellView.imageView.frame.size.height];
|
||||
|
||||
cellView.imageView.image = defaultRSSIcon;
|
||||
}
|
||||
cellView.imageView.image = (fg.typ == GROUP ? [NSImage imageNamed:NSImageNameFolder] : [fg.feed iconImage16]);
|
||||
}
|
||||
// also for refresh column
|
||||
cellView.textField.textColor = (isFeed && refreshDisabled ? [NSColor disabledControlTextColor] : [NSColor controlTextColor]);
|
||||
|
||||
Reference in New Issue
Block a user