feat: Add deafen to pc, fix mobiel view, fix freeze on startup

This commit is contained in:
2026-06-05 15:27:06 +02:00
parent 35f52b0356
commit a675f12e61
85 changed files with 2499 additions and 519 deletions

View File

@@ -2,8 +2,8 @@ import { Injectable, inject } from '@angular/core';
import type { CallNotificationActionIntent } from '../logic/call-notification.rules';
import { buildIncomingCallNotification, buildInCallNotification } from '../logic/call-notification.rules';
import { resolveMobileAdapter } from '../logic/mobile-capacitor-adapter.rules';
import type { MobileNotificationAdapter } from '../contracts/mobile.contracts';
import { CapacitorMobileNotificationsAdapter } from '../adapters/capacitor/capacitor-mobile-notifications.adapter';
import { WebMobileNotificationsAdapter } from '../adapters/web/web-mobile-notifications.adapter';
import { MobilePlatformService } from './mobile-platform.service';
import { MobilePushRegistrationService } from './mobile-push-registration.service';
@@ -13,7 +13,9 @@ import { MobilePushRegistrationService } from './mobile-push-registration.servic
export class MobileNotificationsService {
private readonly mobilePlatform = inject(MobilePlatformService);
private readonly pushRegistration = inject(MobilePushRegistrationService);
private readonly adapter: MobileNotificationAdapter = this.createAdapter();
private adapter: MobileNotificationAdapter = new WebMobileNotificationsAdapter();
private adapterReady: Promise<MobileNotificationAdapter> | null = null;
private callActionHandler: ((input: { callId: string; intent: CallNotificationActionIntent }) => void) | null = null;
private initialized = false;
async initialize(): Promise<void> {
@@ -21,36 +23,65 @@ export class MobileNotificationsService {
return;
}
await this.adapter.initialize();
const adapter = await this.ensureAdapter();
await adapter.initialize();
this.pushRegistration.initialize();
this.initialized = true;
}
async showIncomingCall(displayName: string, callId: string): Promise<void> {
await this.initialize();
await this.adapter.showCallNotification(buildIncomingCallNotification(displayName, callId));
const adapter = await this.ensureAdapter();
await adapter.showCallNotification(buildIncomingCallNotification(displayName, callId));
}
async showActiveCall(input: { callId: string; displayName: string; isMuted: boolean }): Promise<void> {
await this.initialize();
await this.adapter.showCallNotification(buildInCallNotification(input));
const adapter = await this.ensureAdapter();
await adapter.showCallNotification(buildInCallNotification(input));
}
async dismissIncomingCall(callId: string): Promise<void> {
await this.adapter.dismissCallNotification(callId, 'incoming');
const adapter = await this.ensureAdapter();
await adapter.dismissCallNotification(callId, 'incoming');
}
async dismissActiveCall(callId: string): Promise<void> {
await this.adapter.dismissCallNotification(callId, 'active');
const adapter = await this.ensureAdapter();
await adapter.dismissCallNotification(callId, 'active');
}
onCallAction(handler: (input: { callId: string; intent: CallNotificationActionIntent }) => void): void {
this.callActionHandler = handler;
this.adapter.onActionSelected(handler);
}
private createAdapter(): MobileNotificationAdapter {
return this.mobilePlatform.isCapacitor()
? new CapacitorMobileNotificationsAdapter()
: new WebMobileNotificationsAdapter();
private ensureAdapter(): Promise<MobileNotificationAdapter> {
if (!this.adapterReady) {
this.adapterReady = resolveMobileAdapter(
this.mobilePlatform.runtime(),
this.adapter,
async () => {
const { CapacitorMobileNotificationsAdapter } = await import('../adapters/capacitor/capacitor-mobile-notifications.adapter');
return new CapacitorMobileNotificationsAdapter();
}
).then((adapter) => {
this.adapter = adapter;
if (this.callActionHandler) {
this.adapter.onActionSelected(this.callActionHandler);
}
return adapter;
});
}
return this.adapterReady;
}
}