From b27656bb434e72ac91f740704035cf2290ae5c49 Mon Sep 17 00:00:00 2001 From: Laurent Dubertrand Date: Wed, 25 Mar 2026 22:11:28 +0100 Subject: [PATCH] removed backend fiield --- client/src/app/chat-session.service.ts | 30 +++------------- client/src/app/home-page.component.html | 48 +++++-------------------- client/src/app/home-page.component.ts | 10 ------ 3 files changed, 13 insertions(+), 75 deletions(-) diff --git a/client/src/app/chat-session.service.ts b/client/src/app/chat-session.service.ts index bd3f6ca..6e6ac2a 100644 --- a/client/src/app/chat-session.service.ts +++ b/client/src/app/chat-session.service.ts @@ -108,17 +108,12 @@ type DocumentPreviewImageResponse = { imageBase64: string; }; -type RuntimeEnv = { - PRIVATECHAT_CLIENT_SERVER_URL?: string; -}; - function readDefaultServerUrl(): string { - const runtimeWindow = typeof window === 'undefined' - ? undefined - : (window as Window & typeof globalThis & { __PRIVATECHAT_ENV__?: RuntimeEnv }); - const configuredUrl = runtimeWindow?.__PRIVATECHAT_ENV__?.PRIVATECHAT_CLIENT_SERVER_URL?.trim(); + if (typeof window !== 'undefined' && window.location.origin) { + return window.location.origin.replace(/\/+$/, ''); + } - return configuredUrl?.replace(/\/+$/, '') || 'http://localhost:3000'; + return 'http://localhost:3000'; } @Injectable({ providedIn: 'root' }) @@ -138,7 +133,7 @@ export class ChatSessionService { private static readonly typingHeartbeatMs = 900; private static readonly incomingCallRingtoneFileName = 'SymphonyDing.mp3'; - readonly serverUrl = signal(this.readStorage('privatechat.serverUrl') ?? readDefaultServerUrl()); + readonly serverUrl = signal(readDefaultServerUrl()); readonly currentUser = signal(this.readUserStorage()); readonly accessKeys = signal([]); readonly peers = signal([]); @@ -319,21 +314,6 @@ export class ChatSessionService { } } - setServerUrl(url: string): void { - const normalized = url.trim().replace(/\/+$/, ''); - - if (!normalized) { - return; - } - - this.serverUrl.set(normalized); - this.writeStorage('privatechat.serverUrl', normalized); - - if (this.currentUser()) { - void this.connectWebSocket(); - } - } - selectPeer(peerId: string): void { this.activePeerId.set(peerId); this.clearUnreadPeer(peerId); diff --git a/client/src/app/home-page.component.html b/client/src/app/home-page.component.html index 7c55a4e..4d54127 100644 --- a/client/src/app/home-page.component.html +++ b/client/src/app/home-page.component.html @@ -53,22 +53,11 @@

Connect to the signaling backend

-

Use the Fastify server for authentication and peer discovery.

+

Use the current browser host for authentication and peer discovery.

Angular + Bootstrap
-
- - -
-
-
- } @else { -
- Backend settings are managed by the native app in embedded mode. -
- } - -
{{ session.status() }}
+
{{ session.status() }}
@if (session.error()) { -
{{ session.error() }}
+
{{ session.error() }}
} @if (session.notice()) { -
{{ session.notice() }}
+
{{ session.notice() }}
} - - -
-
diff --git a/client/src/app/home-page.component.ts b/client/src/app/home-page.component.ts index a28d294..bd96c9c 100644 --- a/client/src/app/home-page.component.ts +++ b/client/src/app/home-page.component.ts @@ -19,7 +19,6 @@ export class HomePageComponent { authMode: 'login' | 'register' = 'login'; readonly embeddedMode = typeof window !== 'undefined' && window.localStorage.getItem('privatechat.embeddedMode') === '1'; - serverUrl = ''; displayName = ''; username = ''; password = ''; @@ -50,8 +49,6 @@ export class HomePageComponent { }); constructor(readonly session: ChatSessionService) { - this.serverUrl = session.serverUrl(); - if (this.embeddedMode) { effect(() => { const currentUser = this.session.currentUser(); @@ -95,8 +92,6 @@ export class HomePageComponent { } async submitAuth(): Promise { - this.applyServerUrl(); - if (this.authMode === 'register') { const authenticated = await this.session.register(this.username, this.password, this.displayName); this.password = ''; @@ -111,10 +106,6 @@ export class HomePageComponent { await this.session.login(this.username, this.password); } - applyServerUrl(): void { - this.session.setServerUrl(this.serverUrl); - } - async logout(): Promise { await this.session.logout(); this.authMode = 'login'; @@ -123,7 +114,6 @@ export class HomePageComponent { } async loginWithAccessKey(): Promise { - this.applyServerUrl(); await this.session.loginWithAccessKey(this.username); this.password = ''; }