Skip to content

Commit

Permalink
Fixes panel create wallet
Browse files Browse the repository at this point in the history
Fixes panel favicon

Resolves brave/brave-browser#1719
Resolves brave/brave-browser#1792
  • Loading branch information
NejcZdovc committed Oct 24, 2018
1 parent 1d8d721 commit 7e57ba3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ void RewardsServiceImpl::Shutdown() {
void RewardsServiceImpl::OnWalletInitialized(ledger::Result result) {
if (!ready_.is_signaled())
ready_.Signal();

if (result == ledger::Result::WALLET_CREATED) {
SetRewardsMainEnabled(true);

This comment has been minimized.

Copy link
@bridiver

bridiver Dec 15, 2018

Collaborator

@NejcZdovc I don't think these calls should be here. If MainEnabled and AutoContribute should be set to true on wallet creation then the lib should handle that when it calls OnWalletInitialized on the client. Otherwise this behavior can be inconsistent between clients.

This comment has been minimized.

Copy link
@bridiver

bridiver Dec 15, 2018

Collaborator

this will be handled in an upcoming PR from @ryanml
after the state has been transitioned over to prefs I think we should drop this method

SetAutoContribute(true);
result = ledger::Result::LEDGER_OK;
}

TriggerOnWalletInitialized(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ export class RewardsPanel extends React.Component<Props, State> {
chrome.windows.getCurrent({}, this.onWindowCallback)
}

componentDidUpdate (prevProps: Props, prevState: State) {
if (
!prevProps.rewardsPanelData.walletCreated &&
this.props.rewardsPanelData.walletCreated
) {
chrome.tabs.query({
active: true,
currentWindow: true
}, (tabs) => {
if (!tabs || !tabs.length) {
return
}
this.props.actions.onTabRetrieved(tabs[0])
})
}
}

onWindowCallback = (window: chrome.windows.Window) => {
this.setState({
windowId: window.id
Expand Down
4 changes: 2 additions & 2 deletions components/brave_rewards/ui/reducers/wallet_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ const createWallet = (state: Rewards.State) => {
state.enabledAds = true
state.enabledContribute = true
state.createdTimestamp = new Date().getTime()

chrome.send('brave_rewards.getReconcileStamp', [])
chrome.send('brave_rewards.getAddresses', [])
chrome.send('brave_rewards.saveSetting', ['enabledMain', 'true'])
chrome.send('brave_rewards.saveSetting', ['enabledContribute', 'true'])
chrome.send('brave_rewards.getContributionAmount', [])

return state
Expand Down Expand Up @@ -182,6 +181,7 @@ const walletReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State,
}
state = { ...state }
state = createWallet(state)
state.firstLoad = false
break
}
case types.ON_CONTRIBUTION_AMOUNT:
Expand Down

0 comments on commit 7e57ba3

Please # to comment.