Changeset

4677:823370bc2e4c

mod_http_muc_log: Sort rooms with a description before those without The listing looks nicer when rooms have proper titles and descriptions, therefore those that have this should be rewarded.
author Kim Alvefur <zash@zash.se>
date Sun, 12 Sep 2021 00:28:46 +0200
parents 4676:a2cf3b69a3d6
children 4678:0bcbff950f14
files mod_http_muc_log/README.markdown mod_http_muc_log/mod_http_muc_log.lua
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_muc_log/README.markdown	Sun Sep 12 00:13:32 2021 +0200
+++ b/mod_http_muc_log/README.markdown	Sun Sep 12 00:28:46 2021 +0200
@@ -89,8 +89,9 @@
 
 ## Pinned chatrooms
 
-The room list page is normally sorted by address. To override this, or
-pin certain rooms to the top:
+The room list page is normally sorted by address, rooms having a
+description before those that don't. To override this, or pin certain
+rooms to the top:
 
 ``` lua
 http_muc_log_list_order = {
--- a/mod_http_muc_log/mod_http_muc_log.lua	Sun Sep 12 00:13:32 2021 +0200
+++ b/mod_http_muc_log/mod_http_muc_log.lua	Sun Sep 12 00:28:46 2021 +0200
@@ -461,6 +461,11 @@
 
 	table.sort(room_list, function (a, b)
 		if a.priority ~= b.priority then return a.priority > b.priority; end
+		if a.description ~= nil and b.description == nil then
+			return true;
+		elseif a.description == nil and b.description ~= nil then
+			return false;
+		end
 		return a.jid < b.jid;
 	end);