chore: Adjust the default values of some properties.

main
Brett 1 year ago
parent a4b52f5895
commit 2b3f062e5c
  1. 16
      lib/src/models/conversation_info.dart
  2. 20
      lib/src/models/message.dart

@ -25,7 +25,7 @@ class ConversationInfo {
int? recvMsgOpt; int? recvMsgOpt;
// Number of unread messages in the conversation // Number of unread messages in the conversation
int? unreadCount; int unreadCount = 0;
// Latest message in the conversation // Latest message in the conversation
Message? latestMsg; Message? latestMsg;
@ -72,7 +72,7 @@ class ConversationInfo {
this.showName, this.showName,
this.faceURL, this.faceURL,
this.recvMsgOpt, this.recvMsgOpt,
this.unreadCount, this.unreadCount = 0,
this.latestMsg, this.latestMsg,
this.latestMsgSendTime, this.latestMsgSendTime,
this.draftText, this.draftText,
@ -87,8 +87,7 @@ class ConversationInfo {
this.msgDestructTime, this.msgDestructTime,
}); });
ConversationInfo.fromJson(Map<String, dynamic> json) ConversationInfo.fromJson(Map<String, dynamic> json) : conversationID = json['conversationID'] {
: conversationID = json['conversationID'] {
conversationType = json['conversationType']; conversationType = json['conversationType'];
userID = json['userID']; userID = json['userID'];
groupID = json['groupID']; groupID = json['groupID'];
@ -146,19 +145,14 @@ class ConversationInfo {
bool get isSingleChat => conversationType == ConversationType.single; bool get isSingleChat => conversationType == ConversationType.single;
// Check if it's a group chat // Check if it's a group chat
bool get isGroupChat => bool get isGroupChat => conversationType == ConversationType.group || conversationType == ConversationType.superGroup;
conversationType == ConversationType.group ||
conversationType == ConversationType.superGroup;
// Check if it's a valid conversation (not in a group if isNotInGroup is true) // Check if it's a valid conversation (not in a group if isNotInGroup is true)
bool get isValid => isSingleChat || (isGroupChat && !isNotInGroup!); bool get isValid => isSingleChat || (isGroupChat && !isNotInGroup!);
@override @override
bool operator ==(Object other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) || other is ConversationInfo && runtimeType == other.runtimeType && conversationID == other.conversationID;
other is ConversationInfo &&
runtimeType == other.runtimeType &&
conversationID == other.conversationID;
@override @override
int get hashCode => conversationID.hashCode; int get hashCode => conversationID.hashCode;

@ -920,37 +920,27 @@ class MessageEntity {
/// Group message read information /// Group message read information
class GroupHasReadInfo { class GroupHasReadInfo {
/// List of user IDs that have read the message /// Total number of reads
List<String>? hasReadUserIDList;
/// Total number of messages read
int? hasReadCount; int? hasReadCount;
/// Number of group members when this message was sent int? unreadCount;
int? groupMemberCount;
GroupHasReadInfo.fromJson(Map<String, dynamic> json) { GroupHasReadInfo.fromJson(Map<String, dynamic> json) {
if (json['hasReadUserIDList'] == null) {
hasReadUserIDList = <String>[];
} else {
hasReadUserIDList = (json['hasReadUserIDList'] as List).cast<String>();
}
hasReadCount = json['hasReadCount'] ?? 0; hasReadCount = json['hasReadCount'] ?? 0;
groupMemberCount = json['groupMemberCount'] ?? 0; unreadCount = json['unreadCount'] ?? 0;
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final data = Map<String, dynamic>(); final data = Map<String, dynamic>();
data['hasReadUserIDList'] = this.hasReadUserIDList;
data['hasReadCount'] = this.hasReadCount; data['hasReadCount'] = this.hasReadCount;
data['groupMemberCount'] = this.groupMemberCount; data['unreadCount'] = this.unreadCount;
return data; return data;
} }
} }
/// Message read receipt information /// Message read receipt information
class ReadReceiptInfo { class ReadReceiptInfo {
/// Sender's ID /// Sender ID
String? userID; String? userID;
/// Group ID /// Group ID

Loading…
Cancel
Save