From f7cfea9d52336a72bfd3b2bd6cae50fe7017da84 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 19 Oct 2016 15:02:06 +0200 Subject: [PATCH] MOBILE-1824 wiki: Prevent changing state if same offline page clicked --- www/addons/mod/wiki/controllers/index.js | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/www/addons/mod/wiki/controllers/index.js b/www/addons/mod/wiki/controllers/index.js index 3ca83656780..be08736ba08 100644 --- a/www/addons/mod/wiki/controllers/index.js +++ b/www/addons/mod/wiki/controllers/index.js @@ -67,18 +67,20 @@ angular.module('mm.addons.mod_wiki') $scope.gotoPage = function(page) { if (!page.id) { - // It's an offline page. - var stateParams = { - module: module, - moduleid: module.id, - courseid: courseId, - pagetitle: page.title, - pageid: null, - wikiid: wiki.id, - subwikiid: page.subwikiid, - action: 'page' - }; - return $state.go('site.mod_wiki', stateParams); + // It's an offline page. Check if we are already in the same offline page. + if (currentPage || !pageTitle || page.title != pageTitle) { + var stateParams = { + module: module, + moduleid: module.id, + courseid: courseId, + pagetitle: page.title, + pageid: null, + wikiid: wiki.id, + subwikiid: page.subwikiid, + action: 'page' + }; + return $state.go('site.mod_wiki', stateParams); + } } else if (currentPage != page.id) { // Add a new State. return fetchPageContents(page.id).then(function(page) {