<commit_before>// connected-users.js
//
// keeps track of connected users, and publishes to client so that
// presence information can be shared

// https://github.com/tmeasday/meteor-presence

if (Meteor.isServer) {
  Meteor.publish('userPresence', function(spaceId) {
    console.log('publish userPresence');
    // Setup some filter to find the users your logged in user
    // cares about. It's unlikely that you want to publish the
    // presences of _all_ the users in the system.
    var filter = {"state.currentSpace": spaceId};

    // ProTip: unless you need it, don't send lastSeen down as it'll make your
    // templates constantly re-render (and use bandwidth)
    return Meteor.presences.find(filter, {fields: {state: true, userId: true}});
  });
}

if (Meteor.isClient) {
  Meteor.startup( function() {
    Deps.autorun(function() {
      Meteor.subscribe('userPresence', Session.get('currentSpace'));
    });

    Meteor.presences.find().observe({
      added: function(cu) {
        console.log('presence: +', cu.userId);
      },
      removed: function(cu) {
        console.log('presence: -', cu.userId);
      }
    });
  });

  Meteor.Presence.state = function() {
    return {
      online: true,
      currentSpace: Session.get('currentSpace')
    }
  }

  Template.connected.helpers({
    onlineUsers: function() {
      console.log('connected online');
      return Meteor.presences.find();
    }
  });
}
<commit_msg>remove unused code<commit_after>// connected-users.js
//
// keeps track of connected users, and publishes to client so that
// presence information can be shared

// https://github.com/tmeasday/meteor-presence

if (Meteor.isServer) {
  Meteor.publish('userPresence', function(spaceId) {
    // Setup some filter to find the users your logged in user
    // cares about. It's unlikely that you want to publish the
    // presences of _all_ the users in the system.
    var filter = {"state.currentSpace": spaceId};

    // ProTip: unless you need it, don't send lastSeen down as it'll make your
    // templates constantly re-render (and use bandwidth)
    return Meteor.presences.find(filter, {fields: {state: true, userId: true}});
  });
}

if (Meteor.isClient) {
  Meteor.startup( function() {
    Deps.autorun(function() {
      Meteor.subscribe('userPresence', Session.get('currentSpace'));
    });
  });

  Meteor.Presence.state = function() {
    return {
      online: true,
      currentSpace: Session.get('currentSpace')
    }
  }

  Template.connected.helpers({
    onlineUsers: function() {
      return Meteor.presences.find();
    }
  });
}

{'fraction_non_alphanumeric': 0.13428241631396692, 'fraction_numerical': 0.0, 'mean_word_length': 3.0498442367601246, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '800637', 'n_tokens_mistral': 817, 'n_tokens_neox': 787, 'n_words': 217}