mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:06:00 +00:00
Removing dead code part 3 (#2264)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// Copyright 2021 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 AnalyticsEvents
|
||||
import Foundation
|
||||
|
||||
public extension AnalyticsEvent.UserProperties {
|
||||
// Initializer for Element. Strips all Web properties.
|
||||
init(ftueUseCaseSelection: FtueUseCaseSelection?, numFavouriteRooms: Int?, numSpaces: Int?, allChatsActiveFilter: AllChatsActiveFilter?) {
|
||||
self.init(allChatsActiveFilter: nil,
|
||||
ftueUseCaseSelection: ftueUseCaseSelection,
|
||||
numFavouriteRooms: numFavouriteRooms,
|
||||
numSpaces: numSpaces)
|
||||
}
|
||||
}
|
||||
@@ -67,10 +67,9 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
|
||||
}
|
||||
|
||||
// Merge the updated user properties with the existing ones
|
||||
self.pendingUserProperties = AnalyticsEvent.UserProperties(ftueUseCaseSelection: userProperties.ftueUseCaseSelection ?? pendingUserProperties.ftueUseCaseSelection,
|
||||
self.pendingUserProperties = AnalyticsEvent.UserProperties(allChatsActiveFilter: userProperties.allChatsActiveFilter ?? pendingUserProperties.allChatsActiveFilter, ftueUseCaseSelection: userProperties.ftueUseCaseSelection ?? pendingUserProperties.ftueUseCaseSelection,
|
||||
numFavouriteRooms: userProperties.numFavouriteRooms ?? pendingUserProperties.numFavouriteRooms,
|
||||
numSpaces: userProperties.numSpaces ?? pendingUserProperties.numSpaces,
|
||||
allChatsActiveFilter: userProperties.allChatsActiveFilter ?? pendingUserProperties.allChatsActiveFilter)
|
||||
numSpaces: userProperties.numSpaces ?? pendingUserProperties.numSpaces)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@@ -25,13 +25,11 @@ private final class MediaRequest {
|
||||
|
||||
actor MediaLoader: MediaLoaderProtocol {
|
||||
private let client: ClientProtocol
|
||||
private let clientQueue: DispatchQueue
|
||||
private var ongoingRequests = [MediaSourceProxy: MediaRequest]()
|
||||
|
||||
init(client: ClientProtocol,
|
||||
clientQueue: DispatchQueue = .global()) {
|
||||
self.client = client
|
||||
self.clientQueue = clientQueue
|
||||
}
|
||||
|
||||
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data {
|
||||
|
||||
@@ -20,9 +20,7 @@ import UserNotifications
|
||||
|
||||
protocol NotificationItemProxyProtocol {
|
||||
var event: NotificationEvent? { get }
|
||||
|
||||
var eventID: String { get }
|
||||
|
||||
|
||||
var senderID: String { get }
|
||||
|
||||
var roomID: String { get }
|
||||
|
||||
@@ -29,7 +29,6 @@ class RoomProxy: RoomProxyProtocol {
|
||||
private let backgroundTaskName = "SendRoomEvent"
|
||||
|
||||
private let userInitiatedDispatchQueue = DispatchQueue(label: "io.element.elementx.roomproxy.user_initiated", qos: .userInitiated)
|
||||
private let lowPriorityDispatchQueue = DispatchQueue(label: "io.element.elementx.roomproxy.low_priority", qos: .utility)
|
||||
|
||||
private var sendMessageBackgroundTask: BackgroundTaskProtocol?
|
||||
|
||||
@@ -141,10 +140,6 @@ class RoomProxy: RoomProxyProtocol {
|
||||
roomListItem.avatarUrl().flatMap(URL.init(string:))
|
||||
}
|
||||
|
||||
var invitedMembersCount: Int {
|
||||
Int(room.invitedMembersCount())
|
||||
}
|
||||
|
||||
var joinedMembersCount: Int {
|
||||
Int(room.joinedMembersCount())
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
|
||||
private let serialDispatchQueue: DispatchQueue
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
private var roomList: RoomListProtocol?
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
@@ -39,7 +40,6 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
|
||||
private let roomListSubject = CurrentValueSubject<[RoomSummary], Never>([])
|
||||
private let stateSubject = CurrentValueSubject<RoomSummaryProviderState, Never>(.notLoaded)
|
||||
private let countSubject = CurrentValueSubject<UInt, Never>(0)
|
||||
|
||||
private let diffsPublisher = PassthroughSubject<[RoomListEntriesUpdate], Never>()
|
||||
|
||||
@@ -407,15 +407,6 @@ extension MatrixRustSDK.RoomListEntry {
|
||||
return "Filled(\(roomId))"
|
||||
}
|
||||
}
|
||||
|
||||
var isInvalidated: Bool {
|
||||
switch self {
|
||||
case .invalidated:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RoomListEntriesListenerProxy: RoomListEntriesListener {
|
||||
|
||||
@@ -24,9 +24,12 @@ class SecureBackupController: SecureBackupControllerProtocol {
|
||||
private let recoveryKeyStateSubject = CurrentValueSubject<SecureBackupRecoveryKeyState, Never>(.unknown)
|
||||
private let keyBackupStateSubject = CurrentValueSubject<SecureBackupKeyBackupState, Never>(.unknown)
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
private var backupStateListenerTaskHandle: TaskHandle?
|
||||
// periphery:ignore - retaining purpose
|
||||
private var recoveryStateListenerTaskHandle: TaskHandle?
|
||||
|
||||
// periphery:ignore - auto cancels when reassigned
|
||||
/// Used to dedupe remote backup state requests
|
||||
@CancellableTask private var remoteBackupStateTask: Task<Void, Error>?
|
||||
|
||||
|
||||
@@ -64,11 +64,3 @@ protocol SecureBackupControllerProtocol {
|
||||
|
||||
func waitForKeyBackupUpload() async -> Result<Void, SecureBackupControllerError>
|
||||
}
|
||||
|
||||
extension SecureBackupControllerMock {
|
||||
convenience init(keyBackupState: SecureBackupKeyBackupState, recoveryKeyState: SecureBackupRecoveryKeyState) {
|
||||
self.init()
|
||||
underlyingKeyBackupState = CurrentValueSubject<SecureBackupKeyBackupState, Never>(keyBackupState).asCurrentValuePublisher()
|
||||
underlyingRecoveryKeyState = CurrentValueSubject<SecureBackupRecoveryKeyState, Never>(recoveryKeyState).asCurrentValuePublisher()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
|
||||
itemProxiesSubject.value
|
||||
}
|
||||
|
||||
var updatePublisher: AnyPublisher<TimelineProviderUpdate, Never> {
|
||||
var updatePublisher: AnyPublisher<Void, Never> {
|
||||
itemProxiesSubject
|
||||
.combineLatest(backPaginationStateSubject)
|
||||
.map(TimelineProviderUpdate.init)
|
||||
.map { _, _ in () }
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,10 @@ import Foundation
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
struct TimelineProviderUpdate {
|
||||
let items: [TimelineItemProxy]
|
||||
let backPaginationState: BackPaginationStatus
|
||||
}
|
||||
|
||||
@MainActor
|
||||
// sourcery: AutoMockable
|
||||
protocol RoomTimelineProviderProtocol {
|
||||
var updatePublisher: AnyPublisher<TimelineProviderUpdate, Never> { get }
|
||||
var updatePublisher: AnyPublisher<Void, Never> { get }
|
||||
var itemProxies: [TimelineItemProxy] { get }
|
||||
var backPaginationState: BackPaginationStatus { get }
|
||||
}
|
||||
|
||||
@@ -27,11 +27,6 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
private let serialDispatchQueue: DispatchQueue
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private var timelineItemsUpdateTask: Task<Void, Never>? {
|
||||
willSet {
|
||||
timelineItemsUpdateTask?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
let callbacks = PassthroughSubject<RoomTimelineControllerCallback, Never>()
|
||||
|
||||
@@ -257,13 +252,9 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
for (index, collapsibleChunk) in collapsibleChunks.enumerated() {
|
||||
let isLastItem = index == collapsibleChunks.indices.last
|
||||
|
||||
// Try building a stable identifier for items that don't have one
|
||||
// We need to avoid duplicates otherwise the diffable datasource will crash
|
||||
let reversedIndex = collapsibleChunks.count - index
|
||||
|
||||
let items = collapsibleChunk.compactMap { itemProxy in
|
||||
|
||||
let timelineItem = buildTimelineItem(for: itemProxy, chunkIndex: reversedIndex)
|
||||
let timelineItem = buildTimelineItem(for: itemProxy)
|
||||
|
||||
if timelineItem is EncryptedHistoryRoomTimelineItem {
|
||||
canBackPaginate = false
|
||||
@@ -319,7 +310,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
callbacks.send(.isBackPaginating(isBackPaginating))
|
||||
}
|
||||
|
||||
private func buildTimelineItem(for itemProxy: TimelineItemProxy, chunkIndex: Int) -> RoomTimelineItemProtocol? {
|
||||
private func buildTimelineItem(for itemProxy: TimelineItemProxy) -> RoomTimelineItemProtocol? {
|
||||
switch itemProxy {
|
||||
case .event(let eventTimelineItem):
|
||||
let timelineItem = timelineItemFactory.buildTimelineItem(for: eventTimelineItem)
|
||||
|
||||
@@ -89,9 +89,7 @@ class EventTimelineItemProxy {
|
||||
}()
|
||||
|
||||
lazy var canBeRepliedTo = item.canBeRepliedTo()
|
||||
|
||||
lazy var isRoomState = content.kind().isRoomState
|
||||
|
||||
|
||||
lazy var content = item.content()
|
||||
|
||||
lazy var isOwn = item.isOwn()
|
||||
@@ -125,17 +123,6 @@ class EventTimelineItemProxy {
|
||||
lazy var readReceipts = item.readReceipts()
|
||||
}
|
||||
|
||||
extension TimelineItemContentKind {
|
||||
var isRoomState: Bool {
|
||||
switch self {
|
||||
case .state, .roomMembership:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TimelineItemDebugInfo: Identifiable, CustomStringConvertible {
|
||||
let id = UUID()
|
||||
let model: String
|
||||
|
||||
@@ -19,24 +19,18 @@ import UIKit
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
private let mediaProvider: MediaProviderProtocol
|
||||
private let attributedStringBuilder: AttributedStringBuilderProtocol
|
||||
private let stateEventStringBuilder: RoomStateEventStringBuilder
|
||||
private let appSettings: AppSettings
|
||||
|
||||
/// The Matrix ID of the current user.
|
||||
private let userID: String
|
||||
|
||||
init(userID: String,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
attributedStringBuilder: AttributedStringBuilderProtocol,
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder,
|
||||
appSettings: AppSettings) {
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder) {
|
||||
self.userID = userID
|
||||
self.mediaProvider = mediaProvider
|
||||
self.attributedStringBuilder = attributedStringBuilder
|
||||
self.stateEventStringBuilder = stateEventStringBuilder
|
||||
self.appSettings = appSettings
|
||||
}
|
||||
|
||||
func buildTimelineItem(for eventItemProxy: EventTimelineItemProxy) -> RoomTimelineItemProtocol? {
|
||||
@@ -61,7 +55,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
case .message:
|
||||
return buildMessageTimelineItem(eventItemProxy, isOutgoing)
|
||||
case .state(let stateKey, let content):
|
||||
return buildStateTimelineItem(for: eventItemProxy, state: content, stateKey: stateKey, isOutgoing: isOutgoing)
|
||||
return buildStateTimelineItem(for: eventItemProxy, state: content, isOutgoing: isOutgoing)
|
||||
case .roomMembership(userId: let userID, change: let change):
|
||||
return buildStateMembershipChangeTimelineItem(for: eventItemProxy, member: userID, membershipChange: change, isOutgoing: isOutgoing)
|
||||
case .profileChange(let displayName, let prevDisplayName, let avatarUrl, let prevAvatarUrl):
|
||||
@@ -564,7 +558,6 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
|
||||
private func buildStateTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
state: OtherState,
|
||||
stateKey: String,
|
||||
isOutgoing: Bool) -> RoomTimelineItemProtocol? {
|
||||
guard let text = stateEventStringBuilder.buildString(for: state, sender: eventItemProxy.sender, isOutgoing: isOutgoing) else { return nil }
|
||||
return buildStateTimelineItem(for: eventItemProxy, text: text, isOutgoing: isOutgoing)
|
||||
|
||||
@@ -78,8 +78,4 @@ struct RoomTimelineItemView: View {
|
||||
VoiceMessageRoomTimelineView(timelineItem: item, playerState: context.viewState.audioPlayerStateProvider?(item.id) ?? AudioPlayerState(id: .timelineItemIdentifier(item.id), duration: 0))
|
||||
}
|
||||
}
|
||||
|
||||
var timelineGroupStyle: TimelineGroupStyle {
|
||||
viewState.groupStyle
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,6 @@ final class RoomTimelineItemViewState: Identifiable, Equatable, ObservableObject
|
||||
identifier.timelineID
|
||||
}
|
||||
|
||||
var isReactable: Bool {
|
||||
type.isReactable
|
||||
}
|
||||
|
||||
init(type: RoomTimelineItemType, groupStyle: TimelineGroupStyle) {
|
||||
self.type = type
|
||||
self.groupStyle = groupStyle
|
||||
@@ -146,18 +142,4 @@ enum RoomTimelineItemType: Equatable {
|
||||
return item.id
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether or not it is possible to send a reaction to this timeline item.
|
||||
var isReactable: Bool {
|
||||
switch self {
|
||||
case .text, .image, .video, .audio, .file, .emote, .notice, .sticker, .location, .poll, .voice:
|
||||
return true
|
||||
case .redacted, .encrypted, .unsupported, .state: // Event based items that aren't reactable
|
||||
return false
|
||||
case .timelineStart, .encryptedHistory, .separator, .readMarker, .paginationIndicator: // Virtual items are never reactable
|
||||
return false
|
||||
case .group:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
|
||||
private var backPaginationStateObservationToken: TaskHandle?
|
||||
private var roomTimelineObservationToken: TaskHandle?
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
private var timelineListener: RoomTimelineListener?
|
||||
|
||||
private let backPaginationStateSubject = PassthroughSubject<BackPaginationStatus, Never>()
|
||||
@@ -47,10 +49,6 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
innerTimelineProvider
|
||||
}
|
||||
|
||||
var hasPendingUpdatesSubscription: Bool {
|
||||
innerTimelineProvider != nil
|
||||
}
|
||||
|
||||
deinit {
|
||||
backPaginationStateObservationToken?.cancel()
|
||||
roomTimelineObservationToken?.cancel()
|
||||
|
||||
@@ -125,14 +125,3 @@ protocol TimelineProxyProtocol {
|
||||
|
||||
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, TimelineProxyError>
|
||||
}
|
||||
|
||||
extension TimelineProxyProtocol {
|
||||
func sendMessage(_ message: String,
|
||||
html: String,
|
||||
intentionalMentions: IntentionalMentions) async -> Result<Void, TimelineProxyError> {
|
||||
await sendMessage(message,
|
||||
html: html,
|
||||
inReplyTo: nil,
|
||||
intentionalMentions: intentionalMentions)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ enum UserSessionStoreError: Error {
|
||||
case missingCredentials
|
||||
case failedRestoringLogin
|
||||
case failedSettingUpSession
|
||||
case failedRefreshingRestoreToken
|
||||
}
|
||||
|
||||
protocol UserSessionStoreProtocol {
|
||||
|
||||
@@ -18,7 +18,6 @@ import Foundation
|
||||
|
||||
enum UserDiscoveryErrorType: Error {
|
||||
case failedSearchingUsers
|
||||
case failedFetchingSuggestedUsers
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
|
||||
@@ -21,7 +21,6 @@ import MatrixRustSDK
|
||||
|
||||
class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
||||
let audioRecorder: AudioRecorderProtocol
|
||||
private let audioConverter: AudioConverterProtocol
|
||||
private let voiceMessageCache: VoiceMessageCacheProtocol
|
||||
private let mediaPlayerProvider: MediaPlayerProviderProtocol
|
||||
|
||||
@@ -31,7 +30,6 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
||||
}
|
||||
|
||||
private let mp4accMimeType = "audio/m4a"
|
||||
private let waveformSamplesCount = 100
|
||||
|
||||
var isRecording: Bool {
|
||||
audioRecorder.isRecording
|
||||
@@ -53,11 +51,9 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
||||
|
||||
init(audioRecorder: AudioRecorderProtocol = AudioRecorder(),
|
||||
mediaPlayerProvider: MediaPlayerProviderProtocol,
|
||||
audioConverter: AudioConverterProtocol = AudioConverter(),
|
||||
voiceMessageCache: VoiceMessageCacheProtocol = VoiceMessageCache()) {
|
||||
self.audioRecorder = audioRecorder
|
||||
self.mediaPlayerProvider = mediaPlayerProvider
|
||||
self.audioConverter = audioConverter
|
||||
self.voiceMessageCache = voiceMessageCache
|
||||
|
||||
addObservers()
|
||||
|
||||
@@ -18,7 +18,6 @@ import Combine
|
||||
import Foundation
|
||||
|
||||
enum VoiceMessageRecorderError: Error {
|
||||
case genericError
|
||||
case missingRecordingFile
|
||||
case previewNotAvailable
|
||||
case audioRecorderError(AudioRecorderError)
|
||||
@@ -33,11 +32,9 @@ enum VoiceMessageRecorderAction {
|
||||
}
|
||||
|
||||
protocol VoiceMessageRecorderProtocol {
|
||||
var audioRecorder: AudioRecorderProtocol { get }
|
||||
var previewAudioPlayerState: AudioPlayerState? { get }
|
||||
var isRecording: Bool { get }
|
||||
var recordingURL: URL? { get }
|
||||
var recordingDuration: TimeInterval { get }
|
||||
|
||||
var actions: AnyPublisher<VoiceMessageRecorderAction, Never> { get }
|
||||
|
||||
@@ -50,7 +47,6 @@ protocol VoiceMessageRecorderProtocol {
|
||||
func seekPlayback(to progress: Double) async
|
||||
func deleteRecording() async
|
||||
|
||||
func buildRecordingWaveform() async -> Result<[UInt16], VoiceMessageRecorderError>
|
||||
func sendVoiceMessage(inRoom roomProxy: RoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result<Void, VoiceMessageRecorderError>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user