Brion VIBBER has submitted this change and it was merged. Change subject: Bring user to last page viewed on browser restart. ......................................................................
Bring user to last page viewed on browser restart. * Workaround for low memory issue in https://bugzilla.mozilla.org/show_bug.cgi?id=965629 Change-Id: I28086aacdca24054243449e74aa5f2d58e094a9d --- M js/lib/app_history.js M js/lib/chrome.js M js/lib/wikiapp.js 3 files changed, 23 insertions(+), 7 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/js/lib/app_history.js b/js/lib/app_history.js index 86d3820..e288ab5 100644 --- a/js/lib/app_history.js +++ b/js/lib/app_history.js @@ -5,8 +5,10 @@ */ function addCurrentPage() { - var title = app.getCurrentTitle(); - var url = app.getCurrentUrl(); + var title = app.getCurrentTitle(), + url = app.getCurrentUrl(), + langUrl = app.getCurrentLangUrl(); + if(url == 'about:blank') { return; } @@ -23,6 +25,9 @@ } }); }); + if ( langUrl ) { + localStorage["lastReadPage"] = decodeURI( langUrl ); + } } // Removes first element from history diff --git a/js/lib/chrome.js b/js/lib/chrome.js index 7cc26fd..8986675 100644 --- a/js/lib/chrome.js +++ b/js/lib/chrome.js @@ -202,7 +202,8 @@ } function loadFirstPage() { - return app.loadMainPage(); + var lastReadPage = localStorage["lastReadPage"]; + return lastReadPage ? app.navigateToPage(lastReadPage) : app.loadMainPage(); } function isTwoColumnView() { diff --git a/js/lib/wikiapp.js b/js/lib/wikiapp.js index 58b4a49..d205839 100644 --- a/js/lib/wikiapp.js +++ b/js/lib/wikiapp.js @@ -70,8 +70,9 @@ return d; } - function setCurrentPage(page) { + function setCurrentPage(page, langUrl) { app.curPage = page; + app.curLangUrl = langUrl; chrome.renderHtml(page); setPageActionsState(true); @@ -102,7 +103,7 @@ app.curPage = null; } - function loadPage(title, language) { + function loadPage(title, language, langUrl) { var d = $.Deferred(); function doRequest() { @@ -110,7 +111,7 @@ if(page === null) { setErrorPage(404); } - setCurrentPage(page); + setCurrentPage(page, langUrl); d.resolve(page); }).fail(function(xhr, textStatus, errorThrown) { if(textStatus === "abort") { @@ -203,7 +204,7 @@ if(title === "") { title = "Main_Page"; // FIXME } - d = app.loadPage(title, lang); + d = app.loadPage(title, lang, url); d.done(function() { console.log("Navigating to " + title); if(options.hideCurrent) { @@ -222,6 +223,14 @@ function getCurrentUrl() { if(app.curPage) { return app.urlForTitle(app.curPage.title); + } else { + return null; + } + } + + function getCurrentLangUrl() { + if(app.curLangUrl) { + return app.curLangUrl; } else { return null; } @@ -296,6 +305,7 @@ navigateToPage: navigateToPage, getCurrentUrl: getCurrentUrl, getCurrentTitle: getCurrentTitle, + getCurrentLangUrl: getCurrentLangUrl, urlForTitle: urlForTitle, titleForUrl:titleForUrl, languageForUrl: languageForUrl, -- To view, visit https://gerrit.wikimedia.org/r/115330 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I28086aacdca24054243449e74aa5f2d58e094a9d Gerrit-PatchSet: 1 Gerrit-Project: apps/firefox/wikipedia Gerrit-Branch: master Gerrit-Owner: Dr0ptp4kt <ab...@wikimedia.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Dr0ptp4kt <ab...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits