Dr0ptp4kt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/118787
Change subject: Workaround for app crashing on low memory. Retain last page
location.
......................................................................
Workaround for app crashing on low memory. Retain last page location.
Change-Id: I48121f3ddeb3168370ce91d644fa48439a3d0dee
---
M js/lib/app_history.js
M js/lib/wikiapp.js
2 files changed, 15 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/firefox/wikipedia
refs/changes/87/118787/1
diff --git a/js/lib/app_history.js b/js/lib/app_history.js
index e288ab5..c3dec7b 100644
--- a/js/lib/app_history.js
+++ b/js/lib/app_history.js
@@ -26,7 +26,7 @@
});
});
if ( langUrl ) {
- localStorage["lastReadPage"] = decodeURI( langUrl );
+ localStorage["lastReadPage"] = langUrl;
}
}
diff --git a/js/lib/wikiapp.js b/js/lib/wikiapp.js
index d205839..83808f9 100644
--- a/js/lib/wikiapp.js
+++ b/js/lib/wikiapp.js
@@ -70,9 +70,9 @@
return d;
}
- function setCurrentPage(page, langUrl) {
+ function setCurrentPage(page, unencodedLangUrl) {
app.curPage = page;
- app.curLangUrl = langUrl;
+ app.curLangUrl = unencodedLangUrl;
chrome.renderHtml(page);
setPageActionsState(true);
@@ -103,7 +103,7 @@
app.curPage = null;
}
- function loadPage(title, language, langUrl) {
+ function loadPage(title, language, unencodedLangUrl) {
var d = $.Deferred();
function doRequest() {
@@ -111,7 +111,7 @@
if(page === null) {
setErrorPage(404);
}
- setCurrentPage(page, langUrl);
+ setCurrentPage(page, unencodedLangUrl);
d.resolve(page);
}).fail(function(xhr, textStatus, errorThrown) {
if(textStatus === "abort") {
@@ -154,6 +154,13 @@
return app.baseUrlForLanguage( lang ) + "/wiki/" +
encodeURIComponent(title.replace(/ /g, '_'));
}
+ function unencodedUrlForTitle( title, lang ) {
+ if(typeof lang === 'undefined') {
+ lang = preferencesDB.get("language");
+ }
+ return app.baseUrlForLanguage( lang ) + "/wiki/" + title.replace(/ /g,
'_');
+ }
+
function baseUrlForLanguage( lang ) {
var url = window.PROTOCOL + '://' + lang + '.' + PROJECTNAME +
'.org';
return url;
@@ -182,6 +189,7 @@
var d = $.Deferred();
var options = $.extend({cache: false, updateHistory: true},
options || {});
var url = app.urlForTitle(title, lang);
+ var unencodedUrl = app.unencodedUrlForTitle(title, lang);
if(typeof lang === "undefined") {
lang = preferencesDB.get("language");
}
@@ -204,7 +212,7 @@
if(title === "") {
title = "Main_Page"; // FIXME
}
- d = app.loadPage(title, lang, url);
+ d = app.loadPage(title, lang, unencodedUrl);
d.done(function() {
console.log("Navigating to " + title);
if(options.hideCurrent) {
@@ -307,6 +315,7 @@
getCurrentTitle: getCurrentTitle,
getCurrentLangUrl: getCurrentLangUrl,
urlForTitle: urlForTitle,
+ unencodedUrlForTitle: unencodedUrlForTitle,
titleForUrl:titleForUrl,
languageForUrl: languageForUrl,
baseUrlForLanguage: baseUrlForLanguage,
--
To view, visit https://gerrit.wikimedia.org/r/118787
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I48121f3ddeb3168370ce91d644fa48439a3d0dee
Gerrit-PatchSet: 1
Gerrit-Project: apps/firefox/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dr0ptp4kt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits