diff --git a/lib/src/chat/chat_bloc.dart b/lib/src/chat/chat_bloc.dart index f4be92dd..d1dbe73d 100644 --- a/lib/src/chat/chat_bloc.dart +++ b/lib/src/chat/chat_bloc.dart @@ -142,6 +142,7 @@ class ChatBloc extends Bloc { color: color, freshMessageCount: 0, isSelfTalk: false, + isDeviceTalk: false, isGroupChat: false, preview: null, timestamp: null, @@ -162,6 +163,7 @@ class ChatBloc extends Bloc { final colorValue = await chat.getColor(); final freshMessageCount = await context.getFreshMessageCount(_chatId); final isSelfTalk = await chat.isSelfTalk(); + final isDeviceTalk = await chat.isDeviceTalk(); final isVerified = await chat.isVerified(); final color = colorFromArgb(colorValue); final chatSummary = chat.get(ChatExtension.chatSummary); @@ -180,10 +182,9 @@ class ChatBloc extends Bloc { Contact contact = _contactRepository.get(chatContactId); phoneNumbers = contact?.get(ContactExtension.contactPhoneNumber); avatarPath = contact?.get(ContactExtension.contactAvatar); - final isSelfTalk = await chat.isSelfTalk(); if (isSelfTalk) { subTitle = L10n.get(L.chatMessagesSelf); - } else { + } else if(!isDeviceTalk) { final Contact contact = _contactRepository.get(chatContactId); subTitle = await contact.getAddress(); } @@ -194,6 +195,7 @@ class ChatBloc extends Bloc { color: color, freshMessageCount: freshMessageCount, isSelfTalk: isSelfTalk, + isDeviceTalk: isDeviceTalk, isGroupChat: _isGroupChat, preview: chatSummaryState != ChatMsg.messageStateDraft && chatSummaryState != ChatMsg.messageNone ? chatSummary?.preview : L10n.get(L.chatNoMessages), timestamp: chatSummary?.timestamp, diff --git a/lib/src/chat/chat_event_state.dart b/lib/src/chat/chat_event_state.dart index d33f55ed..a6ee0ea2 100644 --- a/lib/src/chat/chat_event_state.dart +++ b/lib/src/chat/chat_event_state.dart @@ -71,6 +71,7 @@ class ChatStateSuccess extends ChatState { final Color color; final int freshMessageCount; final bool isSelfTalk; + final bool isDeviceTalk; final bool isGroupChat; final String preview; final int timestamp; @@ -85,6 +86,7 @@ class ChatStateSuccess extends ChatState { @required this.color, @required this.freshMessageCount, @required this.isSelfTalk, + @required this.isDeviceTalk, @required this.isGroupChat, @required this.preview, @required this.timestamp, diff --git a/lib/src/chatlist/chat_list_item.dart b/lib/src/chatlist/chat_list_item.dart index 0e00ad75..ec6a575f 100644 --- a/lib/src/chatlist/chat_list_item.dart +++ b/lib/src/chatlist/chat_list_item.dart @@ -96,6 +96,7 @@ class _ChatListItemState extends State { String imagePath = ""; bool hasError = false; bool isGroupChat = false; + bool isDeviceTalk = false; if (state is ChatStateSuccess) { name = state.name; @@ -105,12 +106,13 @@ class _ChatListItemState extends State { preview = state.preview; imagePath = state.avatarPath; isGroupChat = state.isGroupChat; + isDeviceTalk = state.isDeviceTalk; } else if (state is ChatStateFailure) { hasError = true; } return Visibility( - visible: !hasError, + visible: !hasError && !isDeviceTalk, child: InkWell( child: AvatarListItem( title: name, diff --git a/lib/src/notifications/local_notification_manager.dart b/lib/src/notifications/local_notification_manager.dart index 2c49cc13..0e021da5 100644 --- a/lib/src/notifications/local_notification_manager.dart +++ b/lib/src/notifications/local_notification_manager.dart @@ -119,15 +119,18 @@ class LocalNotificationManager { notificationHistory.update(chatId.toString(), (value) => messageId, ifAbsent: () => messageId); _chatRepository.putIfAbsent(id: chatId); final chat = _chatRepository.get(chatId); - String title = await chat.getName(); - final count = (await _context.getFreshMessageCount(chatId)) - 1; - if (count > 1) { - title = "$title (+ ${L10n.getFormatted(L.moreMessagesX, [count])})"; + final isDeviceTalk = await chat.isDeviceTalk(); + if(!isDeviceTalk) { + String title = await chat.getName(); + final count = (await _context.getFreshMessageCount(chatId)) - 1; + if (count > 1) { + title = "$title (+ ${L10n.getFormatted(L.moreMessagesX, [count])})"; + } + final teaser = await message.getSummaryText(200); + final payload = chatId?.toString(); + _logger.info("Creating chat notification for chat id $chatId with message id $messageId"); + _notificationManager.showNotificationFromLocal(chatId, title, teaser, payload: payload); } - final teaser = await message.getSummaryText(200); - final payload = chatId?.toString(); - _logger.info("Creating chat notification for chat id $chatId with message id $messageId"); - _notificationManager.showNotificationFromLocal(chatId, title, teaser, payload: payload); } });