Removing dead code part 2 (#2235)

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Mauro
2023-12-15 20:16:16 +01:00
committed by GitHub
parent 2f88d39789
commit 123164f398
91 changed files with 64 additions and 694 deletions
@@ -144,7 +144,7 @@ final class AppSettings {
/// Any pre-defined static client registrations for OIDC issuers.
let oidcStaticRegistrations: [URL: String] = ["https://id.thirdroom.io/realms/thirdroom": "elementx"]
/// The redirect URL used for OIDC.
let oidcRedirectURL: URL = "io.element:/callback"
let oidcRedirectURL = URL(string: "\(InfoPlistReader.main.appScheme):/callback")!
/// The date that the call to `/login` completed successfully. This is used to put
/// a hard wall on the history of encrypted messages until we have key backup.
@@ -22,8 +22,6 @@ import SwiftUI
class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomStringConvertible {
fileprivate let placeholderModule: NavigationModule
private var cancellables = Set<AnyCancellable>()
var sidebarStackModuleCancellable: AnyCancellable?
@Published fileprivate var sidebarModule: NavigationModule? {
@@ -111,6 +109,7 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
}
}
// periphery:ignore - might be useful to have
/// The currently displayed fullscreen cover coordinator
var fullScreenCoverCoordinator: (any CoordinatorProtocol)? {
fullScreenCoverModule?.coordinator
@@ -502,6 +501,7 @@ class NavigationStackCoordinator: ObservableObject, CoordinatorProtocol, CustomS
}
}
// periphery:ignore - might be useful to have
// The currently presented fullscreen cover coordinator
// Fullscreen covers will be presented through the NavigationSplitCoordinator if provided
var fullScreenCoverCoordinator: (any CoordinatorProtocol)? {
@@ -636,6 +636,7 @@ class NavigationStackCoordinator: ObservableObject, CoordinatorProtocol, CustomS
}
}
// periphery:ignore - might be useful to have
/// Present a fullscreen cover on top of the stack. If this NavigationStackCoordinator is embedded within a NavigationSplitCoordinator
/// then the presentation will be proxied to the split
/// - Parameters:
@@ -49,6 +49,7 @@ class NavigationRootCoordinator: ObservableObject, CoordinatorProtocol, CustomSt
}
}
// periphery:ignore - might be useful to have
// The currently presented sheet coordinator
// Sheets will be presented through the NavigationSplitCoordinator if provided
var sheetCoordinator: (any CoordinatorProtocol)? {
@@ -254,7 +254,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
break
case (.notificationSettings, .presentGlobalNotificationSettingsScreen, .globalNotificationSettings):
presentGlobalNotificationSettingsScreen(animated: animated)
presentGlobalNotificationSettingsScreen()
case (.globalNotificationSettings, .dismissGlobalNotificationSettingsScreen, .notificationSettings):
break
@@ -981,7 +981,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
}
private func presentGlobalNotificationSettingsScreen(animated: Bool) {
private func presentGlobalNotificationSettingsScreen() {
let navigationCoordinator = NavigationStackCoordinator()
let parameters = NotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: navigationCoordinator,
userSession: userSession,
@@ -813,27 +813,6 @@ class KeychainControllerMock: KeychainControllerProtocol {
setRestorationTokenForUsernameReceivedInvocations.append((restorationToken: restorationToken, forUsername: forUsername))
setRestorationTokenForUsernameClosure?(restorationToken, forUsername)
}
//MARK: - restorationTokenForUsername
var restorationTokenForUsernameCallsCount = 0
var restorationTokenForUsernameCalled: Bool {
return restorationTokenForUsernameCallsCount > 0
}
var restorationTokenForUsernameReceivedUsername: String?
var restorationTokenForUsernameReceivedInvocations: [String] = []
var restorationTokenForUsernameReturnValue: RestorationToken?
var restorationTokenForUsernameClosure: ((String) -> RestorationToken?)?
func restorationTokenForUsername(_ username: String) -> RestorationToken? {
restorationTokenForUsernameCallsCount += 1
restorationTokenForUsernameReceivedUsername = username
restorationTokenForUsernameReceivedInvocations.append(username)
if let restorationTokenForUsernameClosure = restorationTokenForUsernameClosure {
return restorationTokenForUsernameClosure(username)
} else {
return restorationTokenForUsernameReturnValue
}
}
//MARK: - restorationTokens
var restorationTokensCallsCount = 0
@@ -879,18 +858,6 @@ class KeychainControllerMock: KeychainControllerProtocol {
removeAllRestorationTokensCallsCount += 1
removeAllRestorationTokensClosure?()
}
//MARK: - resetSecrets
var resetSecretsCallsCount = 0
var resetSecretsCalled: Bool {
return resetSecretsCallsCount > 0
}
var resetSecretsClosure: (() -> Void)?
func resetSecrets() {
resetSecretsCallsCount += 1
resetSecretsClosure?()
}
//MARK: - containsPINCode
var containsPINCodeThrowableError: Error?
@@ -1227,16 +1194,6 @@ class NetworkMonitorMock: NetworkMonitorProtocol {
set(value) { underlyingReachabilityPublisher = value }
}
var underlyingReachabilityPublisher: CurrentValuePublisher<NetworkMonitorReachability, Never>!
var isCurrentConnectionExpensive: Bool {
get { return underlyingIsCurrentConnectionExpensive }
set(value) { underlyingIsCurrentConnectionExpensive = value }
}
var underlyingIsCurrentConnectionExpensive: Bool!
var isCurrentConnectionConstrained: Bool {
get { return underlyingIsCurrentConnectionConstrained }
set(value) { underlyingIsCurrentConnectionConstrained = value }
}
var underlyingIsCurrentConnectionConstrained: Bool!
}
class NotificationCenterMock: NotificationCenterProtocol {
@@ -1493,23 +1450,6 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
restoreDefaultNotificationModeRoomIdReceivedInvocations.append(roomId)
try await restoreDefaultNotificationModeRoomIdClosure?(roomId)
}
//MARK: - containsKeywordsRules
var containsKeywordsRulesCallsCount = 0
var containsKeywordsRulesCalled: Bool {
return containsKeywordsRulesCallsCount > 0
}
var containsKeywordsRulesReturnValue: Bool!
var containsKeywordsRulesClosure: (() async -> Bool)?
func containsKeywordsRules() async -> Bool {
containsKeywordsRulesCallsCount += 1
if let containsKeywordsRulesClosure = containsKeywordsRulesClosure {
return await containsKeywordsRulesClosure()
} else {
return containsKeywordsRulesReturnValue
}
}
//MARK: - unmuteRoom
var unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError: Error?
@@ -1571,47 +1511,6 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
setRoomMentionEnabledEnabledReceivedInvocations.append(enabled)
try await setRoomMentionEnabledEnabledClosure?(enabled)
}
//MARK: - isUserMentionEnabled
var isUserMentionEnabledThrowableError: Error?
var isUserMentionEnabledCallsCount = 0
var isUserMentionEnabledCalled: Bool {
return isUserMentionEnabledCallsCount > 0
}
var isUserMentionEnabledReturnValue: Bool!
var isUserMentionEnabledClosure: (() async throws -> Bool)?
func isUserMentionEnabled() async throws -> Bool {
if let error = isUserMentionEnabledThrowableError {
throw error
}
isUserMentionEnabledCallsCount += 1
if let isUserMentionEnabledClosure = isUserMentionEnabledClosure {
return try await isUserMentionEnabledClosure()
} else {
return isUserMentionEnabledReturnValue
}
}
//MARK: - setUserMentionEnabled
var setUserMentionEnabledEnabledThrowableError: Error?
var setUserMentionEnabledEnabledCallsCount = 0
var setUserMentionEnabledEnabledCalled: Bool {
return setUserMentionEnabledEnabledCallsCount > 0
}
var setUserMentionEnabledEnabledReceivedEnabled: Bool?
var setUserMentionEnabledEnabledReceivedInvocations: [Bool] = []
var setUserMentionEnabledEnabledClosure: ((Bool) async throws -> Void)?
func setUserMentionEnabled(enabled: Bool) async throws {
if let error = setUserMentionEnabledEnabledThrowableError {
throw error
}
setUserMentionEnabledEnabledCallsCount += 1
setUserMentionEnabledEnabledReceivedEnabled = enabled
setUserMentionEnabledEnabledReceivedInvocations.append(enabled)
try await setUserMentionEnabledEnabledClosure?(enabled)
}
//MARK: - isCallEnabled
var isCallEnabledThrowableError: Error?
@@ -1746,21 +1645,6 @@ class RoomMemberProxyMock: RoomMemberProxyProtocol {
set(value) { underlyingMembership = value }
}
var underlyingMembership: MembershipState!
var isNameAmbiguous: Bool {
get { return underlyingIsNameAmbiguous }
set(value) { underlyingIsNameAmbiguous = value }
}
var underlyingIsNameAmbiguous: Bool!
var powerLevel: Int {
get { return underlyingPowerLevel }
set(value) { underlyingPowerLevel = value }
}
var underlyingPowerLevel: Int!
var normalizedPowerLevel: Int {
get { return underlyingNormalizedPowerLevel }
set(value) { underlyingNormalizedPowerLevel = value }
}
var underlyingNormalizedPowerLevel: Int!
var isAccountOwner: Bool {
get { return underlyingIsAccountOwner }
set(value) { underlyingIsAccountOwner = value }
@@ -1872,11 +1756,6 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingIsEncrypted = value }
}
var underlyingIsEncrypted: Bool!
var isTombstoned: Bool {
get { return underlyingIsTombstoned }
set(value) { underlyingIsTombstoned = value }
}
var underlyingIsTombstoned: Bool!
var membership: Membership {
get { return underlyingMembership }
set(value) { underlyingMembership = value }
@@ -1888,7 +1767,6 @@ class RoomProxyMock: RoomProxyProtocol {
}
var underlyingHasOngoingCall: Bool!
var canonicalAlias: String?
var alternativeAliases: [String] = []
var hasUnreadNotifications: Bool {
get { return underlyingHasUnreadNotifications }
set(value) { underlyingHasUnreadNotifications = value }
@@ -1908,11 +1786,6 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingMembers = value }
}
var underlyingMembers: CurrentValuePublisher<[RoomMemberProxyProtocol], Never>!
var invitedMembersCount: Int {
get { return underlyingInvitedMembersCount }
set(value) { underlyingInvitedMembersCount = value }
}
var underlyingInvitedMembersCount: Int!
var joinedMembersCount: Int {
get { return underlyingJoinedMembersCount }
set(value) { underlyingJoinedMembersCount = value }
@@ -1933,11 +1806,6 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingTimeline = value }
}
var underlyingTimeline: TimelineProxyProtocol!
var pollHistoryTimeline: TimelineProxyProtocol {
get { return underlyingPollHistoryTimeline }
set(value) { underlyingPollHistoryTimeline = value }
}
var underlyingPollHistoryTimeline: TimelineProxyProtocol!
//MARK: - subscribeForUpdates
@@ -1951,48 +1819,6 @@ class RoomProxyMock: RoomProxyProtocol {
subscribeForUpdatesCallsCount += 1
await subscribeForUpdatesClosure?()
}
//MARK: - loadAvatarURLForUserId
var loadAvatarURLForUserIdCallsCount = 0
var loadAvatarURLForUserIdCalled: Bool {
return loadAvatarURLForUserIdCallsCount > 0
}
var loadAvatarURLForUserIdReceivedUserId: String?
var loadAvatarURLForUserIdReceivedInvocations: [String] = []
var loadAvatarURLForUserIdReturnValue: Result<URL?, RoomProxyError>!
var loadAvatarURLForUserIdClosure: ((String) async -> Result<URL?, RoomProxyError>)?
func loadAvatarURLForUserId(_ userId: String) async -> Result<URL?, RoomProxyError> {
loadAvatarURLForUserIdCallsCount += 1
loadAvatarURLForUserIdReceivedUserId = userId
loadAvatarURLForUserIdReceivedInvocations.append(userId)
if let loadAvatarURLForUserIdClosure = loadAvatarURLForUserIdClosure {
return await loadAvatarURLForUserIdClosure(userId)
} else {
return loadAvatarURLForUserIdReturnValue
}
}
//MARK: - loadDisplayNameForUserId
var loadDisplayNameForUserIdCallsCount = 0
var loadDisplayNameForUserIdCalled: Bool {
return loadDisplayNameForUserIdCallsCount > 0
}
var loadDisplayNameForUserIdReceivedUserId: String?
var loadDisplayNameForUserIdReceivedInvocations: [String] = []
var loadDisplayNameForUserIdReturnValue: Result<String?, RoomProxyError>!
var loadDisplayNameForUserIdClosure: ((String) async -> Result<String?, RoomProxyError>)?
func loadDisplayNameForUserId(_ userId: String) async -> Result<String?, RoomProxyError> {
loadDisplayNameForUserIdCallsCount += 1
loadDisplayNameForUserIdReceivedUserId = userId
loadDisplayNameForUserIdReceivedInvocations.append(userId)
if let loadDisplayNameForUserIdClosure = loadDisplayNameForUserIdClosure {
return await loadDisplayNameForUserIdClosure(userId)
} else {
return loadDisplayNameForUserIdReturnValue
}
}
//MARK: - redact
var redactCallsCount = 0
@@ -2106,23 +1932,6 @@ class RoomProxyMock: RoomProxyProtocol {
return getMemberUserIDReturnValue
}
}
//MARK: - inviter
var inviterCallsCount = 0
var inviterCalled: Bool {
return inviterCallsCount > 0
}
var inviterReturnValue: RoomMemberProxyProtocol?
var inviterClosure: (() async -> RoomMemberProxyProtocol?)?
func inviter() async -> RoomMemberProxyProtocol? {
inviterCallsCount += 1
if let inviterClosure = inviterClosure {
return await inviterClosure()
} else {
return inviterReturnValue
}
}
//MARK: - rejectInvitation
var rejectInvitationCallsCount = 0
@@ -22,9 +22,6 @@ struct RoomMemberProxyMockConfiguration {
var displayName: String
var avatarURL: URL?
var membership: MembershipState
var isNameAmbiguous = false
var powerLevel = 50
var normalizedPowerLevel = 50
var isAccountOwner = false
var isIgnored = false
var canInviteUsers = false
@@ -38,9 +35,6 @@ extension RoomMemberProxyMock {
displayName = configuration.displayName
avatarURL = configuration.avatarURL
membership = configuration.membership
isNameAmbiguous = configuration.isNameAmbiguous
powerLevel = configuration.powerLevel
normalizedPowerLevel = configuration.normalizedPowerLevel
isAccountOwner = configuration.isAccountOwner
isIgnored = configuration.isIgnored
canInviteUsers = configuration.canInviteUsers
@@ -27,7 +27,6 @@ struct RoomProxyMockConfiguration {
var isSpace = Bool.random()
var isPublic = Bool.random()
var isEncrypted = true
var isTombstoned = Bool.random()
var hasOngoingCall = false
var canonicalAlias: String?
var alternativeAliases: [String] = []
@@ -40,7 +39,6 @@ struct RoomProxyMockConfiguration {
}()
var members: [RoomMemberProxyProtocol]?
var inviter: RoomMemberProxyMock?
var memberForID: RoomMemberProxyMock = .mockMe
var ownUserID = "@alice:somewhere.org"
@@ -65,15 +63,12 @@ extension RoomProxyMock {
isSpace = configuration.isSpace
isPublic = configuration.isPublic
isEncrypted = configuration.isEncrypted
isTombstoned = configuration.isTombstoned
hasOngoingCall = configuration.hasOngoingCall
canonicalAlias = configuration.canonicalAlias
alternativeAliases = configuration.alternativeAliases
hasUnreadNotifications = configuration.hasUnreadNotifications
timeline = configuration.timeline
invitedMembersCount = configuration.invitedMembersCount
joinedMembersCount = configuration.joinedMembersCount
activeMembersCount = configuration.activeMembersCount
ownUserID = configuration.ownUserID
@@ -83,10 +78,6 @@ extension RoomProxyMock {
} else {
members = CurrentValueSubject([]).asCurrentValuePublisher()
}
if let inviter = configuration.inviter {
inviterClosure = { inviter }
}
updateMembersClosure = { }
acceptInvitationClosure = { .success(()) }
@@ -95,6 +95,7 @@ extension AlertInfo {
message = L10n.errorUnknown
}
// periphery: ignore - might be useful in the future
/// Initialises the type with the title from an `Error`'s localised description along with the default Ok button.
///
/// Currently this initialiser creates an alert for every error, however in the future it may be updated to filter
@@ -1,22 +0,0 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
extension Image {
/// Empty image view
static let empty = Image(uiImage: .init(ciImage: .empty()))
}
@@ -18,23 +18,11 @@ import Foundation
/// NSRegularExpressions work internally on NSStrings, we need to be careful how we build the ranges for extended grapheme clusters https://stackoverflow.com/a/27880748/730924
extension NSRegularExpression {
func enumerateMatches(in string: String, options: NSRegularExpression.MatchingOptions = [], using block: (NSTextCheckingResult?, NSRegularExpression.MatchingFlags, UnsafeMutablePointer<ObjCBool>) -> Void) {
enumerateMatches(in: string, options: options, range: .init(location: 0, length: (string as NSString).length), using: block)
}
func matches(in string: String, options: NSRegularExpression.MatchingOptions = []) -> [NSTextCheckingResult] {
matches(in: string, options: options, range: .init(location: 0, length: (string as NSString).length))
}
func numberOfMatches(in string: String, options: NSRegularExpression.MatchingOptions = []) -> Int {
numberOfMatches(in: string, options: options, range: .init(location: 0, length: (string as NSString).length))
}
func firstMatch(in string: String, options: NSRegularExpression.MatchingOptions = []) -> NSTextCheckingResult? {
firstMatch(in: string, options: options, range: .init(location: 0, length: (string as NSString).length))
}
func rangeOfFirstMatch(in string: String, options: NSRegularExpression.MatchingOptions = []) -> NSRange {
rangeOfFirstMatch(in: string, options: options, range: .init(location: 0, length: (string as NSString).length))
}
}
@@ -41,9 +41,3 @@ extension PlatformViewVersionPredicate<ViewControllerType, UIViewController> {
.iOS(.v16, .v17)
}
}
extension PlatformViewVersionPredicate<NavigationStackType, UINavigationController> {
static var supportedVersions: Self {
.iOS(.v16, .v17)
}
}
@@ -160,6 +160,7 @@ enum MXLog {
// MARK: - Private
// periphery:ignore:parameters function,column
private static func createSpan(_ name: String,
level: LogLevel,
file: String = #file,
@@ -177,6 +178,7 @@ enum MXLog {
return Span(file: file, line: UInt32(line), level: level, target: target, name: name)
}
// periphery:ignore:parameters function,column,context
private static func log(_ message: Any,
level: LogLevel,
file: String = #file,
@@ -230,15 +230,6 @@ extension MapLibreMapView {
// MARK: - MGLMapView convenient methods
private extension MGLMapView {
func removeAllAnnotations() {
guard let annotations else {
return
}
removeAnnotations(annotations)
}
}
private extension MapTilerStyle {
init(_ colorScheme: ColorScheme) {
switch colorScheme {
@@ -1,27 +0,0 @@
//
// Copyright 2023 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import CoreLocation
import Foundation
enum MapTilerGeocodingError: Error {
case wrongGeocodingURL
case geocodingFailed
}
protocol MapTilerGeoCodingServiceProtocol {
func reverseGeoCoding(for coordinate: CLLocationCoordinate2D) async -> Result<String, MapTilerGeocodingError>
}
@@ -27,14 +27,6 @@ class NetworkMonitor: NetworkMonitorProtocol {
reachabilitySubject.asCurrentValuePublisher()
}
var isCurrentConnectionExpensive: Bool {
pathMonitor.currentPath.isExpensive
}
var isCurrentConnectionConstrained: Bool {
pathMonitor.currentPath.isConstrained
}
init() {
queue = DispatchQueue(label: "io.element.elementx.networkmonitor", qos: .background)
pathMonitor = NWPathMonitor()
@@ -23,8 +23,6 @@ enum NetworkMonitorReachability {
protocol NetworkMonitorProtocol {
var reachabilityPublisher: CurrentValuePublisher<NetworkMonitorReachability, Never> { get }
var isCurrentConnectionExpensive: Bool { get }
var isCurrentConnectionConstrained: Bool { get }
}
// sourcery: AutoMockable
@@ -80,10 +80,13 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider {
// Fixes crashes when inserting mention pills in the composer on Mac
// https://github.com/element-hq/element-x-ios/issues/2070
// periphery:ignore - read comment above
static var supportsSecureCoding = false
// periphery:ignore - read comment above
func encode(with coder: NSCoder) { }
// periphery:ignore - read comment above
init?(coder: NSCoder) {
fatalError("Not implemented")
}
@@ -77,8 +77,6 @@ struct LoadableImage<TransformerView: View, PlaceholderView: View>: View {
private struct LoadableImageContent<TransformerView: View, PlaceholderView: View>: View, ImageDataProvider {
private let mediaSource: MediaSourceProxy
private let blurhash: String?
private let size: CGSize?
private let imageProvider: ImageProviderProtocol?
private let transformer: (AnyView) -> TransformerView
private let placeholder: () -> PlaceholderView
@@ -92,8 +90,6 @@ private struct LoadableImageContent<TransformerView: View, PlaceholderView: View
placeholder: @escaping () -> PlaceholderView) {
self.mediaSource = mediaSource
self.blurhash = blurhash
self.size = size
self.imageProvider = imageProvider
self.transformer = transformer
self.placeholder = placeholder
_contentLoader = StateObject(wrappedValue: ContentLoader(mediaSource: mediaSource, size: size, imageProvider: imageProvider))
@@ -18,8 +18,6 @@ import Compound
import SwiftUI
struct LocationMarkerView: View {
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
var mode: Mode = .map
enum Mode { case map, button }
@@ -58,7 +58,7 @@ private struct PINTextFieldStyle: TextFieldStyle {
let pinCode: String
let isSecure: Bool
public func _body(configuration: TextField<_Label>) -> some View {
func _body(configuration: TextField<_Label>) -> some View {
HStack(spacing: 8) {
ForEach(0..<4) { index in
PINDigitField(digit: digit(index))
@@ -35,22 +35,4 @@ enum LoginMode: Equatable {
return false
}
}
var supportsPasswordFlow: Bool {
switch self {
case .password:
return true
default:
return false
}
}
var isUnsupported: Bool {
switch self {
case .unsupported:
return true
default:
return false
}
}
}
@@ -37,9 +37,7 @@ enum LoginScreenCoordinatorAction {
final class LoginScreenCoordinator: CoordinatorProtocol {
private let parameters: LoginScreenCoordinatorParameters
private var viewModel: LoginScreenViewModelProtocol
@CancellableTask private var currentTask: Task<Void, Error>?
private var authenticationService: AuthenticationServiceProxyProtocol { parameters.authenticationService }
private let actionsSubject: PassthroughSubject<LoginScreenCoordinatorAction, Never> = .init()
@@ -203,7 +203,6 @@ struct MessageComposer_Previews: PreviewProvider, TestablePreview {
]
static func messageComposer(_ content: String = "",
sendingDisabled: Bool = false,
mode: RoomScreenComposerMode = .default) -> MessageComposer {
let viewModel = WysiwygComposerViewModel(minHeight: 22,
maxExpandedHeight: 250)
@@ -228,7 +227,7 @@ struct MessageComposer_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
VStack(spacing: 8) {
messageComposer(sendingDisabled: true)
messageComposer()
messageComposer("Some message",
mode: .edit(originalItemId: .random))
@@ -28,7 +28,6 @@ enum PollFormScreenCoordinatorAction {
}
final class PollFormScreenCoordinator: CoordinatorProtocol {
private let parameters: PollFormScreenCoordinatorParameters
private var viewModel: PollFormScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<PollFormScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -38,8 +37,6 @@ final class PollFormScreenCoordinator: CoordinatorProtocol {
}
init(parameters: PollFormScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = PollFormScreenViewModel(mode: parameters.mode)
}
@@ -68,7 +68,6 @@ private struct MediaPreviewViewController: UIViewControllerRepresentable {
class PreviewHostingController: UIViewController, QLPreviewControllerDataSource, QLPreviewControllerDelegate {
let previewItem: MediaPreviewItem
let shouldHideControls: Bool
let dismissalPublisher: PassthroughSubject<Void, Never>
let onDismiss: () -> Void
private var dismissalObserver: AnyCancellable?
@@ -81,7 +80,6 @@ private struct MediaPreviewViewController: UIViewControllerRepresentable {
onDismiss: @escaping () -> Void) {
self.previewItem = previewItem
self.shouldHideControls = shouldHideControls
self.dismissalPublisher = dismissalPublisher
self.onDismiss = onDismiss
super.init(nibName: nil, bundle: nil)
@@ -152,6 +152,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
}
}
// perphery: ignore - used in release mode
func presentCrashedLastRunAlert() {
state.bindings.alertInfo = AlertInfo(id: UUID(),
title: L10n.crashDetectionDialogContent(InfoPlistReader.main.bundleDisplayName),
@@ -22,5 +22,6 @@ protocol HomeScreenViewModelProtocol {
var context: HomeScreenViewModelType.Context { get }
// periphery: ignore - used in release mode
func presentCrashedLastRunAlert()
}
@@ -33,7 +33,6 @@ enum InviteUsersScreenCoordinatorAction {
}
final class InviteUsersScreenCoordinator: CoordinatorProtocol {
private let parameters: InviteUsersScreenCoordinatorParameters
private let viewModel: InviteUsersScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<InviteUsersScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -43,8 +42,6 @@ final class InviteUsersScreenCoordinator: CoordinatorProtocol {
}
init(parameters: InviteUsersScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = InviteUsersScreenViewModel(selectedUsers: parameters.selectedUsers,
roomType: parameters.roomType,
mediaProvider: parameters.mediaProvider,
@@ -17,6 +17,7 @@
import Foundation
import MatrixRustSDK
// periphery:ignore - for generic conformance
enum InviteUsersScreenErrorType: Error {
case unknown
}
@@ -22,7 +22,6 @@ typealias InviteUsersScreenViewModelType = StateStoreViewModel<InviteUsersScreen
class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScreenViewModelProtocol {
private let roomType: InviteUsersScreenRoomType
private let mediaProvider: MediaProviderProtocol
private let userDiscoveryService: UserDiscoveryServiceProtocol
private let appSettings: AppSettings
private let userIndicatorController: UserIndicatorControllerProtocol
@@ -40,7 +39,6 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
appSettings: AppSettings,
userIndicatorController: UserIndicatorControllerProtocol) {
self.roomType = roomType
self.mediaProvider = mediaProvider
self.userDiscoveryService = userDiscoveryService
self.appSettings = appSettings
self.userIndicatorController = userIndicatorController
@@ -89,6 +87,7 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
}
}
// periphery:ignore - automatically cancelled when set to nil
@CancellableTask
private var fetchUsersTask: Task<Void, Never>?
@@ -26,7 +26,6 @@ enum InvitesScreenCoordinatorAction {
}
final class InvitesScreenCoordinator: CoordinatorProtocol {
private let parameters: InvitesScreenCoordinatorParameters
private var viewModel: InvitesScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<InvitesScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -36,7 +35,6 @@ final class InvitesScreenCoordinator: CoordinatorProtocol {
}
init(parameters: InvitesScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = InvitesScreenViewModel(userSession: parameters.userSession,
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
@@ -155,6 +155,7 @@ class InvitesScreenViewModel: InvitesScreenViewModelType, InvitesScreenViewModel
}
private func displayError(_ error: RoomProxyError) {
MXLog.error("Failed to accept/decline invite: \(error)")
state.bindings.alertInfo = .init(id: true,
title: L10n.commonError,
message: L10n.errorUnknown)
@@ -29,7 +29,6 @@ enum MessageForwardingScreenCoordinatorAction {
}
final class MessageForwardingScreenCoordinator: CoordinatorProtocol {
private let parameters: MessageForwardingScreenCoordinatorParameters
private var viewModel: MessageForwardingScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<MessageForwardingScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -39,8 +38,6 @@ final class MessageForwardingScreenCoordinator: CoordinatorProtocol {
}
init(parameters: MessageForwardingScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = MessageForwardingScreenViewModel(roomSummaryProvider: parameters.roomSummaryProvider,
mediaProvider: parameters.mediaProvider,
sourceRoomID: parameters.sourceRoomID)
@@ -19,7 +19,6 @@ import SwiftUI
final class MigrationScreenCoordinator: CoordinatorProtocol {
private var viewModel: MigrationScreenViewModelProtocol
private var cancellables = Set<AnyCancellable>()
init() {
viewModel = MigrationScreenViewModel()
@@ -16,8 +16,6 @@
import Foundation
enum MigrationScreenViewModelAction { }
struct MigrationScreenViewState: BindableState { }
enum MigrationScreenViewAction { }
@@ -20,12 +20,6 @@ import SwiftUI
typealias MigrationScreenViewModelType = StateStoreViewModel<MigrationScreenViewState, MigrationScreenViewAction>
class MigrationScreenViewModel: MigrationScreenViewModelType, MigrationScreenViewModelProtocol {
private var actionsSubject: PassthroughSubject<MigrationScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<MigrationScreenViewModelAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init() {
super.init(initialViewState: MigrationScreenViewState())
}
@@ -18,6 +18,5 @@ import Combine
@MainActor
protocol MigrationScreenViewModelProtocol {
var actions: AnyPublisher<MigrationScreenViewModelAction, Never> { get }
var context: MigrationScreenViewModelType.Context { get }
}
@@ -22,13 +22,6 @@ enum OnboardingScreenCoordinatorAction {
case login
}
/// The content displayed in a single screen page.
struct OnboardingScreenPageContent {
let title: AttributedString
let message: String
let image: ImageAsset
}
enum OnboardingScreenViewModelAction {
case login
}
@@ -18,13 +18,7 @@ import Compound
import SwiftUI
struct ReportContentScreen: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@ObservedObject var context: ReportContentScreenViewModel.Context
private var horizontalPadding: CGFloat {
horizontalSizeClass == .regular ? 50 : 16
}
var body: some View {
Form {
@@ -35,7 +35,6 @@ enum RoomDetailsScreenCoordinatorAction {
}
final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
private let parameters: RoomDetailsScreenCoordinatorParameters
private var viewModel: RoomDetailsScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<RoomDetailsScreenCoordinatorAction, Never> = .init()
@@ -46,8 +45,6 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
}
init(parameters: RoomDetailsScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = RoomDetailsScreenViewModel(accountUserID: parameters.accountUserID,
roomProxy: parameters.roomProxy,
mediaProvider: parameters.mediaProvider,
@@ -219,12 +219,6 @@ extension RoomDetailsNotificationSettingsState {
return false
}
/// Returns `true` when the settings are loaded and `isDefault` is true.
var isDefault: Bool {
guard case let .loaded(settings) = self else { return false }
return settings.isDefault
}
/// Returns `true` when the settings are loaded and `isDefault` is false.
var isCustom: Bool {
guard case let .loaded(settings) = self else { return false }
@@ -29,7 +29,6 @@ enum RoomMemberDetailsScreenCoordinatorAction {
}
final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
private let parameters: RoomMemberDetailsScreenCoordinatorParameters
private var viewModel: RoomMemberDetailsScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<RoomMemberDetailsScreenCoordinatorAction, Never> = .init()
@@ -40,8 +39,6 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
}
init(parameters: RoomMemberDetailsScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = RoomMemberDetailsScreenViewModel(roomProxy: parameters.roomProxy,
roomMemberProxy: parameters.roomMemberProxy,
mediaProvider: parameters.mediaProvider,
@@ -83,6 +83,5 @@ enum RoomMemberDetailsScreenViewAction {
}
enum RoomMemberDetailsScreenError: Hashable {
case alert(String)
case unknown
}
@@ -28,7 +28,6 @@ enum RoomMembersListScreenCoordinatorAction {
}
final class RoomMembersListScreenCoordinator: CoordinatorProtocol {
private let parameters: RoomMembersListScreenCoordinatorParameters
private var viewModel: RoomMembersListScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<RoomMembersListScreenCoordinatorAction, Never> = .init()
@@ -39,8 +38,6 @@ final class RoomMembersListScreenCoordinator: CoordinatorProtocol {
}
init(parameters: RoomMembersListScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = RoomMembersListScreenViewModel(roomProxy: parameters.roomProxy,
mediaProvider: parameters.mediaProvider,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
@@ -18,8 +18,6 @@ import Compound
import SwiftUI
struct RoomMembersListScreen: View {
@Environment(\.colorScheme) private var colorScheme
@ObservedObject var context: RoomMembersListScreenViewModel.Context
var body: some View {
@@ -38,10 +38,6 @@ final class RoomNotificationSettingsScreenCoordinator: CoordinatorProtocol {
var actions: AnyPublisher<RoomNotificationSettingsScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
private var navigationStackCoordinator: NavigationStackCoordinator? {
parameters.navigationStackCoordinator
}
init(parameters: RoomNotificationSettingsScreenCoordinatorParameters) {
self.parameters = parameters
@@ -81,7 +81,6 @@ struct RoomNotificationSettingsScreenViewState: BindableState {
struct RoomNotificationSettingsScreenViewStateBindings {
var allowCustomSetting = false
var customMode: RoomNotificationModeProxy = .allMessages
/// Information describing the currently displayed alert.
var alertInfo: AlertInfo<RoomNotificationSettingsScreenErrorType>?
}
@@ -24,6 +24,7 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
private let notificationSettingsProxy: NotificationSettingsProxyProtocol
private let roomProxy: RoomProxyProtocol
// periphery:ignore - cancellable tasks cancel when reassigned
@CancellableTask private var fetchNotificationSettingsTask: Task<Void, Error>?
var actions: AnyPublisher<RoomNotificationSettingsScreenViewModelAction, Never> {
@@ -94,9 +95,6 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
if !state.isRestoringDefaultSetting {
state.bindings.allowCustomSetting = !settings.isDefault
}
if state.pendingCustomMode == nil {
state.bindings.customMode = settings.mode
}
} catch {
state.notificationSettingsState = .error
displayError(.loadingSettingsFailed)
@@ -45,7 +45,6 @@ enum RoomScreenCoordinatorAction {
}
final class RoomScreenCoordinator: CoordinatorProtocol {
private var parameters: RoomScreenCoordinatorParameters
private var viewModel: RoomScreenViewModelProtocol
private var composerViewModel: ComposerToolbarViewModel
private var wysiwygViewModel: WysiwygComposerViewModel
@@ -58,8 +57,6 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
}
init(parameters: RoomScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = RoomScreenViewModel(roomProxy: parameters.roomProxy,
timelineController: parameters.timelineController,
mediaProvider: parameters.mediaProvider,
@@ -23,10 +23,6 @@ struct ReactionsSummaryView: View {
@State var selectedReactionKey: String
var selectedReactionIndex: Int {
reactions.firstIndex(where: { $0.key == selectedReactionKey }) ?? 0
}
var body: some View {
VStack(alignment: .leading, spacing: 0) {
reactionButtons
@@ -18,7 +18,6 @@ import SwiftUI
struct PollRoomTimelineView: View {
let timelineItem: PollRoomTimelineItem
@Environment(\.timelineStyle) var timelineStyle
@EnvironmentObject private var context: RoomScreenViewModel.Context
private let feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
@@ -14,13 +14,13 @@
// limitations under the License.
//
// periphery:ignore:all - subscripts lead to false positives
import Foundation
struct AdvancedSettingsScreenViewState: BindableState {
var bindings: AdvancedSettingsScreenViewStateBindings
}
// periphery:ignore - subscript are seen as false positives
@dynamicMemberLookup
struct AdvancedSettingsScreenViewStateBindings {
private let advancedSettings: AdvancedSettingsProtocol
@@ -16,6 +16,7 @@
import Foundation
// periphery:ignore - required for the architecture
enum LegalInformationScreenViewModelAction { }
struct LegalInformationScreenViewState: BindableState {
@@ -16,6 +16,7 @@
import Combine
// periphery:ignore - markdown protocol
@MainActor
protocol LegalInformationScreenViewModelProtocol {
var context: LegalInformationScreenViewModelType.Context { get }
@@ -24,18 +24,11 @@ struct NotificationSettingsEditScreenCoordinatorParameters {
let notificationSettings: NotificationSettingsProxyProtocol
}
enum NotificationSettingsEditScreenCoordinatorAction { }
final class NotificationSettingsEditScreenCoordinator: CoordinatorProtocol {
private let parameters: NotificationSettingsEditScreenCoordinatorParameters
private var viewModel: NotificationSettingsEditScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<NotificationSettingsEditScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
var actions: AnyPublisher<NotificationSettingsEditScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: NotificationSettingsEditScreenCoordinatorParameters) {
self.parameters = parameters
@@ -53,7 +53,6 @@ struct NotificationSettingsEditScreenViewState: BindableState {
}
struct NotificationSettingsEditScreenViewStateBindings {
var searchQuery = ""
var alertInfo: AlertInfo<NotificationSettingsEditScreenErrorType>?
}
@@ -103,8 +102,6 @@ struct NotificationSettingsEditScreenStrings {
}
struct NotificationSettingsEditScreenRoom: Identifiable, Equatable {
static let placeholderLastMessage = AttributedString("Hidden last message")
/// The list item identifier can be a real room identifier, a custom one for invalidated entries
/// or a completely unique one for empty items and skeletons
let id: String
@@ -117,13 +114,4 @@ struct NotificationSettingsEditScreenRoom: Identifiable, Equatable {
var avatarURL: URL?
var notificationMode: RoomNotificationModeProxy?
var isPlaceholder = false
static func placeholder() -> NotificationSettingsEditScreenRoom {
NotificationSettingsEditScreenRoom(id: UUID().uuidString,
roomId: nil,
name: "Placeholder room name",
isPlaceholder: true)
}
}
@@ -26,7 +26,9 @@ class NotificationSettingsEditScreenViewModel: NotificationSettingsEditScreenVie
private let userSession: UserSessionProtocol
private let roomSummaryProvider: RoomSummaryProviderProtocol?
// periphery:ignore - cancellable tasks get cancelled when reassigned
@CancellableTask private var fetchDefaultRoomNotificationModesTask: Task<Void, Error>?
// periphery:ignore - cancellable tasks get cancelled when reassigned
@CancellableTask private var updateRoomsWithUserDefinedModeTask: Task<Void, Error>?
var actions: AnyPublisher<NotificationSettingsEditScreenViewModelAction, Never> {
@@ -19,7 +19,6 @@ import SwiftUI
struct NotificationSettingsEditScreen: View {
@ObservedObject var context: NotificationSettingsEditScreenViewModel.Context
@State var isSearching = false
var body: some View {
Form {
@@ -46,8 +46,7 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
init(parameters: NotificationSettingsScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = NotificationSettingsScreenViewModel(userSession: parameters.userSession,
appSettings: ServiceLocator.shared.settings,
viewModel = NotificationSettingsScreenViewModel(appSettings: ServiceLocator.shared.settings,
userNotificationCenter: parameters.userNotificationCenter,
notificationSettingsProxy: parameters.notificationSettings,
isModallyPresented: parameters.isModallyPresented)
@@ -27,7 +27,6 @@ struct NotificationSettingsScreenViewState: BindableState {
var strings = NotificationSettingsScreenStrings()
let isModallyPresented: Bool
var isUserPermissionGranted: Bool?
var allowedNotificationModes: [RoomNotificationModeProxy] = [.allMessages, .mentionsAndKeywordsOnly]
var fixingConfigurationMismatch = false
// Hide calls settings until calls are available in El-X
let showCallsSettings = false
@@ -24,15 +24,14 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
private let appSettings: AppSettings
private let userNotificationCenter: UserNotificationCenterProtocol
private let notificationSettingsProxy: NotificationSettingsProxyProtocol
private let userSession: UserSessionProtocol
// periphery:ignore - cancellable tasks get cancelled when reassigned
@CancellableTask private var fetchSettingsTask: Task<Void, Error>?
var actions: AnyPublisher<NotificationSettingsScreenViewModelAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(userSession: UserSessionProtocol, appSettings: AppSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol, isModallyPresented: Bool) {
self.userSession = userSession
init(appSettings: AppSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol, isModallyPresented: Bool) {
self.appSettings = appSettings
self.userNotificationCenter = userNotificationCenter
self.notificationSettingsProxy = notificationSettingsProxy
@@ -220,8 +220,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe"), mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
var viewModel = NotificationSettingsScreenViewModel(userSession: userSession,
appSettings: appSettings,
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
userNotificationCenter: notificationCenter,
notificationSettingsProxy: notificationSettingsProxy,
isModallyPresented: true)
@@ -249,8 +248,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe"), mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())
var viewModel = NotificationSettingsScreenViewModel(userSession: userSession,
appSettings: appSettings,
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
userNotificationCenter: notificationCenter,
notificationSettingsProxy: notificationSettingsProxy,
isModallyPresented: true)
@@ -50,10 +50,6 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
// it. Keep it around to avoid having multiple instances if the user re-enables
}
func flush() {
postHog?.flush()
}
func capture(_ event: AnalyticsEventProtocol) {
guard isRunning else { return }
postHog?.capture(event.eventName, properties: attachUserProperties(to: event.properties))
@@ -27,15 +27,12 @@ protocol KeychainControllerProtocol: ClientSessionDelegate {
// MARK: Restoration Tokens
func setRestorationToken(_ restorationToken: RestorationToken, forUsername: String)
func restorationTokenForUsername(_ username: String) -> RestorationToken?
func restorationTokens() -> [KeychainCredentials]
func removeRestorationTokenForUsername(_ username: String)
func removeAllRestorationTokens()
// MARK: App Secrets
/// Removes everything from the keychain excluding any restoration tokens.
func resetSecrets()
/// Whether or not an App Lock PIN code has been set.
func containsPINCode() throws -> Bool
/// Sets a new PIN code for App Lock.
@@ -25,7 +25,6 @@ indirect enum MediaUploadingPreprocessorError: Error {
case failedProcessingImage(MediaUploadingPreprocessorError)
case failedProcessingVideo(MediaUploadingPreprocessorError)
case failedProcessingAudio
case failedProcessingFile
case failedGeneratingVideoThumbnail(Error?)
case failedGeneratingImageThumbnail(Error?)
@@ -28,8 +28,4 @@ extension ImageProviderProtocol {
func imageFromSource(_ source: MediaSourceProxy?) -> UIImage? {
imageFromSource(source, size: nil)
}
func loadImageFromSource(_ source: MediaSourceProxy) async -> Result<UIImage, MediaProviderError> {
await loadImageFromSource(source, size: nil)
}
}
@@ -23,9 +23,3 @@ protocol MediaLoaderProtocol {
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy
}
extension MediaLoaderProtocol {
func loadMediaFileForSource(_ source: MediaSourceProxy) async throws -> MediaFileHandleProxy {
try await loadMediaFileForSource(source, body: nil)
}
}
@@ -40,11 +40,11 @@ struct MediaSourceProxy: Hashable {
// MARK: - Hashable
public static func == (lhs: MediaSourceProxy, rhs: MediaSourceProxy) -> Bool {
static func == (lhs: MediaSourceProxy, rhs: MediaSourceProxy) -> Bool {
lhs.url == rhs.url
}
public func hash(into hasher: inout Hasher) {
func hash(into hasher: inout Hasher) {
hasher.combine(url)
}
}
@@ -23,7 +23,6 @@ enum NotificationConstants {
static let unreadCount = "unread_count"
static let pusherNotificationClientIdentifier = "pusher_notification_client_identifier"
static let receiverIdentifier = "receiver_id"
static let notificationIdentifier = "notification_identifier"
}
enum Category {
@@ -45,10 +45,6 @@ struct NotificationItemProxy: NotificationItemProxyProtocol {
notificationItem.roomInfo.displayName
}
var roomCanonicalAlias: String? {
notificationItem.roomInfo.canonicalAlias
}
var isRoomDirect: Bool {
notificationItem.roomInfo.isDirect
}
@@ -96,27 +92,17 @@ struct EmptyNotificationItemProxy: NotificationItemProxyProtocol {
var senderID: String { "" }
var senderDisplayName: String? { nil }
var senderAvatarURL: String? { nil }
var roomDisplayName: String { "" }
var roomCanonicalAlias: String? { nil }
var roomAvatarURL: String? { nil }
var isNoisy: Bool { false }
var isRoomDirect: Bool { false }
var isRoomEncrypted: Bool? { nil }
var senderAvatarMediaSource: MediaSourceProxy? { nil }
var roomAvatarMediaSource: MediaSourceProxy? { nil }
var notificationIdentifier: String { "" }
var roomJoinedMembers: Int { 0 }
var hasMention: Bool { false }
@@ -35,8 +35,6 @@ protocol NotificationItemProxyProtocol {
var roomDisplayName: String { get }
var roomCanonicalAlias: String? { get }
var roomAvatarMediaSource: MediaSourceProxy? { get }
var roomJoinedMembers: Int { get }
@@ -92,10 +92,6 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
try await notificationSettings.restoreDefaultRoomNotificationMode(roomId: roomId)
await updatedSettings()
}
func containsKeywordsRules() async -> Bool {
await notificationSettings.containsKeywordsRules()
}
func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws {
let backgroundTask = await backgroundTaskService?.startBackgroundTask(withName: "unmuteRoom")
@@ -117,18 +113,6 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
await updatedSettings()
}
func isUserMentionEnabled() async throws -> Bool {
try await notificationSettings.isUserMentionEnabled()
}
func setUserMentionEnabled(enabled: Bool) async throws {
let backgroundTask = await backgroundTaskService?.startBackgroundTask(withName: "setUserMentionEnabled")
defer { backgroundTask?.stop() }
try await notificationSettings.setUserMentionEnabled(enabled: enabled)
await updatedSettings()
}
func isCallEnabled() async throws -> Bool {
try await notificationSettings.isCallEnabled()
}
@@ -32,12 +32,9 @@ protocol NotificationSettingsProxyProtocol {
func getDefaultRoomNotificationMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy
func setDefaultRoomNotificationMode(isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy) async throws
func restoreDefaultNotificationMode(roomId: String) async throws
func containsKeywordsRules() async -> Bool
func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws
func isRoomMentionEnabled() async throws -> Bool
func setRoomMentionEnabled(enabled: Bool) async throws
func isUserMentionEnabled() async throws -> Bool
func setUserMentionEnabled(enabled: Bool) async throws
func isCallEnabled() async throws -> Bool
func setCallEnabled(enabled: Bool) async throws
func isInviteForMeEnabled() async throws -> Bool
@@ -39,12 +39,6 @@ final class RoomMemberProxy: RoomMemberProxyProtocol {
lazy var membership = member.membership()
lazy var isNameAmbiguous = member.isNameAmbiguous()
lazy var powerLevel = Int(member.powerLevel())
lazy var normalizedPowerLevel = Int(member.normalizedPowerLevel())
lazy var isAccountOwner = member.isAccountUser()
lazy var isIgnored = member.isIgnored()
@@ -28,9 +28,6 @@ protocol RoomMemberProxyProtocol: AnyObject {
var displayName: String? { get }
var avatarURL: URL? { get }
var membership: MembershipState { get }
var isNameAmbiguous: Bool { get }
var powerLevel: Int { get }
var normalizedPowerLevel: Int { get }
var isAccountOwner: Bool { get }
var isIgnored: Bool { get }
var canInviteUsers: Bool { get }
+1 -52
View File
@@ -34,6 +34,7 @@ class RoomProxy: RoomProxyProtocol {
private var sendMessageBackgroundTask: BackgroundTaskProtocol?
private(set) var displayName: String?
// periphery:ignore - required for instance retention in the rust codebase
private var roomInfoObservationToken: TaskHandle?
private var subscribedForUpdates = false
@@ -104,10 +105,6 @@ class RoomProxy: RoomProxyProtocol {
room.topic()
}
var isJoined: Bool {
room.membership() == .joined
}
var membership: Membership {
room.membership()
}
@@ -128,10 +125,6 @@ class RoomProxy: RoomProxyProtocol {
(try? room.isEncrypted()) ?? false
}
var isTombstoned: Bool {
room.isTombstoned()
}
var hasOngoingCall: Bool {
room.hasActiveRoomCall()
}
@@ -140,10 +133,6 @@ class RoomProxy: RoomProxyProtocol {
room.canonicalAlias()
}
var alternativeAliases: [String] {
room.alternativeAliases()
}
var hasUnreadNotifications: Bool {
roomListItem.hasUnreadNotifications()
}
@@ -163,36 +152,6 @@ class RoomProxy: RoomProxyProtocol {
var activeMembersCount: Int {
Int(room.activeMembersCount())
}
func loadAvatarURLForUserId(_ userId: String) async -> Result<URL?, RoomProxyError> {
do {
guard let urlString = try await Task.dispatch(on: lowPriorityDispatchQueue, {
try self.room.memberAvatarUrl(userId: userId)
}) else {
return .success(nil)
}
guard let avatarURL = URL(string: urlString) else {
MXLog.error("Invalid avatar URL string: \(String(describing: urlString))")
return .failure(.failedRetrievingMemberAvatarURL)
}
return .success(avatarURL)
} catch {
return .failure(.failedRetrievingMemberAvatarURL)
}
}
func loadDisplayNameForUserId(_ userId: String) async -> Result<String?, RoomProxyError> {
do {
let displayName = try await Task.dispatch(on: lowPriorityDispatchQueue) {
try self.room.memberDisplayName(userId: userId)
}
return .success(displayName)
} catch {
return .failure(.failedRetrievingMemberDisplayName)
}
}
func redact(_ eventID: String) async -> Result<Void, RoomProxyError> {
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
@@ -290,16 +249,6 @@ class RoomProxy: RoomProxyProtocol {
}
}
func inviter() async -> RoomMemberProxyProtocol? {
let inviter = await Task.dispatch(on: .global()) {
self.room.inviter()
}
return inviter.map {
RoomMemberProxy(member: $0, backgroundTaskService: self.backgroundTaskService)
}
}
func rejectInvitation() async -> Result<Void, RoomProxyError> {
await Task.dispatch(on: .global()) {
do {
@@ -19,8 +19,6 @@ import Foundation
import MatrixRustSDK
enum RoomProxyError: Error, Equatable {
case failedRetrievingMemberAvatarURL
case failedRetrievingMemberDisplayName
case failedRedactingEvent
case failedReportingContent
case failedRetrievingMember
@@ -46,11 +44,9 @@ protocol RoomProxyProtocol {
var isPublic: Bool { get }
var isSpace: Bool { get }
var isEncrypted: Bool { get }
var isTombstoned: Bool { get }
var membership: Membership { get }
var hasOngoingCall: Bool { get }
var canonicalAlias: String? { get }
var alternativeAliases: [String] { get }
var hasUnreadNotifications: Bool { get }
var ownUserID: String { get }
@@ -62,9 +58,7 @@ protocol RoomProxyProtocol {
var avatarURL: URL? { get }
var members: CurrentValuePublisher<[RoomMemberProxyProtocol], Never> { get }
var invitedMembersCount: Int { get }
var joinedMembersCount: Int { get }
var activeMembersCount: Int { get }
@@ -73,14 +67,7 @@ protocol RoomProxyProtocol {
var timeline: TimelineProxyProtocol { get }
/// A timeline providing just polls related events
var pollHistoryTimeline: TimelineProxyProtocol { get }
func subscribeForUpdates() async
func loadAvatarURLForUserId(_ userId: String) async -> Result<URL?, RoomProxyError>
func loadDisplayNameForUserId(_ userId: String) async -> Result<String?, RoomProxyError>
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
@@ -93,8 +80,6 @@ protocol RoomProxyProtocol {
func updateMembers() async
func getMember(userID: String) async -> Result<RoomMemberProxyProtocol, RoomProxyError>
func inviter() async -> RoomMemberProxyProtocol?
func rejectInvitation() async -> Result<Void, RoomProxyError>
@@ -48,9 +48,9 @@ struct RoomEventStringBuilder {
let messageType = messageContent.msgtype()
return messageEventStringBuilder.buildAttributedString(for: messageType, senderDisplayName: senderDisplayName, prefixWithSenderName: true)
case .state(let stateKey, let state):
case .state(_, let state):
return stateEventStringBuilder
.buildString(for: state, stateKey: stateKey, sender: sender, isOutgoing: isOutgoing)
.buildString(for: state, sender: sender, isOutgoing: isOutgoing)
.map(AttributedString.init)
case .roomMembership(let userID, let change):
return stateEventStringBuilder
@@ -22,10 +22,6 @@ import WysiwygComposer
struct IntentionalMentions: Equatable {
let userIDs: Set<String>
let atRoom: Bool
static var empty: Self {
IntentionalMentions(userIDs: [], atRoom: false)
}
}
extension IntentionalMentions {
@@ -14,15 +14,14 @@
// limitations under the License.
//
// periphery:ignore:all
import Combine
import Foundation
class MockRoomTimelineController: RoomTimelineControllerProtocol {
/// An array of timeline item arrays that will be inserted in order for each back pagination request.
var backPaginationResponses: [[RoomTimelineItemProtocol]] = []
/// The time delay added to each back pagination request.
var backPaginationDelay: Duration = .milliseconds(500)
/// An array of timeline items that will be appended in order when ``simulateIncomingItems()`` is called.
var incomingItems: [RoomTimelineItemProtocol] = []
@@ -18,23 +18,12 @@ struct LocationRoomTimelineItemContent: Hashable {
let body: String
let geoURI: GeoURI?
let description: String?
let zoomLevel: UInt8?
let asset: AssetType?
enum AssetType {
case sender
case pin
}
init(body: String,
geoURI: GeoURI? = nil,
description: String? = nil,
zoomLevel: UInt8? = nil,
asset: AssetType? = nil) {
description: String? = nil) {
self.body = body
self.geoURI = geoURI
self.description = description
self.zoomLevel = zoomLevel
self.asset = asset
}
}
@@ -121,7 +121,7 @@ struct RoomStateEventStringBuilder {
}
}
func buildString(for state: OtherState, stateKey: String?, sender: TimelineItemSender, isOutgoing: Bool) -> String? {
func buildString(for state: OtherState, sender: TimelineItemSender, isOutgoing: Bool) -> String? {
let senderName = sender.displayName ?? sender.id
switch state {
@@ -526,9 +526,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
private func buildLocationTimelineItemContent(_ locationContent: LocationContent) -> LocationRoomTimelineItemContent {
LocationRoomTimelineItemContent(body: locationContent.body,
geoURI: .init(string: locationContent.geoUri),
description: locationContent.description,
zoomLevel: locationContent.zoomLevel,
asset: locationContent.asset.map { .init(assetType: $0) })
description: locationContent.description)
}
private func buildFileTimelineItemContent(_ messageContent: FileMessageContent) -> FileRoomTimelineItemContent {
@@ -568,7 +566,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
state: OtherState,
stateKey: String,
isOutgoing: Bool) -> RoomTimelineItemProtocol? {
guard let text = stateEventStringBuilder.buildString(for: state, stateKey: stateKey, sender: eventItemProxy.sender, isOutgoing: isOutgoing) else { return nil }
guard let text = stateEventStringBuilder.buildString(for: state, sender: eventItemProxy.sender, isOutgoing: isOutgoing) else { return nil }
return buildStateTimelineItem(for: eventItemProxy, text: text, isOutgoing: isOutgoing)
}
@@ -680,17 +678,6 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
}
}
private extension LocationRoomTimelineItemContent.AssetType {
init(assetType: MatrixRustSDK.AssetType) {
switch assetType {
case .sender:
self = .sender
case .pin:
self = .pin
}
}
}
extension Poll.Kind {
init(pollKind: MatrixRustSDK.PollKind) {
switch pollKind {
@@ -786,8 +786,8 @@ class MockScreen: Identifiable {
ServiceLocator.shared.settings.seenInvites = Set([RoomSummary].mockInvites.dropFirst(1).compactMap(\.id))
let navigationStackCoordinator = NavigationStackCoordinator()
let clientProxy = MockClientProxy(userID: "@mock:client.com")
clientProxy.roomForIdentifierMocks["someAwesomeRoomId1"] = .init(with: .init(displayName: "First room", inviter: .mockCharlie))
clientProxy.roomForIdentifierMocks["someAwesomeRoomId2"] = .init(with: .init(displayName: "Second room", inviter: .mockCharlie))
clientProxy.roomForIdentifierMocks["someAwesomeRoomId1"] = .init(with: .init(displayName: "First room"))
clientProxy.roomForIdentifierMocks["someAwesomeRoomId2"] = .init(with: .init(displayName: "Second room"))
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
clientProxy.inviteSummaryProvider = summaryProvider
@@ -798,8 +798,8 @@ class MockScreen: Identifiable {
ServiceLocator.shared.settings.seenInvites = Set([RoomSummary].mockInvites.compactMap(\.id))
let navigationStackCoordinator = NavigationStackCoordinator()
let clientProxy = MockClientProxy(userID: "@mock:client.com")
clientProxy.roomForIdentifierMocks["someAwesomeRoomId1"] = .init(with: .init(displayName: "First room", inviter: .mockCharlie))
clientProxy.roomForIdentifierMocks["someAwesomeRoomId2"] = .init(with: .init(displayName: "Second room", inviter: .mockCharlie))
clientProxy.roomForIdentifierMocks["someAwesomeRoomId1"] = .init(with: .init(displayName: "First room"))
clientProxy.roomForIdentifierMocks["someAwesomeRoomId2"] = .init(with: .init(displayName: "Second room"))
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
clientProxy.inviteSummaryProvider = summaryProvider