fix: should now sync with other devices
All checks were successful
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

View File

@@ -317,6 +317,46 @@ export class CustomEmojiService {
const peers = this.webrtc.getConnectedPeers();
await Promise.all(peers.map((peerId) => this.sendEmojiToPeer(peerId, emoji)));
await this.relayEmojiViaAccountSync(emoji);
}
private async relayEmojiViaAccountSync(emoji: CustomEmoji): Promise<void> {
if (canInlineCustomEmojiTransfer(emoji)) {
this.webrtc.relayAccountSync({
type: 'custom-emoji-full',
customEmoji: emoji
});
return;
}
const transfer = splitCustomEmojiDataUrl(emoji.dataUrl);
const manifest: CustomEmojiTransferManifest = {
id: emoji.id,
name: emoji.name,
creatorUserId: emoji.creatorUserId,
hash: emoji.hash,
mime: emoji.mime,
size: emoji.size,
createdAt: emoji.createdAt,
updatedAt: emoji.updatedAt
};
this.webrtc.relayAccountSync({
type: 'custom-emoji-full',
customEmojiTransfer: manifest,
total: transfer.total
});
for (let chunkIndex = 0; chunkIndex < transfer.chunks.length; chunkIndex++) {
this.webrtc.relayAccountSync({
type: 'custom-emoji-chunk',
customEmojiId: emoji.id,
index: chunkIndex,
total: transfer.total,
data: transfer.chunks[chunkIndex]
});
}
}
private async sendEmojiToPeer(peerId: string, emoji: CustomEmoji): Promise<void> {

View File

@@ -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);
}