Changeset

4876:fa41d05ee7ef

muc.lib: room:set_historylength(): Condense code, and don't store length when equal to default
author Matthew Wild <mwild1@gmail.com>
date Sun, 13 May 2012 22:58:25 +0100
parents 4875:f9fe28461101
children 4877:6f5b53cb3565
files plugins/muc/muc.lib.lua
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Mon May 14 02:42:42 2012 +0500
+++ b/plugins/muc/muc.lib.lua	Sun May 13 22:58:25 2012 +0100
@@ -339,13 +339,9 @@
 	return self._data.history_length or default_history_length;
 end
 function room_mt:set_historylength(length)
-	if tonumber(length) == nil then
-		return
-	end
-	length = tonumber(length);
-	log("debug", "max_history_length %s", self._data.max_history_length or "nil");
-	if self._data.max_history_length and length > self._data.max_history_length then
-		length = self._data.max_history_length
+	length = math.min(tonumber(length) or default_history_length, self._data_max_history_length or math.huge);
+	if length == default_history_length then
+		length = nil;
 	end
 	self._data.history_length = length;
 end