fix: should now sync with other devices
Queue Release Build / prepare (push) Successful in 25s
Deploy Web Apps / deploy (push) Successful in 7m8s
Queue Release Build / build-windows (push) Successful in 28m10s
Queue Release Build / build-linux (push) Successful in 44m38s
Queue Release Build / build-android (push) Successful in 18m36s
Queue Release Build / finalize (push) Successful in 1m40s

This commit is contained in:
2026-06-09 22:00:39 +02:00
parent 1274ad9b46
commit d0aff6319d
16 changed files with 619 additions and 5 deletions
@@ -7,6 +7,7 @@ import {
signal
} from '@angular/core';
import { Store } from '@ngrx/store';
import { RealtimeSessionFacade } from '../../../../core/realtime';
import { FriendRepository } from '../../infrastructure/friend.repository';
import type { Friend } from '../../domain/models/direct-message.model';
import { selectCurrentUser } from '../../../../store/users/users.selectors';
@@ -15,6 +16,7 @@ import { selectCurrentUser } from '../../../../store/users/users.selectors';
export class FriendService {
private readonly repository = inject(FriendRepository);
private readonly store = inject(Store);
private readonly webrtc = inject(RealtimeSessionFacade);
private readonly currentUser = this.store.selectSignal(selectCurrentUser);
private readonly friendsSignal = signal<Friend[]>([]);
private loadedOwnerId: string | null = null;
@@ -36,11 +38,42 @@ export class FriendService {
await this.repository.addFriend(ownerId, friend);
await this.loadForOwner(ownerId, true);
this.webrtc.relayAccountSync({
type: 'friend-added',
userId,
addedAt: friend.addedAt
});
}
async removeFriend(userId: string): Promise<void> {
const ownerId = await this.requireOwnerId();
await this.repository.removeFriend(ownerId, userId);
await this.loadForOwner(ownerId, true);
this.webrtc.relayAccountSync({
type: 'friend-removed',
userId
});
}
async applyRemoteFriendAdded(userId: string, addedAt: number): Promise<void> {
const ownerId = await this.requireOwnerId();
if (this.isFriend(userId)) {
return;
}
await this.repository.addFriend(ownerId, { userId, addedAt });
await this.loadForOwner(ownerId, true);
}
async applyRemoteFriendRemoved(userId: string): Promise<void> {
const ownerId = await this.requireOwnerId();
if (!this.isFriend(userId)) {
return;
}
await this.repository.removeFriend(ownerId, userId);
await this.loadForOwner(ownerId, true);
}