@@ -1189,6 +1189,23 @@ function initSidebarTooltip() {
11891189 } ) ;
11901190}
11911191
1192+ function buildServerSubList ( ) {
1193+ if ( state . sidebarServersLoading ) return html `< div class ="nav-sub-empty "> < span class ="spinner "> </ span > Loading...</ div > ` ;
1194+ if ( state . servers . length === 0 ) return html `< div class ="nav-sub-empty "> No servers</ div > ` ;
1195+ return state . servers . map ( s => {
1196+ const isInstalling = s . status === 'installing' || s . installed === 0 || s . installed === '0' || s . installed === false ;
1197+ const isSuspended = s . status === 'suspended' ;
1198+ const dotClass = isSuspended ? 'dot-suspended' : ( isInstalling ? 'dot-installing' : 'dot-active' ) ;
1199+ const isActive = state . currentPage === 'server' && state . serverId === s . id ;
1200+ return html `
1201+ < a class ="nav-sub-item ${ isActive ? 'active' : '' } " data-server-nav ="${ s . id } " href ="/server/ ${ s . id } ">
1202+ < span class ="nav-sub-dot ${ dotClass } "> </ span >
1203+ ${ escapeHtml ( s . name ) }
1204+ </ a >
1205+ ` ;
1206+ } ) . join ( '' ) ;
1207+ }
1208+
11921209function renderSidebarNav ( ) {
11931210 const nav = $ ( '#sidebar-nav' ) ;
11941211 if ( ! nav ) return ;
@@ -1239,20 +1256,7 @@ function renderSidebarNav() {
12391256 < svg class ="nav-parent-chevron " viewBox ="0 0 24 24 " fill ="none " stroke ="currentColor " stroke-width ="2 " stroke-linecap ="round " stroke-linejoin ="round "> < polyline points ="9 18 15 12 9 6 "> </ polyline > </ svg >
12401257 </ div >
12411258 < div class ="nav-sub-list ${ state . sidebarServersOpen ? 'open' : '' } " id ="nav-servers-list ">
1242- ${ state . sidebarServersLoading ? html `< div class ="nav-sub-empty "> < span class ="spinner "> </ span > Loading...</ div > ` :
1243- state . servers . length === 0 ? html `< div class ="nav-sub-empty "> No servers</ div > ` :
1244- state . servers . map ( s => {
1245- const isInstalling = s . status === 'installing' || s . installed === 0 || s . installed === '0' || s . installed === false ;
1246- const isSuspended = s . status === 'suspended' ;
1247- const dotClass = isSuspended ? 'dot-suspended' : ( isInstalling ? 'dot-installing' : 'dot-active' ) ;
1248- const isActive = state . currentPage === 'server' && state . serverId === s . id ;
1249- return html `
1250- < a class ="nav-sub-item ${ isActive ? 'active' : '' } " data-server-nav ="${ s . id } " href ="/server/ ${ s . id } ">
1251- < span class ="nav-sub-dot ${ dotClass } "> </ span >
1252- ${ escapeHtml ( s . name ) }
1253- </ a >
1254- ` ;
1255- } ) . join ( '' ) }
1259+ ${ buildServerSubList ( ) }
12561260 </ div >
12571261 < a class ="nav-item " id ="nav-notifications " href ="# ">
12581262 < span style ="position:relative;display:inline-flex ">
@@ -1327,7 +1331,11 @@ function renderSidebarNav() {
13271331 state . sidebarServersLoading = false ;
13281332 }
13291333 navigateTo ( 'servers' ) ;
1330- renderSidebarNav ( ) ;
1334+ const subList = document . querySelector ( '#nav-servers-list' ) ;
1335+ if ( subList ) {
1336+ subList . innerHTML = buildServerSubList ( ) ;
1337+ initIcons ( ) ;
1338+ }
13311339 } ) ;
13321340 }
13331341
0 commit comments