Skip to content

Commit

Permalink
Introduce a feature flag for the new identity pinning violation notif…
Browse files Browse the repository at this point in the history
…ications feature.
  • Loading branch information
stefanceriu committed Oct 10, 2024
1 parent 13bc3a1 commit 4d697a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ final class AppSettings {
case fuzzyRoomListSearchEnabled
case pinningEnabled
case enableOnlySignedDeviceIsolationMode
case identityPinningViolationNotificationsEnabled
}

private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
Expand Down Expand Up @@ -278,6 +279,9 @@ final class AppSettings {
enum SlidingSyncDiscovery: Codable { case proxy, native, forceNative }
@UserPreference(key: UserDefaultsKeys.slidingSyncDiscovery, defaultValue: .native, storageType: .userDefaults(store))
var slidingSyncDiscovery: SlidingSyncDiscovery

@UserPreference(key: UserDefaultsKeys.identityPinningViolationNotificationsEnabled, defaultValue: isDevelopmentBuild, storageType: .userDefaults(store))
var identityPinningViolationNotificationsEnabled

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
}
.store(in: &cancellables)

let identityStatusChangesPublisher = roomProxy.identityStatusChangesPublisher.receive(on: DispatchQueue.main)
let identityStatusChangesPublisher = roomProxy.identityStatusChangesPublisher
.receive(on: DispatchQueue.main)
.filter { [weak self] _ in self?.appSettings.identityPinningViolationNotificationsEnabled ?? false }

Task { [weak self] in
for await changes in identityStatusChangesPublisher.values {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protocol DeveloperOptionsProtocol: AnyObject {
var hideTimelineMedia: Bool { get set }
var enableOnlySignedDeviceIsolationMode: Bool { get set }
var elementCallBaseURLOverride: URL? { get set }
var identityPinningViolationNotificationsEnabled: Bool { get set }
}

extension AppSettings: DeveloperOptionsProtocol { }
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ struct DeveloperOptionsScreen: View {
Toggle(isOn: $context.hideTimelineMedia) {
Text("Hide image & video previews")
}

Toggle(isOn: $context.identityPinningViolationNotificationsEnabled) {
Text("Identity pinning violation notifications")
}
}

Section {
Expand Down

0 comments on commit 4d697a3

Please sign in to comment.