B2G/gaia/apps/sms/js/thread_ui.js
// Method for rendering the list of messages using infinite scroll
Method for rendering the list of messages using infinite scroll
Method for rendering the list of messages using infinite scroll
function thui_renderMessages(filter, callback) {
    this.initializeRendering();
    var self = this;
    var onMessagesRendered = function messagesRendered() {
      if (self.messageIndex < self.CHUNK_SIZE) {
        self.showFirstChunk();
      }
      filter.read = false;
      if (callback) {
        callback();
      }
      setTimeout(function updatingStatus() {
        var messagesUnreadIDs = [];
        var changeStatusOptions = {
          each: function addUnreadMessage(message) {
            messagesUnreadIDs.push(message.id);
            return true;
          },
          filter: filter,
          invert: true,
          end: function handleUnread() {
            MessageManager.markMessagesRead(messagesUnreadIDs, true);
          }
        };
        MessageManager.getMessages(changeStatusOptions);
      });
    };
    var renderingOptions = {
      each: function renderMessage(message) {
        if (self._stopRenderingNextStep) {
          return false;
        }
        self.appendMessage(message, true);
        self.messageIndex++;
        if (self.messageIndex === self.CHUNK_SIZE) {
          self.showFirstChunk();
        }
        return true;
      },
      filter: filter,
      invert: false,
      end: onMessagesRendered
    };
    MessageManager.getMessages(renderingOptions);
    this.isScrolledManually = false;
  }
function thui_renderMessages ( filter , callback ) { this . initializeRendering ( ) ; var self = this ; var onMessagesRendered = function messagesRendered ( ) { if ( self . messageIndex < self . CHUNK_SIZE ) { self . showFirstChunk ( ) ; } filter . read = false ; if ( callback ) { callback ( ) ; } setTimeout ( function updatingStatus ( ) { var messagesUnreadIDs = [ ] ; var changeStatusOptions = { each : function addUnreadMessage ( message ) { messagesUnreadIDs . push ( message . id ) ; return true ; } , filter : filter , invert : true , end : function handleUnread ( ) { MessageManager . markMessagesRead ( messagesUnreadIDs , true ) ; } } ; MessageManager . getMessages ( changeStatusOptions ) ; } ) ; } ; var renderingOptions = { each : function renderMessage ( message ) { if ( self . _stopRenderingNextStep ) { return false ; } self . appendMessage ( message , true ) ; self . messageIndex ++ ; if ( self . messageIndex === self . CHUNK_SIZE ) { self . showFirstChunk ( ) ; } return true ; } , filter : filter , invert : false , end : onMessagesRendered } ; MessageManager . getMessages ( renderingOptions ) ; this . isScrolledManually = false ; }
Method for rendering the list of messages using infinite scroll
Method for rendering the list of messages using infinite scroll
// We initialize all params before rendering // We call getMessages with callbacks // Update STATUS of messages if needed // stop the iteration /*hidden*/ // force the next scroll to bottom