Remove remote-config gate for Optimize Storage

This commit is contained in:
Sasha Weiss 2026-06-10 10:56:11 -07:00 committed by GitHub
parent ee158d4c4c
commit aa353b3f59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 46 additions and 95 deletions

View File

@ -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

View File

@ -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)

View File

@ -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
}

View File

@ -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,

View File

@ -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

View File

@ -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)")

View File

@ -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.