Skip to content

Commit 613afbe

Browse files
authored
RemoteConfig clean up (#1066)
* Delete is_dark_mode_available_ios & is_disabled_steps_supported remote values
1 parent f50a660 commit 613afbe

File tree

9 files changed

+16
-43
lines changed

9 files changed

+16
-43
lines changed

Stepic/Legacy/Model/RemoteConfig/RemoteConfig.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ final class RemoteConfig {
2323
Key.showStreaksNotificationTrigger.rawValue: NSString(string: Self.defaultShowStreaksNotificationTrigger.rawValue),
2424
Key.adaptiveBackendUrl.rawValue: NSString(string: StepikApplicationsInfo.adaptiveRatingURL),
2525
Key.supportedInAdaptiveModeCourses.rawValue: NSArray(array: StepikApplicationsInfo.adaptiveSupportedCourses),
26-
Key.darkModeAvailable.rawValue: NSNumber(value: true),
2726
Key.arQuickLookAvailable.rawValue: NSNumber(value: false),
28-
Key.isDisabledStepsSupported.rawValue: NSNumber(value: false),
2927
Key.searchResultsQueryParams.rawValue: NSDictionary(dictionary: ["is_popular": "true", "is_public": "true"]),
3028
Key.isCoursePricesEnabled.rawValue: NSNumber(value: false),
3129
Key.isCourseRevenueAvailable.rawValue: NSNumber(value: false)
@@ -81,31 +79,13 @@ final class RemoteConfig {
8179
return supportedCourses.compactMap { Int($0) }
8280
}
8381

84-
var isDarkModeAvailable: Bool {
85-
if DeviceInfo.current.OSVersion.major < 13 {
86-
return false
87-
}
88-
89-
return FirebaseRemoteConfig.RemoteConfig
90-
.remoteConfig()
91-
.configValue(forKey: Key.darkModeAvailable.rawValue)
92-
.boolValue
93-
}
94-
9582
var isARQuickLookAvailable: Bool {
9683
FirebaseRemoteConfig.RemoteConfig
9784
.remoteConfig()
9885
.configValue(forKey: Key.arQuickLookAvailable.rawValue)
9986
.boolValue
10087
}
10188

102-
var isDisabledStepsSupported: Bool {
103-
FirebaseRemoteConfig.RemoteConfig
104-
.remoteConfig()
105-
.configValue(forKey: Key.isDisabledStepsSupported.rawValue)
106-
.boolValue
107-
}
108-
10989
var searchResultsQueryParams: JSONDictionary {
11090
guard let configValue = FirebaseRemoteConfig.RemoteConfig.remoteConfig().configValue(
11191
forKey: Key.searchResultsQueryParams.rawValue
@@ -194,9 +174,7 @@ final class RemoteConfig {
194174
case showStreaksNotificationTrigger = "show_streaks_notification_trigger"
195175
case adaptiveBackendUrl = "adaptive_backend_url"
196176
case supportedInAdaptiveModeCourses = "supported_adaptive_courses_ios"
197-
case darkModeAvailable = "is_dark_mode_available_ios"
198177
case arQuickLookAvailable = "is_ar_quick_look_available_ios"
199-
case isDisabledStepsSupported = "is_disabled_steps_supported"
200178
case searchResultsQueryParams = "search_query_params_ios"
201179
case isCoursePricesEnabled = "is_course_prices_enabled_ios"
202180
case isCourseRevenueAvailable = "is_course_revenue_available_ios"

Stepic/Sources/Modules/Settings/SettingsAssembly.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ final class SettingsAssembly: Assembly {
3131
provider: provider,
3232
analytics: StepikAnalytics.shared,
3333
userAccountService: UserAccountService(),
34-
remoteConfig: .shared,
3534
downloadsDeletionService: DownloadsDeletionService(),
3635
dataBackUpdateService: DataBackUpdateService.default
3736
)

Stepic/Sources/Modules/Settings/SettingsInteractor.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ final class SettingsInteractor: SettingsInteractorProtocol {
3535

3636
private let analytics: Analytics
3737
private let userAccountService: UserAccountServiceProtocol
38-
private let remoteConfig: RemoteConfig
3938

4039
private let downloadsDeletionService: DownloadsDeletionServiceProtocol
4140
private let dataBackUpdateService: DataBackUpdateServiceProtocol
@@ -50,7 +49,7 @@ final class SettingsInteractor: SettingsInteractorProtocol {
5049
shouldUseCellularDataForDownloads: self.provider.shouldUseCellularDataForDownloads,
5150
isAutoplayEnabled: self.provider.isAutoplayEnabled,
5251
isAdaptiveModeEnabled: self.provider.isAdaptiveModeEnabled,
53-
isDarkModeAvailable: self.remoteConfig.isDarkModeAvailable,
52+
isDarkModeAvailable: self.provider.isDarkModeAvailable,
5453
isAuthorized: self.isAuthorized
5554
)
5655
}
@@ -66,15 +65,13 @@ final class SettingsInteractor: SettingsInteractorProtocol {
6665
provider: SettingsProviderProtocol,
6766
analytics: Analytics,
6867
userAccountService: UserAccountServiceProtocol,
69-
remoteConfig: RemoteConfig,
7068
downloadsDeletionService: DownloadsDeletionServiceProtocol,
7169
dataBackUpdateService: DataBackUpdateServiceProtocol
7270
) {
7371
self.presenter = presenter
7472
self.provider = provider
7573
self.analytics = analytics
7674
self.userAccountService = userAccountService
77-
self.remoteConfig = remoteConfig
7875
self.downloadsDeletionService = downloadsDeletionService
7976
self.dataBackUpdateService = dataBackUpdateService
8077
}

Stepic/Sources/Modules/Settings/SettingsProvider.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ protocol SettingsProviderProtocol: AnyObject {
1515
var globalStepFontSize: StepFontSize { get set }
1616
var availableStepFontSizes: [StepFontSize] { get }
1717
// ApplicationTheme
18+
var isDarkModeAvailable: Bool { get }
1819
var globalApplicationTheme: ApplicationTheme { get set }
1920
var availableApplicationThemes: [ApplicationTheme] { get }
2021

@@ -82,6 +83,13 @@ final class SettingsProvider: SettingsProviderProtocol {
8283

8384
var availableStepFontSizes: [StepFontSize] { StepFontSize.allCases }
8485

86+
var isDarkModeAvailable: Bool {
87+
if #available(iOS 13.0, *) {
88+
return true
89+
}
90+
return false
91+
}
92+
8593
var globalApplicationTheme: ApplicationTheme {
8694
get {
8795
self.applicationThemeService.theme

Stepic/Sources/Modules/Step/StepAssembly.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ final class StepAssembly: Assembly {
3030
stepID: self.stepID,
3131
presenter: presenter,
3232
provider: provider,
33-
analytics: StepikAnalytics.shared,
34-
remoteConfig: RemoteConfig.shared
33+
analytics: StepikAnalytics.shared
3534
)
3635
let viewController = StepViewController(
3736
interactor: interactor,

Stepic/Sources/Modules/Step/StepDataFlow.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ enum StepDataFlow {
99
let step: Step
1010
let stepFontSize: StepFontSize
1111
let storedImages: [StoredImage]
12-
let isDisabledStepsSupported: Bool
1312
}
1413

1514
struct Response {

Stepic/Sources/Modules/Step/StepInteractor.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ final class StepInteractor: StepInteractorProtocol {
2323
private let provider: StepProviderProtocol
2424
private let analytics: Analytics
2525

26-
private let remoteConfig: RemoteConfig
27-
2826
private let stepID: Step.IdType
2927
private var currentStepPlainObject: StepPlainObject?
3028

@@ -38,13 +36,11 @@ final class StepInteractor: StepInteractorProtocol {
3836
stepID: Step.IdType,
3937
presenter: StepPresenterProtocol,
4038
provider: StepProviderProtocol,
41-
analytics: Analytics,
42-
remoteConfig: RemoteConfig
39+
analytics: Analytics
4340
) {
4441
self.presenter = presenter
4542
self.provider = provider
4643
self.analytics = analytics
47-
self.remoteConfig = remoteConfig
4844

4945
self.stepID = stepID
5046
}
@@ -277,8 +273,7 @@ final class StepInteractor: StepInteractorProtocol {
277273
let data = StepDataFlow.StepLoad.Data(
278274
step: step,
279275
stepFontSize: stepFontSize,
280-
storedImages: storedImages,
281-
isDisabledStepsSupported: self.remoteConfig.isDisabledStepsSupported
276+
storedImages: storedImages
282277
)
283278

284279
return .value(data)

Stepic/Sources/Modules/Step/StepPresenter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class StepPresenter: StepPresenterProtocol {
2828
func presentStep(response: StepDataFlow.StepLoad.Response) {
2929
switch response.result {
3030
case .success(let data):
31-
if !data.step.isEnabled && data.isDisabledStepsSupported {
31+
if !data.step.isEnabled {
3232
let viewModel = self.makeDisabledStepViewModel(
3333
step: data.step,
3434
stepFontSize: data.stepFontSize,

Stepic/Sources/Services/ApplicationThemeService.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ final class ApplicationThemeService: ApplicationThemeServiceProtocol {
2222
get {
2323
if let userSelectedApplicationTheme = self.userSelectedApplicationTheme {
2424
return userSelectedApplicationTheme
25+
} else if #available(iOS 13.0, *) {
26+
return .default
2527
} else {
26-
return self.remoteConfig.isDarkModeAvailable ? .default : .light
28+
return .light
2729
}
2830
}
2931
set {
@@ -40,10 +42,6 @@ final class ApplicationThemeService: ApplicationThemeServiceProtocol {
4042

4143
func registerDefaultTheme() {
4244
if #available(iOS 13.0, *) {
43-
guard self.remoteConfig.isDarkModeAvailable else {
44-
return self.applyTheme(.light)
45-
}
46-
4745
if let userSelectedApplicationTheme = self.userSelectedApplicationTheme {
4846
self.applyTheme(userSelectedApplicationTheme)
4947
} else {

0 commit comments

Comments
 (0)