From adcc03419614aa981777e224809ee8fa5d09d141 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Thu, 29 Mar 2018 21:50:40 +0200 Subject: [PATCH] fix: tasks getting replaced when switching projects in work view #69 --- app-src/scripts/work-view/work-view-d.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app-src/scripts/work-view/work-view-d.js b/app-src/scripts/work-view/work-view-d.js index dd926690a4..9808f375ca 100644 --- a/app-src/scripts/work-view/work-view-d.js +++ b/app-src/scripts/work-view/work-view-d.js @@ -25,17 +25,21 @@ } /* @ngInject */ - function WorkViewCtrl(Tasks, $window, $scope, Dialogs, $rootScope, TasksUtil, $timeout) { + function WorkViewCtrl(Tasks, $window, $scope, Dialogs, $rootScope, TasksUtil, $timeout, EV_PROJECT_CHANGED) { let vm = this; const _ = $window._; // INIT - vm.session = $rootScope.r.currentSession; - vm.config = $rootScope.r.config; - vm.tasksUndone = Tasks.getUndoneToday(); - vm.tasksDone = Tasks.getDoneToday(); - updateTimeTotals(); - focusFirstTask(); + function init() { + vm.session = $rootScope.r.currentSession; + vm.config = $rootScope.r.config; + vm.tasksUndone = Tasks.getUndoneToday(); + vm.tasksDone = Tasks.getDoneToday(); + updateTimeTotals(); + focusFirstTask(); + } + + init(); // PRIVATE FUNCTIONS // ----------------- @@ -133,6 +137,10 @@ updateTasksLsOnly(); })); + $scope.$on(EV_PROJECT_CHANGED, () => { + init(); + }); + // otherwise we update on view change $scope.$on('$destroy', () => { updateGlobalTaskModel();