Skip to content

Commit

Permalink
Tidy up to #473
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jan 20, 2023
1 parent f05fa63 commit 7092055
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.
8 changes: 4 additions & 4 deletions ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
187E18F21EF4DA244E436E58 /* BugReportViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28959C7DB36C7688A01D4045 /* BugReportViewModelProtocol.swift */; };
18E674DB2977DBD60055EA9F /* StateRoomTimelineItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E674DA2977DBD60055EA9F /* StateRoomTimelineItem.swift */; };
18E674DD2977DC2B0055EA9F /* StateRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E674DC2977DC2B0055EA9F /* StateRoomTimelineView.swift */; };
18E674DF2977DD9B0055EA9F /* RoomStateStringBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E674DE2977DD9B0055EA9F /* RoomStateStringBuilder.swift */; };
18E674DF2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E674DE2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift */; };
191161FE9E0DA89704301F37 /* Untranslated.strings in Resources */ = {isa = PBXBuildFile; fileRef = D2F7194F440375338F8E2487 /* Untranslated.strings */; };
1950A80CD198BED283DFC2CE /* ClientProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18F2958E6D247AE2516BEEE8 /* ClientProxy.swift */; };
19839F3526CE8C35AAF241AD /* ServerSelectionViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F52BF30D12BA3BD3D3DBB8F /* ServerSelectionViewModelProtocol.swift */; };
Expand Down Expand Up @@ -586,7 +586,7 @@
184CF8C196BE143AE226628D /* DecorationTimelineItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecorationTimelineItemProtocol.swift; sourceTree = "<group>"; };
18E674DA2977DBD60055EA9F /* StateRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateRoomTimelineItem.swift; sourceTree = "<group>"; };
18E674DC2977DC2B0055EA9F /* StateRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateRoomTimelineView.swift; sourceTree = "<group>"; };
18E674DE2977DD9B0055EA9F /* RoomStateStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateStringBuilder.swift; sourceTree = "<group>"; };
18E674DE2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateEventStringBuilder.swift; sourceTree = "<group>"; };
18F2958E6D247AE2516BEEE8 /* ClientProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientProxy.swift; sourceTree = "<group>"; };
18FE0CDF1FFA92EA7EE17B0B /* RoomTimelineControllerFactoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineControllerFactoryProtocol.swift; sourceTree = "<group>"; };
1941C8817E6B6971BA4415F5 /* VideoRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRoomTimelineView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1992,7 +1992,7 @@
EEE384418EB1FEDFA62C9CD0 /* RoomTimelineViewFactoryProtocol.swift */,
ACB6C5E4950B6C9842F35A38 /* RoomTimelineViewProvider.swift */,
75D1D02F7F3AC1122FCFB4F3 /* Items */,
18E674DE2977DD9B0055EA9F /* RoomStateStringBuilder.swift */,
18E674DE2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift */,
);
path = TimelineItems;
sourceTree = "<group>";
Expand Down Expand Up @@ -2977,7 +2977,7 @@
64FF5CB4E35971255872E1BB /* AuthenticationServiceProxyProtocol.swift in Sources */,
D876EC0FED3B6D46C806912A /* AvatarSize.swift in Sources */,
E0A4DCA633D174EB43AD599F /* BackgroundTaskProtocol.swift in Sources */,
18E674DF2977DD9B0055EA9F /* RoomStateStringBuilder.swift in Sources */,
18E674DF2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift in Sources */,
6D046D653DA28ADF1E6E59A4 /* BackgroundTaskServiceProtocol.swift in Sources */,
38546A6010A2CF240EC9AF73 /* BindableState.swift in Sources */,
B6DF6B6FA8734B70F9BF261E /* BlurHashDecode.swift in Sources */,
Expand Down
6 changes: 2 additions & 4 deletions ElementX/Sources/Services/Client/ClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ class ClientProxy: ClientProxyProtocol {
let visibleRoomsViewProxy = SlidingSyncViewProxy(slidingSync: slidingSync, slidingSyncView: visibleRoomsView)

visibleRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: visibleRoomsViewProxy,
eventStringBuilder: RoomEventStringBuilder(userID: userID,
roomStateStringBuilder: RoomStateStringBuilder(userID: userID)))
eventStringBuilder: RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID)))

visibleRoomsSlidingSyncView = visibleRoomsView

Expand Down Expand Up @@ -330,8 +329,7 @@ class ClientProxy: ClientProxyProtocol {
let allRoomsViewProxy = SlidingSyncViewProxy(slidingSync: slidingSync, slidingSyncView: allRoomsView)

allRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: allRoomsViewProxy,
eventStringBuilder: RoomEventStringBuilder(userID: userID,
roomStateStringBuilder: RoomStateStringBuilder(userID: userID)))
eventStringBuilder: RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID)))

allRoomsSlidingSyncView = allRoomsView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
import Foundation

struct RoomEventStringBuilder {
private let roomStateStringBuilder: RoomStateStringBuilder
private let stateEventStringBuilder: RoomStateEventStringBuilder

/// The Matrix ID of the current user.
private let userID: String

init(userID: String, roomStateStringBuilder: RoomStateStringBuilder) {
self.userID = userID
self.roomStateStringBuilder = roomStateStringBuilder
init(stateEventStringBuilder: RoomStateEventStringBuilder) {
self.stateEventStringBuilder = stateEventStringBuilder
}

// swiftlint:disable:next cyclomatic_complexity
Expand Down Expand Up @@ -62,11 +58,11 @@ struct RoomEventStringBuilder {
}
return prefix(message, with: sender)
case .state(let stateKey, let state):
return roomStateStringBuilder
return stateEventStringBuilder
.buildString(for: state, stateKey: stateKey, sender: sender, isOutgoing: isOutgoing)
.map(AttributedString.init)
case .roomMembership(userId: let userID, change: let change):
return roomStateStringBuilder
return stateEventStringBuilder
.buildString(for: change, member: userID, sender: sender, isOutgoing: isOutgoing)
.map(AttributedString.init)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import MatrixRustSDK
import UIKit

struct RoomStateStringBuilder {
struct RoomStateEventStringBuilder {
let userID: String

// swiftlint:disable:next cyclomatic_complexity function_body_length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import UIKit
struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
private let mediaProvider: MediaProviderProtocol
private let attributedStringBuilder: AttributedStringBuilderProtocol
private let roomStateStringBuilder: RoomStateStringBuilder
private let stateEventStringBuilder: RoomStateEventStringBuilder

/// The Matrix ID of the current user.
private let userID: String

init(userID: String,
mediaProvider: MediaProviderProtocol,
attributedStringBuilder: AttributedStringBuilderProtocol,
roomStateStringBuilder: RoomStateStringBuilder) {
stateEventStringBuilder: RoomStateEventStringBuilder) {
self.userID = userID
self.mediaProvider = mediaProvider
self.attributedStringBuilder = attributedStringBuilder
self.roomStateStringBuilder = roomStateStringBuilder
self.stateEventStringBuilder = stateEventStringBuilder
}

// swiftlint:disable:next cyclomatic_complexity
Expand Down Expand Up @@ -370,7 +370,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
stateKey: String,
sender: TimelineItemSender,
isOutgoing: Bool) -> RoomTimelineItemProtocol? {
guard let text = roomStateStringBuilder.buildString(for: state, stateKey: stateKey, sender: sender, isOutgoing: isOutgoing) else { return nil }
guard let text = stateEventStringBuilder.buildString(for: state, stateKey: stateKey, sender: sender, isOutgoing: isOutgoing) else { return nil }
return buildStateTimelineItem(eventItemProxy: eventItemProxy, text: text, sender: sender, isOutgoing: isOutgoing)
}

Expand All @@ -379,7 +379,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
membershipChange: MembershipChange,
sender: TimelineItemSender,
isOutgoing: Bool) -> RoomTimelineItemProtocol? {
guard let text = roomStateStringBuilder.buildString(for: membershipChange, member: member, sender: eventItemProxy.sender, isOutgoing: isOutgoing) else { return nil }
guard let text = stateEventStringBuilder.buildString(for: membershipChange, member: member, sender: eventItemProxy.sender, isOutgoing: isOutgoing) else { return nil }
return buildStateTimelineItem(eventItemProxy: eventItemProxy, text: text, sender: sender, isOutgoing: isOutgoing)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
let timelineItemFactory = RoomTimelineItemFactory(userID: userId,
mediaProvider: userSession.mediaProvider,
attributedStringBuilder: AttributedStringBuilder(),
roomStateStringBuilder: RoomStateStringBuilder(userID: userId))
stateEventStringBuilder: RoomStateEventStringBuilder(userID: userId))

let timelineController = roomTimelineControllerFactory.buildRoomTimelineController(userId: userId,
roomProxy: roomProxy,
Expand Down

0 comments on commit 7092055

Please sign in to comment.