This repository was archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathnotificationsCtrl.js
More file actions
52 lines (40 loc) · 2.02 KB
/
notificationsCtrl.js
File metadata and controls
52 lines (40 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
angular.module('codebrag.notifications')
.controller('NotificationsCtrl', function($scope, $state, $rootScope, currentCommit, notificationPoller, commitsNotificationsService, followupsNotificationService, currentRepoContext, events) {
$scope.commitsNotifications = commitsNotificationsService.notifications;
$scope.followupsNotification = followupsNotificationService.notification;
currentRepoContext.ready().then(function() {
notificationPoller.start();
});
$scope.goToDestRepo = function(notif) {
commitsNotificationsService.markAsRead(notif);
$scope.openCommits(notif.repo, notif.branch);
};
$scope.openFollowups = function() {
followupsNotificationService.markAsRead();
$rootScope.$broadcast(events.followupsTabOpened);
$state.transitionTo('followups.list');
};
$scope.openCommits = function(repo, branch) {
currentCommit.empty();
currentRepoContext.switchRepo(repo || currentRepoContext.repo);
currentRepoContext.switchBranch(branch || currentRepoContext.branch);
$rootScope.$broadcast(events.commitsTabOpened);
$state.transitionTo('commits.list', {repo: repo || currentRepoContext.repo});
};
$rootScope.$on('commitsNotificationsAvailable', function() {
$scope.commitsNotificationsAvailable = true;
});
$rootScope.$on('allCommitsNotificationsRead', function() {
$scope.commitsNotificationsAvailable = false;
});
$rootScope.$on('followupsNotificationAvailable', function() {
$scope.followupsNotificationAvailable = true;
});
$rootScope.$on('followupsNotificationRead', function() {
$scope.followupsNotificationAvailable = false;
});
$scope.openDashboard = function() {
$rootScope.$broadcast(events.allfollowupsTabOpened);
$state.transitionTo('dashboard.list');
};
});