B2G/gaia/apps/sms/js/thread_ui.js
// Method for updating the header with the info retrieved from Contacts API
Method for updating the header with the info retrieved from Contacts API
Method for updating the header with the info retrieved from Contacts API
function thui_updateHeaderData(callback) {
    var thread, number, others;
    if (Threads.currentId) {
      thread = Threads.active;
    }
    if (!thread) {
      if (callback) {
        callback();
      }
      return;
    }
    if (window.location.hash === '#group-view') {
      return;
    }
    number = thread.participants[0];
    others = thread.participants.length - 1;
    if (!this._mozMobileMessage && callback) {
      this.headerText.textContent = navigator.mozL10n.get(
        'thread-header-text', {
        name: number,
        n: others
      });
      setTimeout(callback);
      return;
    }
    this.headerText.dataset.number = number;
        Jane Doe (+2)
    Contacts.findByPhoneNumber(number, function gotContact(contacts) {
      var carrierTag = document.getElementById('contact-carrier');
      var threadMessages = document.getElementById('thread-messages');
       Bug 867948: contacts null is a legitimate case, and
       getContactDetails is okay with that.
      var details = Utils.getContactDetails(number, contacts);
      var contactName = details.title || number;
      var carrierText;
      this.headerText.dataset.isContact = !!details.isContact;
      this.headerText.textContent = navigator.mozL10n.get(
        'thread-header-text', {
          name: contactName,
          n: others
      });
       The carrier banner is meaningless and confusing in
       group message mode.
      if (thread.participants.length === 1 &&
          (contacts && contacts.length)) {
        carrierText = Utils.getCarrierTag(
          number, contacts[0].tel, details
        );
         Known Contact with at least:
          1. a name
          2. a carrier
          3. a type
        if (carrierText) {
          carrierTag.textContent = carrierText;
          threadMessages.classList.add('has-carrier');
        } else {
          threadMessages.classList.remove('has-carrier');
        }
      } else {
         Hide carrier tag in group message or unknown contact cases.
        threadMessages.classList.remove('has-carrier');
      }
      if (callback) {
        callback();
      }
    }.bind(this));
  }
function thui_updateHeaderData ( callback ) { var thread , number , others ; if ( Threads . currentId ) { thread = Threads . active ; } if ( ! thread ) { if ( callback ) { callback ( ) ; } return ; } if ( window . location . hash === '#group-view' ) { return ; } number = thread . participants [ 0 ] ; others = thread . participants . length - 1 ; if ( ! this . _mozMobileMessage && callback ) { this . headerText . textContent = navigator . mozL10n . get ( 'thread-header-text' , { name : number , n : others } ) ; setTimeout ( callback ) ; return ; } this . headerText . dataset . number = number ; Contacts . findByPhoneNumber ( number , function gotContact ( contacts ) { var carrierTag = document . getElementById ( 'contact-carrier' ) ; var threadMessages = document . getElementById ( 'thread-messages' ) ; var details = Utils . getContactDetails ( number , contacts ) ; var contactName = details . title || number ; var carrierText ; this . headerText . dataset . isContact = ! ! details . isContact ; this . headerText . textContent = navigator . mozL10n . get ( 'thread-header-text' , { name : contactName , n : others } ) ; if ( thread . participants . length === 1 && ( contacts && contacts . length ) ) { carrierText = Utils . getCarrierTag ( number , contacts [ 0 ] . tel , details ) ; if ( carrierText ) { carrierTag . textContent = carrierText ; threadMessages . classList . add ( 'has-carrier' ) ; } else { threadMessages . classList . remove ( 'has-carrier' ) ; } } else { threadMessages . classList . remove ( 'has-carrier' ) ; } if ( callback ) { callback ( ) ; } } . bind ( this ) ) ; }
Method for updating the header with the info retrieved from Contacts API
Method for updating the header with the info retrieved from Contacts API
// For Desktop testing, there is a fake mozContacts but it's not working // completely. So in the case of Desktop testing we are going to execute // the callback directly in order to make it work! // https://bugzilla.mozilla.org/show_bug.cgi?id=836733 // Add data to contact activity interaction // For the basic display, we only need the first contact's information -- // e.g. for 3 contacts, the app displays: // //    Jane Doe (+2) // // Bug 867948: contacts null is a legitimate case, and // getContactDetails is okay with that. // The carrier banner is meaningless and confusing in // group message mode. // Known Contact with at least: // //  1. a name //  2. a carrier //  3. a type // // Hide carrier tag in group message or unknown contact cases.