mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
Remove the room list notification count feature flag.
The room list now always shows the unread notification count for highlighted rooms and the app icon badge always uses the SDK's own unread notification count, both in the app and in the NSE. The push payload's unread count is no longer used, so its UNNotificationContent helper and user info key have been removed along with the setting, its developer options toggle and the feature-disabled unit test.
This commit is contained in:
@@ -31,7 +31,6 @@ nonisolated protocol CommonSettingsProtocol: AnyObject, Sendable {
|
|||||||
var enableOnlySignedDeviceIsolationMode: Bool { get }
|
var enableOnlySignedDeviceIsolationMode: Bool { get }
|
||||||
var threadsEnabled: Bool { get }
|
var threadsEnabled: Bool { get }
|
||||||
var hideQuietNotificationAlerts: Bool { get }
|
var hideQuietNotificationAlerts: Bool { get }
|
||||||
var roomListNotificationCountEnabled: Bool { get }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nonisolated enum AppBuildType {
|
nonisolated enum AppBuildType {
|
||||||
@@ -358,9 +357,6 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
|||||||
@UserPreference(defaultValue: RoomListActivityVisibility.current)
|
@UserPreference(defaultValue: RoomListActivityVisibility.current)
|
||||||
var roomListActivityVisibility: RoomListActivityVisibility
|
var roomListActivityVisibility: RoomListActivityVisibility
|
||||||
|
|
||||||
@UserPreference(defaultValue: false)
|
|
||||||
var roomListNotificationCountEnabled: Bool
|
|
||||||
|
|
||||||
// MARK: - Search Screen
|
// MARK: - Search Screen
|
||||||
|
|
||||||
/// The queries the user searched for and the rooms they opened from the results, most recent first.
|
/// The queries the user searched for and the rooms they opened from the results, most recent first.
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ nonisolated extension UNNotificationContent {
|
|||||||
@objc var threadRootEventID: String? {
|
@objc var threadRootEventID: String? {
|
||||||
userInfo[NotificationConstants.UserInfoKey.threadRootEventIdentifier] as? String
|
userInfo[NotificationConstants.UserInfoKey.threadRootEventIdentifier] as? String
|
||||||
}
|
}
|
||||||
|
|
||||||
var unreadCount: Int? {
|
|
||||||
userInfo[NotificationConstants.UserInfoKey.unreadCount] as? Int
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nonisolated extension UNMutableNotificationContent {
|
nonisolated extension UNMutableNotificationContent {
|
||||||
|
|||||||
@@ -106,8 +106,6 @@ struct HomeScreenViewState: BindableState {
|
|||||||
|
|
||||||
var roomListActivityVisibility: RoomListActivityVisibility = .current
|
var roomListActivityVisibility: RoomListActivityVisibility = .current
|
||||||
|
|
||||||
var roomListNotificationCountEnabled = false
|
|
||||||
|
|
||||||
var reportRoomEnabled = false
|
var reportRoomEnabled = false
|
||||||
|
|
||||||
var shouldShowSpaceFilters = false
|
var shouldShowSpaceFilters = false
|
||||||
|
|||||||
@@ -120,10 +120,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
appSettings.roomListNotificationCountEnabledPublisher
|
|
||||||
.weakAssign(to: \.state.roomListNotificationCountEnabled, on: self)
|
|
||||||
.store(in: &cancellables)
|
|
||||||
|
|
||||||
appSettings.seenInvitesPublisher
|
appSettings.seenInvitesPublisher
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.sink { [weak self] _ in
|
.sink { [weak self] _ in
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ struct HomeScreenRoomCell: View {
|
|||||||
|
|
||||||
let room: HomeScreenRoom
|
let room: HomeScreenRoom
|
||||||
var roomListActivityVisibility: RoomListActivityVisibility = .current
|
var roomListActivityVisibility: RoomListActivityVisibility = .current
|
||||||
var roomListNotificationCountEnabled = false
|
|
||||||
let isSelected: Bool
|
let isSelected: Bool
|
||||||
let mediaProvider: MediaProviderProtocol!
|
let mediaProvider: MediaProviderProtocol!
|
||||||
let action: (HomeScreenViewAction) -> Void
|
let action: (HomeScreenViewAction) -> Void
|
||||||
@@ -158,7 +157,7 @@ struct HomeScreenRoomCell: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if room.badges.isDotShown {
|
if room.badges.isDotShown {
|
||||||
if roomListNotificationCountEnabled, room.isHighlighted, room.badges.notificationCount > 0 {
|
if room.isHighlighted, room.badges.notificationCount > 0 {
|
||||||
Text(formattedNotificationCount)
|
Text(formattedNotificationCount)
|
||||||
.font(.compound.bodySMSemibold)
|
.font(.compound.bodySMSemibold)
|
||||||
.foregroundColor(.compound.textOnSolidPrimary)
|
.foregroundColor(.compound.textOnSolidPrimary)
|
||||||
@@ -255,7 +254,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
|||||||
|
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
ForEach(notificationsStateRooms) { room in
|
ForEach(notificationsStateRooms) { room in
|
||||||
HomeScreenRoomCell(room: room, roomListNotificationCountEnabled: true, isSelected: false, mediaProvider: MediaProviderMock(.init())) { _ in }
|
HomeScreenRoomCell(room: room, isSelected: false, mediaProvider: MediaProviderMock(.init())) { _ in }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.previewLayout(.sizeThatFits)
|
.previewLayout(.sizeThatFits)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ struct HomeScreenRoomList: View {
|
|||||||
|
|
||||||
HomeScreenRoomCell(room: room,
|
HomeScreenRoomCell(room: room,
|
||||||
roomListActivityVisibility: context.viewState.roomListActivityVisibility,
|
roomListActivityVisibility: context.viewState.roomListActivityVisibility,
|
||||||
roomListNotificationCountEnabled: context.viewState.roomListNotificationCountEnabled,
|
|
||||||
isSelected: isSelected,
|
isSelected: isSelected,
|
||||||
mediaProvider: context.mediaProvider,
|
mediaProvider: context.mediaProvider,
|
||||||
action: context.send)
|
action: context.send)
|
||||||
|
|||||||
-1
@@ -58,7 +58,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
|||||||
var focusEventOnNotificationTap: Bool { get set }
|
var focusEventOnNotificationTap: Bool { get set }
|
||||||
|
|
||||||
var roomListActivityVisibility: RoomListActivityVisibility { get set }
|
var roomListActivityVisibility: RoomListActivityVisibility { get set }
|
||||||
var roomListNotificationCountEnabled: Bool { get set }
|
|
||||||
var elementCallBaseURLOverride: URL? { get set }
|
var elementCallBaseURLOverride: URL? { get set }
|
||||||
|
|
||||||
var fuzzyRoomListSearchEnabled: Bool { get set }
|
var fuzzyRoomListSearchEnabled: Bool { get set }
|
||||||
|
|||||||
-5
@@ -67,11 +67,6 @@ struct DeveloperOptionsScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Toggle(isOn: $context.roomListNotificationCountEnabled) {
|
|
||||||
Text("Show unread notification count")
|
|
||||||
Text("Also makes the app icon badge use the SDK's own unread notification count")
|
|
||||||
}
|
|
||||||
|
|
||||||
Toggle(isOn: $context.fuzzyRoomListSearchEnabled) {
|
Toggle(isOn: $context.fuzzyRoomListSearchEnabled) {
|
||||||
Text("Fuzzy searching")
|
Text("Fuzzy searching")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateAppBadgeCount() async {
|
func updateAppBadgeCount() async {
|
||||||
guard let userSession, appSettings.roomListNotificationCountEnabled else { return }
|
guard let userSession else { return }
|
||||||
|
|
||||||
let badgeCount = Int(userSession.clientProxy.totalUnreadNotifications)
|
let badgeCount = Int(userSession.clientProxy.totalUnreadNotifications)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ nonisolated enum NotificationConstants {
|
|||||||
static let roomIdentifier = "room_id"
|
static let roomIdentifier = "room_id"
|
||||||
static let eventIdentifier = "event_id"
|
static let eventIdentifier = "event_id"
|
||||||
static let threadRootEventIdentifier = "thread_root_event_id"
|
static let threadRootEventIdentifier = "thread_root_event_id"
|
||||||
static let unreadCount = "unread_count"
|
|
||||||
static let pusherNotificationClientIdentifier = "pusher_notification_client_identifier"
|
static let pusherNotificationClientIdentifier = "pusher_notification_client_identifier"
|
||||||
static let receiverIdentifier = "receiver_id"
|
static let receiverIdentifier = "receiver_id"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,12 +45,6 @@ nonisolated class NotificationHandler {
|
|||||||
func processEvent(_ eventID: String, roomID: String) async {
|
func processEvent(_ eventID: String, roomID: String) async {
|
||||||
MXLog.info("\(tag) Processing event: \(eventID) in room: \(roomID)")
|
MXLog.info("\(tag) Processing event: \(eventID) in room: \(roomID)")
|
||||||
|
|
||||||
if !settings.roomListNotificationCountEnabled {
|
|
||||||
// Copy over the unread information provided by the push payload to the notification badge.
|
|
||||||
notificationContent.badge = notificationContent.unreadCount as NSNumber?
|
|
||||||
MXLog.info("\(tag) New badge value: \(notificationContent.badge?.stringValue ?? "nil")")
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let notificationItemProxy = await userSession.notificationItemProxy(roomID: roomID, eventID: eventID) else {
|
guard let notificationItemProxy = await userSession.notificationItemProxy(roomID: roomID, eventID: eventID) else {
|
||||||
MXLog.error("\(tag) Failed retrieving notification item")
|
MXLog.error("\(tag) Failed retrieving notification item")
|
||||||
discardNotification()
|
discardNotification()
|
||||||
@@ -84,12 +78,8 @@ nonisolated class NotificationHandler {
|
|||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func deliverNotification() {
|
private func deliverNotification() {
|
||||||
if settings.roomListNotificationCountEnabled {
|
notificationContent.badge = NSNumber(value: incrementBadgeCount())
|
||||||
notificationContent.badge = NSNumber(value: incrementBadgeCount())
|
MXLog.info("\(tag) Delivering notification, new badge value: \(settings.lastKnownBadgeCount)")
|
||||||
MXLog.info("\(tag) Delivering notification, new badge value: \(settings.lastKnownBadgeCount)")
|
|
||||||
} else {
|
|
||||||
MXLog.info("\(tag) Delivering notification")
|
|
||||||
}
|
|
||||||
contentHandler(notificationContent)
|
contentHandler(notificationContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +99,8 @@ nonisolated class NotificationHandler {
|
|||||||
MXLog.info("\(tag) Discarding notification")
|
MXLog.info("\(tag) Discarding notification")
|
||||||
|
|
||||||
let content = UNMutableNotificationContent()
|
let content = UNMutableNotificationContent()
|
||||||
if settings.roomListNotificationCountEnabled {
|
// Nothing new is shown to the user, so leave the badge where the app last put it.
|
||||||
// Nothing new is shown to the user, so leave the badge where the app last put it.
|
content.badge = NSNumber(value: settings.lastKnownBadgeCount)
|
||||||
content.badge = NSNumber(value: settings.lastKnownBadgeCount)
|
|
||||||
} else {
|
|
||||||
content.badge = notificationContent.unreadCount as NSNumber?
|
|
||||||
}
|
|
||||||
MXLog.info("\(tag) New badge value: \(content.badge?.stringValue ?? "nil")")
|
MXLog.info("\(tag) New badge value: \(content.badge?.stringValue ?? "nil")")
|
||||||
|
|
||||||
contentHandler(content)
|
contentHandler(content)
|
||||||
@@ -149,9 +135,7 @@ nonisolated class NotificationHandler {
|
|||||||
|
|
||||||
if let targetNotification = deliveredNotifications.first(where: { $0.request.content.eventID == redactedEventID }) {
|
if let targetNotification = deliveredNotifications.first(where: { $0.request.content.eventID == redactedEventID }) {
|
||||||
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [targetNotification.request.identifier])
|
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [targetNotification.request.identifier])
|
||||||
if settings.roomListNotificationCountEnabled {
|
settings.lastKnownBadgeCount = max(0, settings.lastKnownBadgeCount - 1)
|
||||||
settings.lastKnownBadgeCount = max(0, settings.lastKnownBadgeCount - 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return .processedShouldDiscard
|
return .processedShouldDiscard
|
||||||
|
|||||||
@@ -258,9 +258,6 @@ actor NotificationServiceExtensionActor {
|
|||||||
|
|
||||||
let content = UNMutableNotificationContent()
|
let content = UNMutableNotificationContent()
|
||||||
content.body = L10n.notificationReceivedWhileOfflineIos
|
content.body = L10n.notificationReceivedWhileOfflineIos
|
||||||
if !settings.roomListNotificationCountEnabled {
|
|
||||||
content.badge = originalRequest.content.unreadCount as NSNumber?
|
|
||||||
}
|
|
||||||
content.sound = settings.notificationSound
|
content.sound = settings.notificationSound
|
||||||
|
|
||||||
let request = UNNotificationRequest(identifier: Self.receivedWhileOfflineNotificationID, content: content, trigger: nil)
|
let request = UNNotificationRequest(identifier: Self.receivedWhileOfflineNotificationID, content: content, trigger: nil)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:c02bce898b1b152d033925056fbc6988aa26586e51c72a197f451a8fee6d6165
|
oid sha256:15fb653a9ebbf242796ea7f0642f593a97319565b2229b453f770c17955f4000
|
||||||
size 287212
|
size 288822
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:d6d245a8f330678b0cce10db60408839e0f6a7bbf3e8d0f1e4c4413311485b79
|
oid sha256:995e5af4bcddb8930735d9e309f128ac0d39bea8fbff7f1113848071cbc6defe
|
||||||
size 297921
|
size 299527
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:21900e354eb87dacdb3eb86c8ea6cc89ca3ca5440360d72857027d3a42f75b7d
|
oid sha256:29555629f6c361e8e83c0db0d3ef1dfd63db303ce0078da41f3244969902cc9a
|
||||||
size 203557
|
size 204586
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:9618c5743c9f49ea3f59238f9a8aef209275461954be2ab7faa8d6caadf4da3f
|
oid sha256:7577f36308b256e7748f2e322a20e9b1152b70a6c3ffb02abf2a7d69af5dc432
|
||||||
size 209937
|
size 210956
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:28e5f6a36ceb714001a8dfc51197bad50537e2d1be2a273485964db6d6133fa5
|
oid sha256:b84d846ceee7c653ae220d774cec99ae83fa5ff2ee116ffcb3d8d706a59ef26c
|
||||||
size 242420
|
size 244002
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:99d7a5ca6e985e9b3ce8954428db7f4d1d7f312112e26c2837976edb921c33d3
|
oid sha256:ac03aa9dc61d69183dc984c4469d1b53d312c3eba30bb28cb72db072446862cb
|
||||||
size 248146
|
size 249780
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:7ad39875aa0432eee1f1518b6dcf42b8283ea4cbc8b2b4249d22e455932f27be
|
oid sha256:02f165e945006870b6b483a9ab8539c044813397f036773a3ed87451d41e4843
|
||||||
size 180646
|
size 181783
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:eb914d10c111af3dbd32174ea39fef5efd4d419d94af122c531e58f6acffc327
|
oid sha256:529579d75acd5f8cde370ddfcaef7a45102904031d28674fcf7fb2471403b7a9
|
||||||
size 184978
|
size 186112
|
||||||
|
|||||||
@@ -240,7 +240,6 @@ final class NotificationManagerTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
func updatingAppBadgeCountUsesTheClientSideCount() async {
|
func updatingAppBadgeCountUsesTheClientSideCount() async {
|
||||||
appSettings.roomListNotificationCountEnabled = true
|
|
||||||
clientProxy.totalUnreadNotifications = 7
|
clientProxy.totalUnreadNotifications = 7
|
||||||
|
|
||||||
await notificationManager.updateAppBadgeCount()
|
await notificationManager.updateAppBadgeCount()
|
||||||
@@ -251,23 +250,12 @@ final class NotificationManagerTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
func updatingAppBadgeCountWithoutASessionDoesNothing() async {
|
func updatingAppBadgeCountWithoutASessionDoesNothing() async {
|
||||||
appSettings.roomListNotificationCountEnabled = true
|
|
||||||
notificationManager.setUserSession(nil)
|
notificationManager.setUserSession(nil)
|
||||||
|
|
||||||
await notificationManager.updateAppBadgeCount()
|
await notificationManager.updateAppBadgeCount()
|
||||||
|
|
||||||
#expect(!notificationCenter.setBadgeCountCalled)
|
#expect(!notificationCenter.setBadgeCountCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
func updatingAppBadgeCountWithFeatureDisabledDoesNothing() async {
|
|
||||||
appSettings.roomListNotificationCountEnabled = false
|
|
||||||
clientProxy.totalUnreadNotifications = 7
|
|
||||||
|
|
||||||
await notificationManager.updateAppBadgeCount()
|
|
||||||
|
|
||||||
#expect(!notificationCenter.setBadgeCountCalled)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NotificationManagerTests: @MainActor NotificationManagerDelegate {
|
extension NotificationManagerTests: @MainActor NotificationManagerDelegate {
|
||||||
|
|||||||
Reference in New Issue
Block a user