diff --git a/Mixin.xcodeproj/project.pbxproj b/Mixin.xcodeproj/project.pbxproj index 15f71f0031..c575844957 100644 --- a/Mixin.xcodeproj/project.pbxproj +++ b/Mixin.xcodeproj/project.pbxproj @@ -608,6 +608,7 @@ 7C695D56285B25AB0042177C /* SpotlightManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C695D55285B25AB0042177C /* SpotlightManager.swift */; }; 7C6AD1F526A6794F00E6C41D /* StickersStoreViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C6AD1F426A6794F00E6C41D /* StickersStoreViewController.swift */; }; 7C7635B826A13461006101DB /* HomeAppsConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C7635B726A13461006101DB /* HomeAppsConstants.swift */; }; + 7C7A865428E6E81600D6A4FA /* ConversationItem+DisplayContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C7A865328E6E81600D6A4FA /* ConversationItem+DisplayContent.swift */; }; 7C8CC5A4280D347A00F7CBDF /* PreviewWallpaperViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C8CC5A2280D347A00F7CBDF /* PreviewWallpaperViewController.swift */; }; 7C8CC5A7280D40E900F7CBDF /* PreviewWallpaperCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C8CC5A6280D40E900F7CBDF /* PreviewWallpaperCell.swift */; }; 7C8FA78D27687D1500855AFD /* DeleteAccountSettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C8FA78C27687D1500855AFD /* DeleteAccountSettingViewController.swift */; }; @@ -1635,6 +1636,7 @@ 7C695D55285B25AB0042177C /* SpotlightManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpotlightManager.swift; sourceTree = ""; }; 7C6AD1F426A6794F00E6C41D /* StickersStoreViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickersStoreViewController.swift; sourceTree = ""; }; 7C7635B726A13461006101DB /* HomeAppsConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeAppsConstants.swift; sourceTree = ""; }; + 7C7A865328E6E81600D6A4FA /* ConversationItem+DisplayContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConversationItem+DisplayContent.swift"; sourceTree = ""; }; 7C8CC5A2280D347A00F7CBDF /* PreviewWallpaperViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewWallpaperViewController.swift; sourceTree = ""; }; 7C8CC5A6280D40E900F7CBDF /* PreviewWallpaperCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewWallpaperCell.swift; sourceTree = ""; }; 7C8FA78C27687D1500855AFD /* DeleteAccountSettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteAccountSettingViewController.swift; sourceTree = ""; }; @@ -2157,15 +2159,16 @@ isa = PBXGroup; children = ( 7B04FAB722684242004F8F04 /* AssetSearchResult.swift */, - 7B04FAB922684F51004F8F04 /* SearchResult.swift */, - 7B35AF73228A948A00E8101D /* UserSearchResult.swift */, - 7C4733A028533EB800ECD293 /* PhoneContactSearchResult.swift */, + 7BB0F9502434DDD400BEDA97 /* CircleMemberSearchResult.swift */, 7B35AF75228A98EF00E8101D /* ConversationSearchResult.swift */, + 7BAB76AB228AAE00009ECB8C /* MessageReceiverSearchResult.swift */, + 7BAB76A9228AABEA009ECB8C /* MessageSearchResult.swift */, + 7B35AF79228AA61400E8101D /* MessagesWithGroupSearchResult.swift */, 7B35AF7B228AA6CD00E8101D /* MessagesWithinConversationSearchResult.swift */, 7B35AF77228AA3BD00E8101D /* MessagesWithUserSearchResult.swift */, - 7B35AF79228AA61400E8101D /* MessagesWithGroupSearchResult.swift */, - 7BAB76A9228AABEA009ECB8C /* MessageSearchResult.swift */, - 7BB0F9502434DDD400BEDA97 /* CircleMemberSearchResult.swift */, + 7C4733A028533EB800ECD293 /* PhoneContactSearchResult.swift */, + 7B04FAB922684F51004F8F04 /* SearchResult.swift */, + 7B35AF73228A948A00E8101D /* UserSearchResult.swift */, ); path = "Search Result"; sourceTree = ""; @@ -2214,7 +2217,6 @@ 7BEB97172366CF42002DB190 /* MessageFontSet.swift */, 7CDF316B29890FB200421808 /* ConversationFontSet.swift */, 7BFE47E622845DE100FC4379 /* MessageReceiver.swift */, - 7BAB76AB228AAE00009ECB8C /* MessageReceiverSearchResult.swift */, 7B09E5591FD157EB002E45D3 /* MessageViewModel.swift */, 7B9D825722F1BFEA0099381E /* NetworkOperationIconSet.swift */, 7B9D825522F1BFE90099381E /* NormalNetworkOperationIconSet.swift */, @@ -2249,6 +2251,7 @@ 94D63DD52646C29100FD7EE8 /* MessageViewModelFactory.swift */, 7CC7304F2745F95D002780F5 /* StickerStore.swift */, 7CF7416D27DAD93000DA0004 /* SnapCenterFlowLayout.swift */, + 7C7A865328E6E81600D6A4FA /* ConversationItem+DisplayContent.swift */, ); path = Model; sourceTree = ""; @@ -4847,6 +4850,7 @@ 945278982626BCD600023A6C /* HighlightableButton.swift in Sources */, 7BEB5D9F22B79F5500B8B10E /* EmergencyContactLoginVerificationCodeViewController.swift in Sources */, 7B59535122672D3500D59DB4 /* TopResultCell.swift in Sources */, + 7C7A865428E6E81600D6A4FA /* ConversationItem+DisplayContent.swift in Sources */, 94046B91272DC265007C1D4A /* GroupCallMembersDataSource.swift in Sources */, 7BEE5353222E21D7008D3911 /* KeyboardHeight.swift in Sources */, 7B95534322438ECD00CE95E6 /* TopRoundedView.swift in Sources */, diff --git a/Mixin/Service/Storage/CircleMember+Convenience.swift b/Mixin/Service/Storage/CircleMember+Convenience.swift index 8a3cc6277f..4ef405600d 100644 --- a/Mixin/Service/Storage/CircleMember+Convenience.swift +++ b/Mixin/Service/Storage/CircleMember+Convenience.swift @@ -25,7 +25,8 @@ extension CircleMember { iconUrl: isGroup ? conversation.iconUrl : conversation.ownerAvatarUrl, identityNumber: conversation.ownerIdentityNumber, phoneNumber: nil, - badgeImage: nil) + badgeImage: nil, + conversationContent: conversation.displayContent) } } diff --git a/Mixin/Service/Storage/Search Result/CircleMemberSearchResult.swift b/Mixin/Service/Storage/Search Result/CircleMemberSearchResult.swift index 70a1acb586..68c65f21ea 100644 --- a/Mixin/Service/Storage/Search Result/CircleMemberSearchResult.swift +++ b/Mixin/Service/Storage/Search Result/CircleMemberSearchResult.swift @@ -20,9 +20,13 @@ class CircleMemberSearchResult: SearchResult { textAttributes: SearchResult.titleAttributes, keyword: keyword, keywordAttributes: SearchResult.highlightedTitleAttributes) - description = SearchResult.description(identityNumber: member.identityNumber, - phoneNumber: member.phoneNumber, - keyword: keyword) + if let content = member.conversationContent { + description = SearchResult.description(conversationContent: content) + } else { + description = SearchResult.description(identityNumber: member.identityNumber, + phoneNumber: member.phoneNumber, + keyword: keyword) + } } } diff --git a/Mixin/Service/Storage/Search Result/ConversationSearchResult.swift b/Mixin/Service/Storage/Search Result/ConversationSearchResult.swift index e951b4749d..a168b6330d 100644 --- a/Mixin/Service/Storage/Search Result/ConversationSearchResult.swift +++ b/Mixin/Service/Storage/Search Result/ConversationSearchResult.swift @@ -20,6 +20,7 @@ class ConversationSearchResult: SearchResult { textAttributes: SearchResult.titleAttributes, keyword: keyword, keywordAttributes: SearchResult.highlightedTitleAttributes) + description = SearchResult.description(conversationContent: conversation.displayContent) } } diff --git a/Mixin/UserInterface/Controllers/Chat/Model/MessageReceiverSearchResult.swift b/Mixin/Service/Storage/Search Result/MessageReceiverSearchResult.swift similarity index 76% rename from Mixin/UserInterface/Controllers/Chat/Model/MessageReceiverSearchResult.swift rename to Mixin/Service/Storage/Search Result/MessageReceiverSearchResult.swift index 490e78a24e..3c3665b7d8 100644 --- a/Mixin/UserInterface/Controllers/Chat/Model/MessageReceiverSearchResult.swift +++ b/Mixin/Service/Storage/Search Result/MessageReceiverSearchResult.swift @@ -27,11 +27,10 @@ class MessageReceiverSearchResult: SearchResult { textAttributes: SearchResult.titleAttributes, keyword: keyword, keywordAttributes: SearchResult.highlightedTitleAttributes) - switch receiver.item { - case .group(_): - description = nil - case let .user(user): - description = SearchResult.description(user: user, keyword: keyword) + if let content = receiver.conversationContent { + description = SearchResult.description(conversationContent: content) + } else if case let .user(user) = receiver.item { + description = SearchResult.description(identityNumber: user.identityNumber, phoneNumber: user.phone, keyword: keyword) } } diff --git a/Mixin/Service/Storage/Search Result/SearchResult.swift b/Mixin/Service/Storage/Search Result/SearchResult.swift index 4b6cb28371..30360333d7 100644 --- a/Mixin/Service/Storage/Search Result/SearchResult.swift +++ b/Mixin/Service/Storage/Search Result/SearchResult.swift @@ -95,13 +95,18 @@ extension SearchResult { textAttributes: SearchResult.normalDescriptionAttributes, keyword: keyword, keywordAttributes: SearchResult.highlightedNormalDescriptionAttributes) + } else if let identityNumber { + return NSAttributedString(string: identityNumber, attributes: normalDescriptionAttributes) } else { return nil } } - static func description(user: UserItem, keyword: String) -> NSAttributedString? { - description(identityNumber: user.identityNumber, phoneNumber: user.phone, keyword: keyword) + static func description(conversationContent: String?) -> NSAttributedString? { + guard let conversationContent, !conversationContent.isEmpty else { + return nil + } + return NSAttributedString(string: conversationContent, attributes: normalDescriptionAttributes) } } diff --git a/Mixin/Service/Storage/Search Result/UserSearchResult.swift b/Mixin/Service/Storage/Search Result/UserSearchResult.swift index 70559e9e20..4e1c912518 100644 --- a/Mixin/Service/Storage/Search Result/UserSearchResult.swift +++ b/Mixin/Service/Storage/Search Result/UserSearchResult.swift @@ -22,7 +22,9 @@ class UserSearchResult: SearchResult { textAttributes: SearchResult.titleAttributes, keyword: keyword, keywordAttributes: SearchResult.highlightedTitleAttributes) - description = SearchResult.description(user: user, keyword: keyword) + description = SearchResult.description(identityNumber: user.identityNumber, + phoneNumber: user.phone, + keyword: keyword) } } diff --git a/Mixin/UserInterface/Controllers/Chat/Model/ConversationItem+DisplayContent.swift b/Mixin/UserInterface/Controllers/Chat/Model/ConversationItem+DisplayContent.swift new file mode 100644 index 0000000000..48d3e08faa --- /dev/null +++ b/Mixin/UserInterface/Controllers/Chat/Model/ConversationItem+DisplayContent.swift @@ -0,0 +1,122 @@ +import Foundation +import MixinServices + +extension ConversationItem { + + var displayContent: String { + if messageStatus == MessageStatus.FAILED.rawValue { + return R.string.localizable.chat_decryption_failed_hint(senderFullName) + } else if messageStatus == MessageStatus.UNKNOWN.rawValue { + return R.string.localizable.message_not_support() + } else { + let senderIsMe = senderId == myUserId + let senderName = senderIsMe ? R.string.localizable.you() : senderFullName + let category = contentType + if category.hasSuffix("_TEXT") { + if isGroup() { + return "\(senderName): \(mentionedFullnameReplacedContent)" + } else { + return mentionedFullnameReplacedContent + } + } else if category.hasSuffix("_IMAGE") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_photo())" + } else { + return R.string.localizable.content_photo() + } + } else if category.hasSuffix("_STICKER") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_sticker())" + } else { + return R.string.localizable.content_sticker() + } + } else if category.hasSuffix("_CONTACT") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_contact())" + } else { + return R.string.localizable.content_contact() + } + } else if category.hasSuffix("_DATA") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_file())" + } else { + return R.string.localizable.content_file() + } + } else if category.hasSuffix("_VIDEO") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_video())" + } else { + return R.string.localizable.content_video() + } + } else if category.hasSuffix("_LIVE") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_live())" + } else { + return R.string.localizable.content_live() + } + } else if category.hasSuffix("_AUDIO") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_audio())" + } else { + return R.string.localizable.content_audio() + } + } else if category.hasSuffix("_POST") { + if isGroup() { + return "\(senderName): \(markdownControlCodeRemovedContent)" + } else { + return markdownControlCodeRemovedContent + } + } else if category.hasSuffix("_LOCATION") { + if isGroup() { + return "\(senderName): \(R.string.localizable.content_location())" + } else { + return R.string.localizable.content_location() + } + } else if category.hasPrefix("WEBRTC_") { + return R.string.localizable.content_voice() + } else if category == MessageCategory.SYSTEM_ACCOUNT_SNAPSHOT.rawValue { + return R.string.localizable.content_transfer() + } else if category == MessageCategory.APP_BUTTON_GROUP.rawValue { + return (appButtons?.map({ (appButton) -> String in + return "[\(appButton.label)]" + }) ?? []).joined() + } else if category == MessageCategory.APP_CARD.rawValue, let appCard = appCard { + return "[\(appCard.title)]" + } else if category == MessageCategory.MESSAGE_RECALL.rawValue { + if senderIsMe { + return R.string.localizable.you_deleted_this_message() + } else { + return R.string.localizable.this_message_was_deleted() + } + } else if category == MessageCategory.MESSAGE_PIN.rawValue { + return TransferPinAction.pinMessage(item: self) + } else if category == MessageCategory.KRAKEN_PUBLISH.rawValue { + return R.string.localizable.started_group_call(senderName) + } else if category == MessageCategory.KRAKEN_CANCEL.rawValue { + return R.string.localizable.chat_group_call_cancel(senderName) + } else if category == MessageCategory.KRAKEN_DECLINE.rawValue { + return R.string.localizable.chat_group_call_decline(senderName) + } else if category == MessageCategory.KRAKEN_INVITE.rawValue { + return R.string.localizable.chat_group_call_invite(senderName) + } else if category == MessageCategory.KRAKEN_END.rawValue { + return R.string.localizable.content_group_call_ended() + } else if category.hasSuffix("_TRANSCRIPT") { + return R.string.localizable.content_transcript() + } else { + if contentType.hasPrefix("SYSTEM_") { + return SystemConversationAction.getSystemMessage(actionName: actionName, + userId: senderId, + userFullName: senderFullName, + participantId: participantUserId, + participantFullName: participantFullName, + content: content) + } else if messageId.isEmpty { + return "" + } else { + return R.string.localizable.message_not_support() + } + } + } + } + +} diff --git a/Mixin/UserInterface/Controllers/Chat/Model/MessageReceiver.swift b/Mixin/UserInterface/Controllers/Chat/Model/MessageReceiver.swift index 1831bc4d75..6cd58e414a 100644 --- a/Mixin/UserInterface/Controllers/Chat/Model/MessageReceiver.swift +++ b/Mixin/UserInterface/Controllers/Chat/Model/MessageReceiver.swift @@ -12,6 +12,7 @@ class MessageReceiver { let name: String let badgeImage: UIImage? let item: Item + let conversationContent: String? init?(conversation: ConversationItem) { if conversation.category == ConversationCategory.CONTACT.rawValue { @@ -30,6 +31,7 @@ class MessageReceiver { return nil } conversationId = conversation.conversationId + conversationContent = conversation.displayContent } init(user: UserItem) { @@ -37,6 +39,7 @@ class MessageReceiver { badgeImage = SearchResult.userBadgeImage(isVerified: user.isVerified, appId: user.appId) item = .user(user) conversationId = ConversationDAO.shared.makeConversationId(userId: user.userId, ownerUserId: myUserId) + conversationContent = nil } func matches(lowercasedKeyword keyword: String) -> Bool { diff --git a/Mixin/UserInterface/Controllers/Common/Views/PeerInfoView.swift b/Mixin/UserInterface/Controllers/Common/Views/PeerInfoView.swift index 700c4aaeca..a141eaec32 100644 --- a/Mixin/UserInterface/Controllers/Common/Views/PeerInfoView.swift +++ b/Mixin/UserInterface/Controllers/Common/Views/PeerInfoView.swift @@ -106,7 +106,8 @@ class PeerInfoView: UIView, XibDesignable { badgeImageView.isHidden = badgeImageView.image == nil superscriptLabel.text = nil prefixIconImageView.isHidden = true - descriptionLabel.isHidden = true + descriptionLabel.isHidden = false + descriptionLabel.text = user.identityNumber } func render(user: User, userBiographyAsSubtitle: Bool) { @@ -116,27 +117,25 @@ class PeerInfoView: UIView, XibDesignable { badgeImageView.isHidden = badgeImageView.image == nil superscriptLabel.text = nil prefixIconImageView.isHidden = true - if userBiographyAsSubtitle { - descriptionLabel.isHidden = false - descriptionLabel.text = user.biography - } else { - descriptionLabel.isHidden = true - } + descriptionLabel.isHidden = false + descriptionLabel.text = userBiographyAsSubtitle ? user.biography : user.identityNumber } func render(receiver: MessageReceiver) { switch receiver.item { case let .group(conversation): avatarImageView.setGroupImage(with: conversation.iconUrl) + descriptionLabel.text = receiver.conversationContent case let .user(user): avatarImageView.setImage(with: user.avatarUrl, userId: user.userId, name: user.fullName) + descriptionLabel.text = receiver.conversationContent ?? user.identityNumber } titleLabel.text = receiver.name + descriptionLabel.isHidden = descriptionLabel.text?.isEmpty ?? true badgeImageView.image = receiver.badgeImage badgeImageView.isHidden = badgeImageView.image == nil superscriptLabel.text = nil prefixIconImageView.isHidden = true - descriptionLabel.isHidden = true } func render(member: CircleMember) { @@ -147,12 +146,20 @@ class PeerInfoView: UIView, XibDesignable { userId: member.userId ?? "", name: member.name) } + if let content = member.conversationContent { + descriptionLabel.text = content + descriptionLabel.isHidden = content.isEmpty + } else if let identityNumber = member.identityNumber { + descriptionLabel.text = identityNumber + descriptionLabel.isHidden = false + } else { + descriptionLabel.isHidden = true + } titleLabel.text = member.name badgeImageView.image = member.badgeImage badgeImageView.isHidden = badgeImageView.image == nil superscriptLabel.text = nil prefixIconImageView.isHidden = true - descriptionLabel.isHidden = true } func render(phoneContact: PhoneContact) { diff --git a/Mixin/UserInterface/Controllers/Home/Cells/ConversationCell.swift b/Mixin/UserInterface/Controllers/Home/Cells/ConversationCell.swift index 24c9a3b098..1d84342f9f 100644 --- a/Mixin/UserInterface/Controllers/Home/Cells/ConversationCell.swift +++ b/Mixin/UserInterface/Controllers/Home/Cells/ConversationCell.swift @@ -56,126 +56,20 @@ class ConversationCell: ModernSelectedBackgroundCell { messageStatusImageView.isHidden = false messageStatusImageView.image = #imageLiteral(resourceName: "ic_status_sending") messageTypeImageView.isHidden = true - contentLabel.text = R.string.localizable.chat_decryption_failed_hint(item.senderFullName) } else if item.messageStatus == MessageStatus.UNKNOWN.rawValue { messageStatusImageView.isHidden = true messageTypeImageView.isHidden = true - contentLabel.text = R.string.localizable.message_not_support() } else { expiredImageView.isHidden = item.contentExpireIn == 0 || item.contentType.hasPrefix("SYSTEM_") showMessageIndicate(conversation: item) - let senderIsMe = item.senderId == myUserId - let senderName = senderIsMe ? R.string.localizable.you() : item.senderFullName - let category = item.contentType messageTypeImageView.image = MessageCategory.iconImage(forMessageCategoryString: category) messageTypeImageView.isHidden = (messageTypeImageView.image == nil) - if category.hasSuffix("_TEXT") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(item.mentionedFullnameReplacedContent)" - } else { - contentLabel.text = item.mentionedFullnameReplacedContent - } - } else if category.hasSuffix("_IMAGE") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_photo())" - } else { - contentLabel.text = R.string.localizable.content_photo() - } - } else if category.hasSuffix("_STICKER") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_sticker())" - } else { - contentLabel.text = R.string.localizable.content_sticker() - } - } else if category.hasSuffix("_CONTACT") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_contact())" - } else { - contentLabel.text = R.string.localizable.content_contact() - } - } else if category.hasSuffix("_DATA") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_file())" - } else { - contentLabel.text = R.string.localizable.content_file() - } - } else if category.hasSuffix("_VIDEO") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_video())" - } else { - contentLabel.text = R.string.localizable.content_video() - } - } else if category.hasSuffix("_LIVE") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_live())" - } else { - contentLabel.text = R.string.localizable.content_live() - } - } else if category.hasSuffix("_AUDIO") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_audio())" - } else { - contentLabel.text = R.string.localizable.content_audio() - } - } else if category.hasSuffix("_POST") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(item.markdownControlCodeRemovedContent)" - } else { - contentLabel.text = item.markdownControlCodeRemovedContent - } - } else if category.hasSuffix("_LOCATION") { - if item.isGroup() { - contentLabel.text = "\(senderName): \(R.string.localizable.content_location())" - } else { - contentLabel.text = R.string.localizable.content_location() - } - } else if category.hasPrefix("WEBRTC_") { - contentLabel.text = R.string.localizable.content_voice() - } else if category == MessageCategory.SYSTEM_ACCOUNT_SNAPSHOT.rawValue { - contentLabel.text = R.string.localizable.content_transfer() - } else if category == MessageCategory.APP_BUTTON_GROUP.rawValue { - contentLabel.text = (item.appButtons?.map({ (appButton) -> String in - return "[\(appButton.label)]" - }) ?? []).joined() - } else if category == MessageCategory.APP_CARD.rawValue, let appCard = item.appCard { - contentLabel.text = "[\(appCard.title)]" - } else if category == MessageCategory.MESSAGE_RECALL.rawValue { + if category == MessageCategory.MESSAGE_RECALL.rawValue { setContentLabelFontItalic(true) - if senderIsMe { - contentLabel.text = R.string.localizable.you_deleted_this_message() - } else { - contentLabel.text = R.string.localizable.this_message_was_deleted() - } - } else if category == MessageCategory.MESSAGE_PIN.rawValue { - contentLabel.text = TransferPinAction.pinMessage(item: item) - } else if category == MessageCategory.KRAKEN_PUBLISH.rawValue { - contentLabel.text = R.string.localizable.started_group_call(senderName) - } else if category == MessageCategory.KRAKEN_CANCEL.rawValue { - contentLabel.text = R.string.localizable.chat_group_call_cancel(senderName) - } else if category == MessageCategory.KRAKEN_DECLINE.rawValue { - contentLabel.text = R.string.localizable.chat_group_call_decline(senderName) - } else if category == MessageCategory.KRAKEN_INVITE.rawValue { - contentLabel.text = R.string.localizable.chat_group_call_invite(senderName) - } else if category == MessageCategory.KRAKEN_END.rawValue { - contentLabel.text = R.string.localizable.content_group_call_ended() - } else if category.hasSuffix("_TRANSCRIPT") { - contentLabel.text = R.string.localizable.content_transcript() - } else { - if item.contentType.hasPrefix("SYSTEM_") { - contentLabel.text = SystemConversationAction.getSystemMessage(actionName: item.actionName, - userId: item.senderId, - userFullName: item.senderFullName, - participantId: item.participantUserId, - participantFullName: item.participantFullName, - content: item.content) - } else if item.messageId.isEmpty { - contentLabel.text = "" - } else { - contentLabel.text = R.string.localizable.message_not_support() - } } } + contentLabel.text = item.displayContent let hasUnreadMessage = item.unseenMessageCount > 0 let hasUnreadMention = item.unseenMentionCount > 0 diff --git a/Mixin/UserInterface/Controllers/Setting/BlockedUsersViewController.swift b/Mixin/UserInterface/Controllers/Setting/BlockedUsersViewController.swift index 2189691488..aca9764505 100644 --- a/Mixin/UserInterface/Controllers/Setting/BlockedUsersViewController.swift +++ b/Mixin/UserInterface/Controllers/Setting/BlockedUsersViewController.swift @@ -58,7 +58,7 @@ extension BlockedUsersViewController: UITableViewDelegate, UITableViewDataSource func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseId) as! BlockUserCell - cell.render(user: users[indexPath.row]) + cell.infoView.render(user: users[indexPath.row]) return cell } diff --git a/Mixin/UserInterface/Controllers/Setting/Cells/BlockUserCell.swift b/Mixin/UserInterface/Controllers/Setting/Cells/BlockUserCell.swift index e6a368f456..a2645dc3cd 100644 --- a/Mixin/UserInterface/Controllers/Setting/Cells/BlockUserCell.swift +++ b/Mixin/UserInterface/Controllers/Setting/Cells/BlockUserCell.swift @@ -3,12 +3,6 @@ import MixinServices class BlockUserCell: ModernSelectedBackgroundCell { - @IBOutlet weak var avatarImageView: AvatarImageView! - @IBOutlet weak var nameLabel: UILabel! - - func render(user: UserItem) { - avatarImageView.setImage(with: user) - nameLabel.text = user.fullName - } + @IBOutlet weak var infoView: PeerInfoView! } diff --git a/Mixin/UserInterface/Storyboard/Setting.storyboard b/Mixin/UserInterface/Storyboard/Setting.storyboard index 0f4f5ecda8..c45a1bf2fc 100644 --- a/Mixin/UserInterface/Storyboard/Setting.storyboard +++ b/Mixin/UserInterface/Storyboard/Setting.storyboard @@ -142,17 +142,17 @@ - +