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

brave extension: remove shields blocking data for closed tabs #13872

Merged
merged 1 commit into from
Jun 24, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ export const tabDataChanged: actions.TabDataChanged = (tabId, changeInfo, tab) =
tab
}
}

export function tabRemoved (tabId: number): actions.TabRemovedReturn {
return {
type: types.TAB_REMOVED,
tabId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ chrome.tabs.onCreated.addListener(function (tab: chrome.tabs.Tab) {
chrome.tabs.onUpdated.addListener(function (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) {
tabActions.tabDataChanged(tabId, changeInfo, tab)
})

chrome.tabs.onRemoved.addListener(function (tabId: number) {
tabActions.tabRemoved(tabId)
})
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export default function shieldsPanelReducer (
}
break
}
case tabTypes.TAB_REMOVED: {
delete state.tabs[action.tabId]
break
}
case shieldsPanelTypes.SHIELDS_PANEL_DATA_UPDATED: {
// @ts-expect-error (petemill) - shields Tab / ShieldDetails types are a mess of
// and used interchangably and all this code will be removed soon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
export const ACTIVE_TAB_CHANGED = 'ACTIVE_TAB_CHANGED'
export const TAB_DATA_CHANGED = 'TAB_DATA_CHANGED'
export const TAB_CREATED = 'TAB_CREATED'
export const TAB_REMOVED = 'TAB_REMOVED'
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ interface TabCreatedReturn {

export type TabCreated = (tab: chrome.tabs.Tab) => TabCreatedReturn

export interface TabRemovedReturn {
type: types.TAB_REMOVED
tabId: number
}

interface TabDataChangedReturn {
type: types.TAB_DATA_CHANGED
tabId: number
Expand All @@ -31,4 +36,5 @@ export type TabDataChanged = (tabId: number, changeInfo: chrome.tabs.TabChangeIn
export type tabActions =
ActiveTabChangedReturn |
TabCreatedReturn |
TabDataChangedReturn
TabDataChangedReturn |
TabRemovedReturn
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import * as types from '../../constants/tabTypes'

export type ACTIVE_TAB_CHANGED = typeof types.ACTIVE_TAB_CHANGED
export type TAB_CREATED = typeof types.TAB_CREATED
export type TAB_REMOVED = typeof types.TAB_REMOVED
export type TAB_DATA_CHANGED = typeof types.TAB_DATA_CHANGED
3 changes: 2 additions & 1 deletion components/test/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ export const getMockChrome = () => {
},
onActivated: new ChromeEvent(),
onCreated: new ChromeEvent(),
onUpdated: new ChromeEvent()
onUpdated: new ChromeEvent(),
onRemoved: new ChromeEvent()
},
windows: {
onFocusChanged: new ChromeEvent(),
Expand Down