<commit_before>Meteor.subscribe("discussions");

Template.body.helpers({
  listView: function () {
    return window.location.hash === "#list" ? true : false;
  }
});

Template.discussion.helpers({
  speakers: function () {
    var discussion = Discussions.findOne({_id: Session.get('currentDiscussion')});
    var speakers = _.sortBy(discussion.speakers, function(speaker) {
      return speaker.count;
    });

    var firstSpeaker = speakers[0] ? speakers[0] : undefined;

    //if the user is the first user on the list now ...
    if (firstSpeaker !== undefined && Meteor.userId() === firstSpeaker.owner) {
      // create a notification text ...
      var notificationText = Meteor.user().username + ", you're up! Join the conversation now."

      // invoke Android app notifications
      Meteor.call("userNotification", notificationText, "Chop chop!", Meteor.userId());

      if ("Notification" in window && Notification.permission === "granted") {
        // and push it, if the user uses a browser with Notification() support and has granted us access ...
        var notification = new Notification(notificationText);
      } else if ("Notification" in window && Notification.permission !== "denied") {
        // or ask for access and push it then, if we haven't asked yet
        Notification.requestPermission(function (permission) {
          if (permission === "granted") {
            var notification = new Notification(notificationText);
          }
        });
      }
    }

    return speakers;

    //console.log(Discussions.find({_id: Session.get('currentDiscussion')}, {sort: { "speakers.$.count": 1 } }));
    //return Discussions.findOne({_id: Session.get('currentDiscussion')}, {sort: { "speakers.$.count": 1 } }).speakers;
  },
  isAdmin: function () {
    return Discussions.findOne({_id: Session.get('currentDiscussion')}).owner === Meteor.userId();<commit_msg>ask for Notifications on loading<commit_after>Meteor.subscribe("discussions");

Template.body.helpers({
  listView: function () {
    return window.location.hash === "#list" ? true : false;
  }
});

Template.discussion.helpers({
  speakers: function () {
    var discussion = Discussions.findOne({_id: Session.get('currentDiscussion')});
    var speakers = _.sortBy(discussion.speakers, function(speaker) {
      return speaker.count;
    });

    //  ask for Notification access, if we haven't asked yet
    if ("Notification" in window && Notification.permission !== "denied") {
      Notification.requestPermission();
    }

    var firstSpeaker = speakers[0] ? speakers[0] : undefined;

    //if the user is the first user on the list now ...
    if (firstSpeaker !== undefined && Meteor.userId() === firstSpeaker.owner) {
      // create a notification text ...
      var notificationText = Meteor.user().username + ", you're up! Join the conversation now."

      // invoke Android app notifications
      Meteor.call("userNotification", notificationText, "Chop chop!", Meteor.userId());

      if ("Notification" in window && Notification.permission === "granted") {
        // and push it, if the user uses a browser with Notification() support and has granted us access ...
        var notification = new Notification(notificationText);
      } else if ("Notification" in window && Notification.permission !== "denied") {
        // or ask for access and push it then, if we haven't asked yet
        Notification.requestPermission(function (permission) {
          if (permission === "granted") {
            var notification = new Notification(notificationText);
          }
        });
      }
    }

    return speakers;

    //console.log(Discussions.find({_id: Session.get('currentDiscussion')}, {sort: { "speakers.$.count": 1 } }));
    //return Discussions.findOne({_id: Session.get('currentDiscussion')}, {sort: { "speakers.$.count": 1 } }).speakers;
  },
  isAdmin: function () {
    return Discussions.findOne({_id: Session.get('currentDiscussion')}).owner === Meteor.userId();
{'fraction_non_alphanumeric': 0.14382360310699072, 'fraction_numerical': 0.0020045101478326235, 'mean_word_length': 3.29247311827957, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1151007', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1062, 'n_words': 301}