Skip to content

Commit

Permalink
Merge branch 'develop' into doug/compound-uicolor
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave authored Jul 26, 2023
2 parents 41cc14c + ed28bc5 commit 759208b
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 26 deletions.
4 changes: 0 additions & 4 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ final class AppSettings {
/// Tag describing which set of device specific rules a pusher executes.
@UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store))
var pusherProfileTag: String?

/// Tag describing if the app and the NSE should use the encryption sync
@UserPreference(key: SharedUserDefaultsKeys.isEncryptionSyncEnabled, defaultValue: true, storageType: .userDefaults(store))
var isEncryptionSyncEnabled

// MARK: - Other

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var shouldCollapseRoomStateEvents: Bool { get set }
var userSuggestionsEnabled: Bool { get set }
var readReceiptsEnabled: Bool { get set }
var isEncryptionSyncEnabled: Bool { get set }
var notificationSettingsEnabled: Bool { get set }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ struct DeveloperOptionsScreen: View {
}

Section("Notifications") {
Toggle(isOn: $context.isEncryptionSyncEnabled) {
Text("Use notification encryption sync")
Text("Requires app reboot")
}

Toggle(isOn: $context.notificationSettingsEnabled) {
Text("Show notification settings")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ struct SettingsScreen: View {
versionText
.frame(maxWidth: .infinity)

context.viewState.deviceID.map(Text.init)
if let deviceID = context.viewState.deviceID {
Text(deviceID)
}
}
.compoundFormSectionFooter()
.textSelection(.enabled)
.padding(.top, 24)
}
.compoundFormSection()
Expand Down Expand Up @@ -201,7 +204,8 @@ private extension TimelineStyle {

struct SettingsScreen_Previews: PreviewProvider {
static let viewModel = {
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com",
deviceID: "AAAAAAAAAAA"),
mediaProvider: MockMediaProvider())
ServiceLocator.shared.settings.notificationSettingsEnabled = true
return SettingsScreenViewModel(userSession: userSession,
Expand Down
4 changes: 2 additions & 2 deletions ElementX/Sources/Services/Client/ClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ClientProxy: ClientProxyProtocol {
}
}

var deviceId: String? {
var deviceID: String? {
do {
return try client.deviceId()
} catch {
Expand Down Expand Up @@ -406,7 +406,7 @@ class ClientProxy: ClientProxyProtocol {
do {
let syncService = try await client
.syncService()
.withEncryptionSync(withCrossProcessLock: appSettings.isEncryptionSyncEnabled,
.withEncryptionSync(withCrossProcessLock: true,
appIdentifier: "MainApp")
.finish()
let roomListService = syncService.roomListService()
Expand Down
2 changes: 1 addition & 1 deletion ElementX/Sources/Services/Client/ClientProxyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {

var userID: String { get }

var deviceId: String? { get }
var deviceID: String? { get }

var homeserver: String { get }

Expand Down
5 changes: 3 additions & 2 deletions ElementX/Sources/Services/Client/MockClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MockClientProxy: ClientProxyProtocol {
let callbacks = PassthroughSubject<ClientProxyCallback, Never>()

let userID: String
let deviceId: String? = nil
let deviceID: String?
let homeserver = ""
let restorationToken: RestorationToken? = nil

Expand All @@ -34,8 +34,9 @@ class MockClientProxy: ClientProxyProtocol {

var isSyncing: Bool { false }

internal init(userID: String, roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()) {
internal init(userID: String, deviceID: String? = nil, roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()) {
self.userID = userID
self.deviceID = deviceID
self.roomSummaryProvider = roomSummaryProvider
}

Expand Down
2 changes: 1 addition & 1 deletion ElementX/Sources/Services/Session/MockUserSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct MockUserSession: UserSessionProtocol {
let callbacks = PassthroughSubject<UserSessionCallback, Never>()
let sessionVerificationController: SessionVerificationControllerProxyProtocol? = nil
var userID: String { clientProxy.userID }
var deviceID: String? { clientProxy.deviceId }
var deviceID: String? { clientProxy.deviceID }
var homeserver: String { clientProxy.homeserver }
let clientProxy: ClientProxyProtocol
let mediaProvider: MediaProviderProtocol
Expand Down
2 changes: 1 addition & 1 deletion ElementX/Sources/Services/Session/UserSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UserSession: UserSessionProtocol {
private var authErrorCancellable: AnyCancellable?

var userID: String { clientProxy.userID }
var deviceID: String? { clientProxy.deviceId }
var deviceID: String? { clientProxy.deviceID }
var homeserver: String { clientProxy.homeserver }

let clientProxy: ClientProxyProtocol
Expand Down
2 changes: 1 addition & 1 deletion NSE/Sources/NotificationServiceExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
MXLog.info("\(tag) run with roomId: \(roomId), eventId: \(eventId)")

do {
let userSession = try NSEUserSession(credentials: credentials, isEncryptionSyncEnabled: settings.isEncryptionSyncEnabled)
let userSession = try NSEUserSession(credentials: credentials)
self.userSession = userSession
guard let itemProxy = await userSession.notificationItemProxy(roomID: roomId, eventID: eventId) else {
MXLog.info("\(tag) no notification for the event, discard")
Expand Down
4 changes: 0 additions & 4 deletions NSE/Sources/Other/NSESettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ final class NSESettings {

/// UserDefaults to be used on reads and writes.
private static var store: UserDefaults! = UserDefaults(suiteName: suiteName)

/// Tag describing if the app and the NSE should use the encryption sync
@UserPreference(key: SharedUserDefaultsKeys.isEncryptionSyncEnabled, defaultValue: true, storageType: .userDefaults(store))
var isEncryptionSyncEnabled
}
4 changes: 2 additions & 2 deletions NSE/Sources/Other/NSEUserSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class NSEUserSession {
imageCache: .onlyOnDisk,
backgroundTaskService: nil)

init(credentials: KeychainCredentials, isEncryptionSyncEnabled: Bool) throws {
init(credentials: KeychainCredentials) throws {
userID = credentials.userID
baseClient = try ClientBuilder()
.basePath(path: URL.sessionsBaseDirectory.path)
Expand All @@ -36,7 +36,7 @@ final class NSEUserSession {

notificationClient = baseClient
.notificationClient()
.retryDecryption(withCrossProcessLock: isEncryptionSyncEnabled)
.retryDecryption(withCrossProcessLock: true)
.finish()
}

Expand Down
1 change: 1 addition & 0 deletions changelog.d/623.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make the app version and the device ID copyable in the Settings screen.

0 comments on commit 759208b

Please sign in to comment.