From fc97cbc00672c1ffcbff962bd815836d2ee27cf1 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Mon, 20 Apr 2026 17:47:26 +0100 Subject: [PATCH] Add a feature flag for automatic back pagination. (#5445) --- ElementX/Sources/Application/Settings/AppSettings.swift | 4 ++++ .../DeveloperOptionsScreenModels.swift | 1 + .../View/DeveloperOptionsScreen.swift | 6 ++++++ ElementX/Sources/Services/Client/ClientProxy.swift | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/ElementX/Sources/Application/Settings/AppSettings.swift b/ElementX/Sources/Application/Settings/AppSettings.swift index 5851679ae..bd31a379f 100644 --- a/ElementX/Sources/Application/Settings/AppSettings.swift +++ b/ElementX/Sources/Application/Settings/AppSettings.swift @@ -80,6 +80,7 @@ final class AppSettings { case focusEventOnNotificationTap case linkNewDeviceEnabled case liveLocationSharingEnabled + case automaticBackPaginationEnabled // Doug's tweaks 🔧 case hideUnreadMessagesBadge @@ -447,6 +448,9 @@ final class AppSettings { let verifyWithClassicEnabled = appBuildType != .release + @UserPreference(key: UserDefaultsKeys.automaticBackPaginationEnabled, defaultValue: false, storageType: .userDefaults(store)) + var automaticBackPaginationEnabled + @UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType == .debug, storageType: .userDefaults(store)) var developerOptionsEnabled } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift index f6c6bab3a..41f60f5f6 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift @@ -55,6 +55,7 @@ protocol DeveloperOptionsProtocol: AnyObject { var enableKeyShareOnInvite: Bool { get set } var hideQuietNotificationAlerts: Bool { get set } var focusEventOnNotificationTap: Bool { get set } + var automaticBackPaginationEnabled: Bool { get set } var hideUnreadMessagesBadge: Bool { get set } var elementCallBaseURLOverride: URL? { get set } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index 9d12fd536..8d7e6ba87 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -67,6 +67,11 @@ struct DeveloperOptionsScreen: View { Toggle(isOn: $context.lowPriorityFilterEnabled) { Text("Low priority filter") } + + Toggle(isOn: $context.automaticBackPaginationEnabled) { + Text("Automatic back pagination") + Text("Requires app reboot") + } } Section("Room") { @@ -135,6 +140,7 @@ struct DeveloperOptionsScreen: View { Text("Hide quiet alerts") Text("The badge count will still be updated") } + Toggle(isOn: $context.focusEventOnNotificationTap) { Text("Focus event on notification tap") } diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 7cbb463c1..17b3f05cf 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -201,6 +201,11 @@ class ClientProxy: ClientProxyProtocol { self.appSettings = appSettings self.analyticsService = analyticsService + if appSettings.automaticBackPaginationEnabled { + // Must be called before creating the sync service, timelines etc. + client.enableAutomaticBackpagination() + } + clientQueue = .init(label: "ClientProxyQueue", attributes: .concurrent) mediaLoader = MediaLoader(client: client)