FIX: categories/delete_categories can be undefined (#6657)

FIX: categories/delete_categories can be undefined (#6657)

From f4432648fd22ade6f7a214a5ddda63283f873b6c Mon Sep 17 00:00:00 2001
From: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Date: Fri, 23 Nov 2018 00:57:18 +0100
Subject: [PATCH] FIX: categories/delete_categories can be undefined (#6657)


diff --git a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6
index 0dd8250..96ea1ef 100644
--- a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6
+++ b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6
@@ -114,8 +114,8 @@ export default {
       const router = container.lookup("router:main");
 
       bus.subscribe("/categories", data => {
-        data.categories.forEach(c => site.updateCategory(c));
-        data.deleted_categories.forEach(id => site.removeCategory(id));
+        (data.categories || []).forEach(c => site.updateCategory(c));
+        (data.deleted_categories || []).forEach(id => site.removeCategory(id));
       });
 
       bus.subscribe("/client_settings", data =>

GitHub

2 Likes