Skip to content

Commit 2922917

Browse files
committed
Removes unnecessary getters for the same publisher
Resolves brave/brave-browser#3525
1 parent 1dce7cf commit 2922917

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

components/brave_rewards/resources/extension/brave_rewards/actions/rewards_panel_actions.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ export const onTabId = (tabId: number | undefined) => action(types.ON_TAB_ID, {
1717
tabId
1818
})
1919

20-
export const onTabRetrieved = (tab: chrome.tabs.Tab, publisherBlob: string, onlyDiff: boolean) => action(types.ON_TAB_RETRIEVED, {
20+
export const onTabRetrieved = (tab: chrome.tabs.Tab, publisherBlob: string) => action(types.ON_TAB_RETRIEVED, {
2121
tab,
22-
publisherBlob,
23-
onlyDiff
22+
publisherBlob
2423
})
2524

2625
export const onPublisherData = (windowId: number, publisher: RewardsExtension.Publisher) => action(types.ON_PUBLISHER_DATA, {

components/brave_rewards/resources/extension/brave_rewards/background/api/tabs_api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
export const getTabData = (tabId: number) =>
66
chrome.tabs.get(tabId, (tab: chrome.tabs.Tab) => {
77
const rewardsPanelActions = require('../actions/rewardsPanelActions').default
8-
rewardsPanelActions.onTabRetrieved(tab, '', false)
8+
rewardsPanelActions.onTabRetrieved(tab, '')
99
})

components/brave_rewards/resources/extension/brave_rewards/background/events/tabEvents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import rewardsPanelActions from '../actions/rewardsPanelActions'
66

77
chrome.tabs.onUpdated.addListener((tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => {
8-
rewardsPanelActions.onTabRetrieved(tab, '', true)
8+
rewardsPanelActions.onTabRetrieved(tab, '')
99
})
1010

1111
chrome.tabs.onActivated.addListener((activeInfo: chrome.tabs.TabActiveInfo) => {

components/brave_rewards/resources/extension/brave_rewards/background/reducers/rewards_panel_reducer.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
8282
const publishers: Record<string, RewardsExtension.Publisher> = state.publishers
8383
const publisher = publishers[id]
8484

85-
if ((payload.onlyDiff && publisher && publisher.tabUrl !== tab.url) || !payload.onlyDiff) {
86-
chrome.braveRewards.getPublisherData(tab.windowId, tab.url, tab.favIconUrl || '', payload.publisherBlob || '')
87-
}
88-
8985
if (!publisher || (publisher && publisher.tabUrl !== tab.url)) {
86+
chrome.braveRewards.getPublisherData(
87+
tab.windowId,
88+
tab.url,
89+
tab.favIconUrl || '',
90+
payload.publisherBlob || '')
91+
9092
if (publisher) {
9193
delete publishers[id]
9294
}

components/brave_rewards/resources/extension/brave_rewards/components/app.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class RewardsPanel extends React.Component<Props, State> {
7676
publisherBlob = result[0]
7777
clearInterval(interval)
7878
const rewardsPanelActions = require('../background/actions/rewardsPanelActions').default
79-
rewardsPanelActions.onTabRetrieved(tab, publisherBlob, false)
79+
rewardsPanelActions.onTabRetrieved(tab, publisherBlob)
8080
} else {
8181
chrome.storage.local.get(['rewards_panel_open'], function (result) {
8282
if (result['rewards_panel_open'] === 'false') {
@@ -90,7 +90,7 @@ export class RewardsPanel extends React.Component<Props, State> {
9090
clearInterval(interval)
9191

9292
const rewardsPanelActions = require('../background/actions/rewardsPanelActions').default
93-
rewardsPanelActions.onTabRetrieved(tab, publisherBlob, false)
93+
rewardsPanelActions.onTabRetrieved(tab, publisherBlob)
9494
}
9595
}
9696
})
@@ -107,7 +107,7 @@ export class RewardsPanel extends React.Component<Props, State> {
107107
}
108108
})
109109
} else {
110-
this.props.actions.onTabRetrieved(tab, publisherBlob, false)
110+
this.props.actions.onTabRetrieved(tab, publisherBlob)
111111
}
112112
}
113113
let tab = tabs[0]
@@ -116,10 +116,10 @@ export class RewardsPanel extends React.Component<Props, State> {
116116
if (url && url.host.endsWith('.twitch.tv')) {
117117
pollData(tab, tab.id, url)
118118
} else {
119-
this.props.actions.onTabRetrieved(tab, '', false)
119+
this.props.actions.onTabRetrieved(tab, '')
120120
}
121121
} else {
122-
this.props.actions.onTabRetrieved(tab, '', false)
122+
this.props.actions.onTabRetrieved(tab, '')
123123
}
124124
})
125125
}

0 commit comments

Comments
 (0)