mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
FF to enable filtering notifications by push rules (#1412)
* filtering notification by push rules * changelog * Apply suggestions from code review Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -190,6 +190,10 @@ final class AppSettings {
|
|||||||
@UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store))
|
||||||
var pusherProfileTag: String?
|
var pusherProfileTag: String?
|
||||||
|
|
||||||
|
/// Allows notifications to be filtered based on the push context of the room
|
||||||
|
@UserPreference(key: SharedUserDefaultsKeys.filterNotificationsByPushRulesEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||||
|
var filterNotificationsByPushRulesEnabled
|
||||||
|
|
||||||
// MARK: - Other
|
// MARK: - Other
|
||||||
|
|
||||||
let permalinkBaseURL: URL = "https://matrix.to"
|
let permalinkBaseURL: URL = "https://matrix.to"
|
||||||
|
|||||||
@@ -15,5 +15,5 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
enum SharedUserDefaultsKeys: String {
|
enum SharedUserDefaultsKeys: String {
|
||||||
case isEncryptionSyncEnabled
|
case filterNotificationsByPushRulesEnabled
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -49,6 +49,7 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
|||||||
var notificationSettingsEnabled: Bool { get set }
|
var notificationSettingsEnabled: Bool { get set }
|
||||||
var swiftUITimelineEnabled: Bool { get set }
|
var swiftUITimelineEnabled: Bool { get set }
|
||||||
var pollsInTimelineEnabled: Bool { get set }
|
var pollsInTimelineEnabled: Bool { get set }
|
||||||
|
var filterNotificationsByPushRulesEnabled: Bool { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppSettings: DeveloperOptionsProtocol { }
|
extension AppSettings: DeveloperOptionsProtocol { }
|
||||||
|
|||||||
+4
@@ -42,6 +42,10 @@ struct DeveloperOptionsScreen: View {
|
|||||||
Toggle(isOn: $context.notificationSettingsEnabled) {
|
Toggle(isOn: $context.notificationSettingsEnabled) {
|
||||||
Text("Show notification settings")
|
Text("Show notification settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toggle(isOn: $context.filterNotificationsByPushRulesEnabled) {
|
||||||
|
Text("Filter notifications by push rules")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section("Room creation") {
|
Section("Room creation") {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
|||||||
MXLog.info("\(tag) run with roomId: \(roomId), eventId: \(eventId)")
|
MXLog.info("\(tag) run with roomId: \(roomId), eventId: \(eventId)")
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let userSession = try NSEUserSession(credentials: credentials)
|
let userSession = try NSEUserSession(credentials: credentials, filterByPushRulesEnabled: settings.filterNotificationsByPushRulesEnabled)
|
||||||
self.userSession = userSession
|
self.userSession = userSession
|
||||||
guard let itemProxy = await userSession.notificationItemProxy(roomID: roomId, eventID: eventId) else {
|
guard let itemProxy = await userSession.notificationItemProxy(roomID: roomId, eventID: eventId) else {
|
||||||
MXLog.info("\(tag) no notification for the event, discard")
|
MXLog.info("\(tag) no notification for the event, discard")
|
||||||
|
|||||||
@@ -21,4 +21,8 @@ final class NSESettings {
|
|||||||
|
|
||||||
/// UserDefaults to be used on reads and writes.
|
/// UserDefaults to be used on reads and writes.
|
||||||
private static var store: UserDefaults! = UserDefaults(suiteName: suiteName)
|
private static var store: UserDefaults! = UserDefaults(suiteName: suiteName)
|
||||||
|
|
||||||
|
/// Allows notifications to be filtered based on the push context of the room
|
||||||
|
@UserPreference(key: SharedUserDefaultsKeys.filterNotificationsByPushRulesEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||||
|
var filterNotificationsByPushRulesEnabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ final class NSEUserSession {
|
|||||||
imageCache: .onlyOnDisk,
|
imageCache: .onlyOnDisk,
|
||||||
backgroundTaskService: nil)
|
backgroundTaskService: nil)
|
||||||
|
|
||||||
init(credentials: KeychainCredentials) throws {
|
init(credentials: KeychainCredentials, filterByPushRulesEnabled: Bool) throws {
|
||||||
userID = credentials.userID
|
userID = credentials.userID
|
||||||
baseClient = try ClientBuilder()
|
baseClient = try ClientBuilder()
|
||||||
.basePath(path: URL.sessionsBaseDirectory.path)
|
.basePath(path: URL.sessionsBaseDirectory.path)
|
||||||
@@ -34,10 +34,15 @@ final class NSEUserSession {
|
|||||||
|
|
||||||
try baseClient.restoreSession(session: credentials.restorationToken.session)
|
try baseClient.restoreSession(session: credentials.restorationToken.session)
|
||||||
|
|
||||||
notificationClient = try baseClient
|
var notificationClientBuilder = try baseClient
|
||||||
.notificationClient()
|
.notificationClient()
|
||||||
.retryDecryption(withCrossProcessLock: true)
|
.retryDecryption(withCrossProcessLock: true)
|
||||||
.finish()
|
|
||||||
|
if filterByPushRulesEnabled {
|
||||||
|
notificationClientBuilder = notificationClientBuilder.filterByPushRules()
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationClient = notificationClientBuilder.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
func notificationItemProxy(roomID: String, eventID: String) async -> NotificationItemProxyProtocol? {
|
func notificationItemProxy(roomID: String, eventID: String) async -> NotificationItemProxyProtocol? {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Added an FF to enable push rules filtering. Also invitation notifications will now be always displayed reliably.
|
||||||
Reference in New Issue
Block a user