Cleaning up comments

This commit is contained in:
2026-03-06 05:21:41 +01:00
parent fe2347b54e
commit 10467dfccb
50 changed files with 51 additions and 885 deletions

View File

@@ -31,12 +31,6 @@ import {
STORAGE_KEY_LAST_VISITED_ROUTE
} from './core/constants';
/**
* Root application component.
*
* Initialises the database, loads persisted user and room data,
* handles route restoration, and tracks voice session navigation.
*/
@Component({
selector: 'app-root',
imports: [
@@ -61,30 +55,24 @@ export class App implements OnInit {
private voiceSession = inject(VoiceSessionService);
private externalLinks = inject(ExternalLinkService);
/** Intercept all <a> clicks and open them externally. */
@HostListener('document:click', ['$event'])
onGlobalLinkClick(evt: MouseEvent): void {
this.externalLinks.handleClick(evt);
}
async ngOnInit(): Promise<void> {
// Initialize database
await this.databaseService.initialize();
// Initial time sync with active server
try {
const apiBase = this.servers.getApiBaseUrl();
await this.timeSync.syncWithEndpoint(apiBase);
} catch {}
// Load user data from local storage or create new user
this.store.dispatch(UsersActions.loadCurrentUser());
// Load saved rooms
this.store.dispatch(RoomsActions.loadRooms());
// If not authenticated, redirect to login; else restore last route
const currentUserId = localStorage.getItem(STORAGE_KEY_CURRENT_USER_ID);
if (!currentUserId) {
@@ -103,20 +91,15 @@ export class App implements OnInit {
}
}
// Persist last visited on navigation and track voice session navigation
this.router.events.subscribe((evt) => {
if (evt instanceof NavigationEnd) {
const url = evt.urlAfterRedirects || evt.url;
// Store room route or search
localStorage.setItem(STORAGE_KEY_LAST_VISITED_ROUTE, url);
// Check if user navigated away from voice-connected server
// Extract roomId from URL if on a room route
const roomMatch = url.match(ROOM_URL_PATTERN);
const currentRoomId = roomMatch ? roomMatch[1] : null;
// Update voice session service with current server context
this.voiceSession.checkCurrentRoute(currentRoomId);
}
});