Skip to content

Commit

Permalink
Handle contingency settings state on remote config (#3190)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1207976963085128/f

**Description**:
Display DuckPlayer contingency message and disable settings if necessary
  • Loading branch information
Bunn authored Aug 6, 2024
1 parent 6fb037f commit 3206f7d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 50 deletions.
6 changes: 1 addition & 5 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
1EFDCBC127D2393C00916BC5 /* DownloadsDeleteHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EFDCBC027D2393C00916BC5 /* DownloadsDeleteHelper.swift */; };
22CB1ED8203DDD2C00D2C724 /* AppDeepLinksTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22CB1ED7203DDD2C00D2C724 /* AppDeepLinksTests.swift */; };
2DC3FC65C6D9DA634426672D /* AutofillNoAuthAvailableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DC3FBD62FBAF21E87610FA8 /* AutofillNoAuthAvailableView.swift */; };
31009B382C5D32D100510782 /* DuckPlayerContingencyHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31009B372C5D32D100510782 /* DuckPlayerContingencyHandler.swift */; };
310742A62848CD780012660B /* BackForwardMenuHistoryItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 310742A52848CD780012660B /* BackForwardMenuHistoryItem.swift */; };
310742AB2848E6FD0012660B /* BackForwardMenuHistoryItemURLSanitizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 310742A92848E5B70012660B /* BackForwardMenuHistoryItemURLSanitizerTests.swift */; };
310C4B45281B5A9A00BA79A9 /* AutofillLoginDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 310C4B44281B5A9A00BA79A9 /* AutofillLoginDetailsView.swift */; };
Expand Down Expand Up @@ -1333,7 +1332,6 @@
1EFDCBC027D2393C00916BC5 /* DownloadsDeleteHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadsDeleteHelper.swift; sourceTree = "<group>"; };
22CB1ED7203DDD2C00D2C724 /* AppDeepLinksTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDeepLinksTests.swift; sourceTree = "<group>"; };
2DC3FBD62FBAF21E87610FA8 /* AutofillNoAuthAvailableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutofillNoAuthAvailableView.swift; sourceTree = "<group>"; };
31009B372C5D32D100510782 /* DuckPlayerContingencyHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DuckPlayerContingencyHandler.swift; sourceTree = "<group>"; };
310742A52848CD780012660B /* BackForwardMenuHistoryItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackForwardMenuHistoryItem.swift; sourceTree = "<group>"; };
310742A92848E5B70012660B /* BackForwardMenuHistoryItemURLSanitizerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackForwardMenuHistoryItemURLSanitizerTests.swift; sourceTree = "<group>"; };
310C4B44281B5A9A00BA79A9 /* AutofillLoginDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutofillLoginDetailsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4950,7 +4948,6 @@
D63FF8922C1B67D1006DE24D /* DuckPlayer */ = {
isa = PBXGroup;
children = (
31009B372C5D32D100510782 /* DuckPlayerContingencyHandler.swift */,
31DE43C82C2DAA8F00F8C51F /* Modal */,
31DE43C72C2DAA7F00F8C51F /* Resources */,
D63FF8972C1B6A45006DE24D /* DuckPlayer.swift */,
Expand Down Expand Up @@ -7021,7 +7018,6 @@
F1386BA41E6846C40062FC3C /* TabDelegate.swift in Sources */,
37CF91602BB4737300BADCAE /* CrashCollectionOnboarding.swift in Sources */,
C1B924B72ACD6E6800EE7B06 /* AutofillNeverSavedTableViewCell.swift in Sources */,
31009B382C5D32D100510782 /* DuckPlayerContingencyHandler.swift in Sources */,
3132FA2A27A0788F00DD7A12 /* QuickLookPreviewHelper.swift in Sources */,
D670E5BB2BB6A75300941A42 /* SubscriptionNavigationCoordinator.swift in Sources */,
6F9FFE262C579BCD00A238BE /* NewTabPageShortcutsSettingsStorage.swift in Sources */,
Expand Down Expand Up @@ -10473,7 +10469,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 180.0.1;
version = 181.0.0;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "a3b3df069bbaa06149e43ca26e5df219ee61aa15",
"version" : "180.0.1"
"revision" : "1d5b3d0a52f75ec5899ae79aabe6c879102cf218",
"version" : "181.0.0"
}
},
{
Expand Down
36 changes: 0 additions & 36 deletions DuckDuckGo/DuckPlayer/DuckPlayerContingencyHandler.swift

This file was deleted.

5 changes: 3 additions & 2 deletions DuckDuckGo/SettingsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ struct SettingsPickerCellView<T: CaseIterable & Hashable & CustomStringConvertib
let label: String
let options: [T]
@Binding var selectedOption: T

@Environment(\.isEnabled) private var isEnabled: Bool

/// Initializes a SettingsPickerCellView.
/// Use a custom picker that mimics the MenuPickerStyle
/// But with specific design
Expand All @@ -214,7 +215,7 @@ struct SettingsPickerCellView<T: CaseIterable & Hashable & CustomStringConvertib
HStack {
Text(label)
.daxBodyRegular()
.foregroundColor(Color(designSystemColor: .textPrimary))
.foregroundColor(isEnabled ? Color(designSystemColor: .textPrimary): Color(designSystemColor: .textSecondary))
Spacer()
Menu {
ForEach(options, id: \.self) { option in
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/SettingsDuckPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct SettingsDuckPlayerView: View {
@EnvironmentObject var viewModel: SettingsViewModel
var body: some View {
List {
if viewModel.shouldDisplayDuckPlayerContingencyMessage() {
if viewModel.shouldDisplayDuckPlayerContingencyMessage {
Section {
ContingencyMessageView {
viewModel.openDuckPlayerContingencyMessageSite()
Expand Down Expand Up @@ -60,6 +60,7 @@ struct SettingsDuckPlayerView: View {
SettingsPickerCellView(label: UserText.settingsOpenVideosInDuckPlayerLabel,
options: DuckPlayerMode.allCases,
selectedOption: viewModel.duckPlayerModeBinding)
.disabled(viewModel.shouldDisplayDuckPlayerContingencyMessage)
} footer: {
Text(UserText.settingsDuckPlayerFooter)
.daxFootnoteRegular()
Expand Down
12 changes: 8 additions & 4 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SwiftUI
import Common
import Combine
import SyncUI
import DuckPlayer

import Subscription
import NetworkProtection
Expand All @@ -45,7 +46,9 @@ final class SettingsViewModel: ObservableObject {
// Subscription Dependencies
private let subscriptionManager: SubscriptionManager
private var subscriptionSignOutObserver: Any?
var duckPlayerContingencyHandler: DuckPlayerContingencyHandler { DefaultDuckPlayerContingencyHandler() }
var duckPlayerContingencyHandler: DuckPlayerContingencyHandler {
DefaultDuckPlayerContingencyHandler(privacyConfigurationManager: ContentBlocking.shared.privacyConfigurationManager)
}

private enum UserDefaultsCacheKey: String, UserDefaultsCacheKeyStore {
case subscriptionState = "com.duckduckgo.ios.subscription.state"
Expand Down Expand Up @@ -396,7 +399,7 @@ extension SettingsViewModel {
networkProtection: getNetworkProtectionState(),
subscription: SettingsState.defaults.subscription,
sync: getSyncState(),
duckPlayerEnabled: featureFlagger.isFeatureOn(.duckPlayer),
duckPlayerEnabled: featureFlagger.isFeatureOn(.duckPlayer) || shouldDisplayDuckPlayerContingencyMessage,
duckPlayerMode: appSettings.duckPlayerMode
)

Expand Down Expand Up @@ -539,12 +542,13 @@ extension SettingsViewModel {
completionHandler: nil)
}

func shouldDisplayDuckPlayerContingencyMessage() -> Bool {
var shouldDisplayDuckPlayerContingencyMessage: Bool {
duckPlayerContingencyHandler.shouldDisplayContingencyMessage
}

func openDuckPlayerContingencyMessageSite() {
UIApplication.shared.open(duckPlayerContingencyHandler.learnMoreURL,
guard let url = duckPlayerContingencyHandler.learnMoreURL else { return }
UIApplication.shared.open(url,
options: [:],
completionHandler: nil)
}
Expand Down

0 comments on commit 3206f7d

Please sign in to comment.