Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Mixin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -1635,6 +1636,7 @@
7C695D55285B25AB0042177C /* SpotlightManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpotlightManager.swift; sourceTree = "<group>"; };
7C6AD1F426A6794F00E6C41D /* StickersStoreViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickersStoreViewController.swift; sourceTree = "<group>"; };
7C7635B726A13461006101DB /* HomeAppsConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeAppsConstants.swift; sourceTree = "<group>"; };
7C7A865328E6E81600D6A4FA /* ConversationItem+DisplayContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConversationItem+DisplayContent.swift"; sourceTree = "<group>"; };
7C8CC5A2280D347A00F7CBDF /* PreviewWallpaperViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewWallpaperViewController.swift; sourceTree = "<group>"; };
7C8CC5A6280D40E900F7CBDF /* PreviewWallpaperCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewWallpaperCell.swift; sourceTree = "<group>"; };
7C8FA78C27687D1500855AFD /* DeleteAccountSettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteAccountSettingViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -2249,6 +2251,7 @@
94D63DD52646C29100FD7EE8 /* MessageViewModelFactory.swift */,
7CC7304F2745F95D002780F5 /* StickerStore.swift */,
7CF7416D27DAD93000DA0004 /* SnapCenterFlowLayout.swift */,
7C7A865328E6E81600D6A4FA /* ConversationItem+DisplayContent.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
3 changes: 2 additions & 1 deletion Mixin/Service/Storage/CircleMember+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ extension CircleMember {
iconUrl: isGroup ? conversation.iconUrl : conversation.ownerAvatarUrl,
identityNumber: conversation.ownerIdentityNumber,
phoneNumber: nil,
badgeImage: nil)
badgeImage: nil,
conversationContent: conversation.displayContent)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ConversationSearchResult: SearchResult {
textAttributes: SearchResult.titleAttributes,
keyword: keyword,
keywordAttributes: SearchResult.highlightedTitleAttributes)
description = SearchResult.description(conversationContent: conversation.displayContent)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
9 changes: 7 additions & 2 deletions Mixin/Service/Storage/Search Result/SearchResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
4 changes: 3 additions & 1 deletion Mixin/Service/Storage/Search Result/UserSearchResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -30,13 +31,15 @@ class MessageReceiver {
return nil
}
conversationId = conversation.conversationId
conversationContent = conversation.displayContent
}

init(user: UserItem) {
name = user.fullName
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 {
Expand Down
25 changes: 16 additions & 9 deletions Mixin/UserInterface/Controllers/Common/Views/PeerInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Loading