Skip to content

Commit

Permalink
Fixes rewards disabled for ads
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Jan 11, 2019
1 parent f269e5c commit e156e02
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
8 changes: 0 additions & 8 deletions browser/ui/webui/brave_rewards_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -804,19 +804,11 @@ void RewardsDOMHandler::GetAdsData(const base::ListValue *args) {
if (ads_service_ && web_ui()->CanCallJavascript()) {
base::DictionaryValue adsData;

bool ads_ui_enabled;
bool ads_enabled = ads_service_->is_enabled();
int ads_per_hour = ads_service_->ads_per_hour();

#if BUILDFLAG(BRAVE_ADS_ENABLED)
ads_ui_enabled = true;
#else
ads_ui_enabled = false;
#endif

adsData.SetBoolean("adsEnabled", ads_enabled);
adsData.SetInteger("adsPerHour", ads_per_hour);
adsData.SetBoolean("adsUIEnabled", ads_ui_enabled);

web_ui()->CallJavascriptFunctionUnsafe("brave_rewards.adsData", adsData);
}
Expand Down
14 changes: 4 additions & 10 deletions components/brave_rewards/resources/ui/components/adsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,17 @@ class AdsBox extends React.Component<Props, State> {
}

render () {
let adsEnabled = false
let adsUIEnabled = false
const { adsData } = this.props.rewardsData

if (adsData) {
adsEnabled = adsData.adsEnabled
adsUIEnabled = adsData.adsUIEnabled
}
const { adsData, enabledMain } = this.props.rewardsData
const adsEnabled = adsData && adsData.adsEnabled

return (
<Box
title={getLocale('adsTitle')}
type={'ads'}
description={getLocale('adsDesc')}
toggle={adsUIEnabled}
toggle={enabledMain}
checked={adsEnabled}
settingsChild={this.adsSettings(adsEnabled)}
settingsChild={this.adsSettings(adsEnabled && enabledMain)}
testId={'braveAdsSettings'}
disabledContent={this.adsDisabled()}
onToggle={this.onAdsSettingChange.bind(this, 'adsEnabled', '')}
Expand Down
3 changes: 1 addition & 2 deletions components/brave_rewards/resources/ui/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export const defaultState: Rewards.State = {
excluded: [],
adsData: {
adsEnabled: false,
adsPerHour: 0,
adsUIEnabled: false
adsPerHour: 0
},
pendingContributionTotal: 0
}
Expand Down
1 change: 0 additions & 1 deletion components/definitions/rewards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,5 @@ declare namespace Rewards {
export interface AdsData {
adsEnabled: boolean
adsPerHour: number
adsUIEnabled: boolean
}
}

0 comments on commit e156e02

Please sign in to comment.