()
| 578 | } |
| 579 | |
| 580 | export function initHub() { |
| 581 | migrateServerList(); |
| 582 | renderHubCards(); |
| 583 | startHubProbes(); |
| 584 | |
| 585 | $('hub-add-btn').addEventListener('click', openAddServerDialog); |
| 586 | $('hub-dialog-cancel').addEventListener('click', closeServerDialog); |
| 587 | $('hub-dialog-save').addEventListener('click', saveServerDialog); |
| 588 | $('hub-dialog-delete').addEventListener('click', deleteServerFromDialog); |
| 589 | $('hub-add-overlay').addEventListener('click', (e) => { |
| 590 | if (e.target === $('hub-add-overlay')) closeServerDialog(); |
| 591 | }); |
| 592 | $('hub-dialog-addr').addEventListener('keydown', e => { |
| 593 | if (e.key === 'Enter') saveServerDialog(); |
| 594 | }); |
| 595 | $('hub-dialog-token-toggle').addEventListener('click', () => { |
| 596 | const inp = $('hub-dialog-token'); |
| 597 | inp.type = inp.type === 'password' ? 'text' : 'password'; |
| 598 | }); |
| 599 | |
| 600 | // Back button |
| 601 | $('btn-back').addEventListener('click', () => { |
| 602 | (async () => { |
| 603 | const hadWs = !!S.ws; |
| 604 | S.intentionalDisconnect = hadWs; |
| 605 | S.skipNextCloseHandling = hadWs; |
| 606 | try { |
| 607 | await flushSessionCacheSave(); |
| 608 | } catch {} |
| 609 | if (S.ws) S.ws.close(); |
| 610 | else { |
| 611 | S.intentionalDisconnect = false; |
| 612 | S.skipNextCloseHandling = false; |
| 613 | } |
| 614 | if (S.reconnectTimer) { clearTimeout(S.reconnectTimer); S.reconnectTimer = null; } |
| 615 | resetAppState(); |
| 616 | showConnectScreen(); |
| 617 | })(); |
| 618 | }); |
| 619 | } |
nothing calls this directly
no test coverage detected