Bgerstle has submitted this change and it was merged.

Change subject: Fix for Bug T96450 - history is rewritten when refreshing
......................................................................


Fix for Bug T96450 - history is rewritten when refreshing

- Added new discovery method: MWKHistoryDiscoveryMethodReload
- Use new discovery method throughout the code to determine what to do.
- Add discoveryMethod ivar so it can be tracked throughout the process of 
displaying an article.
- Fix case where navigating by long press on history would also destroy forward 
navigation.
- Fix case where "network connection unavailable banner" would stay visible 
even after the connection was restored and a page successfully loaded
- Move history updating to the last step of displaying an article so it no 
longer needs to be removed in case of failure.
- Remove "invalidate cache" option when reloading page. Reloading ALWAYS 
invalidates the cache.
(it was just bastardizing existing discovery enums to bend the cache 
invalidation logic to its will)
- Removed straggling ivar "didLastNavigateByBackOrForward" - check for the 
discovery method instead
(This was duplicative of the purpose of the 
MWKHistoryDiscoveryMethodBackForward)
- Rename MWKHistoryDiscoveryMethod enum values (they were snake up-cased)
- Use NS_ENUM macro
- Add a method on MWKArticle to determine if it has been cached or not
- Make -[UIViewController hideAlert] a no-op if the view isn't loaded

Change-Id: I2ad1b980535ae6476062193a67ae4888907ba10d
---
M MediaWikiKit/MediaWikiKit/MWKArticle.h
M MediaWikiKit/MediaWikiKit/MWKArticle.m
M MediaWikiKit/MediaWikiKit/MWKHistoryEntry.h
M MediaWikiKit/MediaWikiKit/MWKHistoryEntry.m
M MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
M MediaWikiKit/MediaWikiKitTests/MWKImageListTests.m
M Wikipedia.xcodeproj/project.pbxproj
M Wikipedia/Categories/Alerts/UIViewController+Alert.m
M Wikipedia/Session/SessionSingleton.h
M Wikipedia/View Controllers/History/HistoryViewController.m
M Wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m
M Wikipedia/View Controllers/Navigation/Center/CenterNavController.m
M Wikipedia/View Controllers/Nearby/NearbyViewController.m
M Wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
M Wikipedia/View Controllers/References/ReferenceVC.m
M Wikipedia/View Controllers/SavedPages/SavedPagesViewController.m
M Wikipedia/View Controllers/SearchResults/SearchResultsController.m
M Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Legal/WMFLegalFooterViewController.m
M Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Options/WMFOptionsFooterViewController.m
M Wikipedia/View Controllers/WebView/WebViewController.h
M Wikipedia/View Controllers/WebView/WebViewController.m
M Wikipedia/View Controllers/WebView/WebViewController_Private.h
M WikipediaUnitTests/ArticleLoadingTests.m
R WikipediaUnitTests/Utilities/WMFRandomFileUtilities.h
R WikipediaUnitTests/Utilities/WMFRandomFileUtilities.m
25 files changed, 157 insertions(+), 136 deletions(-)

Approvals:
  Bgerstle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MediaWikiKit/MediaWikiKit/MWKArticle.h 
b/MediaWikiKit/MediaWikiKit/MWKArticle.h
index 1cae18f..0c7bdd3 100644
--- a/MediaWikiKit/MediaWikiKit/MWKArticle.h
+++ b/MediaWikiKit/MediaWikiKit/MWKArticle.h
@@ -81,4 +81,6 @@
 - (void)saveWithoutSavingSectionText;
 - (void)remove;
 
+- (BOOL)isCached;
+
 @end
diff --git a/MediaWikiKit/MediaWikiKit/MWKArticle.m 
b/MediaWikiKit/MediaWikiKit/MWKArticle.m
index 087c230..b6355c8 100644
--- a/MediaWikiKit/MediaWikiKit/MWKArticle.m
+++ b/MediaWikiKit/MediaWikiKit/MWKArticle.m
@@ -221,6 +221,10 @@
     return _sections;
 }
 
+- (BOOL)isCached {
+    return [self.sections count] > 0 ? YES : NO;
+}
+
 #pragma mark - protection status methods
 
 - (MWKProtectionStatus*)requiredProtectionStatus:(NSString*)key 
dict:(NSDictionary*)dict {
diff --git a/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.h 
b/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.h
index 5bf1ff5..34cd119 100644
--- a/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.h
+++ b/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.h
@@ -10,14 +10,15 @@
 
 @class MWKTitle;
 
-typedef enum {
-    MWK_DISCOVERY_METHOD_SEARCH,
-    MWK_DISCOVERY_METHOD_RANDOM,
-    MWK_DISCOVERY_METHOD_LINK,
-    MWK_DISCOVERY_METHOD_BACKFORWARD,
-    MWK_DISCOVERY_METHOD_SAVED,
-    MWK_DISCOVERY_METHOD_UNKNOWN // reserved
-} MWKHistoryDiscoveryMethod;
+typedef NS_ENUM (NSUInteger, MWKHistoryDiscoveryMethod){
+    MWKHistoryDiscoveryMethodSearch,
+    MWKHistoryDiscoveryMethodRandom,
+    MWKHistoryDiscoveryMethodLink,
+    MWKHistoryDiscoveryMethodBackForward,
+    MWKHistoryDiscoveryMethodSaved,
+    MWKHistoryDiscoveryMethodReload,
+    MWKHistoryDiscoveryMethodUnknown
+};
 
 @interface MWKHistoryEntry : MWKSiteDataObject
 
diff --git a/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.m 
b/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.m
index 0742f0d..d8afc72 100644
--- a/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.m
+++ b/MediaWikiKit/MediaWikiKit/MWKHistoryEntry.m
@@ -73,15 +73,15 @@
 
 + 
(NSString*)stringForDiscoveryMethod:(MWKHistoryDiscoveryMethod)discoveryMethod {
     switch (discoveryMethod) {
-        case MWK_DISCOVERY_METHOD_SEARCH:
+        case MWKHistoryDiscoveryMethodSearch:
             return @"search";
-        case MWK_DISCOVERY_METHOD_RANDOM:
+        case MWKHistoryDiscoveryMethodRandom:
             return @"random";
-        case MWK_DISCOVERY_METHOD_LINK:
+        case MWKHistoryDiscoveryMethodLink:
             return @"link";
-        case MWK_DISCOVERY_METHOD_BACKFORWARD:
+        case MWKHistoryDiscoveryMethodBackForward:
             return @"backforward";
-        case MWK_DISCOVERY_METHOD_SAVED:
+        case MWKHistoryDiscoveryMethodSaved:
             return @"saved";
         default:
             return @"unknown";
@@ -90,17 +90,17 @@
 
 + (MWKHistoryDiscoveryMethod)discoveryMethodForString:(NSString*)string {
     if ([string isEqualToString:@"search"]) {
-        return MWK_DISCOVERY_METHOD_SEARCH;
+        return MWKHistoryDiscoveryMethodSearch;
     } else if ([string isEqualToString:@"random"]) {
-        return MWK_DISCOVERY_METHOD_RANDOM;
+        return MWKHistoryDiscoveryMethodRandom;
     } else if ([string isEqualToString:@"link"]) {
-        return MWK_DISCOVERY_METHOD_LINK;
+        return MWKHistoryDiscoveryMethodLink;
     } else if ([string isEqualToString:@"backforward"]) {
-        return MWK_DISCOVERY_METHOD_BACKFORWARD;
+        return MWKHistoryDiscoveryMethodBackForward;
     } else if ([string isEqualToString:@"saved"]) {
-        return MWK_DISCOVERY_METHOD_SAVED;
+        return MWKHistoryDiscoveryMethodSaved;
     } else {
-        return MWK_DISCOVERY_METHOD_UNKNOWN;
+        return MWKHistoryDiscoveryMethodUnknown;
     }
 }
 
diff --git a/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m 
b/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
index c598e44..2f09f90 100644
--- a/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
+++ b/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
@@ -44,24 +44,24 @@
 
 - (void)testAddCount {
     MWKHistoryEntry* entry = [[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                    discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH];
+                                                    discoveryMethod 
:MWKHistoryDiscoveryMethodSearch];
     [historyList addEntry:entry];
     XCTAssertEqual(historyList.length, 1, @"Should have length 1 after 
adding");
 }
 
 - (void)testAddCount2 {
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleLAEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     XCTAssertEqual(historyList.length, 2, @"Should have length 2 after 
adding");
 }
 
 - (void)testAddCount2Same {
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     XCTAssertEqual(historyList.length, 1, @"Should have length 1 after adding 
a duplicate, not 2");
 }
 
@@ -69,17 +69,17 @@
     MWKTitle* title1 = [titleSFEn.site titleWithString:@"This is a title"];
     MWKTitle* title2 = [titleSFEn.site titleWithString:@"This is a title"];
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:title1
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:title2
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     XCTAssertEqual(historyList.length, 1, @"Should have length 1 after adding 
a duplicate, not 2");
 }
 
 - (void)testAddCount2DiffLanguages {
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFFr
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     XCTAssertEqual(historyList.length, 2, @"Should have length 2 after adding 
a duplicate in another language, not 1");
 }
 
@@ -89,22 +89,22 @@
 
 - (void)testEmptyDirtyAfterAdd {
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     XCTAssertTrue(historyList.dirty, @"Should be dirty after adding");
 }
 
 - (void)testEmptyNotDirtyAfterAddAndSave {
     [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                 discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH]];
+                                                 discoveryMethod 
:MWKHistoryDiscoveryMethodSearch]];
     (void)[historyList dataExport];
     XCTAssertFalse(historyList.dirty, @"Should not be dirty after adding then 
exporting");
 }
 
 - (void)testAdd2ThenRemove {
     MWKHistoryEntry* entry1 = [[MWKHistoryEntry alloc] initWithTitle:titleSFEn
-                                                     discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH];
+                                                     discoveryMethod 
:MWKHistoryDiscoveryMethodSearch];
     MWKHistoryEntry* entry2 = [[MWKHistoryEntry alloc] initWithTitle:titleLAEn
-                                                     discoveryMethod 
:MWK_DISCOVERY_METHOD_SEARCH];
+                                                     discoveryMethod 
:MWKHistoryDiscoveryMethodSearch];
     [historyList addEntry:entry1];
     [historyList addEntry:entry2];
     [historyList removeEntry:entry1];
diff --git a/MediaWikiKit/MediaWikiKitTests/MWKImageListTests.m 
b/MediaWikiKit/MediaWikiKitTests/MWKImageListTests.m
index 1ecac44..fac89f2 100644
--- a/MediaWikiKit/MediaWikiKitTests/MWKImageListTests.m
+++ b/MediaWikiKit/MediaWikiKitTests/MWKImageListTests.m
@@ -46,7 +46,7 @@
     [article.sections setSections:mock([MWKSection class])];
 
     NSArray* dummySourceURLs = [@[@"10px-a.jpg", @"10px-b.jpg", 
@"100px-a.jpg", @"10px-c.jpg"] bk_map :^id (id obj) {
-        return [MWKDataStoreValidImageSitePrefix stringByAppendingString:obj];
+        return MWKCreateImageURLWithPath(obj);
     }];
 
     [dummySourceURLs bk_each:^(NSString* sourceURL) {
diff --git a/Wikipedia.xcodeproj/project.pbxproj 
b/Wikipedia.xcodeproj/project.pbxproj
index dcad244..df376b9 100644
--- a/Wikipedia.xcodeproj/project.pbxproj
+++ b/Wikipedia.xcodeproj/project.pbxproj
@@ -232,7 +232,6 @@
                BC92A7731AFA88D3003C4212 /* MWKSection+WMFSharingTests.m in 
Sources */ = {isa = PBXBuildFile; fileRef = BC92A7721AFA88D3003C4212 /* 
MWKSection+WMFSharingTests.m */; };
                BC955BC71A82BEFD000EF9E4 /* MWKImageInfoFetcher.m in Sources */ 
= {isa = PBXBuildFile; fileRef = BC955BC61A82BEFD000EF9E4 /* 
MWKImageInfoFetcher.m */; };
                BC955BCF1A82C2FA000EF9E4 /* 
AFHTTPRequestOperationManager+WMFConfig.m in Sources */ = {isa = PBXBuildFile; 
fileRef = BC955BCE1A82C2FA000EF9E4 /* AFHTTPRequestOperationManager+WMFConfig.m 
*/; };
-               BCA676491AC05EDF00A16160 /* WMFRandomFileUtilities.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCA676481AC05EDF00A16160 /* 
WMFRandomFileUtilities.m */; };
                BCA6764E1AC05FD600A16160 /* Info.plist in Resources */ = {isa = 
PBXBuildFile; fileRef = BCA6764D1AC05FD600A16160 /* Info.plist */; };
                BCA676561AC05FE200A16160 /* NSBundle+TestAssets.m in Sources */ 
= {isa = PBXBuildFile; fileRef = BCA676521AC05FE200A16160 /* 
NSBundle+TestAssets.m */; };
                BCA676571AC05FE200A16160 /* XCTestCase+WMFBundleConvenience.m 
in Sources */ = {isa = PBXBuildFile; fileRef = BCA676541AC05FE200A16160 /* 
XCTestCase+WMFBundleConvenience.m */; };
@@ -245,6 +244,7 @@
                BCAFC5D01AFD5E7D004615BA /* MWKArticle+WMFSharingTests.m in 
Sources */ = {isa = PBXBuildFile; fileRef = BCAFC5CF1AFD5E7D004615BA /* 
MWKArticle+WMFSharingTests.m */; };
                BCAFC5D31AFD5F7E004615BA /* MWKArticle+WMFSharing.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCAFC5D11AFD5F7E004615BA /* 
MWKArticle+WMFSharing.m */; };
                BCAFC5D61AFD625E004615BA /* MainPageMobileView.json in 
Resources */ = {isa = PBXBuildFile; fileRef = BCAFC5D51AFD625E004615BA /* 
MainPageMobileView.json */; };
+               BCAFC5ED1B02490A004615BA /* WMFRandomFileUtilities.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCAFC5EC1B02490A004615BA /* 
WMFRandomFileUtilities.m */; };
                BCB3AE861AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.m in Sources */ = {isa = 
PBXBuildFile; fileRef = BCB3AE851AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.m */; };
                BCB3AE8A1AC11458004AD205 /* 
NSManagedObjectContext+WMFTempContext.m in Sources */ = {isa = PBXBuildFile; 
fileRef = BCB3AE891AC11458004AD205 /* NSManagedObjectContext+WMFTempContext.m 
*/; };
                BCB3AEA71AC1DDE4004AD205 /* OldDataSchemaMigrator.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCB3AEA61AC1DDE4004AD205 /* 
OldDataSchemaMigrator.m */; };
@@ -773,8 +773,6 @@
                BC955BC61A82BEFD000EF9E4 /* MWKImageInfoFetcher.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= MWKImageInfoFetcher.m; sourceTree = "<group>"; };
                BC955BCD1A82C2FA000EF9E4 /* 
AFHTTPRequestOperationManager+WMFConfig.h */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
"AFHTTPRequestOperationManager+WMFConfig.h"; path = 
"Queues/AFHTTPRequestOperationManager+WMFConfig.h"; sourceTree = "<group>"; };
                BC955BCE1A82C2FA000EF9E4 /* 
AFHTTPRequestOperationManager+WMFConfig.m */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = 
"AFHTTPRequestOperationManager+WMFConfig.m"; path = 
"Queues/AFHTTPRequestOperationManager+WMFConfig.m"; sourceTree = "<group>"; };
-               BCA676471AC05EDF00A16160 /* WMFRandomFileUtilities.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path 
= WMFRandomFileUtilities.h; sourceTree = "<group>"; };
-               BCA676481AC05EDF00A16160 /* WMFRandomFileUtilities.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = WMFRandomFileUtilities.m; sourceTree = "<group>"; };
                BCA6764A1AC05FAD00A16160 /* NSArray+PredicateTests.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = "NSArray+PredicateTests.m"; sourceTree = "<group>"; };
                BCA6764D1AC05FD600A16160 /* Info.plist */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = 
Info.plist; sourceTree = "<group>"; };
                BCA676511AC05FE200A16160 /* NSBundle+TestAssets.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"NSBundle+TestAssets.h"; sourceTree = "<group>"; };
@@ -796,6 +794,8 @@
                BCAFC5D11AFD5F7E004615BA /* MWKArticle+WMFSharing.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= "MWKArticle+WMFSharing.m"; sourceTree = "<group>"; };
                BCAFC5D21AFD5F7E004615BA /* MWKArticle+WMFSharing.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"MWKArticle+WMFSharing.h"; sourceTree = "<group>"; };
                BCAFC5D51AFD625E004615BA /* MainPageMobileView.json */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = 
MainPageMobileView.json; path = Fixtures/MainPageMobileView.json; sourceTree = 
"<group>"; };
+               BCAFC5EB1B02490A004615BA /* WMFRandomFileUtilities.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path 
= WMFRandomFileUtilities.h; sourceTree = "<group>"; };
+               BCAFC5EC1B02490A004615BA /* WMFRandomFileUtilities.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = WMFRandomFileUtilities.m; sourceTree = "<group>"; };
                BCB3AE841AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.h */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"NSPersistentStoreCoordinator+WMFTempCoordinator.h"; sourceTree = "<group>"; };
                BCB3AE851AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.m */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = 
"NSPersistentStoreCoordinator+WMFTempCoordinator.m"; sourceTree = "<group>"; };
                BCB3AE881AC11458004AD205 /* 
NSManagedObjectContext+WMFTempContext.h */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"NSManagedObjectContext+WMFTempContext.h"; sourceTree = "<group>"; };
@@ -1216,8 +1216,6 @@
                                040D835C1AB0EE45000896D5 /* WMFGeometry.c */,
                                0484B9041ABB50FA00874073 /* WMFArticleParsing.h 
*/,
                                0484B9051ABB50FA00874073 /* WMFArticleParsing.m 
*/,
-                               BCA676471AC05EDF00A16160 /* 
WMFRandomFileUtilities.h */,
-                               BCA676481AC05EDF00A16160 /* 
WMFRandomFileUtilities.m */,
                        );
                        name = "C Functions";
                        path = "C Methods";
@@ -2101,6 +2099,8 @@
                BCA6764F1AC05FE200A16160 /* Utilities */ = {
                        isa = PBXGroup;
                        children = (
+                               BCAFC5EB1B02490A004615BA /* 
WMFRandomFileUtilities.h */,
+                               BCAFC5EC1B02490A004615BA /* 
WMFRandomFileUtilities.m */,
                                BC282E271AE7FBB1005A5277 /* 
WMFTestFixtureUtilities.h */,
                                BC7ACB621AB34C9C00791497 /* WMFAsyncTestCase.h 
*/,
                                BC7ACB631AB34C9C00791497 /* WMFAsyncTestCase.m 
*/,
@@ -2937,6 +2937,7 @@
                                BC0FED671AAA0268002488D7 /* MWKTitleTests.m in 
Sources */,
                                BC0FED631AAA0263002488D7 /* MWKTestCase.m in 
Sources */,
                                BC92A7731AFA88D3003C4212 /* 
MWKSection+WMFSharingTests.m in Sources */,
+                               BCAFC5ED1B02490A004615BA /* 
WMFRandomFileUtilities.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -3086,7 +3087,6 @@
                                C94BE3EE1A8169ED00F2105B /* WMFShareFunnel.m in 
Sources */,
                                BCB58F671A8AA22200465627 /* 
MWKLicense+ToGlyph.m in Sources */,
                                04C757671A1A9E1B0084AC39 /* 
RecentSearchesViewController.m in Sources */,
-                               BCA676491AC05EDF00A16160 /* 
WMFRandomFileUtilities.m in Sources */,
                                04C43AAE18344131006C643B /* 
CommunicationBridge.m in Sources */,
                                04224501197F5E09005DD0BF /* BulletedLabel.m in 
Sources */,
                                C979727D1A731F2D00C6ED7A /* 
WMFShareOptionsView.m in Sources */,
@@ -3685,6 +3685,7 @@
                                CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
                                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
                                COPY_PHASE_STRIP = NO;
+                               DEAD_CODE_STRIPPING = NO;
                                ENABLE_NS_ASSERTIONS = YES;
                                GCC_C_LANGUAGE_STANDARD = gnu99;
                                GCC_DYNAMIC_NO_PIC = NO;
diff --git a/Wikipedia/Categories/Alerts/UIViewController+Alert.m 
b/Wikipedia/Categories/Alerts/UIViewController+Alert.m
index b04c189..06f4986 100644
--- a/Wikipedia/Categories/Alerts/UIViewController+Alert.m
+++ b/Wikipedia/Categories/Alerts/UIViewController+Alert.m
@@ -38,6 +38,9 @@
 }
 
 - (void)hideAlert {
+    if (!self.isViewLoaded) {
+        return;
+    }
     // Hide existing alert labels if any.
     NSArray* alertLabels = [self.view wmf_subviewsOfClass:[AlertLabel class]];
     [alertLabels makeObjectsPerformSelector:@selector(hide)];
diff --git a/Wikipedia/Session/SessionSingleton.h 
b/Wikipedia/Session/SessionSingleton.h
index 1cf12b5..dc65dbc 100644
--- a/Wikipedia/Session/SessionSingleton.h
+++ b/Wikipedia/Session/SessionSingleton.h
@@ -2,6 +2,7 @@
 //  Copyright (c) 2013 Wikimedia Foundation. Provided under MIT-style license; 
please copy and modify!
 
 #import <Foundation/Foundation.h>
+#import "MWKHistoryEntry.h"
 #import "KeychainCredentials.h"
 #import "ZeroConfigState.h"
 
@@ -93,6 +94,12 @@
 @property (nonatomic, strong) MWKArticle* currentArticle;
 
 
+/**
+ *  The way the current article was discovered.
+ *  Same caviates as the currentArticle
+ */
+@property (nonatomic, assign) MWKHistoryDiscoveryMethod 
currentArticleDiscoveryMethod;
+
 
 @property (strong, nonatomic, readonly) NSString* searchApiUrl;
 
diff --git a/Wikipedia/View Controllers/History/HistoryViewController.m 
b/Wikipedia/View Controllers/History/HistoryViewController.m
index b24e797..f20e5a5 100644
--- a/Wikipedia/View Controllers/History/HistoryViewController.m
+++ b/Wikipedia/View Controllers/History/HistoryViewController.m
@@ -364,7 +364,7 @@
 
     [NAV loadArticleWithTitle:historyEntry.title
                      animated:YES
-              discoveryMethod:MWK_DISCOVERY_METHOD_SAVED
+              discoveryMethod:MWKHistoryDiscoveryMethodBackForward
                    popToWebVC:NO];
 
     [self popModalToRoot];
@@ -467,10 +467,10 @@
 - 
(NSAttributedString*)getIconLabelAttributedStringForDiscoveryMethod:(MWKHistoryDiscoveryMethod)discoveryMethod
 {
     NSString* wikiFontCharacter = nil;
     switch (discoveryMethod) {
-        case MWK_DISCOVERY_METHOD_RANDOM:
+        case MWKHistoryDiscoveryMethodRandom:
             wikiFontCharacter = WIKIGLYPH_DICE;
             break;
-        case MWK_DISCOVERY_METHOD_LINK:
+        case MWKHistoryDiscoveryMethodLink:
             wikiFontCharacter = WIKIGLYPH_LINK;
             break;
         default:
diff --git a/Wikipedia/View 
Controllers/Navigation/Bottom/BottomMenuViewController.m b/Wikipedia/View 
Controllers/Navigation/Bottom/BottomMenuViewController.m
index df7fdbb..04a64e7 100644
--- a/Wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m
+++ b/Wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m
@@ -318,7 +318,7 @@
         [webVC showAlert:historyEntry.title.prefixedText 
type:ALERT_TYPE_BOTTOM duration:0.8];
 
         [webVC navigateToPage:historyEntry.title
-              discoveryMethod:MWK_DISCOVERY_METHOD_BACKFORWARD
+              discoveryMethod:MWKHistoryDiscoveryMethodBackForward
          showLoadingIndicator:YES];
     }
 }
@@ -331,7 +331,7 @@
         [webVC showAlert:historyEntry.title.prefixedText 
type:ALERT_TYPE_BOTTOM duration:0.8];
 
         [webVC navigateToPage:historyEntry.title
-              discoveryMethod:MWK_DISCOVERY_METHOD_BACKFORWARD
+              discoveryMethod:MWKHistoryDiscoveryMethodBackForward
          showLoadingIndicator:YES];
     }
 }
diff --git a/Wikipedia/View Controllers/Navigation/Center/CenterNavController.m 
b/Wikipedia/View Controllers/Navigation/Center/CenterNavController.m
index 724338d..fb4c421 100644
--- a/Wikipedia/View Controllers/Navigation/Center/CenterNavController.m
+++ b/Wikipedia/View Controllers/Navigation/Center/CenterNavController.m
@@ -141,7 +141,7 @@
     MWKTitle* pageTitle = [[SessionSingleton sharedInstance] mainArticleTitle];
     [self loadArticleWithTitle:pageTitle
                       animated:YES
-               discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH
+               discoveryMethod:MWKHistoryDiscoveryMethodSearch
                     popToWebVC:NO];
 }
 
@@ -169,7 +169,7 @@
                     MWKTitle* pageTitle = [[SessionSingleton 
sharedInstance].currentArticleSite titleWithString:title];
                     [self loadArticleWithTitle:pageTitle
                                       animated:YES
-                               discoveryMethod:MWK_DISCOVERY_METHOD_RANDOM
+                               discoveryMethod:MWKHistoryDiscoveryMethodRandom
                                     popToWebVC:NO]; // Don't pop - popModal 
has already been called.
                 }
             }
@@ -190,7 +190,7 @@
 
     [self loadArticleWithTitle:pageTitle
                       animated:YES
-               discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH
+               discoveryMethod:MWKHistoryDiscoveryMethodSearch
                     popToWebVC:NO];
 }
 
diff --git a/Wikipedia/View Controllers/Nearby/NearbyViewController.m 
b/Wikipedia/View Controllers/Nearby/NearbyViewController.m
index bc5fbec..322c3e4 100644
--- a/Wikipedia/View Controllers/Nearby/NearbyViewController.m
+++ b/Wikipedia/View Controllers/Nearby/NearbyViewController.m
@@ -81,7 +81,7 @@
     NSString* title       = rowData[@"title"];
     [NAV loadArticleWithTitle:[[SessionSingleton sharedInstance].searchSite 
titleWithString:title]
                      animated:YES
-              discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH
+              discoveryMethod:MWKHistoryDiscoveryMethodSearch
                    popToWebVC:NO];
 
     [self popModalToRoot];
diff --git a/Wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m 
b/Wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
index d202f7f..a9c61d7 100644
--- a/Wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
+++ b/Wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
@@ -505,13 +505,9 @@
             case FETCH_FINAL_STATUS_SUCCEEDED: {
                 [self.funnel logSavedRevision:[fetchedData[@"newrevid"] 
intValue]];
 
-                // Mark article for refreshing and reload it.
-                //if (uploader.articleID) {
-
                 WebViewController* webVC = [self.navigationController 
searchNavStackForViewControllerOfClass:[WebViewController class]];
-                [webVC reloadCurrentArticleInvalidatingCache:YES];
+                [webVC reloadCurrentArticle];
                 [ROOT popToViewController:webVC animated:YES];
-                //}
             }
             break;
 
diff --git a/Wikipedia/View Controllers/References/ReferenceVC.m 
b/Wikipedia/View Controllers/References/ReferenceVC.m
index eef521d..599b064 100644
--- a/Wikipedia/View Controllers/References/ReferenceVC.m
+++ b/Wikipedia/View Controllers/References/ReferenceVC.m
@@ -62,7 +62,7 @@
                 NSString* title        = [encodedTitle 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                 MWKTitle* pageTitle    = [[SessionSingleton 
sharedInstance].currentArticleSite titleWithString:title];
                 [self.webVC navigateToPage:pageTitle
-                           discoveryMethod:MWK_DISCOVERY_METHOD_LINK
+                           discoveryMethod:MWKHistoryDiscoveryMethodLink
                       showLoadingIndicator:YES];
                 [self.webVC referencesHide];
                 return NO;
diff --git a/Wikipedia/View Controllers/SavedPages/SavedPagesViewController.m 
b/Wikipedia/View Controllers/SavedPages/SavedPagesViewController.m
index f593f9e..2db94ae 100644
--- a/Wikipedia/View Controllers/SavedPages/SavedPagesViewController.m
+++ b/Wikipedia/View Controllers/SavedPages/SavedPagesViewController.m
@@ -264,7 +264,7 @@
 
     [NAV loadArticleWithTitle:savedEntry.title
                      animated:YES
-              discoveryMethod:MWK_DISCOVERY_METHOD_SAVED
+              discoveryMethod:MWKHistoryDiscoveryMethodSaved
                    popToWebVC:NO];
 
     [self popModalToRoot];
diff --git a/Wikipedia/View Controllers/SearchResults/SearchResultsController.m 
b/Wikipedia/View Controllers/SearchResults/SearchResultsController.m
index 4d53c75..4a04df9 100644
--- a/Wikipedia/View Controllers/SearchResults/SearchResultsController.m
+++ b/Wikipedia/View Controllers/SearchResults/SearchResultsController.m
@@ -637,7 +637,7 @@
 
     [NAV loadArticleWithTitle:[[SessionSingleton sharedInstance].searchSite 
titleWithString:title]
                      animated:YES
-              discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH
+              discoveryMethod:MWKHistoryDiscoveryMethodSearch
                    popToWebVC:YES];
 }
 
diff --git a/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Legal/WMFLegalFooterViewController.m 
b/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Legal/WMFLegalFooterViewController.m
index 0f2cf39..22aa31b 100644
--- a/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Legal/WMFLegalFooterViewController.m
+++ b/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Legal/WMFLegalFooterViewController.m
@@ -75,7 +75,7 @@
     MWKSite* site = [[MWKSite alloc] initWithDomain:@"wikipedia.org" 
language:@"en"];
     [NAV loadArticleWithTitle:[site titleWithString:kLicenseTitleOnENWiki]
                      animated:NO
-              discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH
+              discoveryMethod:MWKHistoryDiscoveryMethodSearch
                    popToWebVC:YES];
 }
 
diff --git a/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Options/WMFOptionsFooterViewController.m 
b/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Options/WMFOptionsFooterViewController.m
index 8e09fa4..ab6ae2d 100644
--- a/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Options/WMFOptionsFooterViewController.m
+++ b/Wikipedia/View 
Controllers/WebView/Footer/SubFooters/Options/WMFOptionsFooterViewController.m
@@ -165,7 +165,7 @@
     MWKTitle* title = [site titleWithString:langData[@"*"]];
     [NAV loadArticleWithTitle:title
                      animated:NO
-              discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH
+              discoveryMethod:MWKHistoryDiscoveryMethodSearch
                    popToWebVC:YES];
 
     [self dismissLanguagePicker];
diff --git a/Wikipedia/View Controllers/WebView/WebViewController.h 
b/Wikipedia/View Controllers/WebView/WebViewController.h
index 16677f5..97c7d8f 100644
--- a/Wikipedia/View Controllers/WebView/WebViewController.h
+++ b/Wikipedia/View Controllers/WebView/WebViewController.h
@@ -32,9 +32,7 @@
 - (void)referencesShow:(NSDictionary*)payload;
 - (void)referencesHide;
 
-// Reloads the current article from the core data cache.
-// If "invalidateCache" is set to YES the article will be re-downloaded first.
-- (void)reloadCurrentArticleInvalidatingCache:(BOOL)invalidateCache;
+- (void)reloadCurrentArticle;
 
 - (void)  navigateToPage:(MWKTitle*)title
          discoveryMethod:(MWKHistoryDiscoveryMethod)discoveryMethod
diff --git a/Wikipedia/View Controllers/WebView/WebViewController.m 
b/Wikipedia/View Controllers/WebView/WebViewController.m
index 0f5ca52..1bc0056 100644
--- a/Wikipedia/View Controllers/WebView/WebViewController.m
+++ b/Wikipedia/View Controllers/WebView/WebViewController.m
@@ -136,8 +136,7 @@
 
     [self tocSetupSwipeGestureRecognizers];
 
-
-    [self reloadCurrentArticleInvalidatingCache:NO];
+    [self reloadCurrentArticle];
 
     // Restrict the web view from scrolling horizonally.
     [self.webView.scrollView addObserver:self
@@ -834,7 +833,7 @@
                 MWKTitle* pageTitle = [[SessionSingleton 
sharedInstance].currentArticleSite titleWithInternalLink:href];
 
                 [strSelf navigateToPage:pageTitle
-                        discoveryMethod:MWK_DISCOVERY_METHOD_LINK
+                        discoveryMethod:MWKHistoryDiscoveryMethodLink
                    showLoadingIndicator:YES];
             } else if ([href hasPrefix:@"http:"] || [href hasPrefix:@"https:"] 
|| [href hasPrefix:@"//"]) {
                 // A standard external link, either explicitly http(s) or left 
protocol-relative on web meaning http(s)
@@ -1347,7 +1346,7 @@
     [self hideKeyboard];
 
     if (showLoadingIndicator) {
-        self.loadingIndicatorOverlay.showSpinner = discoveryMethod != 
MWK_DISCOVERY_METHOD_BACKFORWARD;
+        self.loadingIndicatorOverlay.showSpinner = discoveryMethod != 
MWKHistoryDiscoveryMethodBackForward;
         [self.loadingIndicatorOverlay setVisible:YES animated:YES];
     }
 
@@ -1356,14 +1355,8 @@
 
     self.jumpToFragment = title.fragment;
 
-    // Update the history dateVisited timestamp of the article *presently 
shown* by the webView
-    // only if the article to be loaded was NOT loaded via back or forward 
buttons. The article
-    // being *navigated to* has its history dateVisited updated later in this 
method.
-    if (discoveryMethod != MWK_DISCOVERY_METHOD_BACKFORWARD) {
+    if (discoveryMethod != MWKHistoryDiscoveryMethodBackForward && 
discoveryMethod != MWKHistoryDiscoveryMethodReload) {
         [self updateHistoryDateVisitedForArticleBeingNavigatedFrom];
-        self.didLastNavigateByBackOrForward = NO;
-    } else {
-        self.didLastNavigateByBackOrForward = YES;
     }
 
     [self retrieveArticleForPageTitle:title
@@ -1378,9 +1371,9 @@
      */
 }
 
-- (void)reloadCurrentArticleInvalidatingCache:(BOOL)invalidateCache {
+- (void)reloadCurrentArticle {
     [self navigateToPage:session.currentArticle.title
-          discoveryMethod:(invalidateCache ? MWK_DISCOVERY_METHOD_SEARCH : 
MWK_DISCOVERY_METHOD_SAVED)
+          discoveryMethod:MWKHistoryDiscoveryMethodReload
      showLoadingIndicator:YES];
 }
 
@@ -1402,11 +1395,7 @@
                     MWKHistoryEntry* history = 
[session.userDataStore.historyList entryForTitle:article.title];
                     // Get the article's discovery method.
                     MWKHistoryDiscoveryMethod discoveryMethod =
-                        (history) ? history.discoveryMethod : 
MWK_DISCOVERY_METHOD_SEARCH;
-
-                    // Remove the redirect article so it doesn't get saved 
(the article being redirected to will be saved).
-                    [session.userDataStore.historyList removeEntry:history];
-                    [session.currentArticle remove];
+                        (history) ? history.discoveryMethod : 
MWKHistoryDiscoveryMethodSearch;
 
                     // Redirect!
                     [self retrieveArticleForPageTitle:redirectedTitle
@@ -1416,32 +1405,24 @@
 
                 // Update the toc and web view.
                 [self displayArticle:article.title];
+
+                [self hideAlert];
             }
             break;
 
             case FETCH_FINAL_STATUS_FAILED:
             {
-                MWKHistoryEntry* lastEntry = 
session.userDataStore.historyList.mostRecentEntry;
-                if ([lastEntry.title isEqual:article.title]) {
-                    [session.userDataStore.historyList removeEntry:lastEntry];
-                    [session.userDataStore save];
-                }
+                [self displayArticle:article.title];
+
                 NSString* errorMsg = error.localizedDescription;
                 [self showAlert:errorMsg type:ALERT_TYPE_TOP duration:-1];
 
                 [self.loadingIndicatorOverlay setVisible:NO animated:YES];
-                // Reminder: do not clear article data here or no network 
connection when pull to refresh would blast last good saved article data!
             }
             break;
 
             case FETCH_FINAL_STATUS_CANCELLED:
             {
-                MWKHistoryEntry* lastEntry = 
session.userDataStore.historyList.mostRecentEntry;
-                if ([lastEntry.title.prefixedText 
isEqualToString:article.title.prefixedText]) {
-                    [session.userDataStore.historyList removeEntry:lastEntry];
-                    [session.userDataStore save];
-                }
-                // Reminder: do not clear article data here or cancellation 
would blast last good saved article data!
             }
             break;
 
@@ -1499,29 +1480,15 @@
     self.currentTitle = pageTitle;
 
     MWKArticle* article = [session.dataStore 
articleWithTitle:self.currentTitle];
-    session.currentArticle = article;
+    session.currentArticle                = article;
+    session.currentArticleDiscoveryMethod = discoveryMethod;
 
-    switch (discoveryMethod) {
-        case MWK_DISCOVERY_METHOD_SAVED:
-        case MWK_DISCOVERY_METHOD_SEARCH:
-        case MWK_DISCOVERY_METHOD_RANDOM:
-        case MWK_DISCOVERY_METHOD_LINK:
-        case MWK_DISCOVERY_METHOD_UNKNOWN: {
-            // Update the history so the most recently viewed article appears 
at the top.
-            [session.userDataStore updateHistory:article.title 
discoveryMethod:discoveryMethod];
-            break;
-        }
-
-        case MWK_DISCOVERY_METHOD_BACKFORWARD:
-            // Traversing history should not alter it, and should be served 
from the cache.
-            break;
-    }
-
-    switch (discoveryMethod) {
-        case MWK_DISCOVERY_METHOD_SEARCH:
-        case MWK_DISCOVERY_METHOD_RANDOM:
-        case MWK_DISCOVERY_METHOD_LINK:
-        case MWK_DISCOVERY_METHOD_UNKNOWN: {
+    switch (session.currentArticleDiscoveryMethod) {
+        case MWKHistoryDiscoveryMethodSearch:
+        case MWKHistoryDiscoveryMethodRandom:
+        case MWKHistoryDiscoveryMethodLink:
+        case MWKHistoryDiscoveryMethodReload:
+        case MWKHistoryDiscoveryMethodUnknown: {
             // Mark article as needing refreshing so its data will be 
re-downloaded.
             // Reminder: this needs to happen *after* "session.title" has been 
updated
             // with the title of the article being retrieved. Otherwise you 
end up
@@ -1530,8 +1497,8 @@
             break;
         }
 
-        case MWK_DISCOVERY_METHOD_SAVED:
-        case MWK_DISCOVERY_METHOD_BACKFORWARD:
+        case MWKHistoryDiscoveryMethodSaved:
+        case MWKHistoryDiscoveryMethodBackForward:
             break;
     }
 
@@ -1685,6 +1652,28 @@
     MWKArticle* article = [session.dataStore articleWithTitle:title];
     session.currentArticle = article;
 
+    if (![article isCached]) {
+        return;
+    }
+
+    switch (session.currentArticleDiscoveryMethod) {
+        case MWKHistoryDiscoveryMethodSaved:
+        case MWKHistoryDiscoveryMethodSearch:
+        case MWKHistoryDiscoveryMethodRandom:
+        case MWKHistoryDiscoveryMethodLink:
+        case MWKHistoryDiscoveryMethodUnknown: {
+            // Update the history so the most recently viewed article appears 
at the top.
+            [session.userDataStore updateHistory:title 
discoveryMethod:session.currentArticleDiscoveryMethod];
+            break;
+        }
+
+        case MWKHistoryDiscoveryMethodReload:
+        case MWKHistoryDiscoveryMethodBackForward:
+            // Traversing history should not alter it, and should be served 
from the cache.
+            break;
+    }
+
+
     MWLanguageInfo* languageInfo = [MWLanguageInfo 
languageInfoForCode:title.site.language];
     NSString* uidir              = ([WikipediaAppUtils isDeviceLanguageRTL] ? 
@"rtl" : @"ltr");
 
@@ -1725,10 +1714,12 @@
     // removes them.
     //[article 
ifNoThumbnailUseFirstSectionImageAsThumbnailUsingContext:articleDataContext_.mainContext];
 
-    MWKHistoryEntry* historyEntry = [session.userDataStore.historyList 
entryForTitle:article.title];
 
-    if ((self.didLastNavigateByBackOrForward && historyEntry) || 
historyEntry.discoveryMethod == MWK_DISCOVERY_METHOD_SAVED) {
-        CGPoint scrollOffset = CGPointMake(0, historyEntry.scrollPosition);
+    if (session.currentArticleDiscoveryMethod == 
MWKHistoryDiscoveryMethodSaved ||
+        session.currentArticleDiscoveryMethod == 
MWKHistoryDiscoveryMethodBackForward ||
+        session.currentArticleDiscoveryMethod == 
MWKHistoryDiscoveryMethodReload) {
+        MWKHistoryEntry* historyEntry = [session.userDataStore.historyList 
entryForTitle:article.title];
+        CGPoint scrollOffset          = CGPointMake(0, 
historyEntry.scrollPosition);
         self.lastScrollOffset = scrollOffset;
     } else {
         CGPoint scrollOffset = CGPointMake(0, 0);
@@ -1891,7 +1882,7 @@
 }
 
 - (void)refreshWasPulled {
-    [self reloadCurrentArticleInvalidatingCache:YES];
+    [self reloadCurrentArticle];
 }
 
 - (BOOL)refreshShouldShow {
diff --git a/Wikipedia/View Controllers/WebView/WebViewController_Private.h 
b/Wikipedia/View Controllers/WebView/WebViewController_Private.h
index 22966c6..c7fe503 100644
--- a/Wikipedia/View Controllers/WebView/WebViewController_Private.h
+++ b/Wikipedia/View Controllers/WebView/WebViewController_Private.h
@@ -155,8 +155,6 @@
 
 @property (strong, nonatomic) IBOutlet NSLayoutConstraint* 
webViewBottomConstraint;
 
-@property (nonatomic) BOOL didLastNavigateByBackOrForward;
-
 @property (nonatomic) BOOL isCurrentArticleMain;
 
 @property (nonatomic) BOOL keyboardIsVisible;
diff --git a/WikipediaUnitTests/ArticleLoadingTests.m 
b/WikipediaUnitTests/ArticleLoadingTests.m
index cdccb09..37d2ea3 100644
--- a/WikipediaUnitTests/ArticleLoadingTests.m
+++ b/WikipediaUnitTests/ArticleLoadingTests.m
@@ -40,13 +40,32 @@
     [super tearDown];
 }
 
+- (void)testReloadDoesNotAffectHistory {
+    MWKArticle* dummyArticle = [self storeDummyArticleWithTitle:@"foo"];
+    self.session.currentArticle = dummyArticle;
+
+    [self.webVC navigateToPage:dummyArticle.title
+               discoveryMethod:MWKHistoryDiscoveryMethodReload
+          showLoadingIndicator:YES];
+
+    // TODO: verify that mock article fetcher gets a call to fetch article w/ 
mock title
+
+    [self.webVC fetchFinished:mock([ArticleFetcher class])
+                  fetchedData:nil //< unused
+                       status:FETCH_FINAL_STATUS_SUCCEEDED
+                        error:nil];
+
+    assertThat(self.session.currentArticle, is(dummyArticle));
+    assertThat(@(self.session.userDataStore.historyList.length), is(@0));
+}
+
 - (void)testSuccessfulNavigationStoredInHistory {
-    // should be true for every discovery method _except_ back/forward
-    MWKHistoryDiscoveryMethod methods[5] = {MWK_DISCOVERY_METHOD_LINK,
-                                            MWK_DISCOVERY_METHOD_RANDOM,
-                                            MWK_DISCOVERY_METHOD_SAVED,
-                                            MWK_DISCOVERY_METHOD_SEARCH,
-                                            MWK_DISCOVERY_METHOD_UNKNOWN};
+    // should be true for every discovery method _except_ back/forward and 
reload
+    MWKHistoryDiscoveryMethod methods[5] = {MWKHistoryDiscoveryMethodLink,
+                                            MWKHistoryDiscoveryMethodRandom,
+                                            MWKHistoryDiscoveryMethodSaved,
+                                            MWKHistoryDiscoveryMethodSearch,
+                                            MWKHistoryDiscoveryMethodUnknown};
 
     for (NSUInteger i = 0; i < 5; i++) {
         MWKHistoryDiscoveryMethod currentMethod = methods[i];
@@ -76,7 +95,7 @@
     dummyArticle.needsRefresh = YES;
 
     [self.webVC navigateToPage:dummyArticle.title
-               discoveryMethod:MWK_DISCOVERY_METHOD_BACKFORWARD
+               discoveryMethod:MWKHistoryDiscoveryMethodBackForward
           showLoadingIndicator:YES];
 
     // TODO: verify that mock article fetcher gets a call to fetch article w/ 
mock title
@@ -97,20 +116,21 @@
     self.session.currentArticle = originalArticle;
 
     // should be true for every discovery
-    MWKHistoryDiscoveryMethod methods[6] = {MWK_DISCOVERY_METHOD_LINK,
-                                            MWK_DISCOVERY_METHOD_RANDOM,
-                                            MWK_DISCOVERY_METHOD_SAVED,
-                                            MWK_DISCOVERY_METHOD_SEARCH,
-                                            MWK_DISCOVERY_METHOD_UNKNOWN,
-                                            MWK_DISCOVERY_METHOD_BACKFORWARD};
+    MWKHistoryDiscoveryMethod methods[7] = {MWKHistoryDiscoveryMethodReload,
+                                            MWKHistoryDiscoveryMethodLink,
+                                            MWKHistoryDiscoveryMethodRandom,
+                                            MWKHistoryDiscoveryMethodSaved,
+                                            MWKHistoryDiscoveryMethodSearch,
+                                            MWKHistoryDiscoveryMethodUnknown,
+                                            
MWKHistoryDiscoveryMethodBackForward};
 
     FetchFinalStatus finalStatuses[2] = {FETCH_FINAL_STATUS_FAILED, 
FETCH_FINAL_STATUS_CANCELLED};
 
-    for (NSUInteger i = 0; i < 6; i++) {
+    for (NSUInteger i = 0; i < 7; i++) {
         MWKHistoryDiscoveryMethod currentMethod = methods[i];
 
         MWKTitle* failedTitle =
-            [MWKTitle titleWithString:[NSString stringWithFormat:@"failed-%u", 
i]
+            [MWKTitle titleWithString:[NSString 
stringWithFormat:@"failed-%lu", (unsigned long)i]
                                  site:[MWKSite siteWithDomain:@"wikipedia.org" 
language:@"en"]];
 
         for (NSUInteger j = 0; j < 2; j++) {
diff --git a/Wikipedia/C Methods/WMFRandomFileUtilities.h 
b/WikipediaUnitTests/Utilities/WMFRandomFileUtilities.h
similarity index 100%
rename from Wikipedia/C Methods/WMFRandomFileUtilities.h
rename to WikipediaUnitTests/Utilities/WMFRandomFileUtilities.h
diff --git a/Wikipedia/C Methods/WMFRandomFileUtilities.m 
b/WikipediaUnitTests/Utilities/WMFRandomFileUtilities.m
similarity index 100%
rename from Wikipedia/C Methods/WMFRandomFileUtilities.m
rename to WikipediaUnitTests/Utilities/WMFRandomFileUtilities.m

-- 
To view, visit https://gerrit.wikimedia.org/r/210114
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2ad1b980535ae6476062193a67ae4888907ba10d
Gerrit-PatchSet: 5
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Fjalapeno <cfl...@wikimedia.org>
Gerrit-Reviewer: Bgerstle <bgers...@wikimedia.org>
Gerrit-Reviewer: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to