diff --git a/lib/account/notification_service.dart b/lib/account/notification_service.dart index 0d80acf7c9..156800abf5 100644 --- a/lib/account/notification_service.dart +++ b/lib/account/notification_service.dart @@ -6,7 +6,6 @@ import 'package:stream_transform/stream_transform.dart'; import '../blaze/vo/pin_message_minimal.dart'; import '../db/database_event_bus.dart'; -import '../db/extension/conversation.dart'; import '../enum/message_category.dart'; import '../generated/l10n.dart'; @@ -85,17 +84,9 @@ class NotificationService { // quote current user if (await quotedCurrentUser()) return true; - final muteUntil = event.category == ConversationCategory.group - ? event.muteUntil - : event.ownerMuteUntil; - return muteUntil?.isAfter(DateTime.now()) != true; + return event.muteUntil?.isAfter(DateTime.now()) != true; }) .asyncMap((event) async { - final name = conversationValidName( - event.groupName, - event.ownerFullName, - ); - String? body; if (context.settingChangeNotifier.messagePreview) { final mentionCache = @@ -153,7 +144,7 @@ class NotificationService { } await showNotification( - title: name, + title: event.name ?? '', body: body, uri: Uri( scheme: enumConvertToString(NotificationScheme.conversation), diff --git a/lib/db/dao/conversation_dao.g.dart b/lib/db/dao/conversation_dao.g.dart index 7257c60466..e2f0ae68f7 100644 --- a/lib/db/dao/conversation_dao.g.dart +++ b/lib/db/dao/conversation_dao.g.dart @@ -111,7 +111,7 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.expire_in AS expireIn, owner.avatar_url AS avatarUrl, owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, CASE WHEN conversation.category = \'CONTACT\' THEN owner.membership ELSE NULL END AS membership, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, (SELECT COUNT(1) FROM message_mentions AS messageMention WHERE messageMention.conversation_id = conversation.conversation_id AND messageMention.has_read = 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + 'SELECT conversation.conversation_id AS conversationId, COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, COALESCE(owner.full_name, conversation.name) AS name, COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.draft AS draft, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.expire_in AS expireIn, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.app_id AS appId, owner.membership AS membership, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, COALESCE(mentionCounts.count, 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation LEFT JOIN users AS owner ON conversation.category = \'CONTACT\' AND owner.user_id = conversation.owner_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id LEFT JOIN (SELECT conversation_id, COUNT(1) AS count FROM message_mentions WHERE has_read = 0 GROUP BY conversation_id) AS mentionCounts ON conversation.conversation_id = mentionCounts.conversation_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', variables: [ ...generatedwhere.introducedVariables, ...generatedorder.introducedVariables, @@ -129,11 +129,13 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { ...generatedlimit.watchedTables, }).map((QueryRow row) => ConversationItem( conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('muteUntil')), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), draft: row.readNullable('draft'), - groupName: row.readNullable('groupName'), status: Conversations.$converterstatus.fromSql(row.read('status')), lastReadMessageId: row.readNullable('lastReadMessageId'), @@ -142,17 +144,9 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { pinTime: NullAwareTypeConverter.wrapFromSql( Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), expireIn: row.readNullable('expireIn'), - avatarUrl: row.readNullable('avatarUrl'), - name: row.readNullable('name'), ownerVerified: row.readNullable('ownerVerified'), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, - row.readNullable('ownerMuteUntil')), + ownerIdentityNumber: row.readNullable('ownerIdentityNumber'), appId: row.readNullable('appId'), membership: Users.$convertermembership .fromSql(row.readNullable('membership')), @@ -226,7 +220,7 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.expire_in AS expireIn, owner.avatar_url AS avatarUrl, owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, CASE WHEN conversation.category = \'CONTACT\' THEN owner.membership ELSE NULL END AS membership, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, (SELECT COUNT(1) FROM message_mentions AS messageMention WHERE messageMention.conversation_id = conversation.conversation_id AND messageMention.has_read = 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + 'SELECT conversation.conversation_id AS conversationId, COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, COALESCE(owner.full_name, conversation.name) AS name, COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.draft AS draft, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.expire_in AS expireIn, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.app_id AS appId, owner.membership AS membership, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, COALESCE(mentionCounts.count, 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation LEFT JOIN users AS owner ON conversation.category = \'CONTACT\' AND owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id LEFT JOIN (SELECT conversation_id, COUNT(1) AS count FROM message_mentions WHERE has_read = 0 GROUP BY conversation_id) AS mentionCounts ON conversation.conversation_id = mentionCounts.conversation_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', variables: [ ...generatedwhere.introducedVariables, ...generatedorder.introducedVariables, @@ -238,18 +232,20 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { messages, snapshots, expiredMessages, - messageMentions, circleConversations, + messageMentions, ...generatedwhere.watchedTables, ...generatedorder.watchedTables, ...generatedlimit.watchedTables, }).map((QueryRow row) => ConversationItem( conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('muteUntil')), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), draft: row.readNullable('draft'), - groupName: row.readNullable('groupName'), status: Conversations.$converterstatus.fromSql(row.read('status')), lastReadMessageId: row.readNullable('lastReadMessageId'), @@ -258,17 +254,9 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { pinTime: NullAwareTypeConverter.wrapFromSql( Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), expireIn: row.readNullable('expireIn'), - avatarUrl: row.readNullable('avatarUrl'), - name: row.readNullable('name'), ownerVerified: row.readNullable('ownerVerified'), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, - row.readNullable('ownerMuteUntil')), + ownerIdentityNumber: row.readNullable('ownerIdentityNumber'), appId: row.readNullable('appId'), membership: Users.$convertermembership .fromSql(row.readNullable('membership')), @@ -370,7 +358,7 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, CASE WHEN conversation.category = \'CONTACT\' THEN owner.membership ELSE NULL END AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', + 'SELECT conversation.conversation_id AS conversationId, COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, COALESCE(owner.full_name, conversation.name) AS name, COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.pin_time AS pinTime, conversation.owner_id AS ownerId, owner.identity_number AS ownerIdentityNumber, owner.is_verified AS isVerified, owner.app_id AS appId, owner.membership AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation LEFT JOIN users AS owner ON conversation.category = \'CONTACT\' AND owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', variables: [ Variable(query), ...generatedwhere.introducedVariables, @@ -384,23 +372,17 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { ...generatedlimit.watchedTables, }).map((QueryRow row) => SearchConversationItem( conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('muteUntil')), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), pinTime: NullAwareTypeConverter.wrapFromSql( Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), ownerId: row.readNullable('ownerId'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, - row.readNullable('ownerMuteUntil')), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), + ownerIdentityNumber: row.readNullable('ownerIdentityNumber'), isVerified: row.readNullable('isVerified'), appId: row.readNullable('appId'), membership: Users.$convertermembership @@ -435,7 +417,7 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { startIndex: $arrayStartIndex); $arrayStartIndex += generatedorder.amountOfVariables; return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, CASE WHEN conversation.category = \'CONTACT\' THEN owner.membership ELSE NULL END AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE conversation.conversation_id IN ($expandedids) ${generatedorder.sql}', + 'SELECT conversation.conversation_id AS conversationId, COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, COALESCE(owner.full_name, conversation.name) AS name, COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.pin_time AS pinTime, conversation.owner_id AS ownerId, owner.identity_number AS ownerIdentityNumber, owner.is_verified AS isVerified, owner.app_id AS appId, owner.membership AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation LEFT JOIN users AS owner ON conversation.category = \'CONTACT\' AND owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE conversation.conversation_id IN ($expandedids) ${generatedorder.sql}', variables: [ for (var $ in ids) Variable($), ...generatedorder.introducedVariables @@ -447,23 +429,17 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { ...generatedorder.watchedTables, }).map((QueryRow row) => SearchConversationItem( conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('muteUntil')), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), pinTime: NullAwareTypeConverter.wrapFromSql( Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), ownerId: row.readNullable('ownerId'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, - row.readNullable('ownerMuteUntil')), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), + ownerIdentityNumber: row.readNullable('ownerIdentityNumber'), isVerified: row.readNullable('isVerified'), appId: row.readNullable('appId'), membership: Users.$convertermembership @@ -510,7 +486,7 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, CASE WHEN conversation.category = \'CONTACT\' THEN owner.membership ELSE NULL END AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND circleConversation.circle_id = ?2 AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', + 'SELECT conversation.conversation_id AS conversationId, COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, COALESCE(owner.full_name, conversation.name) AS name, COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.pin_time AS pinTime, conversation.owner_id AS ownerId, owner.identity_number AS ownerIdentityNumber, owner.is_verified AS isVerified, owner.app_id AS appId, owner.membership AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation LEFT JOIN users AS owner ON conversation.category = \'CONTACT\' AND owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND circleConversation.circle_id = ?2 AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', variables: [ Variable(query), Variable(circleId), @@ -526,23 +502,17 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { ...generatedlimit.watchedTables, }).map((QueryRow row) => SearchConversationItem( conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('muteUntil')), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), pinTime: NullAwareTypeConverter.wrapFromSql( Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), ownerId: row.readNullable('ownerId'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, - row.readNullable('ownerMuteUntil')), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), + ownerIdentityNumber: row.readNullable('ownerIdentityNumber'), isVerified: row.readNullable('isVerified'), appId: row.readNullable('appId'), membership: Users.$convertermembership @@ -562,7 +532,7 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { Selectable conversationStorageUsage() { return customSelect( - 'SELECT c.conversation_id, c.owner_id, c.category, c.icon_url, c.name, u.identity_number, u.full_name, u.avatar_url, u.is_verified FROM conversations AS c INNER JOIN users AS u ON u.user_id = c.owner_id WHERE c.category IS NOT NULL', + 'SELECT c.conversation_id, c.owner_id, c.category, u.identity_number, u.is_verified, COALESCE(u.full_name, c.name) AS name, COALESCE(u.avatar_url, c.icon_url) AS avatarUrl FROM conversations AS c LEFT JOIN users AS u ON c.category = \'CONTACT\' AND u.user_id = c.owner_id WHERE c.category IS NOT NULL', variables: [], readsFrom: { conversations, @@ -572,12 +542,10 @@ mixin _$ConversationDaoMixin on DatabaseAccessor { ownerId: row.readNullable('owner_id'), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), - iconUrl: row.readNullable('icon_url'), - name: row.readNullable('name'), - identityNumber: row.read('identity_number'), - fullName: row.readNullable('full_name'), - avatarUrl: row.readNullable('avatar_url'), + identityNumber: row.readNullable('identity_number'), isVerified: row.readNullable('is_verified'), + name: row.readNullable('name'), + avatarUrl: row.readNullable('avatarUrl'), )); } @@ -643,22 +611,19 @@ typedef BaseConversationItemCount$where = Expression Function( class ConversationItem { final String conversationId; - final String? groupIconUrl; + final String? avatarUrl; + final String? name; + final DateTime? muteUntil; final ConversationCategory? category; final String? draft; - final String? groupName; final ConversationStatus status; final String? lastReadMessageId; final int? unseenMessageCount; final String? ownerId; final DateTime? pinTime; - final DateTime? muteUntil; final int? expireIn; - final String? avatarUrl; - final String? name; final bool? ownerVerified; - final String ownerIdentityNumber; - final DateTime? ownerMuteUntil; + final String? ownerIdentityNumber; final String? appId; final Membership? membership; final String? content; @@ -678,22 +643,19 @@ class ConversationItem { final UserRelationship? relationship; ConversationItem({ required this.conversationId, - this.groupIconUrl, + this.avatarUrl, + this.name, + this.muteUntil, this.category, this.draft, - this.groupName, required this.status, this.lastReadMessageId, this.unseenMessageCount, this.ownerId, this.pinTime, - this.muteUntil, this.expireIn, - this.avatarUrl, - this.name, this.ownerVerified, - required this.ownerIdentityNumber, - this.ownerMuteUntil, + this.ownerIdentityNumber, this.appId, this.membership, this.content, @@ -715,22 +677,19 @@ class ConversationItem { @override int get hashCode => Object.hashAll([ conversationId, - groupIconUrl, + avatarUrl, + name, + muteUntil, category, draft, - groupName, status, lastReadMessageId, unseenMessageCount, ownerId, pinTime, - muteUntil, expireIn, - avatarUrl, - name, ownerVerified, ownerIdentityNumber, - ownerMuteUntil, appId, membership, content, @@ -754,22 +713,19 @@ class ConversationItem { identical(this, other) || (other is ConversationItem && other.conversationId == this.conversationId && - other.groupIconUrl == this.groupIconUrl && + other.avatarUrl == this.avatarUrl && + other.name == this.name && + other.muteUntil == this.muteUntil && other.category == this.category && other.draft == this.draft && - other.groupName == this.groupName && other.status == this.status && other.lastReadMessageId == this.lastReadMessageId && other.unseenMessageCount == this.unseenMessageCount && other.ownerId == this.ownerId && other.pinTime == this.pinTime && - other.muteUntil == this.muteUntil && other.expireIn == this.expireIn && - other.avatarUrl == this.avatarUrl && - other.name == this.name && other.ownerVerified == this.ownerVerified && other.ownerIdentityNumber == this.ownerIdentityNumber && - other.ownerMuteUntil == this.ownerMuteUntil && other.appId == this.appId && other.membership == this.membership && other.content == this.content && @@ -791,22 +747,19 @@ class ConversationItem { String toString() { return (StringBuffer('ConversationItem(') ..write('conversationId: $conversationId, ') - ..write('groupIconUrl: $groupIconUrl, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('name: $name, ') + ..write('muteUntil: $muteUntil, ') ..write('category: $category, ') ..write('draft: $draft, ') - ..write('groupName: $groupName, ') ..write('status: $status, ') ..write('lastReadMessageId: $lastReadMessageId, ') ..write('unseenMessageCount: $unseenMessageCount, ') ..write('ownerId: $ownerId, ') ..write('pinTime: $pinTime, ') - ..write('muteUntil: $muteUntil, ') ..write('expireIn: $expireIn, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('name: $name, ') ..write('ownerVerified: $ownerVerified, ') ..write('ownerIdentityNumber: $ownerIdentityNumber, ') - ..write('ownerMuteUntil: $ownerMuteUntil, ') ..write('appId: $appId, ') ..write('membership: $membership, ') ..write('content: $content, ') @@ -917,16 +870,13 @@ typedef BaseUnseenConversationCount$where = Expression Function( class SearchConversationItem { final String conversationId; - final String? groupIconUrl; + final String? avatarUrl; + final String? name; + final DateTime? muteUntil; final ConversationCategory? category; - final String? groupName; final DateTime? pinTime; - final DateTime? muteUntil; final String? ownerId; - final DateTime? ownerMuteUntil; - final String ownerIdentityNumber; - final String? fullName; - final String? avatarUrl; + final String? ownerIdentityNumber; final bool? isVerified; final String? appId; final Membership? membership; @@ -940,16 +890,13 @@ class SearchConversationItem { final String? participantFullName; SearchConversationItem({ required this.conversationId, - this.groupIconUrl, + this.avatarUrl, + this.name, + this.muteUntil, this.category, - this.groupName, this.pinTime, - this.muteUntil, this.ownerId, - this.ownerMuteUntil, - required this.ownerIdentityNumber, - this.fullName, - this.avatarUrl, + this.ownerIdentityNumber, this.isVerified, this.appId, this.membership, @@ -963,45 +910,38 @@ class SearchConversationItem { this.participantFullName, }); @override - int get hashCode => Object.hashAll([ - conversationId, - groupIconUrl, - category, - groupName, - pinTime, - muteUntil, - ownerId, - ownerMuteUntil, - ownerIdentityNumber, - fullName, - avatarUrl, - isVerified, - appId, - membership, - messageStatus, - content, - contentType, - senderId, - actionName, - senderFullName, - participantUserId, - participantFullName - ]); + int get hashCode => Object.hash( + conversationId, + avatarUrl, + name, + muteUntil, + category, + pinTime, + ownerId, + ownerIdentityNumber, + isVerified, + appId, + membership, + messageStatus, + content, + contentType, + senderId, + actionName, + senderFullName, + participantUserId, + participantFullName); @override bool operator ==(Object other) => identical(this, other) || (other is SearchConversationItem && other.conversationId == this.conversationId && - other.groupIconUrl == this.groupIconUrl && + other.avatarUrl == this.avatarUrl && + other.name == this.name && + other.muteUntil == this.muteUntil && other.category == this.category && - other.groupName == this.groupName && other.pinTime == this.pinTime && - other.muteUntil == this.muteUntil && other.ownerId == this.ownerId && - other.ownerMuteUntil == this.ownerMuteUntil && other.ownerIdentityNumber == this.ownerIdentityNumber && - other.fullName == this.fullName && - other.avatarUrl == this.avatarUrl && other.isVerified == this.isVerified && other.appId == this.appId && other.membership == this.membership && @@ -1017,16 +957,13 @@ class SearchConversationItem { String toString() { return (StringBuffer('SearchConversationItem(') ..write('conversationId: $conversationId, ') - ..write('groupIconUrl: $groupIconUrl, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('name: $name, ') + ..write('muteUntil: $muteUntil, ') ..write('category: $category, ') - ..write('groupName: $groupName, ') ..write('pinTime: $pinTime, ') - ..write('muteUntil: $muteUntil, ') ..write('ownerId: $ownerId, ') - ..write('ownerMuteUntil: $ownerMuteUntil, ') ..write('ownerIdentityNumber: $ownerIdentityNumber, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') ..write('isVerified: $isVerified, ') ..write('appId: $appId, ') ..write('membership: $membership, ') @@ -1080,26 +1017,22 @@ class ConversationStorageUsage { final String conversationId; final String? ownerId; final ConversationCategory? category; - final String? iconUrl; + final String? identityNumber; + final bool? isVerified; final String? name; - final String identityNumber; - final String? fullName; final String? avatarUrl; - final bool? isVerified; ConversationStorageUsage({ required this.conversationId, this.ownerId, this.category, - this.iconUrl, + this.identityNumber, + this.isVerified, this.name, - required this.identityNumber, - this.fullName, this.avatarUrl, - this.isVerified, }); @override - int get hashCode => Object.hash(conversationId, ownerId, category, iconUrl, - name, identityNumber, fullName, avatarUrl, isVerified); + int get hashCode => Object.hash(conversationId, ownerId, category, + identityNumber, isVerified, name, avatarUrl); @override bool operator ==(Object other) => identical(this, other) || @@ -1107,24 +1040,20 @@ class ConversationStorageUsage { other.conversationId == this.conversationId && other.ownerId == this.ownerId && other.category == this.category && - other.iconUrl == this.iconUrl && - other.name == this.name && other.identityNumber == this.identityNumber && - other.fullName == this.fullName && - other.avatarUrl == this.avatarUrl && - other.isVerified == this.isVerified); + other.isVerified == this.isVerified && + other.name == this.name && + other.avatarUrl == this.avatarUrl); @override String toString() { return (StringBuffer('ConversationStorageUsage(') ..write('conversationId: $conversationId, ') ..write('ownerId: $ownerId, ') ..write('category: $category, ') - ..write('iconUrl: $iconUrl, ') - ..write('name: $name, ') ..write('identityNumber: $identityNumber, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('isVerified: $isVerified') + ..write('isVerified: $isVerified, ') + ..write('name: $name, ') + ..write('avatarUrl: $avatarUrl') ..write(')')) .toString(); } diff --git a/lib/db/dao/message_dao.g.dart b/lib/db/dao/message_dao.g.dart index d9cd592b67..375fd78d4e 100644 --- a/lib/db/dao/message_dao.g.dart +++ b/lib/db/dao/message_dao.g.dart @@ -200,7 +200,7 @@ mixin _$MessageDaoMixin on DatabaseAccessor { final expandedmessageId = $expandVar($arrayStartIndex, messageId.length); $arrayStartIndex += messageId.length; return customSelect( - 'SELECT m.message_id AS messageId, m.conversation_id AS conversationId, sender.user_id AS senderId, sender.full_name AS senderFullName, m.category AS type, m.content AS content, m.quote_content AS quoteContent, m.status AS status, c.name AS groupName, c.mute_until AS muteUntil, conversationOwner.mute_until AS ownerMuteUntil, conversationOwner.user_id AS ownerUserId, conversationOwner.full_name AS ownerFullName, m.created_at AS createdAt, c.category AS category, m."action" AS actionName, conversationOwner.relationship AS relationship, pu.full_name AS participantFullName, pu.user_id AS participantUserId FROM messages AS m INNER JOIN users AS sender ON m.user_id = sender.user_id LEFT JOIN conversations AS c ON m.conversation_id = c.conversation_id LEFT JOIN users AS conversationOwner ON c.owner_id = conversationOwner.user_id LEFT JOIN message_mentions AS mm ON m.message_id = mm.message_id LEFT JOIN users AS pu ON pu.user_id = m.participant_id WHERE m.message_id IN ($expandedmessageId) ORDER BY m.created_at DESC', + 'SELECT m.message_id AS messageId, m.conversation_id AS conversationId, sender.user_id AS senderId, sender.full_name AS senderFullName, m.category AS type, m.content AS content, m.quote_content AS quoteContent, m.status AS status, COALESCE(conversationOwner.full_name, c.name) AS name, COALESCE(conversationOwner.mute_until, c.mute_until) AS muteUntil, m.created_at AS createdAt, c.category AS category, m."action" AS actionName, conversationOwner.relationship AS relationship, pu.full_name AS participantFullName, pu.user_id AS participantUserId, c.owner_id AS ownerUserId FROM messages AS m INNER JOIN users AS sender ON m.user_id = sender.user_id LEFT JOIN conversations AS c ON m.conversation_id = c.conversation_id LEFT JOIN users AS conversationOwner ON c.category = \'CONTACT\' AND c.owner_id = conversationOwner.user_id LEFT JOIN message_mentions AS mm ON m.message_id = mm.message_id LEFT JOIN users AS pu ON pu.user_id = m.participant_id WHERE m.message_id IN ($expandedmessageId) ORDER BY m.created_at DESC', variables: [ for (var $ in messageId) Variable($) ], @@ -218,15 +218,9 @@ mixin _$MessageDaoMixin on DatabaseAccessor { content: row.readNullable('content'), quoteContent: row.readNullable('quoteContent'), status: Messages.$converterstatus.fromSql(row.read('status')), - groupName: row.readNullable('groupName'), + name: row.readNullable('name'), muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, - row.readNullable('ownerMuteUntil')), - ownerUserId: row.readNullable('ownerUserId'), - ownerFullName: row.readNullable('ownerFullName'), + Users.$convertermuteUntil, row.readNullable('muteUntil')), createdAt: Messages.$convertercreatedAt.fromSql(row.read('createdAt')), category: Conversations.$convertercategory @@ -236,6 +230,7 @@ mixin _$MessageDaoMixin on DatabaseAccessor { .fromSql(row.readNullable('relationship')), participantFullName: row.readNullable('participantFullName'), participantUserId: row.readNullable('participantUserId'), + ownerUserId: row.readNullable('ownerUserId'), )); } @@ -245,7 +240,7 @@ mixin _$MessageDaoMixin on DatabaseAccessor { final expandedmessageIds = $expandVar($arrayStartIndex, messageIds.length); $arrayStartIndex += messageIds.length; return customSelect( - 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, u.membership AS membership, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.owner_id = owner.user_id WHERE m.message_id IN ($expandedmessageIds) ORDER BY m.created_at DESC, m."rowid" DESC', + 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, u.membership AS membership, c.owner_id AS ownerId, c.category AS category, c.conversation_id AS conversationId, COALESCE(owner.avatar_url, c.icon_url) AS avatarUrl, COALESCE(owner.full_name, c.name) AS name FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.category = \'CONTACT\' AND c.owner_id = owner.user_id WHERE m.message_id IN ($expandedmessageIds) ORDER BY m.created_at DESC, m."rowid" DESC', variables: [ for (var $ in messageIds) Variable($) ], @@ -269,13 +264,11 @@ mixin _$MessageDaoMixin on DatabaseAccessor { membership: Users.$convertermembership .fromSql(row.readNullable('membership')), ownerId: row.readNullable('ownerId'), - groupIconUrl: row.readNullable('groupIconUrl'), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), conversationId: row.read('conversationId'), - ownerFullName: row.readNullable('ownerFullName'), - ownerAvatarUrl: row.readNullable('ownerAvatarUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), )); } @@ -312,7 +305,7 @@ mixin _$MessageDaoMixin on DatabaseAccessor { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, u.membership AS membership, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.owner_id = owner.user_id WHERE ${generatedwhere.sql} ORDER BY m.created_at DESC, m."rowid" DESC ${generatedlimit.sql}', + 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, u.membership AS membership, c.owner_id AS ownerId, c.category AS category, c.conversation_id AS conversationId, COALESCE(owner.avatar_url, c.icon_url) AS avatarUrl, COALESCE(owner.full_name, c.name) AS name FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.category = \'CONTACT\' AND c.owner_id = owner.user_id WHERE ${generatedwhere.sql} ORDER BY m.created_at DESC, m."rowid" DESC ${generatedlimit.sql}', variables: [ ...generatedwhere.introducedVariables, ...generatedlimit.introducedVariables @@ -339,13 +332,11 @@ mixin _$MessageDaoMixin on DatabaseAccessor { membership: Users.$convertermembership .fromSql(row.readNullable('membership')), ownerId: row.readNullable('ownerId'), - groupIconUrl: row.readNullable('groupIconUrl'), category: Conversations.$convertercategory .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), conversationId: row.read('conversationId'), - ownerFullName: row.readNullable('ownerFullName'), - ownerAvatarUrl: row.readNullable('ownerAvatarUrl'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), )); } @@ -777,17 +768,15 @@ class NotificationMessage { final String? content; final String? quoteContent; final MessageStatus status; - final String? groupName; + final String? name; final DateTime? muteUntil; - final DateTime? ownerMuteUntil; - final String? ownerUserId; - final String? ownerFullName; final DateTime createdAt; final ConversationCategory? category; final String? actionName; final UserRelationship? relationship; final String? participantFullName; final String? participantUserId; + final String? ownerUserId; NotificationMessage({ required this.messageId, required this.conversationId, @@ -797,17 +786,15 @@ class NotificationMessage { this.content, this.quoteContent, required this.status, - this.groupName, + this.name, this.muteUntil, - this.ownerMuteUntil, - this.ownerUserId, - this.ownerFullName, required this.createdAt, this.category, this.actionName, this.relationship, this.participantFullName, this.participantUserId, + this.ownerUserId, }); @override int get hashCode => Object.hash( @@ -819,17 +806,15 @@ class NotificationMessage { content, quoteContent, status, - groupName, + name, muteUntil, - ownerMuteUntil, - ownerUserId, - ownerFullName, createdAt, category, actionName, relationship, participantFullName, - participantUserId); + participantUserId, + ownerUserId); @override bool operator ==(Object other) => identical(this, other) || @@ -842,17 +827,15 @@ class NotificationMessage { other.content == this.content && other.quoteContent == this.quoteContent && other.status == this.status && - other.groupName == this.groupName && + other.name == this.name && other.muteUntil == this.muteUntil && - other.ownerMuteUntil == this.ownerMuteUntil && - other.ownerUserId == this.ownerUserId && - other.ownerFullName == this.ownerFullName && other.createdAt == this.createdAt && other.category == this.category && other.actionName == this.actionName && other.relationship == this.relationship && other.participantFullName == this.participantFullName && - other.participantUserId == this.participantUserId); + other.participantUserId == this.participantUserId && + other.ownerUserId == this.ownerUserId); @override String toString() { return (StringBuffer('NotificationMessage(') @@ -864,17 +847,15 @@ class NotificationMessage { ..write('content: $content, ') ..write('quoteContent: $quoteContent, ') ..write('status: $status, ') - ..write('groupName: $groupName, ') + ..write('name: $name, ') ..write('muteUntil: $muteUntil, ') - ..write('ownerMuteUntil: $ownerMuteUntil, ') - ..write('ownerUserId: $ownerUserId, ') - ..write('ownerFullName: $ownerFullName, ') ..write('createdAt: $createdAt, ') ..write('category: $category, ') ..write('actionName: $actionName, ') ..write('relationship: $relationship, ') ..write('participantFullName: $participantFullName, ') - ..write('participantUserId: $participantUserId') + ..write('participantUserId: $participantUserId, ') + ..write('ownerUserId: $ownerUserId') ..write(')')) .toString(); } @@ -894,12 +875,10 @@ class SearchMessageDetailItem { final bool? verified; final Membership? membership; final String? ownerId; - final String? groupIconUrl; final ConversationCategory? category; - final String? groupName; final String conversationId; - final String? ownerFullName; - final String? ownerAvatarUrl; + final String? avatarUrl; + final String? name; SearchMessageDetailItem({ required this.messageId, required this.senderId, @@ -914,12 +893,10 @@ class SearchMessageDetailItem { this.verified, this.membership, this.ownerId, - this.groupIconUrl, this.category, - this.groupName, required this.conversationId, - this.ownerFullName, - this.ownerAvatarUrl, + this.avatarUrl, + this.name, }); @override int get hashCode => Object.hash( @@ -936,12 +913,10 @@ class SearchMessageDetailItem { verified, membership, ownerId, - groupIconUrl, category, - groupName, conversationId, - ownerFullName, - ownerAvatarUrl); + avatarUrl, + name); @override bool operator ==(Object other) => identical(this, other) || @@ -959,12 +934,10 @@ class SearchMessageDetailItem { other.verified == this.verified && other.membership == this.membership && other.ownerId == this.ownerId && - other.groupIconUrl == this.groupIconUrl && other.category == this.category && - other.groupName == this.groupName && other.conversationId == this.conversationId && - other.ownerFullName == this.ownerFullName && - other.ownerAvatarUrl == this.ownerAvatarUrl); + other.avatarUrl == this.avatarUrl && + other.name == this.name); @override String toString() { return (StringBuffer('SearchMessageDetailItem(') @@ -981,12 +954,10 @@ class SearchMessageDetailItem { ..write('verified: $verified, ') ..write('membership: $membership, ') ..write('ownerId: $ownerId, ') - ..write('groupIconUrl: $groupIconUrl, ') ..write('category: $category, ') - ..write('groupName: $groupName, ') ..write('conversationId: $conversationId, ') - ..write('ownerFullName: $ownerFullName, ') - ..write('ownerAvatarUrl: $ownerAvatarUrl') + ..write('avatarUrl: $avatarUrl, ') + ..write('name: $name') ..write(')')) .toString(); } diff --git a/lib/db/extension/conversation.dart b/lib/db/extension/conversation.dart index 0a14b74114..d716c33803 100644 --- a/lib/db/extension/conversation.dart +++ b/lib/db/extension/conversation.dart @@ -5,11 +5,7 @@ import '../dao/conversation_dao.dart'; extension SearchConversationItemExtension on SearchConversationItem { bool get isGroupConversation => category == ConversationCategory.group; - bool get isMute => - (isGroupConversation && muteUntil?.isAfter(DateTime.now()) == true) || - (!isGroupConversation && ownerMuteUntil?.isAfter(DateTime.now()) == true); - - String get validName => conversationValidName(groupName, fullName); + bool get isMute => muteUntil?.isAfter(DateTime.now()) == true; } extension ConversationItemExtension on ConversationItem { @@ -28,20 +24,10 @@ extension ConversationItemExtension on ConversationItem { relationship == UserRelationship.stranger && appId == null; - String get validName => conversationValidName(groupName, name); - - bool get isMute => - (isGroupConversation && muteUntil?.isAfter(DateTime.now()) == true) || - (!isGroupConversation && ownerMuteUntil?.isAfter(DateTime.now()) == true); - - DateTime? get validMuteUntil => - isGroupConversation ? muteUntil : ownerMuteUntil; + bool get isMute => muteUntil?.isAfter(DateTime.now()) == true; Duration get expireDuration { final expireIn = this.expireIn ?? 0; return expireIn == 0 ? Duration.zero : Duration(seconds: expireIn); } } - -String conversationValidName(String? groupName, String? fullName) => - groupName?.trim().isNotEmpty == true ? groupName! : fullName ?? ''; diff --git a/lib/db/mixin_database.g.dart b/lib/db/mixin_database.g.dart index 36a2e4e174..aefa9facd2 100644 --- a/lib/db/mixin_database.g.dart +++ b/lib/db/mixin_database.g.dart @@ -16403,7 +16403,7 @@ abstract class _$MixinDatabase extends GeneratedDatabase { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, message.sticker_id AS stickerId, message.caption AS caption, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sender.membership AS membership, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, sharedUser.membership AS sharedUserMembership, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, COALESCE(snapshot.snapshot_id, safe_snapshot.snapshot_id) AS snapshotId, COALESCE(snapshot.type, safe_snapshot.type) AS snapshotType, COALESCE(snapshot.amount, safe_snapshot.amount) AS snapshotAmount, COALESCE(snapshot.memo, safe_snapshot.memo) AS snapshotMemo, COALESCE(snapshot.asset_id, safe_snapshot.asset_id) AS assetId, COALESCE(asset.symbol, token.symbol) AS assetSymbol, COALESCE(asset.icon_url, token.icon_url) AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM messages AS message INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN safe_snapshots AS safe_snapshot ON message.snapshot_id = safe_snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN tokens AS token ON safe_snapshot.asset_id = token.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN pin_messages AS pinMessage ON message.message_id = pinMessage.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, message.sticker_id AS stickerId, message.caption AS caption, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sender.membership AS membership, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, sharedUser.membership AS sharedUserMembership, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, COALESCE(snapshot.snapshot_id, safe_snapshot.snapshot_id) AS snapshotId, COALESCE(snapshot.type, safe_snapshot.type) AS snapshotType, COALESCE(snapshot.amount, safe_snapshot.amount) AS snapshotAmount, COALESCE(snapshot.memo, safe_snapshot.memo) AS snapshotMemo, COALESCE(snapshot.asset_id, safe_snapshot.asset_id) AS assetId, COALESCE(asset.symbol, token.symbol) AS assetSymbol, COALESCE(asset.icon_url, token.icon_url) AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM messages AS message INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN safe_snapshots AS safe_snapshot ON message.snapshot_id = safe_snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN tokens AS token ON safe_snapshot.asset_id = token.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN pin_messages AS pinMessage ON message.message_id = pinMessage.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', variables: [ ...generatedwhere.introducedVariables, ...generatedorder.introducedVariables, @@ -16472,7 +16472,6 @@ abstract class _$MixinDatabase extends GeneratedDatabase { conversationOwnerId: row.readNullable('conversationOwnerId'), conversionCategory: Conversations.$convertercategory .fromSql(row.readNullable('conversionCategory')), - groupName: row.readNullable('groupName'), assetUrl: row.readNullable('assetUrl'), assetWidth: row.readNullable('assetWidth'), assetHeight: row.readNullable('assetHeight'), @@ -16543,7 +16542,7 @@ abstract class _$MixinDatabase extends GeneratedDatabase { startIndex: $arrayStartIndex); $arrayStartIndex += generatedlimit.amountOfVariables; return customSelect( - 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, message.caption AS caption, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sender.membership AS membership, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, sharedUser.membership AS sharedUserMembership, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.sticker_id AS stickerId, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, COALESCE(snapshot.snapshot_id, safe_snapshot.snapshot_id) AS snapshotId, COALESCE(snapshot.type, safe_snapshot.type) AS snapshotType, COALESCE(snapshot.amount, safe_snapshot.amount) AS snapshotAmount, COALESCE(snapshot.memo, safe_snapshot.memo) AS snapshotMemo, COALESCE(snapshot.asset_id, safe_snapshot.asset_id) AS assetId, COALESCE(asset.symbol, token.symbol) AS assetSymbol, COALESCE(asset.icon_url, token.icon_url) AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM pin_messages AS pinMessage INNER JOIN messages AS message ON message.message_id = pinMessage.message_id INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN safe_snapshots AS safe_snapshot ON message.snapshot_id = safe_snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN tokens AS token ON safe_snapshot.asset_id = token.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE pinMessage.conversation_id = ?1 ${generatedorder.sql} ${generatedlimit.sql}', + 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, message.caption AS caption, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sender.membership AS membership, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, sharedUser.membership AS sharedUserMembership, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.sticker_id AS stickerId, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, COALESCE(snapshot.snapshot_id, safe_snapshot.snapshot_id) AS snapshotId, COALESCE(snapshot.type, safe_snapshot.type) AS snapshotType, COALESCE(snapshot.amount, safe_snapshot.amount) AS snapshotAmount, COALESCE(snapshot.memo, safe_snapshot.memo) AS snapshotMemo, COALESCE(snapshot.asset_id, safe_snapshot.asset_id) AS assetId, COALESCE(asset.symbol, token.symbol) AS assetSymbol, COALESCE(asset.icon_url, token.icon_url) AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM pin_messages AS pinMessage INNER JOIN messages AS message ON message.message_id = pinMessage.message_id INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN safe_snapshots AS safe_snapshot ON message.snapshot_id = safe_snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN tokens AS token ON safe_snapshot.asset_id = token.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE pinMessage.conversation_id = ?1 ${generatedorder.sql} ${generatedlimit.sql}', variables: [ Variable(conversationId), ...generatedorder.introducedVariables, @@ -16611,7 +16610,6 @@ abstract class _$MixinDatabase extends GeneratedDatabase { conversationOwnerId: row.readNullable('conversationOwnerId'), conversionCategory: Conversations.$convertercategory .fromSql(row.readNullable('conversionCategory')), - groupName: row.readNullable('groupName'), assetUrl: row.readNullable('assetUrl'), assetWidth: row.readNullable('assetWidth'), assetHeight: row.readNullable('assetHeight'), @@ -23033,7 +23031,6 @@ class MessageItem { final Membership? sharedUserMembership; final String? conversationOwnerId; final ConversationCategory? conversionCategory; - final String? groupName; final String? assetUrl; final int? assetWidth; final int? assetHeight; @@ -23095,7 +23092,6 @@ class MessageItem { this.sharedUserMembership, this.conversationOwnerId, this.conversionCategory, - this.groupName, this.assetUrl, this.assetWidth, this.assetHeight, @@ -23159,7 +23155,6 @@ class MessageItem { sharedUserMembership, conversationOwnerId, conversionCategory, - groupName, assetUrl, assetWidth, assetHeight, @@ -23225,7 +23220,6 @@ class MessageItem { other.sharedUserMembership == this.sharedUserMembership && other.conversationOwnerId == this.conversationOwnerId && other.conversionCategory == this.conversionCategory && - other.groupName == this.groupName && other.assetUrl == this.assetUrl && other.assetWidth == this.assetWidth && other.assetHeight == this.assetHeight && @@ -23289,7 +23283,6 @@ class MessageItem { ..write('sharedUserMembership: $sharedUserMembership, ') ..write('conversationOwnerId: $conversationOwnerId, ') ..write('conversionCategory: $conversionCategory, ') - ..write('groupName: $groupName, ') ..write('assetUrl: $assetUrl, ') ..write('assetWidth: $assetWidth, ') ..write('assetHeight: $assetHeight, ') diff --git a/lib/db/moor/dao/common.drift b/lib/db/moor/dao/common.drift index 6541f29b44..95122b4f0e 100644 --- a/lib/db/moor/dao/common.drift +++ b/lib/db/moor/dao/common.drift @@ -38,7 +38,6 @@ SELECT message.message_id AS messageId, sharedUser.membership AS sharedUserMembership, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, - conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, @@ -118,7 +117,6 @@ SELECT message.message_id AS messageId, sharedUser.membership AS sharedUserMembership, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, - conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, diff --git a/lib/db/moor/dao/conversation.drift b/lib/db/moor/dao/conversation.drift index a4ee3674de..2600cedb44 100644 --- a/lib/db/moor/dao/conversation.drift +++ b/lib/db/moor/dao/conversation.drift @@ -9,27 +9,21 @@ WHERE $where; _baseConversationItems AS ConversationItem: SELECT conversation.conversation_id AS conversationId, - conversation.icon_url AS groupIconUrl, + COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, + COALESCE(owner.full_name, conversation.name) AS name, + COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.draft AS draft, - conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, - conversation.mute_until AS muteUntil, conversation.expire_in as expireIn, - owner.avatar_url AS avatarUrl, - owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, - owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, - CASE - WHEN conversation.category = 'CONTACT' THEN owner.membership - ELSE NULL - END AS membership, + owner.membership AS membership, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, @@ -43,47 +37,43 @@ SELECT conversation.conversation_id AS conversationId, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, - ( - SELECT COUNT(1) - FROM message_mentions messageMention - WHERE messageMention.conversation_id = conversation.conversation_id - AND messageMention.has_read = 0 - ) AS mentionCount, + COALESCE(mentionCounts.count, 0) AS mentionCount, owner.relationship AS relationship FROM conversations conversation - INNER JOIN users owner ON owner.user_id = conversation.owner_id + LEFT JOIN users owner ON conversation.category = 'CONTACT' AND owner.user_id = conversation.owner_id LEFT JOIN messages lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages em ON lastMessage.message_id = em.message_id + LEFT JOIN ( + SELECT conversation_id, + COUNT(1) AS count + FROM message_mentions + WHERE has_read = 0 + GROUP BY conversation_id + ) AS mentionCounts ON conversation.conversation_id = mentionCounts.conversation_id WHERE $where ORDER BY $order LIMIT $limit; _baseConversationItemsByCircleId AS ConversationItem: SELECT conversation.conversation_id AS conversationId, - conversation.icon_url AS groupIconUrl, + COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, + COALESCE(owner.full_name, conversation.name) AS name, + COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, conversation.draft AS draft, - conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, - conversation.mute_until AS muteUntil, conversation.expire_in as expireIn, - owner.avatar_url AS avatarUrl, - owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, - owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, - CASE - WHEN conversation.category = 'CONTACT' THEN owner.membership - ELSE NULL - END AS membership, + owner.membership AS membership, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, @@ -97,21 +87,24 @@ SELECT conversation.conversation_id AS conversationId, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, - ( - SELECT COUNT(1) - FROM message_mentions messageMention - WHERE messageMention.conversation_id = conversation.conversation_id - AND messageMention.has_read = 0 - ) AS mentionCount, + COALESCE(mentionCounts.count, 0) AS mentionCount, owner.relationship AS relationship FROM conversations conversation - INNER JOIN users owner ON owner.user_id = conversation.owner_id + LEFT JOIN users owner ON conversation.category = 'CONTACT' + AND owner.user_id = conversation.owner_id LEFT JOIN circle_conversations circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN messages lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages em ON lastMessage.message_id = em.message_id + LEFT JOIN ( + SELECT conversation_id, + COUNT(1) AS count + FROM message_mentions + WHERE has_read = 0 + GROUP BY conversation_id + ) AS mentionCounts ON conversation.conversation_id = mentionCounts.conversation_id WHERE $where ORDER BY $order LIMIT $limit; @@ -149,22 +142,16 @@ LIMIT 1; _fuzzySearchConversation AS SearchConversationItem: SELECT conversation.conversation_id AS conversationId, - conversation.icon_url AS groupIconUrl, + COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, + COALESCE(owner.full_name, conversation.name) AS name, + COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, - conversation.name AS groupName, conversation.pin_time AS pinTime, - conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, - owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, - owner.full_name AS fullName, - owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, - CASE - WHEN conversation.category = 'CONTACT' THEN owner.membership - ELSE NULL - END AS membership, + owner.membership AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, @@ -174,7 +161,7 @@ SELECT conversation.conversation_id AS conversationId, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations conversation - INNER JOIN users owner ON owner.user_id = conversation.owner_id + LEFT JOIN users owner ON conversation.category = 'CONTACT' AND owner.user_id = conversation.owner_id LEFT JOIN messages message ON conversation.last_message_id = message.message_id LEFT JOIN users lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users participant ON participant.user_id = message.participant_id @@ -196,22 +183,16 @@ ORDER BY (conversation.category = 'GROUP' AND conversation.name = :query COLLATE _searchConversationItemByIn AS SearchConversationItem: SELECT conversation.conversation_id AS conversationId, - conversation.icon_url AS groupIconUrl, + COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, + COALESCE(owner.full_name, conversation.name) AS name, + COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, - conversation.name AS groupName, conversation.pin_time AS pinTime, - conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, - owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, - owner.full_name AS fullName, - owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, - CASE - WHEN conversation.category = 'CONTACT' THEN owner.membership - ELSE NULL - END AS membership, + owner.membership AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, @@ -221,7 +202,7 @@ SELECT conversation.conversation_id AS conversationId, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations conversation - INNER JOIN users owner ON owner.user_id = conversation.owner_id + LEFT JOIN users owner ON conversation.category = 'CONTACT' AND owner.user_id = conversation.owner_id LEFT JOIN messages message ON conversation.last_message_id = message.message_id LEFT JOIN users lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users participant ON participant.user_id = message.participant_id @@ -230,22 +211,16 @@ ORDER BY $order; _fuzzySearchConversationInCircle AS SearchConversationItem: SELECT conversation.conversation_id AS conversationId, - conversation.icon_url AS groupIconUrl, + COALESCE(owner.avatar_url, conversation.icon_url) AS avatarUrl, + COALESCE(owner.full_name, conversation.name) AS name, + COALESCE(owner.mute_until, conversation.mute_until) AS muteUntil, conversation.category AS category, - conversation.name AS groupName, conversation.pin_time AS pinTime, - conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, - owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, - owner.full_name AS fullName, - owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, - CASE - WHEN conversation.category = 'CONTACT' THEN owner.membership - ELSE NULL - END AS membership, + owner.membership AS membership, message.status AS messageStatus, message.content AS content, message.category AS contentType, @@ -255,7 +230,7 @@ SELECT conversation.conversation_id AS conversationId, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations conversation - INNER JOIN users owner ON owner.user_id = conversation.owner_id + LEFT JOIN users owner ON conversation.category = 'CONTACT' AND owner.user_id = conversation.owner_id LEFT JOIN messages message ON conversation.last_message_id = message.message_id LEFT JOIN users lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN circle_conversations circleConversation ON conversation.conversation_id = circleConversation.conversation_id @@ -274,10 +249,15 @@ ORDER BY (conversation.category = 'GROUP' AND conversation.name = :query COLLATE limit $limit; conversationStorageUsage AS ConversationStorageUsage: -SELECT c.conversation_id, c.owner_id, c.category, c.icon_url, c.name, u.identity_number, - u.full_name, u.avatar_url, u.is_verified +SELECT c.conversation_id, + c.owner_id, + c.category, + u.identity_number, + u.is_verified, + COALESCE(u.full_name, c.name) AS name, + COALESCE(u.avatar_url, c.icon_url) AS avatarUrl FROM conversations c - INNER JOIN users u ON u.user_id = c.owner_id + LEFT JOIN users u ON c.category = 'CONTACT' AND u.user_id = c.owner_id WHERE c.category IS NOT NULL; diff --git a/lib/db/moor/dao/message.drift b/lib/db/moor/dao/message.drift index c2c1940815..4b3c7935ed 100644 --- a/lib/db/moor/dao/message.drift +++ b/lib/db/moor/dao/message.drift @@ -58,38 +58,32 @@ SELECT m.message_id, m.conversation_id, m.user_id, m.category, m.content, m.medi notificationMessage AS NotificationMessage: -SELECT m.message_id AS messageId, - m.conversation_id AS conversationId, - sender.user_id AS senderId, - sender.full_name AS senderFullName, - m.category AS type, - m.content AS content, - m.quote_content AS quoteContent, - m.status AS status, - c.name AS groupName, - c.mute_until AS muteUntil, - conversationOwner.mute_until AS ownerMuteUntil, - conversationOwner.user_id AS ownerUserId, - conversationOwner.full_name AS ownerFullName, - m.created_at AS createdAt, - c.category AS category, - m.action AS actionName, - conversationOwner.relationship AS relationship, - pu.full_name AS participantFullName, - pu.user_id AS participantUserId -FROM messages m - INNER JOIN users sender - ON m.user_id = sender.user_id - LEFT JOIN conversations c - ON m.conversation_id = c.conversation_id - LEFT JOIN users conversationOwner - ON c.owner_id = conversationOwner.user_id - LEFT JOIN message_mentions mm - ON m.message_id = mm.message_id - LEFT JOIN users pu - ON pu.user_id = m.participant_id -WHERE m.message_id in :messageId -ORDER BY m.created_at DESC; +SELECT m.message_id AS messageId, + m.conversation_id AS conversationId, + sender.user_id AS senderId, + sender.full_name AS senderFullName, + m.category AS type, + m.content AS content, + m.quote_content AS quoteContent, + m.status AS status, + COALESCE(conversationOwner.full_name, c.name) AS name, + COALESCE(conversationOwner.mute_until, c.mute_until) AS muteUntil, + m.created_at AS createdAt, + c.category AS category, + m.action AS actionName, + conversationOwner.relationship AS relationship, + pu.full_name AS participantFullName, + pu.user_id AS participantUserId, + c.owner_id AS ownerUserId +FROM messages m + INNER JOIN users sender ON m.user_id = sender.user_id + LEFT JOIN conversations c ON m.conversation_id = c.conversation_id + LEFT JOIN users conversationOwner ON c.category = 'CONTACT' + AND c.owner_id = conversationOwner.user_id + LEFT JOIN message_mentions mm ON m.message_id = mm.message_id + LEFT JOIN users pu ON pu.user_id = m.participant_id +WHERE m.message_id in :messageId +ORDER BY m.created_at DESC; searchMessageByIds AS SearchMessageDetailItem: @@ -106,16 +100,14 @@ SELECT m.message_id messageId, u.is_verified AS verified, u.membership AS membership, c.owner_id AS ownerId, - c.icon_url AS groupIconUrl, c.category AS category, - c.name AS groupName, c.conversation_id AS conversationId, - owner.full_name AS ownerFullName, - owner.avatar_url AS ownerAvatarUrl + COALESCE(owner.avatar_url, c.icon_url) AS avatarUrl, + COALESCE(owner.full_name, c.name) AS name FROM messages m INNER JOIN conversations c ON c.conversation_id = m.conversation_id INNER JOIN users u ON m.user_id = u.user_id - INNER JOIN users owner ON c.owner_id = owner.user_id + INNER JOIN users owner ON c.category = 'CONTACT' AND c.owner_id = owner.user_id WHERE m.message_id IN :messageIds ORDER BY m.created_at DESC, m.rowid DESC; @@ -137,16 +129,14 @@ SELECT m.message_id messageId, u.is_verified AS verified, u.membership AS membership, c.owner_id AS ownerId, - c.icon_url AS groupIconUrl, c.category AS category, - c.name AS groupName, c.conversation_id AS conversationId, - owner.full_name AS ownerFullName, - owner.avatar_url AS ownerAvatarUrl + COALESCE(owner.avatar_url, c.icon_url) AS avatarUrl, + COALESCE(owner.full_name, c.name) AS name FROM messages m INNER JOIN conversations c ON c.conversation_id = m.conversation_id INNER JOIN users u ON m.user_id = u.user_id - INNER JOIN users owner ON c.owner_id = owner.user_id + INNER JOIN users owner ON c.category = 'CONTACT' AND c.owner_id = owner.user_id WHERE $where ORDER BY m.created_at DESC, m.rowid DESC diff --git a/lib/ui/home/chat_slide_page/chat_info_page.dart b/lib/ui/home/chat_slide_page/chat_info_page.dart index 6f422d38f9..9cd6248c6b 100644 --- a/lib/ui/home/chat_slide_page/chat_info_page.dart +++ b/lib/ui/home/chat_slide_page/chat_info_page.dart @@ -305,8 +305,7 @@ class ChatInfoPage extends HookConsumerWidget { description: muting ? Text( DateFormat('yyyy/MM/dd, hh:mm a').format( - conversationState - .conversation!.validMuteUntil! + conversationState.conversation!.muteUntil! .toLocal()), style: TextStyle( color: context.theme.secondaryText, @@ -639,7 +638,7 @@ class _AddToContactsButton extends StatelessWidget { ), onPressed: () { final username = conversation.user?.fullName ?? - conversation.conversation?.validName; + conversation.conversation?.name; assert(username != null, 'ContactsAdd: username should not be null.'); assert(conversation.isGroup != true, diff --git a/lib/ui/home/chat_slide_page/group_invite/group_invite_dialog.dart b/lib/ui/home/chat_slide_page/group_invite/group_invite_dialog.dart index de49a9f7a5..2448f37bdb 100644 --- a/lib/ui/home/chat_slide_page/group_invite/group_invite_dialog.dart +++ b/lib/ui/home/chat_slide_page/group_invite/group_invite_dialog.dart @@ -96,7 +96,6 @@ class _GroupInviteBody extends StatelessWidget { size: 90, conversationId: conversation.conversationId, fullName: conversation.name, - groupIconUrl: conversation.iconUrl, category: conversation.category, userId: conversation.ownerId, ), diff --git a/lib/ui/home/chat_slide_page/groups_in_common_page.dart b/lib/ui/home/chat_slide_page/groups_in_common_page.dart index 56ab0d1a5e..0d392e6f87 100644 --- a/lib/ui/home/chat_slide_page/groups_in_common_page.dart +++ b/lib/ui/home/chat_slide_page/groups_in_common_page.dart @@ -117,7 +117,6 @@ class _GroupConversationItemWidget extends StatelessWidget { size: ConversationPage.conversationItemAvatarSize, conversationId: group.conversationId, category: ConversationCategory.group, - groupIconUrl: group.groupIconUrl, ), const SizedBox(width: 12), Expanded( diff --git a/lib/ui/home/chat_slide_page/search_message_page.dart b/lib/ui/home/chat_slide_page/search_message_page.dart index 42c921d742..e3cc37e926 100644 --- a/lib/ui/home/chat_slide_page/search_message_page.dart +++ b/lib/ui/home/chat_slide_page/search_message_page.dart @@ -17,6 +17,7 @@ import '../../../utils/system/text_input.dart'; import '../../../widgets/action_button.dart'; import '../../../widgets/app_bar.dart'; import '../../../widgets/avatar_view/avatar_view.dart'; +import '../../../widgets/conversation/badges_widget.dart'; import '../../../widgets/high_light_text.dart'; import '../../../widgets/interactive_decorated_box.dart'; import '../../../widgets/search_text_field.dart'; @@ -420,17 +421,20 @@ class _SearchParticipantList extends HookConsumerWidget { size: 38, ), const SizedBox(width: 16), - Expanded( - child: CustomText( - user.fullName ?? '', - style: TextStyle( - fontSize: 16, - color: context.theme.text, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, + CustomText( + user.fullName ?? '', + style: TextStyle( + fontSize: 16, + color: context.theme.text, ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), + BadgesWidget( + verified: user.isVerified, + isBot: user.isBot, + membership: user.membership, + ) ], ), ), diff --git a/lib/ui/home/conversation/audio_player_bar.dart b/lib/ui/home/conversation/audio_player_bar.dart index e95ab75e58..b1b1388715 100644 --- a/lib/ui/home/conversation/audio_player_bar.dart +++ b/lib/ui/home/conversation/audio_player_bar.dart @@ -91,7 +91,7 @@ class AudioPlayerBar extends HookConsumerWidget { const SizedBox(width: 8), Flexible( child: Text( - conversationItem?.validName ?? '', + conversationItem?.name ?? '', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( diff --git a/lib/ui/home/conversation/conversation_list.dart b/lib/ui/home/conversation/conversation_list.dart index b18df5f9d3..3a02946cfa 100644 --- a/lib/ui/home/conversation/conversation_list.dart +++ b/lib/ui/home/conversation/conversation_list.dart @@ -190,7 +190,7 @@ class ConversationItemWidget extends StatelessWidget { children: [ Flexible( child: CustomText( - conversation.validName, + conversation.name ?? '', style: TextStyle( color: context.theme.text, fontSize: 16, @@ -378,7 +378,7 @@ class _MessageContent extends HookConsumerWidget { conversation.relationship, conversation.participantFullName, conversation.senderFullName, - conversation.groupName, + conversation.name, conversation.draft, hasDraft, ], diff --git a/lib/ui/home/conversation/menu_wrapper.dart b/lib/ui/home/conversation/menu_wrapper.dart index 345ee5ca0e..8ec9c79d85 100644 --- a/lib/ui/home/conversation/menu_wrapper.dart +++ b/lib/ui/home/conversation/menu_wrapper.dart @@ -138,11 +138,10 @@ class ConversationMenuWrapper extends HookConsumerWidget { image: MenuImage.icon(IconFonts.delete), title: context.l10n.deleteChat, callback: () async { - final name = - conversation?.validName ?? searchConversation!.validName; + final name = conversation?.name ?? searchConversation!.name; final ret = await showConfirmMixinDialog( context, - context.l10n.conversationDeleteTitle(name), + context.l10n.conversationDeleteTitle(name ?? ''), description: context.l10n.deleteChatDescription, ); if (ret == null) return; diff --git a/lib/ui/home/conversation/search_list.dart b/lib/ui/home/conversation/search_list.dart index c0b3cd5769..593675be0a 100644 --- a/lib/ui/home/conversation/search_list.dart +++ b/lib/ui/home/conversation/search_list.dart @@ -326,14 +326,13 @@ class SearchList extends HookConsumerWidget { child: SearchItem( avatar: ConversationAvatarWidget( conversationId: conversation.conversationId, - fullName: conversation.validName, - groupIconUrl: conversation.groupIconUrl, + fullName: conversation.name, avatarUrl: conversation.avatarUrl, category: conversation.category, size: ConversationPage.conversationItemAvatarSize, userId: conversation.ownerId, ), - name: conversation.validName, + name: conversation.name ?? '', description: description, trailing: BadgesWidget( verified: conversation.isVerified, @@ -743,29 +742,22 @@ class SearchMessageItem extends HookConsumerWidget { ) : ConversationAvatarWidget( conversationId: message.conversationId, - fullName: conversationValidName( - message.groupName, - message.ownerFullName, - ), - groupIconUrl: message.groupIconUrl, - avatarUrl: message.ownerAvatarUrl, + fullName: message.name, + avatarUrl: message.avatarUrl, category: message.category, size: ConversationPage.conversationItemAvatarSize, userId: message.ownerId, ); return SearchItem( avatar: avatar, - name: showSender - ? message.senderFullName ?? '' - : conversationValidName( - message.groupName, - message.ownerFullName, - ), - trailing: BadgesWidget( - verified: message.verified, - isBot: message.appId != null, - membership: message.membership, - ), + name: showSender ? message.senderFullName ?? '' : message.name ?? '', + trailing: showSender || message.category == ConversationCategory.contact + ? BadgesWidget( + verified: message.verified, + isBot: message.appId != null, + membership: message.membership, + ) + : null, nameHighlight: false, keyword: keyword, descriptionIcon: icon, diff --git a/lib/ui/provider/conversation_provider.dart b/lib/ui/provider/conversation_provider.dart index 71bcdf5ae6..a70634714c 100644 --- a/lib/ui/provider/conversation_provider.dart +++ b/lib/ui/provider/conversation_provider.dart @@ -70,7 +70,7 @@ class ConversationState extends Equatable { bool? get isGroup => conversation?.isGroupConversation ?? (user != null ? false : null); - String? get name => conversation?.validName ?? user?.fullName; + String? get name => conversation?.name ?? user?.fullName; String? get identityNumber => conversation?.ownerIdentityNumber ?? user?.identityNumber; diff --git a/lib/ui/setting/storage_usage_list_page.dart b/lib/ui/setting/storage_usage_list_page.dart index 093c63cacf..dcd0388bbd 100644 --- a/lib/ui/setting/storage_usage_list_page.dart +++ b/lib/ui/setting/storage_usage_list_page.dart @@ -5,7 +5,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:watcher/watcher.dart'; import '../../db/dao/conversation_dao.dart'; -import '../../db/extension/conversation.dart'; import '../../utils/extension/extension.dart'; import '../../utils/hook.dart'; import '../../widgets/app_bar.dart'; @@ -98,8 +97,7 @@ class _Item extends HookConsumerWidget { child: CellItem( leading: ConversationAvatarWidget( conversationId: item.conversationId, - fullName: item.fullName, - groupIconUrl: item.iconUrl, + fullName: item.name, avatarUrl: item.avatarUrl, category: item.category, size: 50, @@ -109,7 +107,7 @@ class _Item extends HookConsumerWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(conversationValidName(item.name, item.fullName)), + Text(item.name ?? ''), Text( sizeString, style: TextStyle( @@ -122,7 +120,7 @@ class _Item extends HookConsumerWidget { onTap: () => ref.read(responsiveNavigatorProvider.notifier).pushPage( ResponsiveNavigatorStateNotifier.storageUsageDetail, arguments: ( - conversationValidName(item.name, item.fullName), + item.name, item.conversationId, ), ), diff --git a/lib/widgets/actions/command_palette_action.dart b/lib/widgets/actions/command_palette_action.dart index 33f8145309..0f8b1a7941 100644 --- a/lib/widgets/actions/command_palette_action.dart +++ b/lib/widgets/actions/command_palette_action.dart @@ -9,7 +9,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../../constants/resources.dart'; import '../../db/dao/conversation_dao.dart'; import '../../db/database_event_bus.dart'; -import '../../db/extension/conversation.dart'; import '../../db/mixin_database.dart'; import '../../ui/home/conversation/search_list.dart'; import '../../ui/home/intent.dart'; @@ -321,14 +320,13 @@ class CommandPalettePage extends HookConsumerWidget { padding: const EdgeInsets.all(14), avatar: ConversationAvatarWidget( conversationId: conversation.conversationId, - fullName: conversation.validName, - groupIconUrl: conversation.groupIconUrl, + fullName: conversation.name, avatarUrl: conversation.avatarUrl, category: conversation.category, size: 40, userId: conversation.ownerId, ), - name: conversation.validName, + name: conversation.name ?? '', trailing: BadgesWidget( verified: conversation.isVerified, isBot: conversation.appId != null, diff --git a/lib/widgets/avatar_view/avatar_view.dart b/lib/widgets/avatar_view/avatar_view.dart index ee8b4cb1ec..ce1359b38d 100644 --- a/lib/widgets/avatar_view/avatar_view.dart +++ b/lib/widgets/avatar_view/avatar_view.dart @@ -20,7 +20,6 @@ class ConversationAvatarWidget extends HookConsumerWidget { this.conversationId, this.userId, this.fullName, - this.groupIconUrl, this.avatarUrl, this.category, }); @@ -29,7 +28,6 @@ class ConversationAvatarWidget extends HookConsumerWidget { final String? userId; final String? conversationId; final String? fullName; - final String? groupIconUrl; final String? avatarUrl; final ConversationCategory? category; final double size; @@ -39,7 +37,6 @@ class ConversationAvatarWidget extends HookConsumerWidget { final _conversationId = conversation?.conversationId ?? conversationId; assert(_conversationId != null); final _name = conversation?.name ?? fullName; - final _groupIconUrl = conversation?.groupIconUrl ?? groupIconUrl; final _avatarUrl = conversation?.avatarUrl ?? avatarUrl; final _category = conversation?.category ?? category; assert(_category != null); @@ -73,7 +70,7 @@ class ConversationAvatarWidget extends HookConsumerWidget { ? AvatarWidget( userId: _userId, name: _name, - avatarUrl: _avatarUrl ?? _groupIconUrl ?? '', + avatarUrl: _avatarUrl ?? '', size: size) : AvatarPuzzlesWidget(list, size), ), diff --git a/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart b/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart index 394e725718..dddc275d28 100644 --- a/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart +++ b/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart @@ -89,19 +89,17 @@ class ConversationFilterCubit extends Cubit { final keyword = state.keyword!.toLowerCase(); final recentConversations = conversations - .where((element) => element.isGroupConversation - ? element.groupName != null && - element.groupName!.toLowerCase().contains(keyword) - : element.name!.toLowerCase().contains(keyword) || - element.ownerIdentityNumber.toLowerCase().startsWith(keyword)) + .where((element) => + (element.name ?? element.ownerIdentityNumber) + ?.toLowerCase() + .contains(keyword) ?? + false) .toList() ..sort(compareValuesBy((e) { - if (e.isGroupConversation) { - return e.groupName!.toLowerCase().indexOf(keyword); - } final indexOf = e.name?.toLowerCase().indexOf(keyword) ?? -1; if (indexOf != -1) return indexOf; - return e.ownerIdentityNumber.indexOf(keyword); + + return e.ownerIdentityNumber?.indexOf(keyword) ?? -1; })); bool where(User element) => diff --git a/lib/widgets/user_selector/conversation_selector.dart b/lib/widgets/user_selector/conversation_selector.dart index 4d14f1dd75..a7287500ef 100644 --- a/lib/widgets/user_selector/conversation_selector.dart +++ b/lib/widgets/user_selector/conversation_selector.dart @@ -27,7 +27,7 @@ import '../interactive_decorated_box.dart'; import 'bloc/conversation_filter_cubit.dart'; String _getConversationName(dynamic item) { - if (item is ConversationItem) return item.validName; + if (item is ConversationItem) return item.name ?? '?'; if (item is User) return item.fullName ?? '?'; throw ArgumentError('must be ConversationItem or User'); } @@ -390,7 +390,7 @@ class _ConversationSelector extends HookConsumerWidget { child: _BaseItem( keyword: conversationFilterState.keyword, avatar: item.avatarWidget, - title: item.validName, + title: item.name ?? '', verified: item.ownerVerified, isBot: item.isBotConversation, membership: item.membership, diff --git a/pubspec.yaml b/pubspec.yaml index 84cb0ae90e..09fcc3a5ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -201,12 +201,12 @@ flutter: # the material Icons class. uses-material-design: true assets: - # assets start + # assets start - # GENERATED CODE - DO NOT MODIFY MANUALLY - # ************************************************************************** - # Auto generated by https://github.com/fluttercandies/assets_generator - # ************************************************************************** + # GENERATED CODE - DO NOT MODIFY MANUALLY + # ************************************************************************** + # Auto generated by https://github.com/fluttercandies/assets_generator + # ************************************************************************** - assets/ - assets/fonts/