fixed some notification stuff
This commit is contained in:
parent
2d6daabe76
commit
d9d18be042
@ -77,6 +77,33 @@ NGApp.factory('TicketViewService', function($rootScope, $resource, $routeParams,
|
||||
service.socket.emit('event.subscribe', 'ticket.' + service.scope.viewTicket);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$rootScope.$on('userAuth', function(e, data) {
|
||||
if (!service.socket) {
|
||||
return;
|
||||
}
|
||||
if (AccountService.user && AccountService.user.prefs && AccountService.user.prefs['notification-desktop-support-all'] == '1') {
|
||||
console.debug('Subscribing to all tickets');
|
||||
service.socket.emit('event.subscribe', 'ticket.all');
|
||||
} else {
|
||||
console.debug('Unsubscribing to all tickets');
|
||||
service.socket.emit('event.unsubscribe', 'ticket.all');
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('user-preference-notification-desktop-support-all', function(e, value) {
|
||||
if (!service.socket) {
|
||||
return;
|
||||
}
|
||||
if (value == '1') {
|
||||
console.debug('Subscribing to all tickets');
|
||||
service.socket.emit('event.subscribe', 'ticket.all');
|
||||
} else {
|
||||
console.debug('Unsubscribing to all tickets');
|
||||
service.socket.emit('event.unsubscribe', 'ticket.all');
|
||||
}
|
||||
});
|
||||
|
||||
// service.websocket = new WebSocket('wss://' + location.host + ':9000/test?_token=' + $.cookie('token'));
|
||||
|
||||
@ -89,8 +116,9 @@ NGApp.factory('TicketViewService', function($rootScope, $resource, $routeParams,
|
||||
phpsessid: $.cookie('PHPSESSID'),
|
||||
host: location.host
|
||||
});
|
||||
|
||||
if (AccountService.user.prefs['notification-desktop-support-all'] == '1') {
|
||||
|
||||
if (AccountService.user && AccountService.user.prefs && AccountService.user.prefs['notification-desktop-support-all'] == '1') {
|
||||
console.debug('Subscribing to all tickets');
|
||||
service.socket.emit('event.subscribe', 'ticket.all');
|
||||
}
|
||||
});
|
||||
|
||||
@ -17,7 +17,7 @@ NGApp.directive('chatSend', function(TicketViewService) {
|
||||
});
|
||||
|
||||
|
||||
NGApp.directive('profilePreference', function (AccountService, $http) {
|
||||
NGApp.directive('profilePreference', function (AccountService, $http, $rootScope) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
templateUrl: 'assets/view/general-profile-preference.html',
|
||||
@ -41,6 +41,8 @@ NGApp.directive('profilePreference', function (AccountService, $http) {
|
||||
|
||||
AccountService.user.prefs[$scope.key] = value;
|
||||
|
||||
$rootScope.$broadcast('user-preference-' + $scope.key, value);
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: App.service + 'config',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user