@@ -23,6 +23,7 @@ import {
23
23
Login ,
24
24
Personalization ,
25
25
escapeHtml ,
26
+ RoomList ,
26
27
} from "./html.js" ;
27
28
import expressWebsockets from "express-ws" ;
28
29
import ical from "node-ical" ;
@@ -634,14 +635,18 @@ app.get(
634
635
title : "RCVerse" ,
635
636
body : RootBody (
636
637
mungeRootBody ( {
637
- zoomRooms,
638
- roomNameToParticipantNames,
639
- participantNameToEntity,
640
- roomNameToNote,
641
- myParticipantName : req . locals . rcPersonName ,
642
- inTheHubParticipantNames,
643
- sortRooms,
644
- locationToNowAndNextEvents,
638
+ roomListContent : RoomList (
639
+ mungeRoomList ( {
640
+ zoomRooms,
641
+ roomNameToParticipantNames,
642
+ participantNameToEntity,
643
+ roomNameToNote,
644
+ myParticipantName : req . locals . rcPersonName ,
645
+ inTheHubParticipantNames,
646
+ sortRooms,
647
+ locationToNowAndNextEvents,
648
+ } ) ,
649
+ ) ,
645
650
personalizations,
646
651
} ) ,
647
652
) ,
@@ -683,6 +688,33 @@ app.ws("/websocket", async function (ws, req) {
683
688
684
689
await getRcUserMiddleware ( req , { appendHeader : ( ) => { } } , ( ) => { } ) ;
685
690
691
+ let { sort } = req . query ;
692
+
693
+ // `?sort=none` uses the default ordering instead of sort by count
694
+ // TODO: This logic is repeated from above, move into munge
695
+ const sortRooms = sort !== "none" ;
696
+
697
+ // TODO: Somehow distinguish between the first connection on page load and
698
+ // a reconnection, and don't send this on the first connection
699
+ // TODO: Somehow distinguish if any messages were actually missed on reconnection
700
+ // and only do this if any missed messages
701
+ // TODO: Add more complicated solution which replays chunks of missed messages
702
+ // instead of refreshing so much of the page
703
+ ws . send (
704
+ RoomList (
705
+ mungeRoomList ( {
706
+ zoomRooms,
707
+ roomNameToParticipantNames,
708
+ participantNameToEntity,
709
+ roomNameToNote,
710
+ myParticipantName : req . locals . rcPersonName ,
711
+ inTheHubParticipantNames,
712
+ sortRooms,
713
+ locationToNowAndNextEvents,
714
+ } ) ,
715
+ ) ,
716
+ ) ;
717
+
686
718
// NOTE: Only use async listeners, so that each listener doesn't block.
687
719
const roomListener = async ( participantName , action , roomName ) => {
688
720
ws . send (
@@ -1122,7 +1154,14 @@ app.post(
1122
1154
1123
1155
// Data mungers take the craziness of the internal data structures
1124
1156
// and make them peaceful and clean for the HTML generator
1125
- const mungeRootBody = ( {
1157
+ const mungeRootBody = ( { roomListContent, personalizations } ) => {
1158
+ return {
1159
+ roomListContent,
1160
+ personalizations,
1161
+ } ;
1162
+ } ;
1163
+
1164
+ const mungeRoomList = ( {
1126
1165
zoomRooms,
1127
1166
roomNameToParticipantNames,
1128
1167
participantNameToEntity,
@@ -1131,7 +1170,6 @@ const mungeRootBody = ({
1131
1170
inTheHubParticipantNames,
1132
1171
sortRooms,
1133
1172
locationToNowAndNextEvents,
1134
- personalizations,
1135
1173
} ) => {
1136
1174
const whoIsInTheHub = mungeWhoIsInTheHub ( {
1137
1175
inTheHubParticipantNames,
@@ -1179,7 +1217,6 @@ const mungeRootBody = ({
1179
1217
return {
1180
1218
whoIsInTheHub,
1181
1219
rooms,
1182
- personalizations,
1183
1220
} ;
1184
1221
} ;
1185
1222
0 commit comments