From 539547b39e204538acdc161e5e3c100e25f4c567 Mon Sep 17 00:00:00 2001 From: Shervin Sarain Date: Sat, 11 Jun 2016 19:57:20 +0200 Subject: [PATCH] prevent sync from clearing selected tags (#7631) * prevent sync from clearing selected tags * improved tag selection bugfix --- website/client/js/services/userServices.js | 4 ++++ website/server/models/user/hooks.js | 1 + website/server/models/user/schema.js | 4 ---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/website/client/js/services/userServices.js b/website/client/js/services/userServices.js index 2b466c6bf9..0f05be7edb 100644 --- a/website/client/js/services/userServices.js +++ b/website/client/js/services/userServices.js @@ -80,6 +80,10 @@ angular.module('habitrpg') _.extend(user, response.data.data); + if (!user.filters) { + user.filters = {}; + } + if (!user._wrapped) { // This wraps user with `ops`, which are functions shared both on client and mobile. When performed on client, // they update the user in the browser and then send the request to the server, where the same operation is diff --git a/website/server/models/user/hooks.js b/website/server/models/user/hooks.js index abdddb8707..04ade1fa11 100644 --- a/website/server/models/user/hooks.js +++ b/website/server/models/user/hooks.js @@ -13,6 +13,7 @@ schema.plugin(baseModel, { private: ['auth.local.hashed_password', 'auth.local.salt', '_cronSignature'], toJSONTransform: function userToJSON (plainObj, originalDoc) { plainObj._tmp = originalDoc._tmp; // be sure to send down drop notifs + delete plainObj.filters; return plainObj; }, diff --git a/website/server/models/user/schema.js b/website/server/models/user/schema.js index 96d2a19904..bd37ec4bf8 100644 --- a/website/server/models/user/schema.js +++ b/website/server/models/user/schema.js @@ -107,10 +107,6 @@ let schema = new Schema({ }, balance: {type: Number, default: 0}, - // Not saved on the user right now - filters: {type: Schema.Types.Mixed, default: () => { - return {}; - }}, purchased: { ads: {type: Boolean, default: false},