fix(chat): Correction race condition + Implémentation TODOs
## Corrections Critiques ### Race Condition - Statuts de Messages - Fix : Les icônes de statut (✓, ✓✓, ✓✓ bleu) ne s'affichaient pas - Cause : WebSocket delivery confirmations arrivaient avant messages locaux - Solution : Pattern Optimistic UI dans chat_bloc.dart - Création message temporaire immédiate - Ajout à la liste AVANT requête HTTP - Remplacement par message serveur à la réponse - Fichier : lib/presentation/state_management/chat_bloc.dart ## Implémentation TODOs (13/21) ### Social (social_header_widget.dart) - ✅ Copier lien du post dans presse-papiers - ✅ Partage natif via Share.share() - ✅ Dialogue de signalement avec 5 raisons ### Partage (share_post_dialog.dart) - ✅ Interface sélection d'amis avec checkboxes - ✅ Partage externe via Share API ### Média (media_upload_service.dart) - ✅ Parsing JSON réponse backend - ✅ Méthode deleteMedia() pour suppression - ✅ Génération miniature vidéo ### Posts (create_post_dialog.dart, edit_post_dialog.dart) - ✅ Extraction URL depuis uploads - ✅ Documentation chargement médias ### Chat (conversations_screen.dart) - ✅ Navigation vers notifications - ✅ ConversationSearchDelegate pour recherche ## Nouveaux Fichiers ### Configuration - build-prod.ps1 : Script build production avec dart-define - lib/core/constants/env_config.dart : Gestion environnements ### Documentation - TODOS_IMPLEMENTED.md : Documentation complète TODOs ## Améliorations ### Architecture - Refactoring injection de dépendances - Amélioration routing et navigation - Optimisation providers (UserProvider, FriendsProvider) ### UI/UX - Amélioration thème et couleurs - Optimisation animations - Meilleure gestion erreurs ### Services - Configuration API avec env_config - Amélioration datasources (events, users) - Optimisation modèles de données
This commit is contained in:
116
lib/domain/entities/story.dart
Normal file
116
lib/domain/entities/story.dart
Normal file
@@ -0,0 +1,116 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Type de média dans une story.
|
||||
enum StoryMediaType {
|
||||
image,
|
||||
video,
|
||||
}
|
||||
|
||||
/// Entité de domaine représentant une story.
|
||||
///
|
||||
/// Cette entité est pure et indépendante de la couche de données.
|
||||
/// Elle représente une story éphémère (24h) dans le domaine métier.
|
||||
class Story extends Equatable {
|
||||
const Story({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.userFirstName,
|
||||
required this.userLastName,
|
||||
required this.userProfileImageUrl,
|
||||
required this.userIsVerified,
|
||||
required this.mediaType,
|
||||
required this.mediaUrl,
|
||||
required this.createdAt,
|
||||
required this.expiresAt,
|
||||
this.thumbnailUrl,
|
||||
this.durationSeconds,
|
||||
this.isActive = true,
|
||||
this.viewsCount = 0,
|
||||
this.hasViewed = false,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String userId;
|
||||
final String userFirstName;
|
||||
final String userLastName;
|
||||
final String userProfileImageUrl;
|
||||
final bool userIsVerified;
|
||||
final StoryMediaType mediaType;
|
||||
final String mediaUrl;
|
||||
final String? thumbnailUrl;
|
||||
final int? durationSeconds;
|
||||
final DateTime createdAt;
|
||||
final DateTime expiresAt;
|
||||
final bool isActive;
|
||||
final int viewsCount;
|
||||
final bool hasViewed;
|
||||
|
||||
/// Retourne le nom complet de l'auteur.
|
||||
String get authorFullName => '$userFirstName $userLastName';
|
||||
|
||||
/// Vérifie si la story est expirée.
|
||||
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
||||
|
||||
/// Retourne la durée formatée (MM:SS) pour les vidéos.
|
||||
String? get formattedDuration {
|
||||
if (durationSeconds == null) return null;
|
||||
final minutes = durationSeconds! ~/ 60;
|
||||
final seconds = durationSeconds! % 60;
|
||||
return '$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
userId,
|
||||
userFirstName,
|
||||
userLastName,
|
||||
userProfileImageUrl,
|
||||
userIsVerified,
|
||||
mediaType,
|
||||
mediaUrl,
|
||||
thumbnailUrl,
|
||||
durationSeconds,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
isActive,
|
||||
viewsCount,
|
||||
hasViewed,
|
||||
];
|
||||
|
||||
Story copyWith({
|
||||
String? id,
|
||||
String? userId,
|
||||
String? userFirstName,
|
||||
String? userLastName,
|
||||
String? userProfileImageUrl,
|
||||
bool? userIsVerified,
|
||||
StoryMediaType? mediaType,
|
||||
String? mediaUrl,
|
||||
String? thumbnailUrl,
|
||||
int? durationSeconds,
|
||||
DateTime? createdAt,
|
||||
DateTime? expiresAt,
|
||||
bool? isActive,
|
||||
int? viewsCount,
|
||||
bool? hasViewed,
|
||||
}) {
|
||||
return Story(
|
||||
id: id ?? this.id,
|
||||
userId: userId ?? this.userId,
|
||||
userFirstName: userFirstName ?? this.userFirstName,
|
||||
userLastName: userLastName ?? this.userLastName,
|
||||
userProfileImageUrl: userProfileImageUrl ?? this.userProfileImageUrl,
|
||||
userIsVerified: userIsVerified ?? this.userIsVerified,
|
||||
mediaType: mediaType ?? this.mediaType,
|
||||
mediaUrl: mediaUrl ?? this.mediaUrl,
|
||||
thumbnailUrl: thumbnailUrl ?? this.thumbnailUrl,
|
||||
durationSeconds: durationSeconds ?? this.durationSeconds,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
expiresAt: expiresAt ?? this.expiresAt,
|
||||
isActive: isActive ?? this.isActive,
|
||||
viewsCount: viewsCount ?? this.viewsCount,
|
||||
hasViewed: hasViewed ?? this.hasViewed,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user