Commit 636f0210 authored by JC Brand's avatar JC Brand

Various fixes in the delta algorithm

parent 993c8f16
...@@ -568,23 +568,19 @@ ...@@ -568,23 +568,19 @@
}); });
if (!exclude_existing) { if (!exclude_existing) {
// Get the changed affiliations // Get the changed affiliations
var same_list = _.intersection(new_jids, old_jids); delta = delta.concat(_.filter(new_list, function (item) {
delta = delta.concat(_.filter(same_list, function (item) { var idx = _.indexOf(old_jids, item.jid);
var old_item;
var idx = _.indexOf(old_jids, item);
if (idx >= 0) { if (idx >= 0) {
old_item = old_list[idx]; return item.affiliation !== old_list[idx].affiliation;
return item.jid !== old_item.jid &&
item.affiliation !== old_item.affiliation;
} }
return false; return false;
})); }));
} }
if (remove_absentees) { if (remove_absentees) {
// Get the removed affiliations // Get the removed affiliations
delta = _.map(_.difference(old_jids, new_jids), function (jid) { delta = delta.concat(_.map(_.difference(old_jids, new_jids), function (jid) {
return {'jid': jid, 'affiliation': 'none'}; return {'jid': jid, 'affiliation': 'none'};
}); }));
} }
return delta; return delta;
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment