mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
vector-im/element-x-ios/issues/53 - Various tweaks following code review
This commit is contained in:
committed by
Stefan Ceriu
parent
73f507045b
commit
8fec97217f
@@ -16,7 +16,7 @@ struct EventBriefFactory: EventBriefFactoryProtocol {
|
||||
self.memberDetailProvider = memberDetailProvider
|
||||
}
|
||||
|
||||
func eventBriefForMessage(_ message: RoomMessageProtocol?) async -> EventBrief? {
|
||||
func buildEventBriefFor(message: RoomMessageProtocol?) async -> EventBrief? {
|
||||
guard let message = message else {
|
||||
return nil
|
||||
}
|
||||
@@ -37,7 +37,7 @@ struct EventBriefFactory: EventBriefFactoryProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func buildEventBrief(message: RoomMessageProtocol, htmlBody: String?) async -> EventBrief? {
|
||||
private func buildEventBrief(message: RoomMessageProtocol, htmlBody: String?) async -> EventBrief? {
|
||||
switch await memberDetailProvider.loadDisplayNameForUserId(message.sender) {
|
||||
case .success(let displayName):
|
||||
return EventBrief(eventId: message.id,
|
||||
|
||||
@@ -10,5 +10,5 @@ import Foundation
|
||||
|
||||
@MainActor
|
||||
protocol EventBriefFactoryProtocol {
|
||||
func eventBriefForMessage(_ message: RoomMessageProtocol?) async -> EventBrief?
|
||||
func buildEventBriefFor(message: RoomMessageProtocol?) async -> EventBrief?
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ struct MockRoomSummary: RoomSummaryProtocol {
|
||||
|
||||
var avatar: UIImage?
|
||||
|
||||
func loadDetails() {
|
||||
func loadDetails() async {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -48,19 +48,19 @@ class RoomSummary: RoomSummaryProtocol {
|
||||
|
||||
private(set) var displayName: String? {
|
||||
didSet {
|
||||
self.callbacks.send(.updatedData)
|
||||
callbacks.send(.updatedData)
|
||||
}
|
||||
}
|
||||
|
||||
private(set) var lastMessage: EventBrief? {
|
||||
didSet {
|
||||
self.callbacks.send(.updatedData)
|
||||
callbacks.send(.updatedData)
|
||||
}
|
||||
}
|
||||
|
||||
private(set) var avatar: UIImage? {
|
||||
didSet {
|
||||
self.callbacks.send(.updatedData)
|
||||
callbacks.send(.updatedData)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class RoomSummary: RoomSummaryProtocol {
|
||||
self.eventBriefFactory = eventBriefFactory
|
||||
|
||||
Task {
|
||||
lastMessage = await eventBriefFactory.eventBriefForMessage(roomProxy.messages.last)
|
||||
lastMessage = await eventBriefFactory.buildEventBriefFor(message: roomProxy.messages.last)
|
||||
}
|
||||
|
||||
roomProxy.callbacks
|
||||
@@ -85,7 +85,7 @@ class RoomSummary: RoomSummaryProtocol {
|
||||
switch callback {
|
||||
case .updatedMessages:
|
||||
Task {
|
||||
self.lastMessage = await eventBriefFactory.eventBriefForMessage(roomProxy.messages.last)
|
||||
self.lastMessage = await eventBriefFactory.buildEventBriefFor(message: roomProxy.messages.last)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,13 +98,13 @@ class RoomSummary: RoomSummaryProtocol {
|
||||
}
|
||||
|
||||
await withTaskGroup(of: Void.self) { group in
|
||||
group.addTask(priority: .medium) {
|
||||
group.addTask {
|
||||
await self.loadDisplayName()
|
||||
}
|
||||
group.addTask(priority: .medium) {
|
||||
group.addTask {
|
||||
await self.loadAvatar()
|
||||
}
|
||||
group.addTask(priority: .medium) {
|
||||
group.addTask {
|
||||
await self.loadLastMessage()
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class RoomSummary: RoomSummaryProtocol {
|
||||
|
||||
switch await roomProxy.paginateBackwards(count: 1) {
|
||||
case .success:
|
||||
lastMessage = await eventBriefFactory.eventBriefForMessage(roomProxy.messages.last)
|
||||
lastMessage = await eventBriefFactory.buildEventBriefFor(message: roomProxy.messages.last)
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed back paginating with error: \(error)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user