Dr0ptp4kt has submitted this change and it was merged.

Change subject: Cache regressions fixes related to pull to refresh and offline 
mode.
......................................................................


Cache regressions fixes related to pull to refresh and offline mode.

Fix for pull to refresh when you don't have an internet connection
causing the saved article record to be blasted.

Fix for "needsRefresh" flag persisting after article data has been
retrieved/refreshed. This was causing articles which had formerly been
refreshed to not load from cache if you didn't have an internet
connection. Note: to test do clean install of master, load an article,
pull to refresh, load a different article, disconnect internet,
bring up "Recent" and select the first article - you'll get a
network error message. Apply this patch and do the same and you'll
see the proper behavior which is the cached article loads just fine.

Change-Id: I642bbab9a6fecc78ca24bd81b18e3658ec661a40
---
M wikipedia/Networking/Fetchers/ArticleFetcher.m
M wikipedia/View Controllers/WebView/WebViewController.m
2 files changed, 9 insertions(+), 8 deletions(-)

Approvals:
  Dr0ptp4kt: Verified; Looks good to me, approved
  Fjalapeno: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/wikipedia/Networking/Fetchers/ArticleFetcher.m 
b/wikipedia/Networking/Fetchers/ArticleFetcher.m
index 1897ee4..33541fd 100644
--- a/wikipedia/Networking/Fetchers/ArticleFetcher.m
+++ b/wikipedia/Networking/Fetchers/ArticleFetcher.m
@@ -112,6 +112,12 @@
             }
             
             [self associateThumbFromTempDirWithArticle];
+
+            // Reminder: must reset "needsRefresh" to NO here! Otherwise saved 
articles
+            // (which had been refreshed at least once) won't work if you're 
offline
+            // because the system thinks a fresh is *still* needed and will 
try to load
+            // from network rather than from cache.
+            self.article.needsRefresh = NO;
             
             [self.article save];
             
diff --git a/wikipedia/View Controllers/WebView/WebViewController.m 
b/wikipedia/View Controllers/WebView/WebViewController.m
index 1975696..817aeab 100644
--- a/wikipedia/View Controllers/WebView/WebViewController.m
+++ b/wikipedia/View Controllers/WebView/WebViewController.m
@@ -1365,7 +1365,7 @@
                     MWKHistoryDiscoveryMethod discoveryMethod =
                     (history) ? history.discoveryMethod : 
MWK_DISCOVERY_METHOD_SEARCH;
 
-                    // Remove the article so it doesn't get saved.
+                    // Remove the redirect article so it doesn't get saved 
(the article being redirected to will be saved).
                     [session.userDataStore.historyList removeEntry:history];
                     [session.article remove];
 
@@ -1388,17 +1388,12 @@
                 [self showAlert:errorMsg type:ALERT_TYPE_TOP duration:-1];
 
                 [self loadingIndicatorHide];
-
-                // Remove the article so it doesn't get saved.
-                //[article.managedObjectContext deleteObject:article];
-                [article remove];
+                // 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:
             {
-                // Remove the article so it doesn't get saved.
-                //[article.managedObjectContext deleteObject:article];
-                [article remove];
+                // Reminder: do not clear article data here or cancellation 
would blast last good saved article data!
             }
                 break;
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I642bbab9a6fecc78ca24bd81b18e3658ec661a40
Gerrit-PatchSet: 2
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <[email protected]>
Gerrit-Reviewer: Bgerstle <[email protected]>
Gerrit-Reviewer: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: Fjalapeno <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to