alecpl
2010-05-06 9800a825e7a98d3bd857f168e697555259098932
- improve performance and consistency by setting all list-related env data in list action only


3 files modified
39 ■■■■■ changed files
program/js/app.js 18 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 19 ●●●●● patch | view | raw | blame | history
program/steps/mail/list.inc 2 ●●●●● patch | view | raw | blame | history
program/js/app.js
@@ -165,9 +165,10 @@
        if (this.gui_objects.messagelist) {
          this.message_list = new rcube_list_widget(this.gui_objects.messagelist,
            {multiselect:true, multiexpand:true, draggable:true, keyboard:true,
            column_movable:this.env.col_movable, column_fixed:0, dblclick_time:this.dblclick_time});
          this.message_list = new rcube_list_widget(this.gui_objects.messagelist, {
            multiselect:true, multiexpand:true, draggable:true, keyboard:true,
            column_movable:this.env.col_movable, column_fixed:0, dblclick_time:this.dblclick_time
            });
          this.message_list.row_init = function(o){ p.init_message_row(o); };
          this.message_list.addEventListener('dblclick', function(o){ p.msglist_dbl_click(o); });
          this.message_list.addEventListener('click', function(o){ p.msglist_click(o); });
@@ -186,7 +187,6 @@
          this.enable_command('toggle_status', 'toggle_flag', 'menu-open', 'menu-save', true);
          // load messages
          if (this.env.messagecount)
            this.command('list');
        }
@@ -246,16 +246,6 @@
        // show printing dialog
        else if (this.env.action == 'print')
          window.print();
        if (this.env.messagecount) {
          this.enable_command('select-all', 'select-none', 'expunge', true);
          this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading);
        }
        if (this.purge_mailbox_test())
          this.enable_command('purge', true);
        this.set_page_buttons();
        // get unread count for each mailbox
        if (this.gui_objects.mailboxlist) {
program/steps/mail/func.inc
@@ -96,9 +96,6 @@
    
      $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
      $OUTPUT->set_env('search_mods', $search_mods);
      // make sure the message count is refreshed (for default view)
      $IMAP->messagecount($mbox_name, $IMAP->threading ? 'THREADS' : 'ALL', true);
    }
    
  // set current mailbox and some other vars in client environment
@@ -175,14 +172,10 @@
    $a_show_cols[$f] = 'to';
  $skin_path = $_SESSION['skin_path'] = $CONFIG['skin_path'];
  $message_count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
  
  // set client env
  $OUTPUT->add_gui_object('messagelist', $attrib['id']);
  $OUTPUT->set_env('autoexpand_threads', intval($CONFIG['autoexpand_threads']));
  $OUTPUT->set_env('messagecount', $message_count);
  $OUTPUT->set_env('current_page', $IMAP->list_page);
  $OUTPUT->set_env('pagecount', ceil($message_count/$IMAP->page_size));
  $OUTPUT->set_env('sort_col', $_SESSION['sort_col']);
  $OUTPUT->set_env('sort_order', $_SESSION['sort_order']);
  
@@ -209,9 +202,6 @@
  
  $OUTPUT->set_env('messages', array());
  $OUTPUT->set_env('coltypes', $a_show_cols);
  if (!$message_count)
    $OUTPUT->show_message('nomessagesfound', 'notice');
  
  $OUTPUT->include_script('list.js');
  
@@ -483,7 +473,7 @@
function rcmail_get_messagecount_text($count=NULL, $page=NULL)
  {
  global $IMAP, $MESSAGE;
  global $RCMAIL, $IMAP, $MESSAGE;
  
  if (isset($MESSAGE->index))
    {
@@ -496,7 +486,11 @@
    $page = $IMAP->list_page;
    
  $start_msg = ($page-1) * $IMAP->page_size + 1;
  $max = $count!==NULL ? $count : $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
  if ($count!==NULL)
    $max = $count;
  else if ($RCMAIL->action)
    $max = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
  if ($max==0)
    $out = rcube_label('mailboxempty');
@@ -1528,3 +1522,4 @@
));
?>
program/steps/mail/list.inc
@@ -78,6 +78,7 @@
$OUTPUT->set_env('messagecount', $count);
$OUTPUT->set_env('pagecount', $pages);
$OUTPUT->set_env('threading', (bool) $IMAP->threading);
$OUTPUT->set_env('current_page', $IMAP->list_page);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
$OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
@@ -97,3 +98,4 @@
$OUTPUT->send();
?>