Skip to content

Commit

Permalink
Removes unnecessary getters for the same publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Mar 2, 2019
1 parent 1dce7cf commit 2922917
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export const onTabId = (tabId: number | undefined) => action(types.ON_TAB_ID, {
tabId
})

export const onTabRetrieved = (tab: chrome.tabs.Tab, publisherBlob: string, onlyDiff: boolean) => action(types.ON_TAB_RETRIEVED, {
export const onTabRetrieved = (tab: chrome.tabs.Tab, publisherBlob: string) => action(types.ON_TAB_RETRIEVED, {
tab,
publisherBlob,
onlyDiff
publisherBlob
})

export const onPublisherData = (windowId: number, publisher: RewardsExtension.Publisher) => action(types.ON_PUBLISHER_DATA, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
export const getTabData = (tabId: number) =>
chrome.tabs.get(tabId, (tab: chrome.tabs.Tab) => {
const rewardsPanelActions = require('../actions/rewardsPanelActions').default
rewardsPanelActions.onTabRetrieved(tab, '', false)
rewardsPanelActions.onTabRetrieved(tab, '')
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import rewardsPanelActions from '../actions/rewardsPanelActions'

chrome.tabs.onUpdated.addListener((tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => {
rewardsPanelActions.onTabRetrieved(tab, '', true)
rewardsPanelActions.onTabRetrieved(tab, '')
})

chrome.tabs.onActivated.addListener((activeInfo: chrome.tabs.TabActiveInfo) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ export const rewardsPanelReducer = (state: RewardsExtension.State | undefined, a
const publishers: Record<string, RewardsExtension.Publisher> = state.publishers
const publisher = publishers[id]

if ((payload.onlyDiff && publisher && publisher.tabUrl !== tab.url) || !payload.onlyDiff) {
chrome.braveRewards.getPublisherData(tab.windowId, tab.url, tab.favIconUrl || '', payload.publisherBlob || '')
}

if (!publisher || (publisher && publisher.tabUrl !== tab.url)) {
chrome.braveRewards.getPublisherData(

This comment has been minimized.

Copy link
@jasonrsadler

jasonrsadler Apr 7, 2019

Contributor

Moving this here prevents media publishers from showing in panel

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Apr 8, 2019

Author Contributor

which media publishers?

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Apr 8, 2019

Author Contributor

this was working correctly, so something else changed. Tracking it down

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Apr 8, 2019

Author Contributor

confirmed it's not related to this change, something is not working in c++

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Apr 8, 2019

Author Contributor

fix here #2178

tab.windowId,
tab.url,
tab.favIconUrl || '',
payload.publisherBlob || '')

if (publisher) {
delete publishers[id]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class RewardsPanel extends React.Component<Props, State> {
publisherBlob = result[0]
clearInterval(interval)
const rewardsPanelActions = require('../background/actions/rewardsPanelActions').default
rewardsPanelActions.onTabRetrieved(tab, publisherBlob, false)
rewardsPanelActions.onTabRetrieved(tab, publisherBlob)
} else {
chrome.storage.local.get(['rewards_panel_open'], function (result) {
if (result['rewards_panel_open'] === 'false') {
Expand All @@ -90,7 +90,7 @@ export class RewardsPanel extends React.Component<Props, State> {
clearInterval(interval)

const rewardsPanelActions = require('../background/actions/rewardsPanelActions').default
rewardsPanelActions.onTabRetrieved(tab, publisherBlob, false)
rewardsPanelActions.onTabRetrieved(tab, publisherBlob)
}
}
})
Expand All @@ -107,7 +107,7 @@ export class RewardsPanel extends React.Component<Props, State> {
}
})
} else {
this.props.actions.onTabRetrieved(tab, publisherBlob, false)
this.props.actions.onTabRetrieved(tab, publisherBlob)
}
}
let tab = tabs[0]
Expand All @@ -116,10 +116,10 @@ export class RewardsPanel extends React.Component<Props, State> {
if (url && url.host.endsWith('.twitch.tv')) {
pollData(tab, tab.id, url)
} else {
this.props.actions.onTabRetrieved(tab, '', false)
this.props.actions.onTabRetrieved(tab, '')
}
} else {
this.props.actions.onTabRetrieved(tab, '', false)
this.props.actions.onTabRetrieved(tab, '')
}
})
}
Expand Down

0 comments on commit 2922917

Please sign in to comment.