From d1bb71f99db8ce91b62b47a3e922614b45859822 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 14:39:27 +1000 Subject: [PATCH] allow for incomplete fixture --- app/assets/javascripts/discourse/models/user.js.es6 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/models/user.js.es6 b/app/assets/javascripts/discourse/models/user.js.es6 index 99aca34d6fc..223ebc19661 100644 --- a/app/assets/javascripts/discourse/models/user.js.es6 +++ b/app/assets/javascripts/discourse/models/user.js.es6 @@ -184,12 +184,15 @@ const User = RestModel.extend({ ['muted','watched','tracked','watched_first_post'].forEach(s => { let prop = s === "watched_first_post" ? "watchedFirstPostCategories" : s + "Categories"; - let cats = this.get(prop).map(c => c.get('id')); - updatedState[s + '_category_ids'] = cats; + let cats = this.get(prop); + if (cats) { + let cat_ids = cats.map(c => c.get('id')); + updatedState[s + '_category_ids'] = cat_ids; - // HACK: denote lack of categories - if (cats.length === 0) { cats = [-1]; } - data[s + '_category_ids'] = cats; + // HACK: denote lack of categories + if (cats.length === 0) { cat_ids = [-1]; } + data[s + '_category_ids'] = cat_ids; + } }); if (!Discourse.SiteSettings.edit_history_visible_to_public) {