From 70920550e7294c85bf08473da42f8fa7bc5c8f29 Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 20 Jan 2023 14:09:59 +0000 Subject: [PATCH] Tidy up to #473 --- ElementX.xcodeproj/project.pbxproj | 8 ++++---- ElementX/Sources/Services/Client/ClientProxy.swift | 6 ++---- .../Room/RoomSummary/RoomEventStringBuilder.swift | 14 +++++--------- ...der.swift => RoomStateEventStringBuilder.swift} | 2 +- .../TimelineItems/RoomTimelineItemFactory.swift | 10 +++++----- .../UserSession/UserSessionFlowCoordinator.swift | 2 +- 6 files changed, 18 insertions(+), 24 deletions(-) rename ElementX/Sources/Services/Timeline/TimelineItems/{RoomStateStringBuilder.swift => RoomStateEventStringBuilder.swift} (99%) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index c20bcda3eb..0afa1d6adc 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -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 */; }; @@ -586,7 +586,7 @@ 184CF8C196BE143AE226628D /* DecorationTimelineItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecorationTimelineItemProtocol.swift; sourceTree = ""; }; 18E674DA2977DBD60055EA9F /* StateRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateRoomTimelineItem.swift; sourceTree = ""; }; 18E674DC2977DC2B0055EA9F /* StateRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateRoomTimelineView.swift; sourceTree = ""; }; - 18E674DE2977DD9B0055EA9F /* RoomStateStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateStringBuilder.swift; sourceTree = ""; }; + 18E674DE2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateEventStringBuilder.swift; sourceTree = ""; }; 18F2958E6D247AE2516BEEE8 /* ClientProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientProxy.swift; sourceTree = ""; }; 18FE0CDF1FFA92EA7EE17B0B /* RoomTimelineControllerFactoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineControllerFactoryProtocol.swift; sourceTree = ""; }; 1941C8817E6B6971BA4415F5 /* VideoRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRoomTimelineView.swift; sourceTree = ""; }; @@ -1992,7 +1992,7 @@ EEE384418EB1FEDFA62C9CD0 /* RoomTimelineViewFactoryProtocol.swift */, ACB6C5E4950B6C9842F35A38 /* RoomTimelineViewProvider.swift */, 75D1D02F7F3AC1122FCFB4F3 /* Items */, - 18E674DE2977DD9B0055EA9F /* RoomStateStringBuilder.swift */, + 18E674DE2977DD9B0055EA9F /* RoomStateEventStringBuilder.swift */, ); path = TimelineItems; sourceTree = ""; @@ -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 */, diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 8baee58beb..40edd1c879 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -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 @@ -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 diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift index 193bc2394c..d42ce84719 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift @@ -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 @@ -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) } diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateStringBuilder.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift similarity index 99% rename from ElementX/Sources/Services/Timeline/TimelineItems/RoomStateStringBuilder.swift rename to ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift index 7e40c36ea7..cce6f38867 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateStringBuilder.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift @@ -17,7 +17,7 @@ import MatrixRustSDK import UIKit -struct RoomStateStringBuilder { +struct RoomStateEventStringBuilder { let userID: String // swiftlint:disable:next cyclomatic_complexity function_body_length diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift index 016cf3ba64..b3bbd22d5a 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift @@ -20,7 +20,7 @@ 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 @@ -28,11 +28,11 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { 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 @@ -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) } @@ -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) } diff --git a/ElementX/Sources/Services/UserSession/UserSessionFlowCoordinator.swift b/ElementX/Sources/Services/UserSession/UserSessionFlowCoordinator.swift index 98696110b4..f79acedcdf 100644 --- a/ElementX/Sources/Services/UserSession/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/Services/UserSession/UserSessionFlowCoordinator.swift @@ -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,