Skip to content

Commit

Permalink
Update AppPrefs key for the switch on the objective screen
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed Oct 17, 2024
1 parent 03c32c0 commit 185a0fe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ object AppPrefs {
AI_PRODUCT_CREATION_SURVEY_DISMISSED,
CUSTOM_FIELDS_TOP_BANNER_DISMISSED,
BLAZE_CAMPAIGN_SELECTED_OBJECTIVE,
BLAZE_CAMPAIGN_STORE_OBJECTIVE_ENABLED
BLAZE_CAMPAIGN_OBJECTIVE_SWITCH_CHECKED
}

/**
Expand Down Expand Up @@ -278,9 +278,9 @@ object AppPrefs {
get() = getString(DeletablePrefKey.BLAZE_CAMPAIGN_SELECTED_OBJECTIVE, "")
set(value) = setString(DeletablePrefKey.BLAZE_CAMPAIGN_SELECTED_OBJECTIVE, value)

var blazeCampaignStoreObjectiveEnabled: Boolean
get() = getBoolean(DeletablePrefKey.BLAZE_CAMPAIGN_STORE_OBJECTIVE_ENABLED, true)
set(value) = setBoolean(DeletablePrefKey.BLAZE_CAMPAIGN_STORE_OBJECTIVE_ENABLED, value)
var blazeCampaignObjectiveSwitchChecked: Boolean
get() = getBoolean(DeletablePrefKey.BLAZE_CAMPAIGN_OBJECTIVE_SWITCH_CHECKED, true)
set(value) = setBoolean(DeletablePrefKey.BLAZE_CAMPAIGN_OBJECTIVE_SWITCH_CHECKED, value)

fun getProductSortingChoice(currentSiteId: Int) = getString(getProductSortingKey(currentSiteId)).orNullIfEmpty()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AppPrefsWrapper @Inject constructor() {

var blazeCampaignSelectedObjective by AppPrefs::blazeCampaignSelectedObjective

var blazeCampaignStoreObjectiveEnabled by AppPrefs::blazeCampaignStoreObjectiveEnabled
var blazeCampaignObjectiveSwitchChecked by AppPrefs::blazeCampaignObjectiveSwitchChecked

fun getAppInstallationDate() = AppPrefs.installationDate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,10 @@ class BlazeRepository @Inject constructor(
}
}

fun isStoreObjectiveEnabled() = appPrefsWrapper.blazeCampaignStoreObjectiveEnabled
fun isCampaignObjectiveSwitchChecked() = appPrefsWrapper.blazeCampaignObjectiveSwitchChecked

fun setStoreObjectiveEnabled(enabled: Boolean) {
appPrefsWrapper.blazeCampaignStoreObjectiveEnabled = enabled
fun setCampaignObjectiveSwitchChecked(enabled: Boolean) {
appPrefsWrapper.blazeCampaignObjectiveSwitchChecked = enabled
}

fun storeSelectedObjective(objectiveId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BlazeCampaignObjectiveViewModel @Inject constructor(
)
private val storeObjectiveSwitchState = savedState.getStateFlow(
scope = this,
initialValue = blazeRepository.isStoreObjectiveEnabled(),
initialValue = blazeRepository.isCampaignObjectiveSwitchChecked(),
key = "storeObjectiveSwitchState"
)

Expand Down Expand Up @@ -71,7 +71,7 @@ class BlazeCampaignObjectiveViewModel @Inject constructor(

fun onSaveTapped() {
viewState.value?.isStoreSelectionButtonToggled?.let {
blazeRepository.setStoreObjectiveEnabled(it)
blazeRepository.setCampaignObjectiveSwitchChecked(it)
if (it) {
blazeRepository.storeSelectedObjective(selectedId.value.orEmpty())
}
Expand Down

0 comments on commit 185a0fe

Please sign in to comment.