feat: Add profile images

This commit is contained in:
2026-04-17 03:05:47 +02:00
parent 35b616fb77
commit 17738ec484
49 changed files with 2622 additions and 89 deletions

View File

@@ -0,0 +1,44 @@
# Profile Avatar Domain
Owns local profile picture workflow: source validation, crop/zoom editor state, static 256x256 WebP rendering, animated avatar preservation, desktop file persistence, and P2P avatar sync metadata.
## Responsibilities
- Accept `.webp`, `.gif`, `.jpg`, `.jpeg` profile image sources.
- Let user drag and zoom source inside fixed preview frame before saving.
- Render static avatars to `256x256` WebP with client-side compression.
- Preserve animated `.gif` and animated `.webp` uploads without flattening frames.
- Persist desktop copy at `user/<username>/profile/profile.<ext>` under app data.
- Expose helpers used by store effects to keep avatar metadata (`avatarHash`, `avatarMime`, `avatarUpdatedAt`) consistent.
## Module map
```mermaid
graph TD
PC[ProfileCardComponent] --> PAE[ProfileAvatarEditorComponent]
PAE --> PAF[ProfileAvatarFacade]
PAF --> PAI[ProfileAvatarImageService]
PAF --> PAS[ProfileAvatarStorageService]
PAF --> Store[UsersActions.updateCurrentUserAvatar]
Store --> UAV[UserAvatarEffects]
UAV --> RTC[WebRTC data channel]
UAV --> DB[DatabaseService]
click PAE "feature/profile-avatar-editor/" "Crop and zoom editor UI" _blank
click PAF "application/services/profile-avatar.facade.ts" "Facade used by UI and effects" _blank
click PAI "infrastructure/services/profile-avatar-image.service.ts" "Canvas render and compression" _blank
click PAS "infrastructure/services/profile-avatar-storage.service.ts" "Electron file persistence" _blank
```
## Flow
1. `ProfileCardComponent` opens file picker from editable avatar button.
2. `ProfileAvatarEditorComponent` previews exact crop using drag + zoom.
3. `ProfileAvatarImageService` renders static uploads to `256x256` WebP, but keeps animated GIF and WebP sources intact.
4. `ProfileAvatarStorageService` writes desktop copy when Electron is available.
5. `UserAvatarEffects` broadcasts avatar summary, answers requests, streams chunks, and persists received avatars locally.
## Notes
- Static uploads are normalized to WebP. Animated GIF and animated WebP uploads keep their original animation, mime type, and full-frame presentation.
- `avatarUrl` stays local display data. Version conflict resolution uses `avatarUpdatedAt` and `avatarHash`.