Browse Source

rework buffer expiry system a bit

Andrew Dolgov 1 year ago
parent
commit
6dbc41201f
2 changed files with 5 additions and 11 deletions
  1. 1 1
      index.php
  2. 4 10
      js/tt-irc.js

+ 1 - 1
index.php

@@ -295,7 +295,7 @@
 	</div> <!-- sidebar -->
 
 	<div id="log" data-bind="with: activeChannel" >
-	<ul id="log-list" data-bind="foreach: lines">
+	<ul id="log-list" data-bind="foreach: lines.slice(lines.length-BUFFER_MAX_LINES)">
 		<li data-bind="html: format, attr: { rowid: $data.id, ident: $data.ident, ts: $data.unixts }, css: { row: true, HL: is_hl, LV: is_lv }"> </li>
 	</ul>
 	</div> <!-- log -->

+ 4 - 10
js/tt-irc.js

@@ -28,6 +28,8 @@ var sfw_mode = false;
 var url_data_cache = [];
 var image_embed_cache = [];
 
+const BUFFER_MAX_LINES = 200;
+
 const MSGT_PRIVMSG = 0;
 const MSGT_COMMAND = 1;
 const MSGT_BROADCAST = 2;
@@ -2166,16 +2168,8 @@ function push_message(connection_id, channel, message, message_type, no_tab_hl)
 
 		if (chan && chan.lines) {
 
-			var max_lines = getURLParam("ml");
-
-			if (max_lines)
-				max_lines = parseInt(max_lines);
-			else
-				max_lines = navigator.userAgent.indexOf("Firefox") != -1 ? 100 : 150;
-
-			if (chan.lines().length > max_lines)
-				while (chan.lines().length > max_lines - 15)
-					chan.lines.shift();
+			if (chan.lines().length > BUFFER_MAX_LINES + 100)
+				chan.lines().splice(0, BUFFER_MAX_LINES);
 
 			chan.lines.push(new Message(message, chan));
 		}