mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Removing dead code part 2 (#2235)
Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+2
-3
@@ -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] = []
|
||||
|
||||
|
||||
+1
-12
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user