Skip to content

Commit

Permalink
Merge branch 'develop' into feature/search-and-discover
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan2232004 authored Dec 16, 2024
2 parents 2cad58c + f5b8956 commit 988535e
Show file tree
Hide file tree
Showing 48 changed files with 5,164 additions and 1,931 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ flutter_*.png
*.DS_Store
*.iml
.flutter-plugins*
coverage/
coverage/

*.g.dart
49 changes: 34 additions & 15 deletions lib/core/models/chat_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,46 @@ class ChatModel {
@HiveField(1)
final List<String> userIds;
@HiveField(2)
final String? photo;
final List<String>? admins;
@HiveField(3)
final ChatType type;
final List<String>? creators;
@HiveField(4)
Uint8List? photoBytes;
final String? photo;
@HiveField(5)
String? id;
final ChatType type;
@HiveField(6)
final List<String>? admins;
Uint8List? photoBytes;
@HiveField(7)
final String? description;
String? id;
@HiveField(8)
final DateTime? lastMessageTimestamp;
final String? description;
@HiveField(9)
final bool isArchived;
final DateTime? lastMessageTimestamp;
@HiveField(10)
final bool isMuted;
final bool isArchived;
@HiveField(11)
final String? draft;
final bool isMuted;
@HiveField(12)
final bool isMentioned;
final String? draft;
@HiveField(13)
List<MessageModel> messages;
final bool isMentioned;
@HiveField(14)
List<MessageModel> messages;
@HiveField(15)
final DateTime? muteUntil; // Add this field
@HiveField(16)
final bool messagingPermission; //1->anyone 0->admins


ChatModel({
required this.title,
required this.userIds,
this.admins,
this.creators,
this.photo,
required this.type,
this.id,
this.photoBytes,
this.admins,
this.description,
this.lastMessageTimestamp,
this.isArchived = false,
Expand All @@ -60,6 +66,7 @@ class ChatModel {
this.draft,
required this.messages,
this.muteUntil, // Initialize this field
this.messagingPermission = true,
});

Future<void> _setPhotoBytes() async {
Expand Down Expand Up @@ -92,14 +99,16 @@ class ChatModel {
other.photo == photo &&
other.id == id &&
other.admins == admins &&
other.creators == creators &&
other.description == description &&
other.lastMessageTimestamp == lastMessageTimestamp &&
other.isArchived == isArchived &&
other.isMuted == isMuted &&
other.muteUntil == muteUntil &&
other.draft == draft &&
other.isMentioned == isMentioned &&
other.messages == messages;
other.messages == messages&&
other.messagingPermission == messagingPermission;
}

@override
Expand All @@ -115,8 +124,10 @@ class ChatModel {
isArchived.hashCode ^
isMuted.hashCode ^
draft.hashCode ^
creators.hashCode ^
isMentioned.hashCode ^
messages.hashCode; // Include messages in hashCode
messages.hashCode^ // Include messages in hashCode
messagingPermission.hashCode;
}

@override
Expand All @@ -128,13 +139,15 @@ class ChatModel {
'photo: $photo,\n'
'id: $id,\n'
'admins: $admins,\n'
'creators: $creators,\n'
'description: $description,\n'
'lastMessageTimestamp: $lastMessageTimestamp,\n'
'isArchived: $isArchived,\n'
'isMuted: $isMuted,\n'
'draft: $draft,\n'
'isMentioned: $isMentioned,\n'
'messages: $messages,\n' // Add messages to the string representation
'messagingPermission: $messagingPermission,\n'
')');
}

Expand All @@ -146,6 +159,7 @@ class ChatModel {
String? id,
Uint8List? photoBytes,
List<String>? admins,
List<String>? creators,
String? description,
DateTime? lastMessageTimestamp,
bool? isArchived,
Expand All @@ -154,6 +168,7 @@ class ChatModel {
String? draft,
bool? isMentioned,
List<MessageModel>? messages,
bool? messagingPermission,
}) {
return ChatModel(
title: title ?? this.title,
Expand All @@ -163,6 +178,7 @@ class ChatModel {
id: id ?? this.id,
photoBytes: photoBytes ?? this.photoBytes,
admins: admins ?? this.admins,
creators: creators ?? this.creators,
description: description ?? this.description,
lastMessageTimestamp: lastMessageTimestamp ?? this.lastMessageTimestamp,
isArchived: isArchived ?? this.isArchived,
Expand All @@ -171,6 +187,7 @@ class ChatModel {
draft: draft ?? this.draft,
isMentioned: isMentioned ?? this.isMentioned,
messages: messages ?? this.messages,
messagingPermission: messagingPermission ?? this.messagingPermission,
);
}

Expand All @@ -182,13 +199,15 @@ class ChatModel {
'photo': photo,
'id': id,
'admins': admins,
'creators': creators,
'description': description,
'lastMessageTimestamp': lastMessageTimestamp?.toIso8601String(),
'isArchived': isArchived,
'isMuted': isMuted,
'muteUntil': muteUntil?.toIso8601String(), // Add this field
'draft': draft,
'isMentioned': isMentioned,
'messagingPermission': messagingPermission,
'messages': messages.map((message) => message.toMap()).toList(),
};
}
Expand Down
Loading

0 comments on commit 988535e

Please sign in to comment.