Skip to content

Commit

Permalink
fix: remove search feature flag (#474)
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Rodriguez <[email protected]>
  • Loading branch information
BrandonTR and Brandon Rodriguez authored Oct 18, 2024
1 parent 77960f4 commit 2dde237
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 35 deletions.
3 changes: 1 addition & 2 deletions iosApp/iosApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct ContentView: View {
ZStack(alignment: .top) {
mapWithSheets
VStack(alignment: .trailing, spacing: 0) {
if contentVM.searchEnabled, nearbyVM.navigationStack.lastSafe() == .nearby {
if nearbyVM.navigationStack.lastSafe() == .nearby {
SearchOverlay(searchObserver: searchObserver, nearbyVM: nearbyVM, searchVM: searchVM)
}
if !searchObserver.isSearching, !viewportProvider.viewport.isFollowing,
Expand All @@ -117,7 +117,6 @@ struct ContentView: View {
}
.onAppear {
Task { await errorBannerVM.activate() }
Task { await contentVM.loadSettings() }
Task { await contentVM.loadConfig() }
}
.onChange(of: scenePhase) { newPhase in
Expand Down
6 changes: 0 additions & 6 deletions iosApp/iosApp/Pages/Settings/Setting+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ extension Setting: Identifiable {

var name: String {
switch key {
case .search:
"Search"
case .searchRouteResults:
"Search - Route Results"
case .map:
Expand All @@ -27,8 +25,6 @@ extension Setting: Identifiable {

var icon: String {
switch key {
case .search:
"magnifyingglass"
case .searchRouteResults:
"point.topleft.down.to.point.bottomright.curvepath.fill"
case .map:
Expand All @@ -38,8 +34,6 @@ extension Setting: Identifiable {

var category: SettingsSection.Category {
switch key {
case .search:
.featureFlags
case .searchRouteResults:
.featureFlags
case .map:
Expand Down
16 changes: 1 addition & 15 deletions iosApp/iosApp/ViewModels/ContentViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,19 @@ import shared

class ContentViewModel: ObservableObject {
@Published var configResponse: ApiResult<ConfigResponse>?
@Published var searchEnabled: Bool
private var settings: Set<Setting> = []

var configUseCase: ConfigUseCase
var settingsRepo: ISettingsRepository

init(configUseCase: ConfigUseCase = UsecaseDI().configUsecase,
configResponse: ApiResult<ConfigResponse>? = nil,
searchEnabled: Bool = false,
settingsRepo: ISettingsRepository = RepositoryDI().settings) {
configResponse: ApiResult<ConfigResponse>? = nil) {
self.configUseCase = configUseCase
self.configResponse = configResponse
self.searchEnabled = searchEnabled
self.settingsRepo = settingsRepo
}

func configureMapboxToken(token: String) {
MapboxOptions.accessToken = token
}

@MainActor func loadSettings() async {
do {
let settings = try await settingsRepo.getSettings()
searchEnabled = settings.first(where: { $0.key == .search })?.isOn ?? false
} catch {}
}

@MainActor func loadConfig() async {
do {
configResponse = try await configUseCase.getConfig()
Expand Down
8 changes: 4 additions & 4 deletions iosApp/iosAppTests/Pages/Settings/SettingsPageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ final class SettingsPageTests: XCTestCase {

init(
mapDebug: Bool,
searchFeatureFlag: Bool,
searchRouteResults: Bool,
onGet: (() -> Void)? = nil,
onSet: ((Set<Setting>) -> Void)? = nil
) {
settings = [
Setting(key: .map, isOn: mapDebug),
Setting(key: .search, isOn: searchFeatureFlag),
Setting(key: .searchRouteResults, isOn: searchRouteResults),
]
self.onGet = onGet
self.onSet = onSet
Expand All @@ -48,7 +48,7 @@ final class SettingsPageTests: XCTestCase {

let settingsRepository = FakeSettingsRepository(
mapDebug: true,
searchFeatureFlag: false,
searchRouteResults: false,
onGet: {
loadedPublisher.send(())
}
Expand All @@ -71,7 +71,7 @@ final class SettingsPageTests: XCTestCase {

let settingsRepository = FakeSettingsRepository(
mapDebug: false,
searchFeatureFlag: false,
searchRouteResults: false,
onGet: {
loadedPublisher.send(())
},
Expand Down
7 changes: 0 additions & 7 deletions iosApp/iosAppTests/Views/ContentViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,4 @@ final class ContentViewModelTests: XCTestCase {
await contentVM.loadConfig()
XCTAssertEqual(contentVM.configResponse, expectedResult)
}

func testLoadSettingsSetsSettings() async {
let expectedResult: Set<Setting> = [.init(key: .search, isOn: true)]
let contentVM = ContentViewModel(settingsRepo: MockSettingsRepository(settings: expectedResult))
await contentVM.loadSettings()
XCTAssertTrue(contentVM.searchEnabled)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class SettingsRepository : ISettingsRepository, KoinComponent {

enum class Settings(val dataStoreKey: Preferences.Key<Boolean>) {
Map(booleanPreferencesKey("map_debug")),
Search(booleanPreferencesKey("search_featureFlag")),
SearchRouteResults(booleanPreferencesKey("searchRouteResults_featureFlag")),
}

Expand Down

0 comments on commit 2dde237

Please sign in to comment.