From b187762d55e6f428548e5ed80ac7abbe3cc08347 Mon Sep 17 00:00:00 2001 From: Julie Wang Date: Thu, 21 Jun 2018 10:52:27 -0700 Subject: [PATCH] [Folder] List view load fix (#2069) * [Folder] List view load fix -List view data takes long time to display, has to do with Angular not triggering its digestive cycle when switching views -Resolved issue by explicitly triggering the digestive cycle -Fixes issue #2067 * Added comment to clarify code addition fix #2069 --- .../features/listview/src/controllers/ListViewController.js | 5 +++++ .../listview/test/controllers/ListViewControllerSpec.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/features/listview/src/controllers/ListViewController.js b/platform/features/listview/src/controllers/ListViewController.js index 385ab635bc..456abec91c 100644 --- a/platform/features/listview/src/controllers/ListViewController.js +++ b/platform/features/listview/src/controllers/ListViewController.js @@ -32,6 +32,11 @@ define(function () { this.utc = formatService.getFormat('utc'); + //Trigger digestive cycle with $apply to update list view + setTimeout(function () { + $scope.$apply(); + }); + $scope.$on('$destroy', function () { unlisten(); }); diff --git a/platform/features/listview/test/controllers/ListViewControllerSpec.js b/platform/features/listview/test/controllers/ListViewControllerSpec.js index ea0a5e0ce8..d4b3638f5f 100644 --- a/platform/features/listview/test/controllers/ListViewControllerSpec.js +++ b/platform/features/listview/test/controllers/ListViewControllerSpec.js @@ -104,7 +104,7 @@ define( scope = jasmine.createSpyObj( "$scope", - ["$on"] + ["$on", "$apply"] ); scope.domainObject = domainObject; @@ -146,6 +146,7 @@ define( runs(function () { expect(scope.children.length).toEqual(0); }); + expect(scope.$apply).toHaveBeenCalled(); }); it("releases listeners on $destroy", function () { expect(scope.$on).toHaveBeenCalledWith('$destroy', jasmine.any(Function));