From b5f7b49ff8be3d384f707382b53e5510187152f0 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 9 Sep 2016 11:57:27 +0200 Subject: [PATCH] [FIX] web_tour: clear inconsistent localstorage keys When users switch from one version to another, the localstorage is not cleared and users can get errors because the tour manager is trying to load steps (according to the localstorage content) which could not exist anymore. This could also happen when a module which extends another module tour is installed. --- addons/web_tour/static/src/js/tour_manager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index b8101cf6c4e..09c399f851e 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -57,6 +57,13 @@ return core.Class.extend({ url: options.url, test: options.test, }; + + var tour_is_consumed = _.contains(this.consumed_tours, name); + if (tour_is_consumed || tour.current_step >= tour.steps.length) { + local_storage.removeItem(getStepKey(name)); + tour.current_step = 0; + } + if (options.skip_enabled) { tour.skip_link = '

' + _t('Skip tour') + '

'; tour.skip_handler = function (tip) { @@ -65,7 +72,7 @@ return core.Class.extend({ }; } this.tours[name] = tour; - if (name === this.running_tour || (!tour.test && !_.contains(this.consumed_tours, name))) { + if (name === this.running_tour || (!tour.test && !tour_is_consumed)) { this.active_tooltips[name] = steps[tour.current_step]; } },