Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Simplify badge icon logic #7500

Merged
merged 1 commit into from
Mar 16, 2017
Merged
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
31 changes: 7 additions & 24 deletions app/common/state/extensionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ const extensionState = {
tabId = tabId ? tabId.toString() : '-1'
let extension = extensionState.getExtensionById(state, extensionId)
if (extension && extension.get('browserAction')) {
let icons = extension.getIn(['manifest', 'icons'])
let defaultIcons = extension.getIn(['manifest', 'browser_action', 'default_icon'])
let tabBrowserAction = extension.getIn(['tabs', tabId]) || Immutable.Map()
return extension.get('browserAction').merge({icons, defaultIcons}).merge(tabBrowserAction).merge({base_path: extension.get('base_path')})
return extension.get('browserAction').merge(tabBrowserAction).merge({base_path: extension.get('base_path')})
}
return null
},
Expand Down Expand Up @@ -89,36 +87,21 @@ const extensionState = {

browserActionBackgroundImage: (browserAction, tabId) => {
tabId = tabId ? tabId.toString() : '-1'
let path = browserAction.get('path')
let basePath = browserAction.get('base_path')
if (basePath) {
let baseIcons19 = browserAction.getIn(['icons', '19'])
let baseIcons38 = browserAction.getIn(['icons', '38'])
if (baseIcons19 && baseIcons38) {
// Older extensions may provide a string path
if (typeof path === 'string') {
return `-webkit-image-set(
url(${basePath}/${baseIcons19}) 1x,
url(${basePath}/${baseIcons38}) 2x`
url(${basePath}/${path}) 1x`
}
let tabsPath19 = browserAction.getIn(['tabs', tabId, 'path', '19'])
let tabsPath38 = browserAction.getIn(['tabs', tabId, 'path', '38'])
if (tabsPath19 && tabsPath38) {
return `-webkit-image-set(
url(${basePath}/${tabsPath19}) 1x,
url(${basePath}/${tabsPath38}) 2x`
}
let basePath19 = browserAction.getIn(['path', '19'])
let basePath38 = browserAction.getIn(['path', '38'])
let basePath19 = path.get('19')
let basePath38 = path.get('38')
if (basePath19 && basePath38) {
return `-webkit-image-set(
url(${basePath}/${basePath19}) 1x,
url(${basePath}/${basePath38}) 2x`
}
let baseIcons16 = browserAction.getIn(['icons', '16'])
let baseIcons48 = browserAction.getIn(['icons', '48'])
if (baseIcons16 && baseIcons48) {
return `-webkit-image-set(
url(${basePath}/${baseIcons16}) 1x,
url(${basePath}/${baseIcons48}) 2x`
}
}
return ''
},
Expand Down