adium 2746:38433bea7f5e: If we're already coalessing messages, f...

commits at adium.im commits at adium.im
Mon Oct 19 21:21:55 UTC 2009


details:	http://hg.adium.im/adium/rev/38433bea7f5e
revision:	2746:38433bea7f5e
author:		Stephen Holt <sholt at adium.im>
date:		Mon Oct 19 17:19:19 2009 -0400

If we're already coalessing messages, fold in the last message and coalesce that one too.
Subject: adium 2747:bd02bf4291ca: set the timeout to 100ms from 200ms.

details:	http://hg.adium.im/adium/rev/bd02bf4291ca
revision:	2747:bd02bf4291ca
author:		Stephen Holt <sholt at adium.im>
date:		Mon Oct 19 17:19:51 2009 -0400

set the timeout to 100ms from 200ms.

diffs (135 lines):

diff -r d8970611ed55 -r bd02bf4291ca Plugins/WebKit Message View/Template.html
--- a/Plugins/WebKit Message View/Template.html	Mon Oct 19 15:00:32 2009 -0400
+++ b/Plugins/WebKit Message View/Template.html	Mon Oct 19 17:19:51 2009 -0400
@@ -26,15 +26,11 @@
 			this.isCoalescing = false;
 			this.shouldScroll = false;
 			
-			function rmInsert() {
-				
-			}
-			
 			function outputHTML() {
 				var insert = document.getElementById("insert");
-				if(insert) 
+				if(insert)
 					insert.parentNode.removeChild(insert);
-					
+
 				document.getElementById("Chat").appendChild(self.fragment);
 				alignChat(self.shouldScroll);
 				
@@ -43,9 +39,18 @@
 				self.isCoalescing = false;
 			}
 			
+			function insertHTMLToNode(html, node) {
+				var newMessage = document.createElement("div");
+				newMessage.innerHTML = html;
+				var children = newMessage.childNodes;
+				for (var i = 0; i < children.length; i++) {
+					node.appendChild(children[i]);
+				}
+			}
+			
 			this.coalesce = function() {
 				if(!self.isCoalescing) {
-					self.timeoutID = window.setTimeout(outputHTML, 200);
+					self.timeoutID = window.setTimeout(outputHTML, 100);
 					self.isCoalescing = true;
 				}
 			}
@@ -60,7 +65,6 @@
 			}
 			
 			this.append = function(html, shouldScroll) {
-				
 				var lastAppend = self.fragment.lastChild;
 				if(lastAppend){
 					var insert = lastAppend.querySelector("#insert");
@@ -68,13 +72,23 @@
 						insert.parentNode.removeChild(insert);
 				}
 				
-				var newMessage = document.createElement("div");
-				newMessage.innerHTML = html;
-				var children = newMessage.childNodes;
-				for (var i = 0; i < children.length; i++) {
-					self.fragment.appendChild(children[i]);
+				insertHTMLToNode(html, self.fragment);
+
+				if(shouldScroll) self.shouldScroll = shouldScroll;
+				self.coalesce();
+			}
+			
+			this.appendNext = function(html, shouldScroll) {
+				insert = self.fragment.querySelector("#insert");
+				if(insert) {
+					var insertParent = insert.parentNode;
+					insertParent.removeNode(insert);
+					insertHTMLToNode(html, insertParent);
+				} else {
+					self.append(html, shouldScroll);
 				}
-				if(shouldScroll) self.shouldScroll = shouldScroll;
+				if(shouldScroll)
+					self.shouldScroll = shouldScroll;
 				self.coalesce();
 			}
 		}
@@ -88,37 +102,33 @@
 		
 		function appendMessageNoScroll(html, shouldScroll) {			
 			shouldScroll = shouldScroll || false;
-			
-			//Remove the current insertion point
-			var insert = document.getElementById("insert");
-			if(insert) 
-				insert.parentNode.removeChild(insert);
-			
 			coalescedHTML.append(html, shouldScroll)
 		}
 		
 		function appendNextMessage(html){
 			var shouldScroll = nearBottom();
-			appendNextMessageNoScroll(html);
+			appendNextMessageNoScroll(html, shouldScroll);
 			alignChat(shouldScroll);
 		}
 		
-		function appendNextMessageNoScroll(html){
-			//cancel any coallescing
-			coalescedHTML.cancel();
-			
-			//Locate the insertion point
-			var insert = document.getElementById("insert");
-			if(insert){
-				//make new node
-				var range = document.createRange();
-				range.selectNode(insert.parentNode);
-				var newNode = range.createContextualFragment(html);
+		function appendNextMessageNoScroll(html, shouldScroll){
+			shouldScroll = shouldScroll || false;
+			if(coalescedHTML.isCoalescing){
+				coalescedHTML.appendNext(html, shouldScroll);
+			} else {
+				//Locate the insertion point
+				var insert = document.getElementById("insert");
+				if(insert){
+					//make new node
+					var range = document.createRange();
+					range.selectNode(insert.parentNode);
+					var newNode = range.createContextualFragment(html);
 
-				//swap
-				insert.parentNode.replaceChild(newNode,insert);
-			} else {
-				appendMessageNoScroll(html);
+					//swap
+					insert.parentNode.replaceChild(newNode,insert);
+				} else {
+					appendMessageNoScroll(html);
+				}
 			}
 		}
 




More information about the commits mailing list