Skip to content

Commit adcc034

Browse files
committed
fix: tasks getting replaced when switching projects in work view #69
1 parent f4b7887 commit adcc034

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

app-src/scripts/work-view/work-view-d.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@
2525
}
2626

2727
/* @ngInject */
28-
function WorkViewCtrl(Tasks, $window, $scope, Dialogs, $rootScope, TasksUtil, $timeout) {
28+
function WorkViewCtrl(Tasks, $window, $scope, Dialogs, $rootScope, TasksUtil, $timeout, EV_PROJECT_CHANGED) {
2929
let vm = this;
3030
const _ = $window._;
3131

3232
// INIT
33-
vm.session = $rootScope.r.currentSession;
34-
vm.config = $rootScope.r.config;
35-
vm.tasksUndone = Tasks.getUndoneToday();
36-
vm.tasksDone = Tasks.getDoneToday();
37-
updateTimeTotals();
38-
focusFirstTask();
33+
function init() {
34+
vm.session = $rootScope.r.currentSession;
35+
vm.config = $rootScope.r.config;
36+
vm.tasksUndone = Tasks.getUndoneToday();
37+
vm.tasksDone = Tasks.getDoneToday();
38+
updateTimeTotals();
39+
focusFirstTask();
40+
}
41+
42+
init();
3943

4044
// PRIVATE FUNCTIONS
4145
// -----------------
@@ -133,6 +137,10 @@
133137
updateTasksLsOnly();
134138
}));
135139

140+
$scope.$on(EV_PROJECT_CHANGED, () => {
141+
init();
142+
});
143+
136144
// otherwise we update on view change
137145
$scope.$on('$destroy', () => {
138146
updateGlobalTaskModel();

0 commit comments

Comments
 (0)