Skip to content

Commit 01e69e8

Browse files
authored
Merge pull request #55 from zjc19891106/main
HIM-18142
2 parents d317773 + 4d31dd0 commit 01e69e8

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

Example/EaseChatUIKit.xcodeproj/xcuserdata/zhujichao1.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>EaseChatUIKit_Example.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>4</integer>
10+
<integer>5</integer>
1111
</dict>
1212
</dict>
1313
</dict>

Sources/EaseChatUIKit/Classes/UI/Components/Contact/Controllers/NewContactRequestController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ import UIKit
5757
}
5858

5959
@objc open func requestProfiles() {
60+
var userIds = [String]()
61+
for user in self.datas {
62+
if let userCache = ChatUIKitContext.shared?.userCache?[user.userId],!userCache.nickname.isEmpty {
63+
continue
64+
}
65+
userIds.append(user.userId)
66+
}
6067
if ChatUIKitContext.shared?.userProfileProvider != nil {
61-
let userIds = self.datas.map { $0.userId }
6268
Task(priority: .background) {
6369
let profiles = await ChatUIKitContext.shared?.userProfileProvider?.fetchProfiles(profileIds: userIds) ?? []
6470
for profile in profiles {
@@ -73,7 +79,7 @@ import UIKit
7379
}
7480
} else {
7581
if ChatUIKitContext.shared?.userProfileProviderOC != nil {
76-
ChatUIKitContext.shared?.userProfileProviderOC?.fetchProfiles(profileIds: self.datas.map { $0.userId }, completion: { [weak self] profiles in
82+
ChatUIKitContext.shared?.userProfileProviderOC?.fetchProfiles(profileIds: userIds, completion: { [weak self] profiles in
7783
for profile in profiles {
7884
if let info = self?.datas.first(where: { $0.userId == profile.id }) {
7985
info.nickname = profile.nickname

Sources/EaseChatUIKit/Classes/UI/Components/Contact/Views/ContactView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ extension ContactView: UITableViewDelegate,UITableViewDataSource {
215215
}
216216

217217
public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
218-
218+
if !self.firstRefresh {
219+
self.requestDisplayInfo()
220+
}
219221
}
220222

221223
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
@@ -337,8 +339,14 @@ extension ContactView: IContactListDriver {
337339

338340
if self.firstRefresh {
339341
self.firstRefresh = false
342+
var unknownInfoIds = [String]()
343+
for info in infos {
344+
if info.nickname.isEmpty || info.avatarURL.isEmpty {
345+
unknownInfoIds.append(info.id)
346+
}
347+
}
340348
for eventHandle in self.eventsDelegates.allObjects {
341-
eventHandle.onContactListEndScrollNeededDisplayInfos(ids: infos.map({ $0.id }))
349+
eventHandle.onContactListEndScrollNeededDisplayInfos(ids: unknownInfoIds)
342350
}
343351
}
344352
let tuple = ContactSorter.sort(contacts: self.rawData)

Sources/EaseChatUIKit/Classes/UI/Components/Conversation/ViewModel/ConversationViewModel.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,14 @@ extension ConversationViewModel: ConversationListActionEventsDelegate {
152152
for id in ids {
153153
if let conversation = ChatClient.shared().chatManager?.getConversationWithConvId(id) {
154154
if conversation.type == .chat {
155+
if let userCache = ChatUIKitContext.shared?.userCache?[id],!userCache.nickname.isEmpty {
156+
continue
157+
}
155158
privateChats.append(id)
156159
} else {
160+
if let groupCache = ChatUIKitContext.shared?.groupCache?[id],!groupCache.nickname.isEmpty {
161+
continue
162+
}
157163
groupChats.append(id)
158164
}
159165
}
@@ -438,7 +444,7 @@ extension ConversationViewModel: ConversationServiceListener {
438444
self.driver?.refreshList(infos: items)
439445

440446
if infos.count < 11 || self.firstLoadConversation {
441-
let requestCount = items.count < 11 ? (items.count - 1):10
447+
let requestCount = items.count < 11 ? items.count:10
442448
if requestCount > 0 {
443449
self.requestDisplayProfiles(ids: items.prefix(upTo: requestCount).map({ $0.id }))
444450
self.firstLoadConversation = false

0 commit comments

Comments
 (0)