fix: tasks getting replaced when switching projects in work view #69

This commit is contained in:
Johannes Millan 2018-03-29 21:50:40 +02:00
parent f4b7887a36
commit adcc034196

View file

@ -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();