From dc573293948327aedff9ac4c7726ee1106c45be7 Mon Sep 17 00:00:00 2001 From: Greg O'Neill Date: Mon, 7 Jan 2019 17:04:07 -0500 Subject: [PATCH] Defer the creation of a holds notification state until we have a need to persist that knowledge beyond a single sync session. --- Simplified.xcodeproj/project.pbxproj | 8 ---- Simplified/NYPLAppDelegate.m | 4 +- Simplified/NYPLBookDetailButtonsView.m | 3 -- Simplified/NYPLCatalogNavigationController.m | 2 - Simplified/NYPLHoldsNotificationState.h | 19 --------- Simplified/NYPLHoldsNotificationState.m | 42 -------------------- 6 files changed, 2 insertions(+), 76 deletions(-) delete mode 100644 Simplified/NYPLHoldsNotificationState.h delete mode 100644 Simplified/NYPLHoldsNotificationState.m diff --git a/Simplified.xcodeproj/project.pbxproj b/Simplified.xcodeproj/project.pbxproj index 2e122003b..d61c766a7 100644 --- a/Simplified.xcodeproj/project.pbxproj +++ b/Simplified.xcodeproj/project.pbxproj @@ -143,7 +143,6 @@ 2DEF10BA201ECCEA0082843A /* NYPLMyBooksSimplifiedBearerToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 2DEF10B9201ECCEA0082843A /* NYPLMyBooksSimplifiedBearerToken.m */; }; 2DF321831DC3B83500E1858F /* NYPLAnnotations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DF321821DC3B83500E1858F /* NYPLAnnotations.swift */; }; 2DFAC8ED1CD8DDD1003D9EC0 /* NYPLOPDSCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 2DFAC8EC1CD8DDD1003D9EC0 /* NYPLOPDSCategory.m */; }; - 524DAD78219F652500F4C808 /* NYPLHoldsNotificationState.m in Sources */ = {isa = PBXBuildFile; fileRef = 524DAD77219F652500F4C808 /* NYPLHoldsNotificationState.m */; }; 52545185217A76FF00BBC1B4 /* NYPLUserNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52545184217A76FF00BBC1B4 /* NYPLUserNotifications.swift */; }; 52592BB821220A1100587288 /* NYPLLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 52592BB721220A1100587288 /* NYPLLocalization.m */; }; 5A5B901B1B946FAD002C53E9 /* NYPLReaderContainerDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5A5B901A1B946FAD002C53E9 /* NYPLReaderContainerDelegate.mm */; }; @@ -175,7 +174,6 @@ A823D823192BABA400B55DE2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A823D822192BABA400B55DE2 /* Images.xcassets */; }; A92FB0F921CDCE3D004740F4 /* NYPLReturnPromptHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92FB0F821CDCE3D004740F4 /* NYPLReturnPromptHelper.swift */; }; A93F9F9721CDACF700BD3B0C /* NYPLAppReviewPrompt.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93F9F9621CDACF700BD3B0C /* NYPLAppReviewPrompt.swift */; }; - A9580CA821D5BF3B00BD2CF4 /* NYPLUserNotificationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9580CA721D5BF3B00BD2CF4 /* NYPLUserNotificationDelegate.swift */; }; AE77E7E37D89FB3EED630624 /* NYPLOPDSType.m in Sources */ = {isa = PBXBuildFile; fileRef = AE77EFD5622206475B6715A9 /* NYPLOPDSType.m */; }; AE77E9B832371587493FF281 /* NYPLOPDSEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = AE77E4AF64208439F78B3D73 /* NYPLOPDSEntry.m */; }; AE77EB0CB5B94AEC591E2D91 /* NYPLOPDSLink.m in Sources */ = {isa = PBXBuildFile; fileRef = AE77ECC029F3DABDB46A64EB /* NYPLOPDSLink.m */; }; @@ -490,8 +488,6 @@ 2DF321821DC3B83500E1858F /* NYPLAnnotations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NYPLAnnotations.swift; sourceTree = ""; }; 2DFAC8EB1CD8DDD1003D9EC0 /* NYPLOPDSCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NYPLOPDSCategory.h; sourceTree = ""; }; 2DFAC8EC1CD8DDD1003D9EC0 /* NYPLOPDSCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NYPLOPDSCategory.m; sourceTree = ""; }; - 524DAD72219F628700F4C808 /* NYPLHoldsNotificationState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NYPLHoldsNotificationState.h; sourceTree = ""; }; - 524DAD77219F652500F4C808 /* NYPLHoldsNotificationState.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NYPLHoldsNotificationState.m; sourceTree = ""; }; 52545184217A76FF00BBC1B4 /* NYPLUserNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYPLUserNotifications.swift; sourceTree = ""; }; 52592BB721220A1100587288 /* NYPLLocalization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NYPLLocalization.m; sourceTree = ""; }; 52592BBB21220A4F00587288 /* NYPLLocalization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NYPLLocalization.h; sourceTree = ""; }; @@ -542,7 +538,6 @@ A823D833192BABA400B55DE2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; A92FB0F821CDCE3D004740F4 /* NYPLReturnPromptHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYPLReturnPromptHelper.swift; sourceTree = ""; }; A93F9F9621CDACF700BD3B0C /* NYPLAppReviewPrompt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYPLAppReviewPrompt.swift; sourceTree = ""; }; - A9580CA721D5BF3B00BD2CF4 /* NYPLUserNotificationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYPLUserNotificationDelegate.swift; sourceTree = ""; }; AE77E0F3FB181D0C1529C865 /* NYPLOPDSLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NYPLOPDSLink.h; sourceTree = ""; }; AE77E304AA30ABF2921B6393 /* NYPLOPDSFeed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NYPLOPDSFeed.h; sourceTree = ""; }; AE77E4AF64208439F78B3D73 /* NYPLOPDSEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NYPLOPDSEntry.m; sourceTree = ""; }; @@ -900,8 +895,6 @@ 11C5DCF31976D22F005A9945 /* NYPLHoldsViewController.h */, 11C5DCF41976D22F005A9945 /* NYPLHoldsViewController.m */, 52545184217A76FF00BBC1B4 /* NYPLUserNotifications.swift */, - 524DAD72219F628700F4C808 /* NYPLHoldsNotificationState.h */, - 524DAD77219F652500F4C808 /* NYPLHoldsNotificationState.m */, ); name = Holds; sourceTree = ""; @@ -1464,7 +1457,6 @@ 2DC8D9DC1D09F797007DD125 /* UpdateCheck.swift in Sources */, 11BFDB33199C01F700378691 /* NYPLReaderTOCViewController.m in Sources */, 2D62568B1D412BCB0080A81F /* BundledHTMLViewController.swift in Sources */, - 524DAD78219F652500F4C808 /* NYPLHoldsNotificationState.m in Sources */, 110AF8961961D94D004887C3 /* NYPLBookDetailView.m in Sources */, 0813875A1BC5767F003DEA6A /* UIButton+NYPLAppearanceAdditions.m in Sources */, 1139DA6519C7755D00A07810 /* NYPLBookCoverRegistry.m in Sources */, diff --git a/Simplified/NYPLAppDelegate.m b/Simplified/NYPLAppDelegate.m index 0209df360..f296b7927 100644 --- a/Simplified/NYPLAppDelegate.m +++ b/Simplified/NYPLAppDelegate.m @@ -61,7 +61,7 @@ - (BOOL)application:(__attribute__((unused)) UIApplication *)application // Initialize Offline Requests Queue [NetworkQueue shared]; self.reachabilityManager = [NYPLReachability sharedReachability]; - + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.tintColor = [NYPLConfiguration mainColor]; self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; @@ -71,7 +71,7 @@ - (BOOL)application:(__attribute__((unused)) UIApplication *)application self.window.rootViewController = vc; [self beginCheckingForUpdates]; - + return YES; } diff --git a/Simplified/NYPLBookDetailButtonsView.m b/Simplified/NYPLBookDetailButtonsView.m index 0e196626d..ad65fe71d 100644 --- a/Simplified/NYPLBookDetailButtonsView.m +++ b/Simplified/NYPLBookDetailButtonsView.m @@ -390,9 +390,6 @@ - (void)didSelectRead - (void)didSelectDownload { - if (self.state == NYPLBookButtonsStateCanHold) { -// [NYPLHoldsNotifications verifyAuthorization]; - } self.activityIndicator.center = self.downloadButton.center; [self.delegate didSelectDownloadForBook:self.book]; } diff --git a/Simplified/NYPLCatalogNavigationController.m b/Simplified/NYPLCatalogNavigationController.m index da875c861..cbee0c262 100644 --- a/Simplified/NYPLCatalogNavigationController.m +++ b/Simplified/NYPLCatalogNavigationController.m @@ -177,7 +177,6 @@ - (void)viewDidLoad [super viewDidLoad]; NYPLSettings *settings = [NYPLSettings sharedSettings]; if (settings.userHasSeenWelcomeScreen == YES) { - NYPLLOG(@"RELOAD FROM CATALOG IS BEING RUN"); Account *account = [[AccountsManager sharedInstance] currentAccount]; [[NYPLSettings sharedSettings] setAccountMainFeedURL:[NSURL URLWithString:account.catalogUrl]]; [UIApplication sharedApplication].delegate.window.tintColor = [NYPLConfiguration mainColor]; @@ -212,7 +211,6 @@ - (void)viewDidAppear:(BOOL)animated if (settings.acceptedEULABeforeMultiLibrary == NO) { NYPLWelcomeScreenViewController *welcomeScreenVC = [[NYPLWelcomeScreenViewController alloc] initWithCompletion:^(Account *const account) { - [[NYPLBookRegistry sharedRegistry] save]; [AccountsManager shared].currentAccount = account; [self reloadSelectedLibraryAccount]; diff --git a/Simplified/NYPLHoldsNotificationState.h b/Simplified/NYPLHoldsNotificationState.h deleted file mode 100644 index c4aa7cf1b..000000000 --- a/Simplified/NYPLHoldsNotificationState.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// NYPLHoldsNotificationState.h -// Simplified -// -// Created by Vui Nguyen on 11/16/18. -// Copyright © 2018 NYPL Labs. All rights reserved. -// - -typedef NS_ENUM(NSInteger, NYPLHoldsNotificationState) { - NYPLHoldsNotificationStateNotApplicable, - NYPLHoldsNotificationStateReadyForFirstNotification, - NYPLHoldsNotificationStateFirstNotificationSent, - NYPLHoldsNotificationStateReadyForFinalNotification, - NYPLHoldsNotificationStateFinalNotificationSent -}; - -NYPLHoldsNotificationState NYPLHoldsNotificationStateFromString(NSString *holdsNotificationString); - -NSString *NYPLHoldsNotificationStateToString(NYPLHoldsNotificationState holdsNotificationState); diff --git a/Simplified/NYPLHoldsNotificationState.m b/Simplified/NYPLHoldsNotificationState.m deleted file mode 100644 index 754a46130..000000000 --- a/Simplified/NYPLHoldsNotificationState.m +++ /dev/null @@ -1,42 +0,0 @@ -// -// NYPLHoldsNotificationState.m -// SimplyE -// -// Created by Vui Nguyen on 11/16/18. -// Copyright © 2018 NYPL Labs. All rights reserved. -// - -#import "NYPLHoldsNotificationState.h" - -static NSString *const NotApplicable = @"not-applicable"; -static NSString *const ReadyForFirstNotification = @"ready-for-first-notification"; -static NSString *const FirstNotificationSent = @"first-notification-sent"; -static NSString *const ReadyForFinalNotification = @"ready-for-final-notification"; -static NSString *const FinalNotificationSent = @"final-notification-sent"; - -NYPLHoldsNotificationState NYPLHoldsNotificationStateFromString(NSString *string) -{ - if([string isEqualToString:NotApplicable]) return NYPLHoldsNotificationStateNotApplicable; - if([string isEqualToString:ReadyForFirstNotification]) return NYPLHoldsNotificationStateReadyForFirstNotification; - if([string isEqualToString:FirstNotificationSent]) return NYPLHoldsNotificationStateFirstNotificationSent; - if([string isEqualToString:ReadyForFinalNotification]) return NYPLHoldsNotificationStateReadyForFinalNotification; - if([string isEqualToString:FinalNotificationSent]) return NYPLHoldsNotificationStateFinalNotificationSent; - - @throw NSInvalidArgumentException; -} - -NSString *NYPLHoldsNotificationStateToString(NYPLHoldsNotificationState state) -{ - switch(state) { - case NYPLHoldsNotificationStateNotApplicable: - return NotApplicable; - case NYPLHoldsNotificationStateReadyForFirstNotification: - return ReadyForFirstNotification; - case NYPLHoldsNotificationStateFirstNotificationSent: - return FirstNotificationSent; - case NYPLHoldsNotificationStateReadyForFinalNotification: - return ReadyForFinalNotification; - case NYPLHoldsNotificationStateFinalNotificationSent: - return FinalNotificationSent; - } -}