Skip to content

Commit

Permalink
#1899 (dashboard)
Browse files Browse the repository at this point in the history
- Added NewsBlur Dashboard to top of feeds list.
- Updated StoryCache to cache stories for multiple feeds.
  • Loading branch information
Dejal committed Oct 30, 2024
1 parent 99145a2 commit 4fab57a
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 39 deletions.
1 change: 1 addition & 0 deletions clients/ios/Classes/AddSiteViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ - (NSArray *)folders {
@"widget_stories",
@"river_blurblogs",
@"river_global",
@"dashboard",
@"infrequent",
@"everything"]);
}
Expand Down
7 changes: 5 additions & 2 deletions clients/ios/Classes/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class DetailViewController: BaseViewController {

/// Whether or not using the list layout; see also the previous properties.
@objc var storyTitlesInList: Bool {
return layout == .list
return layout == .list || storyTitlesInDashboard
}

/// Whether or not using the magazine layout; see also the previous properties.
Expand All @@ -128,14 +128,17 @@ class DetailViewController: BaseViewController {

/// Whether or not using the list, magazine, or grid layout; see also the previous properties.
@objc var storyTitlesInGridView: Bool {
return [.list, .magazine, .grid].contains(layout)
return [.list, .magazine, .grid].contains(layout) || storyTitlesInDashboard
}

/// Whether or not using the legacy list for non-grid layout.
@objc var storyTitlesInLegacyTable: Bool {
return !storyTitlesInGridView && style != .experimental
}

/// Whether or not showing the dashboard.
@objc var storyTitlesInDashboard = false

/// Preference values.
enum StyleValue {
static let standard = "standard"
Expand Down
2 changes: 1 addition & 1 deletion clients/ios/Classes/FeedChooserItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (NSString *)identifierString {
- (NSString *)title {
NSString *title = self.info[@"feed_title"];

if ([title isEqualToString:@" "] || [title isEqualToString:@"everything"] || [title isEqualToString:@"infrequent"]) {
if ([title isEqualToString:@" "] || [title isEqualToString:@"dashboard"] || [title isEqualToString:@"everything"] || [title isEqualToString:@"infrequent"]) {
return @"";
} else {
return title;
Expand Down
46 changes: 28 additions & 18 deletions clients/ios/Classes/FeedDetailObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,11 @@ - (void)fetchRiverPage:(int)page withCallback:(void(^)(void))callback {
if (self.pageFetching || self.pageFinished) return;
// NSLog(@"Fetching River in storiesCollection (pg. %ld): %@", (long)page, storiesCollection);

if ([storiesCollection.activeFolder isEqualToString:@"dashboard"]) {
NSLog(@"⚠️ Called fetchRiverPage with dashboard; this should never occur"); // log
return;
}

[self loadingFeed];

storiesCollection.feedPage = page;
Expand Down Expand Up @@ -1861,6 +1866,8 @@ - (void)setTitleForBackButton {
feedTitle = @"All Shared Stories";
} else if ([storiesCollection.activeFolder isEqualToString:@"river_global"]) {
feedTitle = @"Global Shared Stories";
} else if ([storiesCollection.activeFolder isEqualToString:@"dashboard"]) {
feedTitle = @"NewsBlur Dashboard";
} else if ([storiesCollection.activeFolder isEqualToString:@"everything"]) {
feedTitle = @"All Stories";
} else if ([storiesCollection.activeFolder isEqualToString:@"infrequent"]) {
Expand Down Expand Up @@ -2413,7 +2420,7 @@ - (void)markFeedsReadFromTimestamp:(NSInteger)cutoffTimestamp andOlder:(BOOL)old
NSMutableDictionary *params = [NSMutableDictionary dictionary];

if (storiesCollection.isRiverView) {
if ([storiesCollection.activeFolder isEqual:@"everything"] || [storiesCollection.activeFolder isEqual:@"infrequent"]) {
if ([storiesCollection.activeFolder isEqual:@"dashboard"] || [storiesCollection.activeFolder isEqual:@"everything"] || [storiesCollection.activeFolder isEqual:@"infrequent"]) {
for (NSString *folderName in appDelegate.dictFoldersArray) {
for (id feedId in [appDelegate.dictFolders objectForKey:folderName]) {
if (![feedId isKindOfClass:[NSString class]] || ![feedId startsWith:@"saved:"]) {
Expand Down Expand Up @@ -2551,6 +2558,7 @@ - (IBAction)doOpenSettingsMenu:(id)sender {
MenuViewController *viewController = [MenuViewController new];
__weak MenuViewController *weakViewController = viewController;

BOOL dashboard = appDelegate.storiesCollection.isDashboard;
BOOL everything = appDelegate.storiesCollection.isEverything;
BOOL infrequent = appDelegate.storiesCollection.isInfrequent;
BOOL river = [self isRiver];
Expand All @@ -2571,15 +2579,15 @@ - (IBAction)doOpenSettingsMenu:(id)sender {
}
}

if ((!everything || !appDelegate.storiesCollection.isRiverView) && !infrequent && !saved && !read && !social && !widget) {
if ((!dashboard || !everything || !appDelegate.storiesCollection.isRiverView) && !infrequent && !saved && !read && !social && !widget) {
NSString *manageText = [NSString stringWithFormat:@"Manage this %@", appDelegate.storiesCollection.isRiverView ? @"folder" : @"site"];

[viewController addTitle:manageText iconName:@"menu_icn_move.png" selectionShouldDismiss:NO handler:^{
[self manageSite:weakViewController.navigationController manageText:manageText everything:everything];
}];
}

if (!appDelegate.storiesCollection.isRiverView && !infrequent && !saved && !read && !social && !widget) {
if (!appDelegate.storiesCollection.isRiverView && !dashboard && !infrequent && !saved && !read && !social && !widget) {
[viewController addTitle:@"Train this site" iconName:@"menu_icn_train.png" selectionShouldDismiss:YES handler:^{
[self openTrainSite];
}];
Expand All @@ -2592,19 +2600,21 @@ - (IBAction)doOpenSettingsMenu:(id)sender {
}];
}

[viewController addTitle:@"Notifications" iconName:@"dialog-notifications" iconColor:UIColorFromRGB(0xD58B4F) selectionShouldDismiss:YES handler:^{
[self
openNotificationsWithFeed:[NSString stringWithFormat:@"%@", [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"]]];
}];

[viewController addTitle:@"Statistics" iconName:@"menu_icn_statistics.png" selectionShouldDismiss:YES handler:^{
[self
openStatisticsWithFeed:[NSString stringWithFormat:@"%@", [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"]]];
}];

[viewController addTitle:@"Insta-fetch stories" iconName:@"menu_icn_fetch.png" selectionShouldDismiss:YES handler:^{
[self instafetchFeed];
}];
if (!dashboard) {
[viewController addTitle:@"Notifications" iconName:@"dialog-notifications" iconColor:UIColorFromRGB(0xD58B4F) selectionShouldDismiss:YES handler:^{
[self
openNotificationsWithFeed:[NSString stringWithFormat:@"%@", [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"]]];
}];

[viewController addTitle:@"Statistics" iconName:@"menu_icn_statistics.png" selectionShouldDismiss:YES handler:^{
[self
openStatisticsWithFeed:[NSString stringWithFormat:@"%@", [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"]]];
}];

[viewController addTitle:@"Insta-fetch stories" iconName:@"menu_icn_fetch.png" selectionShouldDismiss:YES handler:^{
[self instafetchFeed];
}];
}
}

NSString *preferenceKey = self.appDelegate.storiesCollection.markReadFilterKey;
Expand All @@ -2625,7 +2635,7 @@ - (IBAction)doOpenSettingsMenu:(id)sender {
[self reloadStories];
}];

if (infrequent || !river) {
if (!dashboard || infrequent || !river) {
[viewController addSegmentedControlWithTitles:@[@"All stories", @"Unread only"] selectIndex:[appDelegate.storiesCollection.activeReadFilter isEqualToString:@"all"] ? 0 : 1 selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
if (selectedIndex == 0) {
[userPreferences setObject:@"all" forKey:self.appDelegate.storiesCollection.readFilterKey];
Expand Down Expand Up @@ -3080,7 +3090,7 @@ - (void)openMoveView:(UINavigationController *)menuNavigationController {
if ([title isEqualToString:@"everything"]) {
title = @"Top Level";
iconName = @"menu_icn_all.png";
} else if ([title isEqualToString:@"infrequent"]) {
} else if ([title isEqualToString:@"dashboard"] || [title isEqualToString:@"infrequent"]) {
continue;
} else {
NSArray *components = [title componentsSeparatedByString:@""];
Expand Down
5 changes: 3 additions & 2 deletions clients/ios/Classes/FeedsObjCViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
// indices in appDelegate.dictFoldersArray and button tags
// keep in sync with NewsBlurTopSectionNames
static enum {
NewsBlurTopSectionInfrequentSiteStories = 0,
NewsBlurTopSectionAllStories = 1
NewsBlurTopSectionDashboard = 0,
NewsBlurTopSectionInfrequentSiteStories = 1,
NewsBlurTopSectionAllStories = 2
} NewsBlurTopSection;

@interface FeedsObjCViewController : BaseViewController
Expand Down
19 changes: 14 additions & 5 deletions clients/ios/Classes/FeedsObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

+ (void)initialize {
// keep in sync with NewsBlurTopSection
NewsBlurTopSectionNames = @[/* 0 */ @"infrequent",
/* 1 */ @"everything"];
NewsBlurTopSectionNames = @[/* 0 */ @"dashboard",
/* 1 */ @"infrequent",
/* 2 */ @"everything"];
}

- (void)viewDidLoad {
Expand Down Expand Up @@ -1390,7 +1391,13 @@ - (void)settingsUpdateSpecifierDictionary:(NSMutableDictionary *)dictionary {
[values addObject:@"everything"];

for (NSString *folder in self.appDelegate.dictFoldersArray) {
if ([folder hasPrefix:@"river_"] || [folder isEqualToString:@"everything"] || [folder isEqualToString:@"infrequent"] || [folder isEqualToString:@"widget"] || [folder isEqualToString:@"read_stories"] || [folder hasPrefix:@"saved_"]) {
if ([folder hasPrefix:@"river_"] ||
[folder isEqualToString:@"dashboard"] ||
[folder isEqualToString:@"everything"] ||
[folder isEqualToString:@"infrequent"] ||
[folder isEqualToString:@"widget"] ||
[folder isEqualToString:@"read_stories"] ||
[folder hasPrefix:@"saved_"]) {
continue;
}

Expand Down Expand Up @@ -1912,7 +1919,9 @@ - (CGFloat)tableView:(UITableView *)tableView
NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:section];

BOOL visibleFeeds = [[self.visibleFolders objectForKey:folderName] boolValue];
if (!visibleFeeds && section != NewsBlurTopSectionInfrequentSiteStories && section != NewsBlurTopSectionAllStories &&
if (!visibleFeeds && section != NewsBlurTopSectionDashboard &&
section != NewsBlurTopSectionInfrequentSiteStories &&
section != NewsBlurTopSectionAllStories &&
![folderName isEqualToString:@"river_global"] &&
![folderName isEqualToString:@"river_blurblogs"] &&
![folderName isEqualToString:@"saved_searches"] &&
Expand Down Expand Up @@ -2223,7 +2232,7 @@ - (void)markFeedRead:(NSString *)feedId cutoffDays:(NSInteger)days {
}

- (void)markFeedsRead:(NSArray *)feedIds cutoffDays:(NSInteger)days {
if (feedIds.count == 1 && ([feedIds.firstObject isEqual:@"everything"] || [feedIds.firstObject isEqual:@"infrequent"])) {
if (feedIds.count == 1 && ([feedIds.firstObject isEqual:@"dashboard"] || [feedIds.firstObject isEqual:@"everything"] || [feedIds.firstObject isEqual:@"infrequent"])) {
[self markEverythingReadWithDays:days infrequent:[feedIds.firstObject isEqual:@"infrequent"]];
return;
}
Expand Down
16 changes: 13 additions & 3 deletions clients/ios/Classes/FolderTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ - (void) drawRect:(CGRect)rect {
UIFont *font = [UIFont fontWithName:@"WhitneySSm-Medium" size:boldFontDescriptor.pointSize];
NSInteger titleOffsetY = ((rect.size.height - font.pointSize) / 2) - 1;
NSString *folderTitle;
if (section == NewsBlurTopSectionInfrequentSiteStories) {
if (section == NewsBlurTopSectionDashboard) {
folderTitle = @"NewsBlur Dashboard";
} else if (section == NewsBlurTopSectionInfrequentSiteStories) {
folderTitle = @"Infrequent Site Stories";
} else if (section == NewsBlurTopSectionAllStories) {
folderTitle = @"All Site Stories";
Expand Down Expand Up @@ -179,7 +181,7 @@ - (void) drawRect:(CGRect)rect {
disclosureButton.frame = CGRectMake(customView.frame.size.width - 32, CGRectGetMidY(rect)-disclosureHeight/2-1, disclosureHeight, disclosureHeight);

// Add collapse button to all folders except Everything
if (section != NewsBlurTopSectionInfrequentSiteStories && section != NewsBlurTopSectionAllStories && ![folderName isEqual:@"read_stories"] && ![folderName isEqual:@"river_global"] && ![folderName isEqual:@"widget_stories"]) {
if (section != NewsBlurTopSectionDashboard && section != NewsBlurTopSectionInfrequentSiteStories && section != NewsBlurTopSectionAllStories && ![folderName isEqual:@"read_stories"] && ![folderName isEqual:@"river_global"] && ![folderName isEqual:@"widget_stories"]) {
if (!isFolderCollapsed) {
UIImage *disclosureImage = [UIImage imageNamed:@"disclosure_down.png"];
[disclosureButton setImage:disclosureImage forState:UIControlStateNormal];
Expand Down Expand Up @@ -211,7 +213,15 @@ - (void) drawRect:(CGRect)rect {
int width = 20;
int height = 20;

if (section == NewsBlurTopSectionInfrequentSiteStories) {
if (section == NewsBlurTopSectionDashboard) {
folderImage = [UIImage imageNamed:@"saved-stories"];
if (!appDelegate.isPhone) {
folderImageViewX = 10;
} else {
folderImageViewX = 7;
}
allowLongPress = YES;
} else if (section == NewsBlurTopSectionInfrequentSiteStories) {
folderImage = [UIImage imageNamed:@"ak-icon-infrequent.png"];
if (!appDelegate.isPhone) {
folderImageViewX = 10;
Expand Down
1 change: 1 addition & 0 deletions clients/ios/Classes/MoveSiteViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ - (NSArray *)pickerFolders {
[self.folders addObject:@"— Top Level —"];

for (NSString *folder in appDelegate.dictFoldersArray) {
if ([folder isEqualToString:@"dashboard"]) continue;
if ([folder isEqualToString:@"everything"]) continue;
if ([folder isEqualToString:@"infrequent"]) continue;
if ([folder isEqualToString:@"river_blurblogs"]) continue;
Expand Down
Loading

0 comments on commit 4fab57a

Please sign in to comment.