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}"
randomTimeout = taiga.randomInt(700, 1000)
@.subscribe null, routingKey, (data) =>
@rootScope.$broadcast "notifications:updated"
@rootScope.$broadcast "notifications:new"
###########################################
# Heartbeat (Ping - Pong)

View File

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

View File

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