From 1b8dfaf0490a77c0d3e0f369090a85a06bc28ff2 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 10 May 2019 01:52:27 +0100 Subject: [PATCH] Fix HashNavigation reload bug --- .../controllers/hub_node_controller.js.coffee | 11 +++++++++-- .../controllers/producer_node_controller.js.coffee | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee index e587dcfb62..9b08a09139 100644 --- a/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee @@ -1,7 +1,11 @@ -Darkswarm.controller "HubNodeCtrl", ($scope, HashNavigation, Navigation, $location, $templateCache, CurrentHub, $http) -> +Darkswarm.controller "HubNodeCtrl", ($scope, HashNavigation, Navigation, $location, CurrentHub, $http, $timeout) -> $scope.shopfront_loading = false $scope.enterprise_details = [] + $timeout -> + if $scope.open() + $scope.load_shopfront() + # Toggles shopfront tabs open/closed. Fetches enterprise details from the api, diplays them and adds them # to $scope.enterprise_details, or simply displays the details again if previously fetched $scope.toggle = (event) -> @@ -14,6 +18,9 @@ Darkswarm.controller "HubNodeCtrl", ($scope, HashNavigation, Navigation, $locati $scope.toggle_tab(event) return + $scope.load_shopfront(event) + + $scope.load_shopfront = (event=null) -> $scope.shopfront_loading = true $scope.toggle_tab(event) @@ -26,7 +33,7 @@ Darkswarm.controller "HubNodeCtrl", ($scope, HashNavigation, Navigation, $locati console.error(data) $scope.toggle_tab = (event) -> - HashNavigation.toggle $scope.hub.hash if !angular.element(event.target).inheritedData('is-link') + HashNavigation.toggle $scope.hub.hash if event && !angular.element(event.target).inheritedData('is-link') # Returns boolean: pulldown tab is currently open/closed $scope.open = -> diff --git a/app/assets/javascripts/darkswarm/controllers/producer_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/producer_node_controller.js.coffee index e8aeb58af2..0cacb566d5 100644 --- a/app/assets/javascripts/darkswarm/controllers/producer_node_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/producer_node_controller.js.coffee @@ -1,7 +1,11 @@ -Darkswarm.controller "ProducerNodeCtrl", ($scope, HashNavigation, $anchorScroll, $http) -> +Darkswarm.controller "ProducerNodeCtrl", ($scope, HashNavigation, $anchorScroll, $http, $timeout) -> $scope.shopfront_loading = false $scope.enterprise_details = [] + $timeout -> + if $scope.open() + $scope.load_shopfront() + # Toggles shopfront tabs open/closed. Fetches enterprise details from the api, diplays them and adds them # to $scope.enterprise_details, or simply displays the details again if previously fetched $scope.toggle = (event) -> @@ -14,6 +18,9 @@ Darkswarm.controller "ProducerNodeCtrl", ($scope, HashNavigation, $anchorScroll, $scope.toggle_tab(event) return + $scope.load_shopfront(event) + + $scope.load_shopfront = (event=null) -> $scope.shopfront_loading = true $scope.toggle_tab(event) @@ -26,7 +33,7 @@ Darkswarm.controller "ProducerNodeCtrl", ($scope, HashNavigation, $anchorScroll, console.error(data) $scope.toggle_tab = (event) -> - HashNavigation.toggle $scope.producer.hash if !angular.element(event.target).inheritedData('is-link') + HashNavigation.toggle $scope.producer.hash if event && !angular.element(event.target).inheritedData('is-link') $scope.open = -> HashNavigation.active($scope.producer.hash)