Skip to content

Commit

Permalink
Uplift of #2407 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-browser-releases committed May 11, 2019
1 parent 547a9db commit ee8742e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
return
}

const id = payload.id
let notifications: Record<number, RewardsExtension.Notification> = state.notifications
const id: string = payload.id
let notifications: Record<string, RewardsExtension.Notification> = state.notifications

if (!notifications) {
notifications = []
// Array check for previous version of state types
// (https://github.com/brave/brave-browser/issues/4344)
if (!notifications || Array.isArray(notifications)) {
notifications = {}
}

notifications[id] = {
Expand Down Expand Up @@ -368,7 +370,7 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
break
}
case types.ON_ALL_NOTIFICATIONS: {
const list = payload.list
const list: RewardsExtension.Notification[] = payload.list

if (!list) {
break
Expand All @@ -377,8 +379,10 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
let notifications: Record<number, RewardsExtension.Notification> = state.notifications
let id = ''

if (!notifications) {
notifications = []
// Array check for previous version of state types
// (https://github.com/brave/brave-browser/issues/4344)
if (!notifications || Array.isArray(notifications)) {
notifications = {}
}

list.forEach((notification: RewardsExtension.Notification) => {
Expand Down
2 changes: 1 addition & 1 deletion components/definitions/rewardsExtensions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare namespace RewardsExtension {
currentNotification?: string
enabledAC: boolean
enabledMain: boolean
notifications: Record<number, Notification>
notifications: Record<string, Notification>
publishers: Record<string, Publisher>
report: Report
grants?: GrantInfo[]
Expand Down

0 comments on commit ee8742e

Please sign in to comment.