<commit_before>import React from 'react';

const RoomListItem = React.createClass({
  mixins: [ReactMeteorData],

  getMeteorData () {
    const messagesHandle = Meteor.subscribe("chatterMessages", {
      roomId: this.props.room._id,
      messageLimit: 30
    });

    const usersHandle = Meteor.subscribe("chatterUsers", {
      roomId: this.props.room._id
    });

    const countHandle = Meteor.subscribe("chatterUserRoomCounts", {
      roomId: this.props.room._id
    });

    const subsReady = messagesHandle.ready() && usersHandle.ready() && countHandle.ready();

    let message = "";
    let avatar = null;
    let timeAgo = "";
    let count = 0;

    if (subsReady) {
      const lastMessage = Chatter.Message.findOne({roomId: this.props.room._id }, {sort: {createdAt: -1, limit: 1}});
      const checkCount = Chatter.UserRoomCount.findOne({roomId: this.props.room._id, userId: Meteor.userId() });
      count =  typeof checkCount === 'undefined' ? "0" : checkCount.count;
      const roomEmpty = typeof lastMessage === 'undefined';
      message = roomEmpty ?  "no messages yet" : lastMessage.message;
      timeAgo = roomEmpty ? "" : lastMessage.timeAgo();
      avatar = roomEmpty ?  "http://localhost:3000/packages/jorgeer_chatter-semantic/public/images/default.jpg" : lastMessage.userAvatar;
    }

    return {
      message,
      avatar,
      timeAgo,
      count
    }
  },<commit_msg>refactored and simplified roomList component<commit_after>import React from 'react';

const RoomListItem = React.createClass({
  mixins: [ReactMeteorData],

  getMeteorData () {
    const messagesHandle = Meteor.subscribe("chatterMessages", {
      roomId: this.props.room._id,
      messageLimit: 30
    });

    const usersHandle = Meteor.subscribe("chatterUsers", {
      roomId: this.props.room._id
    });

    const countHandle = Meteor.subscribe("chatterUserRoomCounts", {
      roomId: this.props.room._id
    });

    const subsReady = messagesHandle.ready() && usersHandle.ready() && countHandle.ready();

    let message = "no messages yet",
        avatar = "http://localhost:3000/packages/jorgeer_chatter-semantic/public/images/default.jpg",
        timeAgo = "",
        count = 0;

    if (subsReady) {
      const checkCount = Chatter.UserRoomCount.findOne({roomId: this.props.room._id, userId: Meteor.userId() });
      count =  typeof checkCount === 'undefined' ? "0" : checkCount.count;

      const lastMessage = Chatter.Message.findOne({roomId: this.props.room._id }, {sort: {createdAt: -1, limit: 1}});
      if (typeof lastMessage != 'undefined') {
        message = lastMessage.message;
        timeAgo = lastMessage.timeAgo();
        avatar = lastMessage.userAvatar;
      }
    }

    return {
      message,
      avatar,
      timeAgo,
      count
    }
  },
{'fraction_non_alphanumeric': 0.13340486409155938, 'fraction_numerical': 0.00715307582260372, 'mean_word_length': 3.0244604316546764, 'pattern_counts': {'":': 0, '<': 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': '2744146', 'n_tokens_mistral': 893, 'n_tokens_neox': 855, 'n_words': 172}