From eb4228c57fc15cd34faeea62b2af6546b9738b90 Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Thu, 26 Sep 2024 12:02:21 -0700 Subject: [PATCH] #1247 (Mac Catalyst edition) - Settings fix for Sequoia. - Added Delete Account to Logout confirmation; if chosen, logs out and shows the Delete Account web page. - Fixed crash in reloading feed after logging out. --- clients/ios/Classes/Feed.swift | 2 +- clients/ios/Classes/NewsBlurAppDelegate.m | 39 ++++++++++++------- .../ios/Resources/MainInterface.storyboard | 8 ++-- .../mac/Settings.bundle/StoryList.plist | 8 ++-- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/clients/ios/Classes/Feed.swift b/clients/ios/Classes/Feed.swift index 57ef2fc5ec..b47528f1eb 100644 --- a/clients/ios/Classes/Feed.swift +++ b/clients/ios/Classes/Feed.swift @@ -137,7 +137,7 @@ class Feed: Identifiable { var feed: [String : Any]? = appDelegate.dictActiveFeeds[id] as? [String : Any] - if feed == nil { + if feed == nil, appDelegate.dictFeeds != nil { feed = appDelegate.dictFeeds[id] as? [String : Any] } diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index 8873aa5cc6..470c6a2973 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -1927,27 +1927,40 @@ - (NSArray *)feedIdsForFolderTitle:(NSString *)folderTitle { - (void)confirmLogout { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Positive?" message:nil preferredStyle:UIAlertControllerStyleAlert]; + [alertController addAction:[UIAlertAction actionWithTitle: @"Logout" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { [alertController dismissViewControllerAnimated:YES completion:nil]; - NSLog(@"Logging out..."); - NSString *urlString = [NSString stringWithFormat:@"%@/reader/logout?api=1", - self.url]; - [self GET:urlString parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { - [MBProgressHUD hideHUDForView:self.view animated:YES]; - [self showLogin]; - } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { - [MBProgressHUD hideHUDForView:self.view animated:YES]; - }]; - - [MBProgressHUD hideHUDForView:self.view animated:YES]; - MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; - HUD.labelText = @"Logging out..."; + [self actuallyLogout]; }]]; +#if TARGET_OS_MACCATALYST + [alertController addAction:[UIAlertAction actionWithTitle: @"Delete Account" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { + [alertController dismissViewControllerAnimated:YES completion:nil]; + [self actuallyLogout]; + NSURL *url = [NSURL URLWithString:@"https://www.newsblur.com/profile/delete_account"]; + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + }]]; +#endif [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [self.feedsViewController presentViewController:alertController animated:YES completion:nil]; } +- (void)actuallyLogout { + NSLog(@"Logging out..."); + NSString *urlString = [NSString stringWithFormat:@"%@/reader/logout?api=1", + self.url]; + [self GET:urlString parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + [MBProgressHUD hideHUDForView:self.view animated:YES]; + [self showLogin]; + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + [MBProgressHUD hideHUDForView:self.view animated:YES]; + }]; + + [MBProgressHUD hideHUDForView:self.view animated:YES]; + MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + HUD.labelText = @"Logging out..."; +} + - (void)showConnectToService:(NSString *)serviceName { AuthorizeServicesViewController *serviceVC = [[AuthorizeServicesViewController alloc] init]; serviceVC.url = [NSString stringWithFormat:@"/oauth/%@_connect", serviceName]; diff --git a/clients/ios/Resources/MainInterface.storyboard b/clients/ios/Resources/MainInterface.storyboard index b404ac37d1..d7049a8a2d 100644 --- a/clients/ios/Resources/MainInterface.storyboard +++ b/clients/ios/Resources/MainInterface.storyboard @@ -1,9 +1,9 @@ - + - + @@ -15,7 +15,7 @@ - + @@ -900,7 +900,7 @@ - + diff --git a/clients/ios/Resources/mac/Settings.bundle/StoryList.plist b/clients/ios/Resources/mac/Settings.bundle/StoryList.plist index da498cfbce..5be61fac8a 100644 --- a/clients/ios/Resources/mac/Settings.bundle/StoryList.plist +++ b/clients/ios/Resources/mac/Settings.bundle/StoryList.plist @@ -162,7 +162,7 @@ Title Show Infrequent Site Stories DefaultValue - YES + Key show_infrequent_site_stories @@ -172,7 +172,7 @@ Title Show Global Shared Stories DefaultValue - YES + Key show_global_shared_stories @@ -182,7 +182,7 @@ Title Mark stories read on scroll DefaultValue - YES + Key default_scroll_read_filter @@ -192,7 +192,7 @@ Title Show override mark read on scroll DefaultValue - YES + Key override_scroll_read_filter