From 9ec6455f2a77a5b2cbbd26dbe481367f7f078dcc Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Mon, 3 Jun 2013 20:46:56 -0400 Subject: [PATCH] groups: some ridiculous workarounds on the model.push/unshift bug --- src/app/groups.coffee | 5 +++++ src/app/misc.coffee | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/groups.coffee b/src/app/groups.coffee index 150a107e9e..a30dad6f79 100644 --- a/src/app/groups.coffee +++ b/src/app/groups.coffee @@ -128,6 +128,11 @@ module.exports.app = (appExports, model, app) -> return unless /\S/.test text group = e.at() + + # get rid of duplicate member ids - this is a weird place to put it, but works for now + members = group.get('members'); uniqMembers = _.uniq(members) + group.set('members', uniqMembers) if !_.isEqual(uniqMembers, members) + chat = group.at('chat') model.set('_chatMessage', '') diff --git a/src/app/misc.coffee b/src/app/misc.coffee index 1236949db5..91c3b4f7ae 100644 --- a/src/app/misc.coffee +++ b/src/app/misc.coffee @@ -110,14 +110,15 @@ module.exports.fixCorruptUser = (model) -> user.del("tasks.#{key}") delete tasks[key] true - resetDom = false batchTxn model, (uObj, paths, batch) -> - ## fix https://github.com/lefnire/habitrpg/issues/1086 uniqPets = _.uniq(uObj.items.pets) batch.set('items.pets', uniqPets) if !_.isEqual(uniqPets, uObj.items.pets) + uniqInvites = _.uniq(uObj.invitations?.guilds) + batch.set('invitations.guilds', uniqInvites) if !_.isEqual(uniqInvites, uObj.invitations?.guilds) + ## Task List Cleanup ['habit','daily','todo','reward'].forEach (type) ->