From fd0c123e44391aa01a85c5aeebbd0cea418f0808 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 08 Dec 2013 04:57:44 -0500
Subject: [PATCH] Fix fixed header issue after removing rows (1295420)

---
 program/js/list.js |   15 +++++++++++++--
 program/js/app.js  |    2 --
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index ac06df6..398417a 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -6843,7 +6843,6 @@
 
           if ((response.action == 'list' || response.action == 'search') && this.message_list) {
             this.msglist_select(this.message_list);
-            this.message_list.resize();
             this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount });
           }
         }
@@ -6854,7 +6853,6 @@
             this.enable_command('search-create', this.env.source == '');
             this.enable_command('search-delete', this.env.search_id);
             this.update_group_commands();
-            this.contact_list.resize();
             this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
           }
         }
diff --git a/program/js/list.js b/program/js/list.js
index e3a38ba..f33be87 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -249,6 +249,9 @@
   // reset scroll position (in Opera)
   if (this.frame)
     this.frame.scrollTop = 0;
+
+  // fix list header after removing any rows
+  this.resize();
 },
 
 
@@ -257,7 +260,7 @@
  */
 remove_row: function(uid, sel_next)
 {
-  var node = this.rows[uid] ? this.rows[uid].obj : null;
+  var self = this, node = this.rows[uid] ? this.rows[uid].obj : null;
 
   if (!node)
     return;
@@ -269,6 +272,10 @@
 
   delete this.rows[uid];
   this.rowcount--;
+
+  // fix list header after removing any rows
+  clearTimeout(this.resize_timeout)
+  this.resize_timeout = setTimeout(function() { self.resize(); }, 50);
 },
 
 
@@ -277,7 +284,7 @@
  */
 insert_row: function(row, before)
 {
-  var tbody = this.tbody;
+  var self = this, tbody = this.tbody;
 
   // create a real dom node first
   if (row.nodeName === undefined) {
@@ -305,6 +312,10 @@
 
   this.init_row(row);
   this.rowcount++;
+
+  // fix list header after adding any rows
+  clearTimeout(this.resize_timeout)
+  this.resize_timeout = setTimeout(function() { self.resize(); }, 50);
 },
 
 /**

--
Gitblit v1.9.1