Repair notifications sync

stable
Daniel García 2018-11-27 09:29:50 +01:00 committed by Alex Hermida
parent 0bd3b38a26
commit 09855054be
3 changed files with 11 additions and 7 deletions

View File

@ -121,7 +121,7 @@ class EventsService
routingKey = "web_notifications.#{userId}" routingKey = "web_notifications.#{userId}"
randomTimeout = taiga.randomInt(700, 1000) randomTimeout = taiga.randomInt(700, 1000)
@.subscribe null, routingKey, (data) => @.subscribe null, routingKey, (data) =>
@rootScope.$broadcast "notifications:updated" @rootScope.$broadcast "notifications:new"
########################################### ###########################################
# Heartbeat (Ping - Pong) # Heartbeat (Ping - Pong)

View File

@ -41,7 +41,7 @@ DropdownNotificationsDirective = ($rootScope, notificationsService, currentUserS
$scope.setAllAsRead = () -> $scope.setAllAsRead = () ->
notificationsService.setNotificationsAsRead().then -> notificationsService.setNotificationsAsRead().then ->
$rootScope.$emit("notifications:updated") $rootScope.$emit("notifications:dismiss-all")
directive = { directive = {
templateUrl: "navigation-bar/dropdown-notifications/dropdown-notifications.html" templateUrl: "navigation-bar/dropdown-notifications/dropdown-notifications.html"

View File

@ -41,10 +41,16 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
@.initList() @.initList()
@.loadNotifications() @.loadNotifications()
@rootScope.$on "notifications:updated", (event) => @rootScope.$on "notifications:dismiss", (event) =>
if @.onlyUnread if @.onlyUnread
@.reloadList() @.reloadList()
@rootScope.$on "notifications:new", (event) =>
@.reloadList()
@rootScope.$on "notifications:dismiss-all", (event) =>
@.reloadList()
initList: ()-> initList: ()->
@.notificationsList = Immutable.List() @.notificationsList = Immutable.List()
@.list = @notificationsService.getNotificationsList(@.user.get("id"), @.onlyUnread?) @.list = @notificationsService.getNotificationsList(@.user.get("id"), @.onlyUnread?)
@ -80,13 +86,11 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
else else
@location.path(url) @location.path(url)
@rootScope.$broadcast "notifications:updated" @rootScope.$broadcast "notifications:dismiss"
setAllAsRead: () -> setAllAsRead: () ->
@.loading = true
@scope.$emit("notifications:loading")
@notificationsService.setNotificationsAsRead().then => @notificationsService.setNotificationsAsRead().then =>
@rootScope.$emit("notifications:updated") @rootScope.$broadcast "notifications:dismiss-all"
angular.module("taigaNotifications").controller("Notifications", NotificationsController) angular.module("taigaNotifications").controller("Notifications", NotificationsController)