@@ -663,14 +663,14 @@ - (void) viewWillAppear:(BOOL)animated {
663
663
664
664
- (void ) _rateNow : (id )argument {
665
665
[[AppDelegate sharedDelegate ] logEvent: @" rating.now" ];
666
- [[NSUserDefaults standardUserDefaults ] setInteger: -1 forKey: kDefaultUserKey_LaunchCount ];
666
+ [[NSUserDefaults standardUserDefaults ] setInteger: -1 forKey: kDefaultKey_LaunchCount ];
667
667
668
668
[[UIApplication sharedApplication ] openURL: [NSURL URLWithString: [[NSBundle mainBundle ] objectForInfoDictionaryKey: @" iTunesURL" ]]];
669
669
}
670
670
671
671
- (void ) _rateLater : (id )argument {
672
672
[[AppDelegate sharedDelegate ] logEvent: @" rating.later" ];
673
- [[NSUserDefaults standardUserDefaults ] setInteger: 0 forKey: kDefaultUserKey_LaunchCount ];
673
+ [[NSUserDefaults standardUserDefaults ] setInteger: 0 forKey: kDefaultKey_LaunchCount ];
674
674
}
675
675
676
676
- (void ) _showRatingScreen {
@@ -686,7 +686,19 @@ - (void) _showRatingScreen {
686
686
[[UIApplication sharedApplication ] endIgnoringInteractionEvents ];
687
687
}
688
688
689
+ - (void ) _requireUpdate {
690
+ [self _forceUpdate ];
691
+ [[NSUserDefaults standardUserDefaults ] setInteger: kLibraryVersion forKey: kDefaultKey_LibraryVersion ];
692
+ }
693
+
689
694
- (void ) _viewDidReallyAppear {
695
+ BOOL needLibraryUpdate = [[NSUserDefaults standardUserDefaults ] integerForKey: kDefaultKey_LibraryVersion ] != kLibraryVersion ;
696
+ if (needLibraryUpdate) {
697
+ LOG_VERBOSE (@" Library is outdated at version %i " , [[NSUserDefaults standardUserDefaults ] integerForKey: kDefaultKey_LibraryVersion ]);
698
+ [_currentComic release ];
699
+ _currentComic = nil ;
700
+ }
701
+
690
702
if (_currentComic) {
691
703
Comic* comic = [[_currentComic retain ] autorelease ];
692
704
[_currentComic release ];
@@ -707,16 +719,27 @@ - (void) _viewDidReallyAppear {
707
719
}];
708
720
_launchView = nil ;
709
721
710
- NSInteger count = [[NSUserDefaults standardUserDefaults ] integerForKey: kDefaultUserKey_LaunchCount ];
722
+ NSInteger count = [[NSUserDefaults standardUserDefaults ] integerForKey: kDefaultKey_LaunchCount ];
711
723
if (count >= 0 ) {
712
- [[NSUserDefaults standardUserDefaults ] setInteger: (count + 1 ) forKey: kDefaultUserKey_LaunchCount ];
713
- if ((count + 1 >= kLaunchCountBeforeRating ) && !self.modalViewController && [[NetReachability sharedNetReachability ] state ]) {
724
+ [[NSUserDefaults standardUserDefaults ] setInteger: (count + 1 ) forKey: kDefaultKey_LaunchCount ];
725
+ if (!needLibraryUpdate && (count + 1 >= kLaunchCountBeforeRating ) && !self.modalViewController && [[NetReachability sharedNetReachability ] state ]) {
714
726
[[UIApplication sharedApplication ] beginIgnoringInteractionEvents ];
715
727
[self performSelector: @selector (_showRatingScreen ) withObject: nil afterDelay: kShowRatingDelay ];
716
728
} else {
717
- LOG_VERBOSE (@" Launch count is now %i " , [[NSUserDefaults standardUserDefaults ] integerForKey: kDefaultUserKey_LaunchCount ]);
729
+ LOG_VERBOSE (@" Launch count is now %i " , [[NSUserDefaults standardUserDefaults ] integerForKey: kDefaultKey_LaunchCount ]);
718
730
}
719
731
}
732
+
733
+ if (needLibraryUpdate) {
734
+ [[AppDelegate sharedInstance ] showAlertWithTitle: NSLocalizedString(@" REQUIRE_UPDATE_TITLE" , nil )
735
+ message: NSLocalizedString(@" REQUIRE_UPDATE_MESSAGE" , nil )
736
+ confirmButton: NSLocalizedString(@" REQUIRE_UPDATE_CONTINUE" , nil )
737
+ cancelButton: NSLocalizedString(@" REQUIRE_UPDATE_CANCEL" , nil )
738
+ delegate: self
739
+ confirmSelector: @selector (_requireUpdate )
740
+ cancelSelector: NULL
741
+ argument: nil ];
742
+ }
720
743
}
721
744
722
745
- (void ) viewDidAppear : (BOOL )animated {
@@ -749,6 +772,13 @@ - (void) saveState {
749
772
[[NSUserDefaults standardUserDefaults ] setInteger: _currentComic.sqlRowID forKey: kDefaultKey_CurrentComic ];
750
773
}
751
774
775
+ - (void ) _forceUpdate {
776
+ LoggingPurgeHistory (0.0 );
777
+ [[LibraryUpdater sharedUpdater ] update: YES ];
778
+ [self _updateStatistics ];
779
+ [self _setCurrentCollection: nil ];
780
+ }
781
+
752
782
@end
753
783
754
784
@implementation LibraryViewController (LibraryUpdaterDelegate)
@@ -921,13 +951,6 @@ - (IBAction) update:(id)sender {
921
951
[[LibraryUpdater sharedUpdater ] update: NO ];
922
952
}
923
953
924
- - (void ) _forceUpdate {
925
- LoggingPurgeHistory (0.0 );
926
- [[LibraryUpdater sharedUpdater ] update: YES ];
927
- [self _updateStatistics ];
928
- [self _setCurrentCollection: nil ];
929
- }
930
-
931
954
- (IBAction ) forceUpdate : (id )sender {
932
955
[[AppDelegate sharedInstance ] showAlertWithTitle: NSLocalizedString(@" FORCE_UPDATE_TITLE" , nil )
933
956
message: NSLocalizedString(@" FORCE_UPDATE_MESSAGE" , nil )
0 commit comments