Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes upgrade path #687

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deps = {
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
"vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403",
"vendor/sparkle": "https://github.com/brave/Sparkle.git@c0759cce415d7c0feae45005c8a013b1898711f0",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@779c1a8d5c312b6d154963dd9b1810f53ac62b97",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@3e35b5eb7c1087884f00e1dacb3e801314880fc0",
"vendor/bat-native-rapidjson": "https://github.com/brave-intl/bat-native-rapidjson.git@86aafe2ef89835ae71c9ed7c2527e3bb3000930e",
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@9b119931c702d55be994117eb505d56310720b1d",
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@adeff3254bb90ccdc9699040d5a4e1cd6b8393b7",
Expand Down
8 changes: 5 additions & 3 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,11 @@ void RewardsServiceImpl::OnGrant(ledger::Result result,
const ledger::Grant& grant) {
TriggerOnGrant(result, grant);

RewardsNotificationsService::RewardsNotificationArgs args;
rewards_notifications_service_->AddNotification(
RewardsNotificationsService::REWARDS_NOTIFICATION_GRANT, args);
if (result == ledger::Result::LEDGER_OK) {
RewardsNotificationsService::RewardsNotificationArgs args;
rewards_notifications_service_->AddNotification(
RewardsNotificationsService::REWARDS_NOTIFICATION_GRANT, args);
}
}

void RewardsServiceImpl::OnGrantCaptcha(const std::string& image, const std::string& hint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
return
}

const id = payload.id.toString()
const id = `n_${payload.id}`
let notifications: Record<number, RewardsExtension.Notification> = state.notifications

if (!notifications) {
notifications = []
}

notifications[id] = {
id: id,
type: payload.type,
Expand All @@ -126,7 +131,8 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
}
case types.DELETE_NOTIFICATION:
{
chrome.rewardsNotifications.deleteNotification(parseInt(payload.id, 10))
const id = payload.id.toString().replace('n_', '')
chrome.rewardsNotifications.deleteNotification(parseInt(id, 10))
break
}
case types.ON_NOTIFICATION_DELETED:
Expand Down
121 changes: 64 additions & 57 deletions components/brave_rewards/ui/components/donationsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Provider } from 'brave-ui/features/rewards/profile'
import { getLocale } from '../../../common/locale'
import * as rewardsActions from '../actions/rewards_actions'
import * as utils from '../utils'
import { DetailRow } from 'brave-ui/features/rewards/tableDonation'

// Assets
const donate = require('../../../img/rewards/donate_disabled.svg')
Expand Down Expand Up @@ -104,65 +105,71 @@ class DonationBox extends React.Component<Props, State> {
const { walletInfo, recurringList, tipsList } = this.props.rewardsData

// Recurring
const recurring = recurringList.map((item: Rewards.Publisher) => {
let name = item.name
if (item.provider) {
name = `${name} ${getLocale('on')} ${item.provider}`
}

let faviconUrl = `chrome://favicon/size/48@1x/${item.url}`
if (item.favIcon) {
faviconUrl = `chrome://favicon/size/48@1x/${item.favIcon}`
}

return {
profile: {
name,
verified: item.verified,
provider: (item.provider ? item.provider : undefined) as Provider,
src: faviconUrl
},
contribute: {
tokens: item.percentage.toFixed(1),
converted: utils.convertBalance(item.percentage.toString(), walletInfo.rates)
},
url: item.url,
type: 'recurring' as any,
onRemove: () => { this.actions.removeRecurring(item.id) }
}
})
let recurring: DetailRow[] = []
if (recurringList) {
recurring = recurringList.map((item: Rewards.Publisher) => {
let name = item.name
if (item.provider) {
name = `${name} ${getLocale('on')} ${item.provider}`
}

let faviconUrl = `chrome://favicon/size/48@1x/${item.url}`
if (item.favIcon) {
faviconUrl = `chrome://favicon/size/48@1x/${item.favIcon}`
}

return {
profile: {
name,
verified: item.verified,
provider: (item.provider ? item.provider : undefined) as Provider,
src: faviconUrl
},
contribute: {
tokens: item.percentage.toFixed(1),
converted: utils.convertBalance(item.percentage.toString(), walletInfo.rates)
},
url: item.url,
type: 'recurring' as any,
onRemove: () => { this.actions.removeRecurring(item.id) }
}
})
}

// Tips
const tips = tipsList.map((item: Rewards.Publisher) => {
let name = item.name
if (item.provider) {
name = `${name} ${getLocale('on')} ${item.provider}`
}

let faviconUrl = `chrome://favicon/size/48@1x/${item.url}`
if (item.favIcon) {
faviconUrl = `chrome://favicon/size/48@1x/${item.favIcon}`
}

const token = utils.convertProbiToFixed(item.percentage.toString())

return {
profile: {
name,
verified: item.verified,
provider: (item.provider ? item.provider : undefined) as Provider,
src: faviconUrl
},
contribute: {
tokens: token,
converted: utils.convertBalance(token, walletInfo.rates)
},
url: item.url,
text: item.tipDate ? new Date(item.tipDate * 1000).toLocaleDateString() : undefined,
type: 'donation' as any,
onRemove: () => { this.actions.removeRecurring(item.id) }
}
})
let tips: DetailRow[] = []
if (tipsList) {
tips = tipsList.map((item: Rewards.Publisher) => {
let name = item.name
if (item.provider) {
name = `${name} ${getLocale('on')} ${item.provider}`
}

let faviconUrl = `chrome://favicon/size/48@1x/${item.url}`
if (item.favIcon) {
faviconUrl = `chrome://favicon/size/48@1x/${item.favIcon}`
}

const token = utils.convertProbiToFixed(item.percentage.toString())

return {
profile: {
name,
verified: item.verified,
provider: (item.provider ? item.provider : undefined) as Provider,
src: faviconUrl
},
contribute: {
tokens: token,
converted: utils.convertBalance(token, walletInfo.rates)
},
url: item.url,
text: item.tipDate ? new Date(item.tipDate * 1000).toLocaleDateString() : undefined,
type: 'donation' as any,
onRemove: () => { this.actions.removeRecurring(item.id) }
}
})
}

return recurring.concat(tips)
}
Expand Down