Changeset 6d2714b in github


Ignore:
Timestamp:
Apr 11, 2008 12:53:59 PM (5 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
480f8c5a
Parents:
fe6b7ae
Message:

#1484972: optimization: mark as read in one action with preview, deleted redundant quota reads

Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • index.php

    reaa3947 r6d2714b  
    327327    include('program/steps/mail/rss.inc'); 
    328328     
    329   if ($_action=='quotadisplay') 
    330     include('program/steps/mail/quotadisplay.inc'); 
    331  
    332  
    333329  // make sure the message count is refreshed 
    334330  $IMAP->messagecount($_SESSION['mbox'], 'ALL', TRUE); 
  • program/js/app.js

    rcb6b51e r6d2714b  
    180180          this.enable_command('compose', 'add-contact', false); 
    181181          parent.rcmail.show_contentframe(true); 
    182           parent.rcmail.mark_message('read', this.env.uid); 
    183182          } 
    184183 
     
    15701569    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag); 
    15711570  }; 
     1571 
     1572  // set class to read/unread 
     1573  this.mark_as_read_from_preview = function(uid) 
     1574  { 
     1575    var icn_src; 
     1576    var rows = parent.rcmail.message_list.rows; 
     1577    if(rows[uid].unread) 
     1578      { 
     1579        rows[uid].unread = false; 
     1580        rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); 
     1581        parent.rcmail.set_classname(rows[uid].obj, 'unread', false); 
     1582 
     1583        if (rows[uid].replied && parent.rcmail.env.repliedicon) 
     1584          icn_src = parent.rcmail.env.repliedicon; 
     1585        else if (parent.rcmail.env.messageicon) 
     1586          icn_src = parent.rcmail.env.messageicon; 
     1587       
     1588        if (rows[uid].icon && icn_src) 
     1589          rows[uid].icon.src = icn_src; 
     1590      } 
     1591  } 
     1592   
    15721593   
    15731594  // mark all message rows as deleted/undeleted 
     
    32553276    }; 
    32563277 
     3278 
    32573279  // replace content of quota display 
    3258   this.set_quota = function() 
    3259     { 
    3260     if (this.gui_objects.quotadisplay && 
    3261         this.gui_objects.quotadisplay.attributes.getNamedItem('display') && 
    3262         this.gui_objects.quotadisplay.attributes.getNamedItem('id')) 
    3263       this.http_request('quotadisplay', '_display='+ 
    3264       this.gui_objects.quotadisplay.attributes.getNamedItem('display').nodeValue+ 
    3265       '&_id='+this.gui_objects.quotadisplay.attributes.getNamedItem('id').nodeValue, false); 
    3266      }; 
     3280  this.set_quota = function(content) 
     3281    { 
     3282    if (this.gui_objects.quotadisplay && content) 
     3283      this.gui_objects.quotadisplay.innerHTML = content; 
     3284    }; 
    32673285 
    32683286 
     
    33093327    }; 
    33103328 
    3311  
     3329  // update parent's mailboxlist (from preview) 
     3330  this.set_unread_count_from_preview = function(mbox, count, set_title) 
     3331  { 
     3332    parent.rcmail.set_unread_count(mbox, count, set_title); 
     3333  } 
     3334   
    33123335  // add row to contacts list 
    33133336  this.add_contact_row = function(cid, cols, select) 
  • program/steps/mail/check_recent.inc

    rcf1f0f9 r6d2714b  
    3838      $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX')); 
    3939      $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); 
    40       $OUTPUT->command('set_quota', $IMAP->get_quota()); 
     40      $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); 
    4141 
    4242      // add new message headers to list 
  • program/steps/mail/func.inc

    r3790508 r6d2714b  
    409409    $attrib['id'] = 'rcmquotadisplay'; 
    410410 
     411  if(isset($attrib['display'])) 
     412    $_SESSION['quota_display'] = $attrib['display']; 
     413 
    411414  $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); 
    412415 
     
    415418 
    416419  $out = '<span' . $attrib_str . '>'; 
    417   $out .= rcmail_quota_content($attrib['display']); 
     420  $out .= rcmail_quota_content(); 
    418421  $out .= '</span>'; 
    419422  return $out; 
     
    421424 
    422425 
    423 function rcmail_quota_content($display) 
     426function rcmail_quota_content($quota=NULL) 
    424427  { 
    425428  global $IMAP, $COMM_PATH; 
    426429 
    427   if (!$IMAP->get_capability('QUOTA')) 
    428     $quota_text = rcube_label('unknown'); 
    429   else if ($quota = $IMAP->get_quota()) 
    430     { 
    431     $quota_text = sprintf("%s / %s (%.0f%%)", 
    432                           show_bytes($quota["used"] * 1024), 
    433                           show_bytes($quota["total"] * 1024), 
    434                           $quota["percent"]); 
     430  $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; 
     431 
     432  if (is_array($quota) && !empty($quota['used']) && !empty($quota['total'])) 
     433    { 
     434      if (!isset($quota['percent'])) 
     435        $quota['percent'] = $quota['used'] / $quota['total']; 
     436    } 
     437  elseif (!$IMAP->get_capability('QUOTA')) 
     438    return rcube_label('unknown'); 
     439  else 
     440    $quota = $IMAP->get_quota(); 
     441 
     442  if ($quota) 
     443    { 
     444    $quota_text = sprintf('%s / %s (%.0f%%)', 
     445                          show_bytes($quota['used'] * 1024), 
     446                          show_bytes($quota['total'] * 1024), 
     447                          $quota['percent']); 
    435448 
    436449    // show quota as image (by Brett Patterson) 
  • program/steps/mail/move_del.inc

    rd41d67a r6d2714b  
    9393  $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); 
    9494 
    95 $OUTPUT->command('set_quota', $IMAP->get_quota()); 
     95$OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); 
    9696 
    9797// add new rows from next page (if any) 
  • program/steps/mail/show.inc

    r17b5fb7 r6d2714b  
    5454    $MESSAGE['is_safe'] = 1; 
    5555 
     56  $mbox_name = $IMAP->get_mailbox_name(); 
     57   
    5658  // calculate Etag for this request 
    57   $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE)); 
     59  $etag = md5($MESSAGE['UID'].$mbox_name.session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE)); 
    5860 
    5961  // allow caching, unless remote images are present 
     
    7678    $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); 
    7779 
    78  
    7980  // mark message as read 
    80   if (!$MESSAGE['headers']->seen && $_action != 'preview') 
    81     $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); 
     81  if (!$MESSAGE['headers']->seen) 
     82    { 
     83      $marked = $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); 
     84      if($_action == 'preview' && $marked != -1) 
     85        { 
     86        $OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); 
     87        $OUTPUT->command('mark_as_read_from_preview', $MESSAGE['UID']); 
     88        } 
     89    } 
    8290 
    8391  // give message uid to the client 
     
    8694   
    8795  // check for unset disposition notification 
    88   if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $IMAP->get_mailbox_name() != $CONFIG['drafts_mbox']) 
     96  if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $mbox_name != $CONFIG['drafts_mbox']) 
    8997  { 
    9098    if (intval($CONFIG['mdn_requests']) === 1) 
Note: See TracChangeset for help on using the changeset viewer.