Skip to content

Commit

Permalink
Presence map: normalise enter/update actions to present in #put
Browse files Browse the repository at this point in the history
Neater than juggling different broadcast and map-member presence messages
in #setPresence

Fixes presence test failures broken by 9c4f8d7
  • Loading branch information
SimonWoolf committed Oct 19, 2015
1 parent 16c0f7e commit ed82bd4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/lib/client/realtimepresence.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ var RealtimePresence = (function() {
break;
case presenceAction.UPDATE:
case presenceAction.ENTER:
presence.action = presenceAction.PRESENT;
case presenceAction.PRESENT:
if(members.put(presence)) {
broadcastMessages.push(presence);
Expand Down Expand Up @@ -259,6 +258,10 @@ var RealtimePresence = (function() {
};

PresenceMap.prototype.put = function(item) {
if(Utils.arrIn([presenceAction.ENTER, presenceAction.UPDATE], item.action)) {
item = Utils.copy(item);
item.action = presenceAction.PRESENT;
}
var map = this.map, key = memberKey(item);
/* we've seen this member, so do not remove it at the end of sync */
if(this.residualMembers)
Expand Down

0 comments on commit ed82bd4

Please sign in to comment.