diff --git a/Signal/Backups/BackupSettingsViewController.swift b/Signal/Backups/BackupSettingsViewController.swift index 7d76711ba1..1a5c9cfbd2 100644 --- a/Signal/Backups/BackupSettingsViewController.swift +++ b/Signal/Backups/BackupSettingsViewController.swift @@ -69,7 +69,6 @@ class BackupSettingsViewController: backupSubscriptionManager: DependenciesBridge.shared.backupSubscriptionManager, db: DependenciesBridge.shared.db, deviceSleepManager: deviceSleepManager, - remoteConfig: SSKEnvironment.shared.remoteConfigManagerRef, subscriptionConfigManager: DependenciesBridge.shared.subscriptionConfigManager, tsAccountManager: DependenciesBridge.shared.tsAccountManager, ) @@ -93,7 +92,6 @@ class BackupSettingsViewController: backupSubscriptionManager: BackupSubscriptionManager, db: DB, deviceSleepManager: DeviceSleepManager, - remoteConfig: RemoteConfigProvider, subscriptionConfigManager: SubscriptionConfigManager, tsAccountManager: TSAccountManager, ) { @@ -148,7 +146,6 @@ class BackupSettingsViewController: ), hasBackupFailed: backupFailureStateManager.hasFailedBackup(tx: tx), isBackgroundAppRefreshDisabled: Self.isBackgroundAppRefreshDisabled(), - isOptimizeStorageRemoteConfigEnabled: remoteConfig.currentConfig().isOptimizeStorageEnabled, ) return viewModel @@ -677,8 +674,7 @@ class BackupSettingsViewController: let welcomeToBackupsSheet: WelcomeToBackupsSheet switch backupPlan { - case _ where !viewModel.isOptimizeStorageRemoteConfigEnabled, - .disabled, + case .disabled, .disabling, .free: welcomeToBackupsSheet = WelcomeToBackupsSheet( @@ -1621,10 +1617,6 @@ private class BackupSettingsViewModel: ObservableObject { /// from running.) @Published var isBackgroundAppRefreshDisabled: Bool - /// Whether the "Optimze Storage" feature is available to this user, per - /// remote config. Not to be confused with `isOptimizeLocalStorageAvailable`. - @Published var isOptimizeStorageRemoteConfigEnabled: Bool - weak var actionsDelegate: ActionsDelegate? init( @@ -1641,7 +1633,6 @@ private class BackupSettingsViewModel: ObservableObject { mediaTierCapacityOverflow: UInt64?, hasBackupFailed: Bool, isBackgroundAppRefreshDisabled: Bool, - isOptimizeStorageRemoteConfigEnabled: Bool, ) { self.backupSubscriptionConfiguration = backupSubscriptionConfiguration @@ -1661,8 +1652,6 @@ private class BackupSettingsViewModel: ObservableObject { self.mediaTierCapacityOverflow = mediaTierCapacityOverflow self.hasBackupFailed = hasBackupFailed self.isBackgroundAppRefreshDisabled = isBackgroundAppRefreshDisabled - - self.isOptimizeStorageRemoteConfigEnabled = isOptimizeStorageRemoteConfigEnabled } // MARK: - @@ -1722,7 +1711,7 @@ private class BackupSettingsViewModel: ObservableObject { // MARK: - /// Whether the "Optimze Storage" feature is available, per the current - /// `BackupPlan`. Not to be confused with `isOptimizeStorageRemoteConfigEnabled`. + /// `BackupPlan`. var isOptimizeLocalStorageAvailable: Bool { switch backupPlan { case .disabled, .disabling, .free: @@ -2008,36 +1997,32 @@ struct BackupSettingsView: View { viewModel: viewModel, ) - if viewModel.isOptimizeStorageRemoteConfigEnabled { - Toggle( - OWSLocalizedString( - "BACKUP_SETTINGS_OPTIMIZE_LOCAL_STORAGE_TOGGLE_TITLE", - comment: "Title for a toggle allowing users to change the Optimize Local Storage setting.", - ), - isOn: Binding( - get: { viewModel.isOptimizeLocalStorageEnabled }, - set: { viewModel.setOptimizeLocalStorage($0) }, - ), - ).disabled(!viewModel.isOptimizeLocalStorageAvailable) - } + Toggle( + OWSLocalizedString( + "BACKUP_SETTINGS_OPTIMIZE_LOCAL_STORAGE_TOGGLE_TITLE", + comment: "Title for a toggle allowing users to change the Optimize Local Storage setting.", + ), + isOn: Binding( + get: { viewModel.isOptimizeLocalStorageEnabled }, + set: { viewModel.setOptimizeLocalStorage($0) }, + ), + ).disabled(!viewModel.isOptimizeLocalStorageAvailable) } footer: { - if viewModel.isOptimizeStorageRemoteConfigEnabled { - let footerText: String = if viewModel.isOptimizeLocalStorageAvailable { - OWSLocalizedString( - "BACKUP_SETTINGS_OPTIMIZE_LOCAL_STORAGE_TOGGLE_FOOTER_AVAILABLE", - comment: "Footer for a toggle allowing users to change the Optimize Local Storage setting, if the toggle is available.", - ) - } else { - OWSLocalizedString( - "BACKUP_SETTINGS_OPTIMIZE_LOCAL_STORAGE_TOGGLE_FOOTER_UNAVAILABLE", - comment: "Footer for a toggle allowing users to change the Optimize Local Storage setting, if the toggle is unavailable.", - ) - } - - Text(footerText) - .foregroundStyle(Color.Signal.secondaryLabel) - .font(.caption) + let footerText: String = if viewModel.isOptimizeLocalStorageAvailable { + OWSLocalizedString( + "BACKUP_SETTINGS_OPTIMIZE_LOCAL_STORAGE_TOGGLE_FOOTER_AVAILABLE", + comment: "Footer for a toggle allowing users to change the Optimize Local Storage setting, if the toggle is available.", + ) + } else { + OWSLocalizedString( + "BACKUP_SETTINGS_OPTIMIZE_LOCAL_STORAGE_TOGGLE_FOOTER_UNAVAILABLE", + comment: "Footer for a toggle allowing users to change the Optimize Local Storage setting, if the toggle is unavailable.", + ) } + + Text(footerText) + .foregroundStyle(Color.Signal.secondaryLabel) + .font(.caption) } SignalSection { @@ -3256,7 +3241,6 @@ private extension BackupSettingsViewModel { mediaTierCapacityOverflow: mediaTierCapacityOverflow, hasBackupFailed: hasBackupFailed, isBackgroundAppRefreshDisabled: isBackgroundAppRefreshDisabled, - isOptimizeStorageRemoteConfigEnabled: true, ) let actionsDelegate = PreviewActionsDelegate() viewModel.actionsDelegate = actionsDelegate diff --git a/Signal/src/ViewControllers/AppSettings/Internal/InternalBackupSettingsViewController.swift b/Signal/src/ViewControllers/AppSettings/Internal/InternalBackupSettingsViewController.swift index 7b18acdcae..49310897f7 100644 --- a/Signal/src/ViewControllers/AppSettings/Internal/InternalBackupSettingsViewController.swift +++ b/Signal/src/ViewControllers/AppSettings/Internal/InternalBackupSettingsViewController.swift @@ -64,27 +64,25 @@ class InternalBackupSettingsViewController: OWSTableViewController2 { let vc = InternalListMediaViewController() self?.navigationController?.pushViewController(vc, animated: true) }) - if RemoteConfig.current.isOptimizeStorageEnabled { - section.add(.switch( - withText: "Regenerate backup thumbnails", - subtitle: "Regenerate backup thumbnails on next offloading run", - isOn: { db.read(block: backupSettingsStore.shouldGenerateThumbnailsOnNextOffloading(tx:)) }, - actionBlock: { _ in - db.write { tx in - let currentValue = backupSettingsStore.shouldGenerateThumbnailsOnNextOffloading(tx: tx) - backupSettingsStore.setShouldGenerateThumbnailsOnNextOffloading(!currentValue, tx: tx) - } - }, - )) - section.add(.switch( - withText: "Aggressive optimize media", - subtitle: "Don't keep recent attachments when optimize media is enabled", - isOn: { Attachment.offloadingThresholdOverride }, - actionBlock: { _ in - Attachment.offloadingThresholdOverride = !Attachment.offloadingThresholdOverride - }, - )) - } + section.add(.switch( + withText: "Regenerate backup thumbnails", + subtitle: "Regenerate backup thumbnails on next offloading run", + isOn: { db.read(block: backupSettingsStore.shouldGenerateThumbnailsOnNextOffloading(tx:)) }, + actionBlock: { _ in + db.write { tx in + let currentValue = backupSettingsStore.shouldGenerateThumbnailsOnNextOffloading(tx: tx) + backupSettingsStore.setShouldGenerateThumbnailsOnNextOffloading(!currentValue, tx: tx) + } + }, + )) + section.add(.switch( + withText: "Aggressive optimize media", + subtitle: "Don't keep recent attachments when optimize media is enabled", + isOn: { Attachment.offloadingThresholdOverride }, + actionBlock: { _ in + Attachment.offloadingThresholdOverride = !Attachment.offloadingThresholdOverride + }, + )) contents.add(section) diff --git a/SignalServiceKit/Backups/Attachments/AttachmentOffloadingManager.swift b/SignalServiceKit/Backups/Attachments/AttachmentOffloadingManager.swift index 82ebd0b431..e55286c6b5 100644 --- a/SignalServiceKit/Backups/Attachments/AttachmentOffloadingManager.swift +++ b/SignalServiceKit/Backups/Attachments/AttachmentOffloadingManager.swift @@ -87,10 +87,6 @@ public class AttachmentOffloadingManagerImpl: AttachmentOffloadingManager { } public func offloadAttachmentsIfNeeded() async throws { - guard remoteConfig.currentConfig().isOptimizeStorageEnabled else { - return - } - guard db.read(block: { offloadingIsAllowed(tx: $0) }) else { return } diff --git a/SignalServiceKit/Environment/BuildFlags.swift b/SignalServiceKit/Environment/BuildFlags.swift index 9b22fba994..4e96b0c574 100644 --- a/SignalServiceKit/Environment/BuildFlags.swift +++ b/SignalServiceKit/Environment/BuildFlags.swift @@ -149,12 +149,6 @@ public enum DebugFlags { public static let extraDebugLogs = build <= .internal - public static let mediaGalleryOnlyAllowDownloaded = TestableFlag( - !SSKEnvironment.shared.remoteConfigManagerRef.currentConfig().isOptimizeStorageEnabled, - title: LocalizationNotNeeded("Media Gallery: only allow downloaded"), - details: LocalizationNotNeeded("Only allow downloaded media to appear in the Media Gallery."), - ) - public static let messageSendsFail = TestableFlag( false, title: LocalizationNotNeeded("Message Sends Fail"), @@ -202,7 +196,6 @@ public enum DebugFlags { public static func allTestableFlags() -> [TestableFlag] { return [ - mediaGalleryOnlyAllowDownloaded, callingUseTestSFU, callingNeverRelay, callingForceVp9Off, diff --git a/SignalServiceKit/Environment/RemoteConfigManager.swift b/SignalServiceKit/Environment/RemoteConfigManager.swift index afc3938dbe..c45642a1cf 100644 --- a/SignalServiceKit/Environment/RemoteConfigManager.swift +++ b/SignalServiceKit/Environment/RemoteConfigManager.swift @@ -165,13 +165,6 @@ public class RemoteConfig { !isEnabled(.paypalMonthlyDonationKillSwitch) } - public var isOptimizeStorageEnabled: Bool { - isEnabled( - .optimizeStorageEnabled, - defaultValue: BuildFlags.Backups.showOptimizeMedia, - ) - } - public func standardMediaQualityLevel(callingCode: Int?) -> ImageQualityLevel? { guard let csvString = self.value(.standardMediaQualityLevel), @@ -652,7 +645,6 @@ private enum IsEnabledFlag: String, FlagType { case enableGifSearch = "global.gifSearch" case groupTerminateReceiveKillSwitch = "ios.groupTerminateReceiveKillSwitch" case messageResendKillSwitch = "ios.messageResendKillSwitch" - case optimizeStorageEnabled = "ios.optimizeStorageEnabled" case paymentsResetKillSwitch = "ios.paymentsResetKillSwitch" case paypalGiftDonationKillSwitch = "ios.paypalGiftDonationKillSwitch" case paypalMonthlyDonationKillSwitch = "ios.paypalMonthlyDonationKillSwitch" @@ -682,7 +674,6 @@ private enum IsEnabledFlag: String, FlagType { case .enableGifSearch: false case .groupTerminateReceiveKillSwitch: true case .messageResendKillSwitch: false - case .optimizeStorageEnabled: true case .paymentsResetKillSwitch: false case .paypalGiftDonationKillSwitch: false case .paypalMonthlyDonationKillSwitch: false diff --git a/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinder.swift b/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinder.swift index 3ae92679a9..3bc78c054b 100644 --- a/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinder.swift +++ b/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinder.swift @@ -290,12 +290,6 @@ public struct MediaGalleryAttachmentFinder { // Never show past edit revisions in the gallery .filter(isPastEditRevisionColumn == false) - if DebugFlags.mediaGalleryOnlyAllowDownloaded.get() { - let attachmentAssociation = RecordType.belongsTo(Attachment.Record.self) - let localFileColumn = Column(Attachment.Record.CodingKeys.localRelativeFilePath) - query = query.joining(required: attachmentAssociation.filter(localFileColumn != nil)) - } - switch filter { case .allPhotoVideoCategory: query = query.filter(literal: "isVisualMediaContentType = \(true)") diff --git a/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinderTest.swift b/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinderTest.swift index f6b8295227..28b3028a22 100644 --- a/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinderTest.swift +++ b/SignalServiceKit/Storage/MediaGallery/MediaGalleryAttachmentFinderTest.swift @@ -8,10 +8,7 @@ import GRDB import XCTest @testable import SignalServiceKit -class MediaGalleryAttachmentFinderTest: SSKBaseTest { - // TODO: Convert this back to an XCTestCase once the - // `mediaGalleryOnlyAllowDownloaded` TestableFlag is removed. - +class MediaGalleryAttachmentFinderTest: XCTestCase { private let attachmentStore = AttachmentStore() private var db: InMemoryDB! @@ -192,8 +189,6 @@ class MediaGalleryAttachmentFinderTest: SSKBaseTest { // MARK: - Index Usage func testAllQueriesUseIndex() throws { - DebugFlags.mediaGalleryOnlyAllowDownloaded.set(false) - let (thread, _) = insertThreadAndInteraction() // Set up some parametrized values for tests.