mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -30,7 +30,9 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
|
||||
/// Not persisted for now, should be set on start.
|
||||
private var superProperties: AnalyticsEvent.SuperProperties?
|
||||
|
||||
var isRunning: Bool { postHog != nil }
|
||||
var isRunning: Bool {
|
||||
postHog != nil
|
||||
}
|
||||
|
||||
func start(analyticsConfiguration: AnalyticsConfiguration) {
|
||||
// Only start if analytics have been configured in BuildSettings
|
||||
|
||||
@@ -36,9 +36,9 @@ class Signposter {
|
||||
|
||||
private var appStartupTransaction: Span?
|
||||
|
||||
// We have a manual start method because we need to configure the ServiceLocator *before* we configure
|
||||
// Sentry but this class is created in the AnalyticsService and so spans and transactions are dropped
|
||||
// until Sentry has been configured. Therefore doing this in the init doesn't work.
|
||||
/// We have a manual start method because we need to configure the ServiceLocator *before* we configure
|
||||
/// Sentry but this class is created in the AnalyticsService and so spans and transactions are dropped
|
||||
/// until Sentry has been configured. Therefore doing this in the init doesn't work.
|
||||
func start() {
|
||||
appStartupTransaction = SentrySDK.startTransaction(name: Name.appStartup, operation: Name.appStarted)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ class AppLockService: AppLockServiceProtocol {
|
||||
private let timer: AppLockTimer
|
||||
private let unlockPolicy: LAPolicy = .deviceOwnerAuthenticationWithBiometrics
|
||||
|
||||
var isMandatory: Bool { appSettings.appLockIsMandatory }
|
||||
var isMandatory: Bool {
|
||||
appSettings.appLockIsMandatory
|
||||
}
|
||||
|
||||
var isEnabled: Bool {
|
||||
do {
|
||||
@@ -31,7 +33,9 @@ class AppLockService: AppLockServiceProtocol {
|
||||
}
|
||||
|
||||
private var isEnabledSubject: PassthroughSubject<Bool, Never> = .init()
|
||||
var isEnabledPublisher: AnyPublisher<Bool, Never> { isEnabledSubject.eraseToAnyPublisher() }
|
||||
var isEnabledPublisher: AnyPublisher<Bool, Never> {
|
||||
isEnabledSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
var biometryType: LABiometryType {
|
||||
updateBiometrics()
|
||||
@@ -49,7 +53,9 @@ class AppLockService: AppLockServiceProtocol {
|
||||
return state == context.evaluatedPolicyDomainState
|
||||
}
|
||||
|
||||
var numberOfPINAttempts: AnyPublisher<Int, Never> { appSettings.$appLockNumberOfPINAttempts }
|
||||
var numberOfPINAttempts: AnyPublisher<Int, Never> {
|
||||
appSettings.$appLockNumberOfPINAttempts
|
||||
}
|
||||
|
||||
init(keychainController: KeychainControllerProtocol, appSettings: AppSettings, context: LAContext = .init()) {
|
||||
self.keychainController = keychainController
|
||||
|
||||
@@ -15,11 +15,15 @@ import LocalAuthentication
|
||||
class LAContextMock: LAContext {
|
||||
var biometryTypeValue: LABiometryType!
|
||||
private var internalBiometryTypeValue: LABiometryType!
|
||||
override var biometryType: LABiometryType { internalBiometryTypeValue }
|
||||
override var biometryType: LABiometryType {
|
||||
internalBiometryTypeValue
|
||||
}
|
||||
|
||||
var evaluatedPolicyDomainStateValue: Data?
|
||||
private var internalEvaluatedPolicyDomainStateValue: Data?
|
||||
override var evaluatedPolicyDomainState: Data? { internalEvaluatedPolicyDomainStateValue }
|
||||
override var evaluatedPolicyDomainState: Data? {
|
||||
internalEvaluatedPolicyDomainStateValue
|
||||
}
|
||||
|
||||
override func canEvaluatePolicy(_ policy: LAPolicy, error: NSErrorPointer) -> Bool {
|
||||
let result = super.canEvaluatePolicy(policy, error: error)
|
||||
|
||||
@@ -13,9 +13,9 @@ enum AudioPlayerError: Error {
|
||||
case genericError
|
||||
}
|
||||
|
||||
// There used to be a MediaPlayerProtocol that AudioPlayerProtocol inherited from.
|
||||
// This should be called something else but we already have an AudioPlayerState,
|
||||
// AudioPlayerPlaybackState and InternalAudioPlayerState so who knows what to call this.
|
||||
/// There used to be a MediaPlayerProtocol that AudioPlayerProtocol inherited from.
|
||||
/// This should be called something else but we already have an AudioPlayerState,
|
||||
/// AudioPlayerPlaybackState and InternalAudioPlayerState so who knows what to call this.
|
||||
enum MediaPlayerState {
|
||||
case loading
|
||||
case playing
|
||||
|
||||
@@ -21,7 +21,10 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
||||
private let appHooks: AppHooks
|
||||
|
||||
private let homeserverSubject: CurrentValueSubject<LoginHomeserver, Never>
|
||||
var homeserver: CurrentValuePublisher<LoginHomeserver, Never> { homeserverSubject.asCurrentValuePublisher() }
|
||||
var homeserver: CurrentValuePublisher<LoginHomeserver, Never> {
|
||||
homeserverSubject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
private(set) var flow: AuthenticationFlow
|
||||
|
||||
init(userSessionStore: UserSessionStoreProtocol,
|
||||
|
||||
@@ -216,10 +216,12 @@ class CheckCodeSenderProxy: Equatable {
|
||||
try await underlyingSender.send(code: code)
|
||||
}
|
||||
|
||||
// Bypassed for now whilst we wait for an SDK update (however its worth noting that
|
||||
// things should still fail if the wrong code is provided, just not necessarily with
|
||||
// the right error being shown). https://github.com/matrix-org/matrix-rust-sdk/pull/5957
|
||||
func validate(checkCode: UInt8) -> Bool { true }
|
||||
/// Bypassed for now whilst we wait for an SDK update (however its worth noting that
|
||||
/// things should still fail if the wrong code is provided, just not necessarily with
|
||||
/// the right error being shown). https://github.com/matrix-org/matrix-rust-sdk/pull/5957
|
||||
func validate(checkCode: UInt8) -> Bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
extension UIImage {
|
||||
|
||||
@@ -23,7 +23,10 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
private let progressSubject = PassthroughSubject<Double, Never>()
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
var isEnabled: Bool { rageshakeURL != .disabled }
|
||||
var isEnabled: Bool {
|
||||
rageshakeURL != .disabled
|
||||
}
|
||||
|
||||
var lastCrashEventID: String?
|
||||
|
||||
init(rageshakeURLPublisher: CurrentValuePublisher<RageshakeConfiguration, Never>,
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
@preconcurrency import Combine
|
||||
import CryptoKit
|
||||
import Foundation
|
||||
import OrderedCollections
|
||||
|
||||
import MatrixRustSDK
|
||||
import OrderedCollections
|
||||
|
||||
class ClientProxy: ClientProxyProtocol {
|
||||
private let client: ClientProtocol
|
||||
|
||||
@@ -83,7 +83,7 @@ enum SessionVerificationState {
|
||||
case unverified
|
||||
}
|
||||
|
||||
// The `Decodable` conformance is just for the purpose of migration
|
||||
/// The `Decodable` conformance is just for the purpose of migration
|
||||
enum TimelineMediaVisibility: Decodable {
|
||||
case always
|
||||
case privateOnly
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
struct ComposerDraftProxy: Equatable {
|
||||
|
||||
@@ -14,7 +14,7 @@ import MatrixRustSDK
|
||||
import PushKit
|
||||
import UIKit
|
||||
|
||||
// Keep this class testable
|
||||
/// Keep this class testable
|
||||
struct TimeProvider {
|
||||
var clock: any Clock<Duration>
|
||||
var now: () -> Date
|
||||
|
||||
@@ -10,6 +10,11 @@ import MatrixRustSDK
|
||||
|
||||
/// Adds the missing methods for conformance to the protocol.
|
||||
extension KeychainControllerMock {
|
||||
func retrieveSessionFromKeychain(userId: String) throws -> Session { fatalError("Not implemented") }
|
||||
func saveSessionInKeychain(session: Session) { fatalError("Not implemented") }
|
||||
func retrieveSessionFromKeychain(userId: String) throws -> Session {
|
||||
fatalError("Not implemented")
|
||||
}
|
||||
|
||||
func saveSessionInKeychain(session: Session) {
|
||||
fatalError("Not implemented")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ class MediaPlayerProvider: MediaPlayerProviderProtocol {
|
||||
private lazy var audioPlayer = AudioPlayer()
|
||||
private var audioPlayerStates: [String: AudioPlayerState] = [:]
|
||||
|
||||
var player: AudioPlayerProtocol { audioPlayer }
|
||||
var player: AudioPlayerProtocol {
|
||||
audioPlayer
|
||||
}
|
||||
|
||||
deinit {
|
||||
audioPlayerStates = [:]
|
||||
|
||||
@@ -30,17 +30,19 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
|
||||
private var subscribedForUpdates = false
|
||||
|
||||
// A room identifier is constant and lazy stops it from being fetched
|
||||
// multiple times over FFI
|
||||
/// A room identifier is constant and lazy stops it from being fetched
|
||||
/// multiple times over FFI
|
||||
lazy var id: String = room.id()
|
||||
|
||||
var ownUserID: String { room.ownUserId() }
|
||||
var ownUserID: String {
|
||||
room.ownUserId()
|
||||
}
|
||||
|
||||
// The predecessor is set on room creation and never changes, so we lazily store it.
|
||||
/// The predecessor is set on room creation and never changes, so we lazily store it.
|
||||
lazy var predecessorRoom = room.predecessorRoom()
|
||||
|
||||
// The successor may change over time, so we access it dynamically.
|
||||
// It's suggested to observe it through the `infoPublisher`
|
||||
/// The successor may change over time, so we access it dynamically.
|
||||
/// It's suggested to observe it through the `infoPublisher`
|
||||
var successorRoom: SuccessorRoom? {
|
||||
room.successorRoom()
|
||||
}
|
||||
|
||||
@@ -12,48 +12,139 @@ import MatrixRustSDK
|
||||
struct RoomInfoProxy: RoomInfoProxyProtocol {
|
||||
let roomInfo: RoomInfo
|
||||
|
||||
var id: String { roomInfo.id }
|
||||
var creators: [String] { roomInfo.creators ?? [] }
|
||||
var displayName: String? { roomInfo.displayName }
|
||||
var rawName: String? { roomInfo.rawName }
|
||||
var topic: String? { roomInfo.topic }
|
||||
/// The room's avatar URL. Use this for editing and favour ``avatar`` for display.
|
||||
var avatarURL: URL? { roomInfo.avatarUrl.flatMap(URL.init) }
|
||||
var id: String {
|
||||
roomInfo.id
|
||||
}
|
||||
|
||||
// Here we're assuming unknown rooms are unencrypted.
|
||||
// Fortunately https://github.com/matrix-org/matrix-rust-sdk/pull/4778 makes that very much of an edge case and we
|
||||
// also automatically start a `latestEncryptionState` fetch if needed.
|
||||
// In the worst case, even if we are to assume a room is unencrypted, the SDK will still determine the correct
|
||||
// state before any message is sent.
|
||||
var isEncrypted: Bool { roomInfo.encryptionState == .encrypted }
|
||||
var creators: [String] {
|
||||
roomInfo.creators ?? []
|
||||
}
|
||||
|
||||
var displayName: String? {
|
||||
roomInfo.displayName
|
||||
}
|
||||
|
||||
var rawName: String? {
|
||||
roomInfo.rawName
|
||||
}
|
||||
|
||||
var topic: String? {
|
||||
roomInfo.topic
|
||||
}
|
||||
|
||||
/// The room's avatar URL. Use this for editing and favour ``avatar`` for display.
|
||||
var avatarURL: URL? {
|
||||
roomInfo.avatarUrl.flatMap(URL.init)
|
||||
}
|
||||
|
||||
/// Here we're assuming unknown rooms are unencrypted.
|
||||
/// Fortunately https://github.com/matrix-org/matrix-rust-sdk/pull/4778 makes that very much of an edge case and we
|
||||
/// also automatically start a `latestEncryptionState` fetch if needed.
|
||||
/// In the worst case, even if we are to assume a room is unencrypted, the SDK will still determine the correct
|
||||
/// state before any message is sent.
|
||||
var isEncrypted: Bool {
|
||||
roomInfo.encryptionState == .encrypted
|
||||
}
|
||||
|
||||
var isDirect: Bool { roomInfo.isDirect }
|
||||
var isSpace: Bool { roomInfo.isSpace }
|
||||
var isDirect: Bool {
|
||||
roomInfo.isDirect
|
||||
}
|
||||
|
||||
var isSpace: Bool {
|
||||
roomInfo.isSpace
|
||||
}
|
||||
|
||||
var successor: SuccessorRoom? { roomInfo.successorRoom }
|
||||
var isFavourite: Bool { roomInfo.isFavourite }
|
||||
var canonicalAlias: String? { roomInfo.canonicalAlias }
|
||||
var alternativeAliases: [String] { roomInfo.alternativeAliases }
|
||||
var membership: Membership { roomInfo.membership }
|
||||
var inviter: RoomMemberProxyProtocol? { roomInfo.inviter.map(RoomMemberProxy.init) }
|
||||
var heroes: [RoomHero] { roomInfo.heroes }
|
||||
var activeMembersCount: Int { Int(roomInfo.activeMembersCount) }
|
||||
var invitedMembersCount: Int { Int(roomInfo.invitedMembersCount) }
|
||||
var joinedMembersCount: Int { Int(roomInfo.joinedMembersCount) }
|
||||
var highlightCount: Int { Int(roomInfo.highlightCount) }
|
||||
var notificationCount: Int { Int(roomInfo.notificationCount) }
|
||||
var cachedUserDefinedNotificationMode: RoomNotificationMode? { roomInfo.cachedUserDefinedNotificationMode }
|
||||
var hasRoomCall: Bool { roomInfo.hasRoomCall }
|
||||
var activeRoomCallParticipants: [String] { roomInfo.activeRoomCallParticipants }
|
||||
var isMarkedUnread: Bool { roomInfo.isMarkedUnread }
|
||||
var unreadMessagesCount: UInt { UInt(roomInfo.numUnreadMessages) }
|
||||
var unreadNotificationsCount: UInt { UInt(roomInfo.numUnreadNotifications) }
|
||||
var unreadMentionsCount: UInt { UInt(roomInfo.numUnreadMentions) }
|
||||
var pinnedEventIDs: Set<String> { Set(roomInfo.pinnedEventIds) }
|
||||
var joinRule: JoinRule? { roomInfo.joinRule }
|
||||
var historyVisibility: RoomHistoryVisibility { roomInfo.historyVisibility }
|
||||
var successor: SuccessorRoom? {
|
||||
roomInfo.successorRoom
|
||||
}
|
||||
|
||||
var isFavourite: Bool {
|
||||
roomInfo.isFavourite
|
||||
}
|
||||
|
||||
var canonicalAlias: String? {
|
||||
roomInfo.canonicalAlias
|
||||
}
|
||||
|
||||
var alternativeAliases: [String] {
|
||||
roomInfo.alternativeAliases
|
||||
}
|
||||
|
||||
var membership: Membership {
|
||||
roomInfo.membership
|
||||
}
|
||||
|
||||
var inviter: RoomMemberProxyProtocol? {
|
||||
roomInfo.inviter.map(RoomMemberProxy.init)
|
||||
}
|
||||
|
||||
var heroes: [RoomHero] {
|
||||
roomInfo.heroes
|
||||
}
|
||||
|
||||
var activeMembersCount: Int {
|
||||
Int(roomInfo.activeMembersCount)
|
||||
}
|
||||
|
||||
var invitedMembersCount: Int {
|
||||
Int(roomInfo.invitedMembersCount)
|
||||
}
|
||||
|
||||
var joinedMembersCount: Int {
|
||||
Int(roomInfo.joinedMembersCount)
|
||||
}
|
||||
|
||||
var highlightCount: Int {
|
||||
Int(roomInfo.highlightCount)
|
||||
}
|
||||
|
||||
var notificationCount: Int {
|
||||
Int(roomInfo.notificationCount)
|
||||
}
|
||||
|
||||
var cachedUserDefinedNotificationMode: RoomNotificationMode? {
|
||||
roomInfo.cachedUserDefinedNotificationMode
|
||||
}
|
||||
|
||||
var hasRoomCall: Bool {
|
||||
roomInfo.hasRoomCall
|
||||
}
|
||||
|
||||
var activeRoomCallParticipants: [String] {
|
||||
roomInfo.activeRoomCallParticipants
|
||||
}
|
||||
|
||||
var isMarkedUnread: Bool {
|
||||
roomInfo.isMarkedUnread
|
||||
}
|
||||
|
||||
var unreadMessagesCount: UInt {
|
||||
UInt(roomInfo.numUnreadMessages)
|
||||
}
|
||||
|
||||
var unreadNotificationsCount: UInt {
|
||||
UInt(roomInfo.numUnreadNotifications)
|
||||
}
|
||||
|
||||
var unreadMentionsCount: UInt {
|
||||
UInt(roomInfo.numUnreadMentions)
|
||||
}
|
||||
|
||||
var pinnedEventIDs: Set<String> {
|
||||
Set(roomInfo.pinnedEventIds)
|
||||
}
|
||||
|
||||
var joinRule: JoinRule? {
|
||||
roomInfo.joinRule
|
||||
}
|
||||
|
||||
var historyVisibility: RoomHistoryVisibility {
|
||||
roomInfo.historyVisibility
|
||||
}
|
||||
|
||||
var powerLevels: RoomPowerLevelsProxyProtocol? { RoomPowerLevelsProxy(roomInfo.powerLevels) }
|
||||
var powerLevels: RoomPowerLevelsProxyProtocol? {
|
||||
RoomPowerLevelsProxy(roomInfo.powerLevels)
|
||||
}
|
||||
}
|
||||
|
||||
struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol {
|
||||
@@ -61,17 +152,51 @@ struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol {
|
||||
|
||||
let successor: SuccessorRoom? = nil
|
||||
|
||||
var id: String { roomPreviewInfo.roomId }
|
||||
var displayName: String? { roomPreviewInfo.name }
|
||||
var heroes: [RoomHero] { roomPreviewInfo.heroes ?? [] }
|
||||
var topic: String? { roomPreviewInfo.topic }
|
||||
var canonicalAlias: String? { roomPreviewInfo.canonicalAlias }
|
||||
var avatarURL: URL? { roomPreviewInfo.avatarUrl.flatMap(URL.init) }
|
||||
var isDirect: Bool { roomPreviewInfo.isDirect ?? false }
|
||||
var isSpace: Bool { roomPreviewInfo.roomType == .space }
|
||||
var activeMembersCount: Int { Int(roomPreviewInfo.numActiveMembers ?? roomPreviewInfo.numJoinedMembers) }
|
||||
var joinedMembersCount: Int { Int(roomPreviewInfo.numJoinedMembers) }
|
||||
var id: String {
|
||||
roomPreviewInfo.roomId
|
||||
}
|
||||
|
||||
var displayName: String? {
|
||||
roomPreviewInfo.name
|
||||
}
|
||||
|
||||
var heroes: [RoomHero] {
|
||||
roomPreviewInfo.heroes ?? []
|
||||
}
|
||||
|
||||
var topic: String? {
|
||||
roomPreviewInfo.topic
|
||||
}
|
||||
|
||||
var canonicalAlias: String? {
|
||||
roomPreviewInfo.canonicalAlias
|
||||
}
|
||||
|
||||
var avatarURL: URL? {
|
||||
roomPreviewInfo.avatarUrl.flatMap(URL.init)
|
||||
}
|
||||
|
||||
var isDirect: Bool {
|
||||
roomPreviewInfo.isDirect ?? false
|
||||
}
|
||||
|
||||
var isSpace: Bool {
|
||||
roomPreviewInfo.roomType == .space
|
||||
}
|
||||
|
||||
var activeMembersCount: Int {
|
||||
Int(roomPreviewInfo.numActiveMembers ?? roomPreviewInfo.numJoinedMembers)
|
||||
}
|
||||
|
||||
var joinedMembersCount: Int {
|
||||
Int(roomPreviewInfo.numJoinedMembers)
|
||||
}
|
||||
|
||||
var joinRule: JoinRule? { roomPreviewInfo.joinRule }
|
||||
var membership: Membership? { roomPreviewInfo.membership }
|
||||
var joinRule: JoinRule? {
|
||||
roomPreviewInfo.joinRule
|
||||
}
|
||||
|
||||
var membership: Membership? {
|
||||
roomPreviewInfo.membership
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@ final class RoomMemberProxy: RoomMemberProxyProtocol {
|
||||
self.member = member
|
||||
}
|
||||
|
||||
var userID: String { member.userId }
|
||||
var userID: String {
|
||||
member.userId
|
||||
}
|
||||
|
||||
var displayName: String? { member.displayName }
|
||||
var displayName: String? {
|
||||
member.displayName
|
||||
}
|
||||
|
||||
var disambiguatedDisplayName: String? {
|
||||
guard let displayName else {
|
||||
@@ -28,13 +32,23 @@ final class RoomMemberProxy: RoomMemberProxyProtocol {
|
||||
return member.isNameAmbiguous ? "\(displayName) (\(userID))" : displayName
|
||||
}
|
||||
|
||||
var avatarURL: URL? { member.avatarUrl.flatMap(URL.init(string:)) }
|
||||
var avatarURL: URL? {
|
||||
member.avatarUrl.flatMap(URL.init(string:))
|
||||
}
|
||||
|
||||
var membership: MembershipState { member.membership }
|
||||
var membership: MembershipState {
|
||||
member.membership
|
||||
}
|
||||
|
||||
var membershipChangeReason: String? { member.membershipChangeReason }
|
||||
var membershipChangeReason: String? {
|
||||
member.membershipChangeReason
|
||||
}
|
||||
|
||||
var isIgnored: Bool { member.isIgnored }
|
||||
var isIgnored: Bool {
|
||||
member.isIgnored
|
||||
}
|
||||
|
||||
var powerLevel: RoomPowerLevel { .init(rustPowerLevel: member.powerLevel) }
|
||||
var powerLevel: RoomPowerLevel {
|
||||
.init(rustPowerLevel: member.powerLevel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,5 +59,7 @@ extension [RoomMemberProxyProtocol] {
|
||||
}
|
||||
|
||||
extension RoomMemberProxyProtocol {
|
||||
var role: RoomRole { .init(powerLevel: powerLevel) }
|
||||
var role: RoomRole {
|
||||
.init(powerLevel: powerLevel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ struct RoomPermissionsSetting: Identifiable {
|
||||
static let allValues: [(title: String, tag: RoomRole)] = [(title: L10n.screenRoomChangePermissionsAdministrators, tag: .administrator),
|
||||
(title: L10n.screenRoomChangePermissionsModerators, tag: .moderator),
|
||||
(title: L10n.screenRoomChangePermissionsEveryone, tag: .user)]
|
||||
var id: KeyPath<RoomPermissions, Int64> { keyPath }
|
||||
var id: KeyPath<RoomPermissions, Int64> {
|
||||
keyPath
|
||||
}
|
||||
|
||||
/// The title of this setting.
|
||||
let title: String
|
||||
@@ -69,16 +71,6 @@ struct RoomPermissionsSetting: Identifiable {
|
||||
Self.allValues.filter { $0.tag <= ownPowerLevel.role }
|
||||
}
|
||||
}
|
||||
|
||||
init(title: String,
|
||||
value: Int64,
|
||||
ownPowerLevel: RoomPowerLevel,
|
||||
keyPath: KeyPath<RoomPermissions, Int64>) {
|
||||
self.ownPowerLevel = ownPowerLevel
|
||||
self.title = title
|
||||
self.value = value
|
||||
self.keyPath = keyPath
|
||||
}
|
||||
}
|
||||
|
||||
struct RoomPermissions {
|
||||
|
||||
@@ -214,7 +214,7 @@ extension JoinedRoomProxyProtocol {
|
||||
return membersPublisher.value
|
||||
}
|
||||
|
||||
// This is a horrible workaround for not having any server names available when using tombstone links with v12 room IDs.
|
||||
/// This is a horrible workaround for not having any server names available when using tombstone links with v12 room IDs.
|
||||
func knownServerNames(maxCount: Int) -> any Sequence<String> {
|
||||
membersPublisher.value
|
||||
.prefix(1000) // No need to go crazy here…
|
||||
|
||||
@@ -62,21 +62,33 @@ struct RoomSummary {
|
||||
let isFavourite: Bool
|
||||
let isTombstoned: Bool
|
||||
|
||||
var hasUnreadMessages: Bool { unreadMessagesCount > 0 }
|
||||
var hasUnreadMentions: Bool { unreadMentionsCount > 0 }
|
||||
var hasUnreadNotifications: Bool { unreadNotificationsCount > 0 }
|
||||
var isMuted: Bool { notificationMode == .mute }
|
||||
var hasUnreadMessages: Bool {
|
||||
unreadMessagesCount > 0
|
||||
}
|
||||
|
||||
var hasUnreadMentions: Bool {
|
||||
unreadMentionsCount > 0
|
||||
}
|
||||
|
||||
var hasUnreadNotifications: Bool {
|
||||
unreadNotificationsCount > 0
|
||||
}
|
||||
|
||||
var isMuted: Bool {
|
||||
notificationMode == .mute
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomSummary: CustomStringConvertible {
|
||||
var description: String { """
|
||||
RoomSummary: - id: \(id) \
|
||||
- isDirect: \(isDirect) \
|
||||
- unreadMessagesCount: \(unreadMessagesCount) \
|
||||
- unreadMentionsCount: \(unreadMentionsCount) \
|
||||
- unreadNotificationsCount: \(unreadNotificationsCount) \
|
||||
- notificationMode: \(notificationMode?.rawValue ?? "nil")
|
||||
"""
|
||||
var description: String {
|
||||
"""
|
||||
RoomSummary: - id: \(id) \
|
||||
- isDirect: \(isDirect) \
|
||||
- unreadMessagesCount: \(unreadMessagesCount) \
|
||||
- unreadMentionsCount: \(unreadMentionsCount) \
|
||||
- unreadNotificationsCount: \(unreadNotificationsCount) \
|
||||
- notificationMode: \(notificationMode?.rawValue ?? "nil")
|
||||
"""
|
||||
}
|
||||
|
||||
/// Used where summaries are shown in a list e.g. message forwarding,
|
||||
@@ -135,7 +147,7 @@ extension RoomSummary {
|
||||
isTombstoned = false
|
||||
}
|
||||
|
||||
// This doesn't have to work properly for DM invites, the heroes are always empty
|
||||
/// This doesn't have to work properly for DM invites, the heroes are always empty
|
||||
var avatar: RoomAvatar {
|
||||
guard !isTombstoned else {
|
||||
return .tombstoned
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
final class RoomDirectorySearchProxy: RoomDirectorySearchProxyProtocol {
|
||||
|
||||
@@ -18,8 +18,13 @@ final class LeaveSpaceHandleProxy {
|
||||
|
||||
private let leaveHandle: LeaveSpaceHandleProtocol
|
||||
|
||||
var canLeave: Bool { mode != .spaceNeedsNewOwner }
|
||||
var selectedCount: Int { rooms.count { $0.isSelected } }
|
||||
var canLeave: Bool {
|
||||
mode != .spaceNeedsNewOwner
|
||||
}
|
||||
|
||||
var selectedCount: Int {
|
||||
rooms.count { $0.isSelected }
|
||||
}
|
||||
|
||||
init(spaceID: String, leaveHandle: LeaveSpaceHandleProtocol) {
|
||||
id = spaceID
|
||||
|
||||
@@ -10,7 +10,9 @@ import Combine
|
||||
import MatrixRustSDK
|
||||
|
||||
class SpaceRoomListProxy: SpaceRoomListProxyProtocol {
|
||||
var id: String { spaceServiceRoomPublisher.value.id }
|
||||
var id: String {
|
||||
spaceServiceRoomPublisher.value.id
|
||||
}
|
||||
|
||||
private let spaceRoomList: SpaceRoomListProtocol
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ struct SpaceServiceFilter: Identifiable, Equatable {
|
||||
descendants = Set(filter.descendants)
|
||||
}
|
||||
|
||||
// Same rooms might appear on multiple levels
|
||||
/// Same rooms might appear on multiple levels
|
||||
var id: String {
|
||||
room.id + "\(level)"
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ struct GeoURI: Hashable {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
// Parse a geo URI string like "geo:53.99803101552848,-8.25347900390625;u=10"
|
||||
/// Parse a geo URI string like "geo:53.99803101552848,-8.25347900390625;u=10"
|
||||
private static func parseGeoURI(from string: String) -> GeoURI? {
|
||||
guard
|
||||
let matchOutput = try? RegexGeoURI.standard.wholeMatch(in: string)?.output,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import MatrixRustSDK
|
||||
import WysiwygComposer
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ class MockTimelineController: TimelineControllerProtocol {
|
||||
var roomProxy: JoinedRoomProxyProtocol?
|
||||
var timelineProxy: TimelineProxyProtocol?
|
||||
|
||||
var roomID: String { roomProxy?.id ?? "MockRoomIdentifier" }
|
||||
var roomID: String {
|
||||
roomProxy?.id ?? "MockRoomIdentifier"
|
||||
}
|
||||
|
||||
var timelineKind: TimelineKind
|
||||
|
||||
let callbacks = PassthroughSubject<TimelineControllerCallback, Never>()
|
||||
|
||||
@@ -250,8 +250,8 @@ class TimelineController: TimelineControllerProtocol {
|
||||
await activeTimeline.messageEventContent(for: timelineItemID)
|
||||
}
|
||||
|
||||
// Handle this parallel to the timeline items so we're not forced
|
||||
// to bundle the Rust side objects within them
|
||||
/// Handle this parallel to the timeline items so we're not forced
|
||||
/// to bundle the Rust side objects within them
|
||||
func debugInfo(for itemID: TimelineItemIdentifier) -> TimelineItemDebugInfo {
|
||||
for timelineItemProxy in activeTimelineItemProvider.itemProxies {
|
||||
switch timelineItemProxy {
|
||||
@@ -428,14 +428,12 @@ class TimelineController: TimelineControllerProtocol {
|
||||
let isLastItem = index == collapsibleChunks.indices.last
|
||||
|
||||
let items = collapsibleChunk.compactMap { itemProxy in
|
||||
let timelineItem = self.buildTimelineItem(for: itemProxy,
|
||||
isDM: isDM,
|
||||
hasPredecessor: hasPredecessor,
|
||||
roomDisplayName: displayName,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
activeTimeline: activeTimeline)
|
||||
|
||||
return timelineItem
|
||||
self.buildTimelineItem(for: itemProxy,
|
||||
isDM: isDM,
|
||||
hasPredecessor: hasPredecessor,
|
||||
roomDisplayName: displayName,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
activeTimeline: activeTimeline)
|
||||
}
|
||||
|
||||
if items.isEmpty {
|
||||
|
||||
@@ -14,5 +14,7 @@ struct ReadReceipt: Hashable {
|
||||
}
|
||||
|
||||
extension ReadReceipt: Identifiable {
|
||||
var id: String { userID }
|
||||
var id: String {
|
||||
userID
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -10,11 +10,11 @@ import Foundation
|
||||
|
||||
/// Properties of a matrix event that are common between all timeline items.
|
||||
struct RoomTimelineItemProperties: Hashable {
|
||||
// Information on the item this one replying to
|
||||
/// Information on the item this one replying to
|
||||
var replyDetails: TimelineItemReplyDetails?
|
||||
// Whether it's part of a thread or not
|
||||
/// Whether it's part of a thread or not
|
||||
var isThreaded = false
|
||||
// Information about the thread this message is the root of, if any
|
||||
/// Information about the thread this message is the root of, if any
|
||||
var threadSummary: TimelineItemThreadSummary?
|
||||
/// Whether the item has been edited.
|
||||
var isEdited = false
|
||||
|
||||
@@ -624,7 +624,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
return .init(body: messageContent.body, formattedBody: formattedBody, formattedBodyHTMLString: htmlBody)
|
||||
}
|
||||
|
||||
// This fixes the issue of the name not belonging to the first <p> defined paragraph
|
||||
/// This fixes the issue of the name not belonging to the first <p> defined paragraph
|
||||
private func buildEmoteFormattedBodyFromHTML(html: String, name: String) -> AttributedString? {
|
||||
let htmlBodyPlaceholder = "{htmlBodyPlaceholder}"
|
||||
var finalString = AttributedString(L10n.commonEmote(name, htmlBodyPlaceholder))
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
protocol RoomTimelineItemFactoryProtocol {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//
|
||||
import OrderedCollections
|
||||
|
||||
// Copyright 2025 Element Creations Ltd.
|
||||
// Copyright 2022-2025 New Vector Ltd.
|
||||
//
|
||||
@@ -7,8 +9,6 @@
|
||||
//
|
||||
import SwiftUI
|
||||
|
||||
import OrderedCollections
|
||||
|
||||
struct RoomTimelineItemView: View {
|
||||
@Environment(\.timelineContext) var context
|
||||
@ObservedObject var viewState: RoomTimelineItemViewState
|
||||
|
||||
@@ -12,8 +12,13 @@ struct SessionDirectories: Hashable, Codable {
|
||||
let dataDirectory: URL
|
||||
let cacheDirectory: URL
|
||||
|
||||
var dataPath: String { dataDirectory.path(percentEncoded: false) }
|
||||
var cachePath: String { cacheDirectory.path(percentEncoded: false) }
|
||||
var dataPath: String {
|
||||
dataDirectory.path(percentEncoded: false)
|
||||
}
|
||||
|
||||
var cachePath: String {
|
||||
cacheDirectory.path(percentEncoded: false)
|
||||
}
|
||||
|
||||
// MARK: Data Management
|
||||
|
||||
|
||||
@@ -16,11 +16,18 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
private let appHooks: AppHooks
|
||||
|
||||
/// Whether or not there are sessions in the store.
|
||||
var hasSessions: Bool { !keychainController.restorationTokens().isEmpty }
|
||||
var hasSessions: Bool {
|
||||
!keychainController.restorationTokens().isEmpty
|
||||
}
|
||||
|
||||
/// All the user IDs managed by the store.
|
||||
var userIDs: [String] { keychainController.restorationTokens().map(\.userID) }
|
||||
var userIDs: [String] {
|
||||
keychainController.restorationTokens().map(\.userID)
|
||||
}
|
||||
|
||||
var clientSessionDelegate: ClientSessionDelegate { keychainController }
|
||||
var clientSessionDelegate: ClientSessionDelegate {
|
||||
keychainController
|
||||
}
|
||||
|
||||
init(keychainController: KeychainControllerProtocol,
|
||||
appSettings: AppSettings,
|
||||
|
||||
@@ -64,5 +64,7 @@ extension SearchUsersResultsProxy {
|
||||
}
|
||||
|
||||
extension UserProfileProxy: Identifiable {
|
||||
var id: String { userID }
|
||||
var id: String {
|
||||
userID
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user