From c5dce3603b17f35638a4ab9c7274ae1bfd294aab Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Sun, 30 Sep 2018 19:50:45 +0200
Subject: [PATCH] [fix] Registry Map: fix marker loading

---
 .../map/js/controllers/registry-controllers.js    | 15 +++++++++------
 www/plugins/map/js/controllers/wot-controllers.js | 12 +++++++-----
 .../map/templates/registry/popup_marker.html      |  6 +++---
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/www/plugins/map/js/controllers/registry-controllers.js b/www/plugins/map/js/controllers/registry-controllers.js
index 8c458fb9e..562dfe96f 100644
--- a/www/plugins/map/js/controllers/registry-controllers.js
+++ b/www/plugins/map/js/controllers/registry-controllers.js
@@ -82,7 +82,8 @@ function MapRegistryViewController($scope, $filter, $templateCache, $interpolate
     };
 
   $scope.loading = true;
-  $scope.mapId = 'map-wot-' + $scope.$id;
+  $scope.loadingMarker = true;
+  $scope.mapId = 'map-registry-' + $scope.$id;
 
   $scope.map = MapUtils.map({
     cache: 'map-registry',
@@ -317,12 +318,14 @@ function MapRegistryViewController($scope, $filter, $templateCache, $interpolate
               lat: hit.geoPoint.lat,
               lng: hit.geoPoint.lon,
               getMessageScope: function () {
-                $scope.loading = true;
-                $scope.$applyAsync(function() {
-                  angular.extend($scope.formData, hit);
-                  $scope.loading = false;
+                var scope = $scope.$new();
+                scope.loadingMarker = true;
+                scope.formData = {};
+                scope.$applyAsync(function() {
+                  angular.extend(scope.formData, hit);
+                  scope.loadingMarker = false;
                 });
-                return $scope;
+                return scope;
               },
               focus: false,
               message: pageMarkerTemplate,
diff --git a/www/plugins/map/js/controllers/wot-controllers.js b/www/plugins/map/js/controllers/wot-controllers.js
index 8128c72fc..7626ed09d 100644
--- a/www/plugins/map/js/controllers/wot-controllers.js
+++ b/www/plugins/map/js/controllers/wot-controllers.js
@@ -338,17 +338,19 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti
               lat: hit.geoPoint.lat,
               lng: hit.geoPoint.lon,
               getMessageScope: function () {
-                $scope.loadingMarker = true;
-                $scope.$applyAsync(function() {
-                  $scope.formData = {
+                var scope = $scope.$new();
+                scope.loadingMarker = true;
+                scope.formData = {};
+                scope.$applyAsync(function() {
+                  scope.formData = {
                     pubkey: hit.pubkey,
                     uid: hit.uid,
                     name: hit.name,
                     profile: hit
                   };
-                  $scope.loadingMarker = false;
+                  scope.loadingMarker = false;
                 });
-                return $scope;
+                return scope;
               },
               focus: false,
               message: markerTemplate,
diff --git a/www/plugins/map/templates/registry/popup_marker.html b/www/plugins/map/templates/registry/popup_marker.html
index cec8ff96e..444f732ac 100644
--- a/www/plugins/map/templates/registry/popup_marker.html
+++ b/www/plugins/map/templates/registry/popup_marker.html
@@ -1,5 +1,5 @@
 <div class="item no-border no-padding item-avatar "
-     ng-if="loading">
+     ng-if="loadingMarker">
 
   <i class="item-image icon ion-person"></i>
 
@@ -17,7 +17,7 @@
 </div>
 
 <a class="item no-border no-padding item-avatar ink animate-fade-in animate-show-hide ng-hide"
-     ng-show="!loading"
+     ng-show="!loadingMarker"
      ui-sref="app.view_page({id: formData.id, title: formData.name})">
   <i ng-if="formData.avatar" class="item-image avatar" style="background-image: url({{::formData.avatar.src}}"></i>
   <i ng-if="!formData.avatar" class="item-image icon cion-page-{{::formData.type}}"></i>
@@ -41,7 +41,7 @@
        ng-class="{'ion-arrow-down-b': !showDescription, 'ion-arrow-up-b': showDescription}"
        ng-click="showDescription=!showDescription;"
        title="{{'PROFILE.DESCRIPTION'|translate}}"
-       ng-show="!loading && formData.description">
+       ng-show="!loadingMarker && formData.description">
       &nbsp;
     </a>
   </div>
-- 
GitLab