From 09855054bec5c7f1a86bdb7519935678986fb037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 27 Nov 2018 09:29:50 +0100 Subject: [PATCH] Repair notifications sync --- app/coffee/modules/events.coffee | 2 +- .../dropdown-notifications.directive.coffee | 2 +- .../notifications/notifications.controller.coffee | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/coffee/modules/events.coffee b/app/coffee/modules/events.coffee index 307bf27c..c45d9177 100644 --- a/app/coffee/modules/events.coffee +++ b/app/coffee/modules/events.coffee @@ -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) diff --git a/app/modules/navigation-bar/dropdown-notifications/dropdown-notifications.directive.coffee b/app/modules/navigation-bar/dropdown-notifications/dropdown-notifications.directive.coffee index 56748848..a18ad6b7 100644 --- a/app/modules/navigation-bar/dropdown-notifications/dropdown-notifications.directive.coffee +++ b/app/modules/navigation-bar/dropdown-notifications/dropdown-notifications.directive.coffee @@ -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" diff --git a/app/modules/notifications/notifications.controller.coffee b/app/modules/notifications/notifications.controller.coffee index 69b9236a..26e3f2a2 100644 --- a/app/modules/notifications/notifications.controller.coffee +++ b/app/modules/notifications/notifications.controller.coffee @@ -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)